_ dyld _ get _ image _ vmaddr _ slide and _ dyld _ get _ image _ header method return nothing
I am trying to call a function using dynamic library in IOS program with ill2cpp engine
To do this, I need to add the address of the function from the disassembled UnityFramework code (ill2cpp) with the address at which this library was loaded into the program memory
I use the image list command for the LLDB debugger and find the index at which the library was loaded:
The index turned out to be 488 (already taking into account my additional library)
I wrote the following code to get the address where the library was loaded (this address can be seen in the photo, after the index and identifier):
#include <unistd.h>
#include <dispatch/dispatch.h>
#include <mach-o/dyld.h>
static bool (*in_Room)();
%ctor {
const struct mach_header* header = _dyld_get_image_header(488); // 448 is index of library
uintptr_t global_addr = (uintptr_t)header;
uintptr_t EXEC_ADDR1 = global_addr + 0x1b27cdc;
in_Room = (bool(*)())EXEC_ADDR1;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
while(1)
{
sleep(20);
in_Room(); // function call
}
});
}
But this did not help in any way: the _ dyld _ get _ image _ header method did not return anything, and therefore the clean address from the disassembler was called:
The debugger showed that there was an attempt to access a non-existent address in the program memory, that is, to the address 0x1b27cdc, because the _dyld _ get _ image _ header method did not return anything
Why didn't the method return anything? How can I get the address of the library?
I will be glad for any help!