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

Method initialize

KittyMemoryEx/KittyMemoryMgr.cpp:4–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2
3bool KittyMemoryMgr::initialize(pid_t pid, EKittyMemOP eMemOp, bool initMemPatch)
4{
5 _init = false;
6 _pid = pid;
7
8 if (_pid <= 0)
9 {
10 KITTY_LOGE("KittyMemoryMgr: Invalid arg (pid).");
11 return false;
12 }
13
14 _process_name = KittyMemoryEx::getProcessName(_pid);
15
16 if (_pMemOp.get())
17 _pMemOp.reset();
18
19 _eMemOp = eMemOp;
20 switch (eMemOp)
21 {
22 case EK_MEM_OP_SYSCALL:
23 _pMemOp = std::make_unique<KittyMemSys>();
24 break;
25 case EK_MEM_OP_IO:
26 _pMemOp = std::make_unique<KittyMemIO>();
27 break;
28 default:
29 KITTY_LOGE("KittyMemoryMgr: Unknown memory operation.");
30 return false;
31 }
32
33 if (!_pMemOp->init(_pid))
34 {
35 KITTY_LOGE("KittyMemoryMgr: Couldn't initialize memory operation.");
36 return false;
37 }
38
39 _init = true;
40
41 // patching mem only avaialabe for IO operation
42 if (initMemPatch)
43 {
44 if (eMemOp == EK_MEM_OP_IO)
45 {
46 memPatch = MemoryPatchMgr(_pMemOp.get());
47 memBackup = MemoryBackupMgr(_pMemOp.get());
48 }
49 else
50 {
51 if (_pMemOpPatch.get())
52 _pMemOpPatch.reset();
53
54 _pMemOpPatch = std::make_unique<KittyMemIO>();
55 if (_pMemOpPatch->init(pid))
56 {
57 memPatch = MemoryPatchMgr(_pMemOpPatch.get());
58 memBackup = MemoryBackupMgr(_pMemOpPatch.get());
59 }
60 else
61 {

Callers 2

mainFunction · 0.80
mainFunction · 0.80

Calls 11

getProcessNameFunction · 0.85
MemoryPatchMgrClass · 0.85
MemoryBackupMgrClass · 0.85
KittyScannerMgrClass · 0.85
ElfScannerMgrClass · 0.85
LinkerScannerMgrClass · 0.85
KittyTraceMgrClass · 0.85
findElfMethod · 0.80
pidMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected