mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-19 08:25:09 -04:00
Image size stuff I guess
This commit is contained in:
parent
d950a6f1c7
commit
69f54d106f
1 changed files with 6 additions and 6 deletions
|
@ -80,13 +80,13 @@ size_t getImageSize(struct mach_header_64 const* header) {
|
|||
if (header == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
size_t sz = sizeof(struct mach_header_64); // Size of the header
|
||||
sz += header->sizeofcmds; // Size of the load commands
|
||||
size_t sz = 0;
|
||||
|
||||
auto lc = (struct load_command const*) (header + 1);
|
||||
for (uint32_t i = 0; i < header->ncmds; i++) {
|
||||
if (lc->cmd == LC_SEGMENT) {
|
||||
sz += ((struct segment_command_64 const*) lc)->vmsize; // Size of segments
|
||||
auto seg = (struct segment_command_64 const*) lc;
|
||||
if (lc->cmd == LC_SEGMENT_64 && strcmp(seg->segname, SEG_PAGEZERO) != 0) {
|
||||
sz += seg->vmsize; // Size of segments
|
||||
}
|
||||
lc = (struct load_command const*) ((char *) lc + lc->cmdsize);
|
||||
}
|
||||
|
@ -127,9 +127,9 @@ static struct dyld_image_info const* imageFromAddress(void const* addr) {
|
|||
--iter;
|
||||
|
||||
auto image = *iter;
|
||||
// auto imageSize = getImageSize((struct mach_header_64 const*)image->imageLoadAddress);
|
||||
auto imageSize = getImageSize((struct mach_header_64 const*)image->imageLoadAddress);
|
||||
auto imageAddress = (uintptr_t)image->imageLoadAddress;
|
||||
if ((uintptr_t)addr >= imageAddress/* && (uintptr_t)addr < imageAddress + imageSize*/) {
|
||||
if ((uintptr_t)addr >= imageAddress && (uintptr_t)addr < imageAddress + imageSize) {
|
||||
return image;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Reference in a new issue