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

Function main

example-android/example.cpp:11–353  ·  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 std::string targetLib = "libil2cpp.so";
46 ElfScanner g_il2cppElf{};
47 // loop until our target library is found
48 do
49 {
50 sleep(1);
51 // findElf can find libs in split apk too
52 g_il2cppElf = kittyMemMgr.elfScanner.findElf(targetLib);
53 // use filter
54 g_il2cppElf = kittyMemMgr.elfScanner.findElf(targetLib, EScanElfType::Any, EScanElfFilter::App);
55
56 // find via linker or native bridge solist
57 auto nativeSo = kittyMemMgr.linkerScanner.findSoInfo(targetLib);
58 auto emulatedSo = kittyMemMgr.nbScanner.findSoInfo(targetLib);
59
60 if (nativeSo.ptr)
61 {
62 KITTY_LOGI("Found native libil2cpp.so soinfo at %p", (void *)nativeSo.ptr);
63 g_il2cppElf = kittyMemMgr.elfScanner.createWithSoInfo(nativeSo);
64 }
65 if (emulatedSo.ptr)
66 {
67 KITTY_LOGI("Found emulated libil2cpp.so soinfo at %p", (void *)emulatedSo.ptr);
68 g_il2cppElf = kittyMemMgr.elfScanner.createWithSoInfo(emulatedSo);

Callers

nothing calls this directly

Calls 15

getProcessIDFunction · 0.85
getExternalStorageFunction · 0.85
hexDumpFunction · 0.85
getAppExternalDataDirFunction · 0.85
initializeMethod · 0.80
findElfMethod · 0.80
findSoInfoMethod · 0.80
createWithSoInfoMethod · 0.80
findSymbolAllMethod · 0.80
dynamicMethod · 0.80
realPathMethod · 0.80
filePathMethod · 0.80

Tested by

no test coverage detected