| 9 | KittyMemoryMgr kittyMemMgr; |
| 10 | |
| 11 | int main(int argc, char *args[]) |
| 12 | { |
| 13 | setbuf(stdout, nullptr); |
| 14 | setbuf(stderr, nullptr); |
| 15 | setbuf(stdin, nullptr); |
| 16 | |
| 17 | // ./exe [target process name] |
| 18 | if (argc < 2) |
| 19 | { |
| 20 | KITTY_LOGE("Missing arg (process name)."); |
| 21 | return 1; |
| 22 | } |
| 23 | |
| 24 | std::string processName = args[1]; |
| 25 | // get process ID |
| 26 | pid_t processID = KittyMemoryEx::getProcessID(processName); |
| 27 | if (!processID) |
| 28 | { |
| 29 | KITTY_LOGI("Couldn't find process id of %s.", processName.c_str()); |
| 30 | return 1; |
| 31 | } |
| 32 | |
| 33 | KITTY_LOGI("Process Name: %s", processName.c_str()); |
| 34 | KITTY_LOGI("Process ID: %d", processID); |
| 35 | |
| 36 | // initialize KittyMemoryMgr instance with process ID |
| 37 | if (!kittyMemMgr.initialize(processID, EK_MEM_OP_SYSCALL, true)) |
| 38 | { |
| 39 | KITTY_LOGI("Error occurred )':"); |
| 40 | return 1; |
| 41 | } |
| 42 | |
| 43 | KITTY_LOGI("================ GET ELF BASE ==============="); |
| 44 | |
| 45 | ElfScanner g_il2cppElf{}; |
| 46 | // loop until our target library is found |
| 47 | do |
| 48 | { |
| 49 | sleep(1); |
| 50 | // findElf can find libs in split apk too |
| 51 | g_il2cppElf = kittyMemMgr.elfScanner.findElf("libil2cpp.so"); |
| 52 | // use filter |
| 53 | g_il2cppElf = kittyMemMgr.elfScanner.findElf("libil2cpp.so", EScanElfType::Any, EScanElfFilter::App); |
| 54 | |
| 55 | // find via linker or native bridge solist |
| 56 | auto nativeSo = kittyMemMgr.linkerScanner.findSoInfo("libil2cpp.so"); |
| 57 | auto emulatedSo = kittyMemMgr.nbScanner.findSoInfo("libil2cpp.so"); |
| 58 | |
| 59 | if (nativeSo.ptr) |
| 60 | { |
| 61 | KITTY_LOGI("Found native libil2cpp.so soinfo at %p", (void *)nativeSo.ptr); |
| 62 | g_il2cppElf = kittyMemMgr.elfScanner.createWithSoInfo(nativeSo); |
| 63 | } |
| 64 | if (emulatedSo.ptr) |
| 65 | { |
| 66 | KITTY_LOGI("Found emulated libil2cpp.so soinfo at %p", (void *)emulatedSo.ptr); |
| 67 | g_il2cppElf = kittyMemMgr.elfScanner.createWithSoInfo(emulatedSo); |
| 68 | } |
nothing calls this directly
no test coverage detected