MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / main

Function main

example-linux/example.cpp:11–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9KittyMemoryMgr kittyMemMgr;
10
11int 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());

Callers

nothing calls this directly

Calls 15

getProcessIDFunction · 0.85
hexDumpFunction · 0.85
initializeMethod · 0.80
findElfMethod · 0.80
findSymbolAllMethod · 0.80
dynamicMethod · 0.80
realPathMethod · 0.80
filePathMethod · 0.80
baseMethod · 0.80
loadBiasMethod · 0.80
loadSizeMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected