| 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 | |
| 51 | // findElf can find libs in split apk too |
| 52 | g_il2cppElf = kittyMemMgr.elfScanner.findElf("libil2cpp.so"); |
| 53 | |
| 54 | // incase il2cpp is renamed, you can find elf by any special symbol |
| 55 | for (auto &it : kittyMemMgr.elfScanner.findSymbolAll("il2cpp_init")) |
| 56 | { |
| 57 | // make sure it has dynamic |
| 58 | if (it.second.dynamic()) |
| 59 | { |
| 60 | KITTY_LOGI("Found il2cpp_init at %p from %s", (void *)it.first, it.second.realPath().c_str()); |
| 61 | g_il2cppElf = it.second; |
| 62 | break; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | } while (!g_il2cppElf.isValid()); |
| 67 | |
| 68 | KITTY_LOGI("il2cpp filePath: %s", g_il2cppElf.filePath().c_str()); |
nothing calls this directly
no test coverage detected