KittyMemoryEx 1.0.0
Dedicated library for runtime code patching, memory scanning, tracing, injection and some more useful memory utilities. works for both Android and Linux
Loading...
Searching...
No Matches
KittyMemoryMgr.hpp
1#pragma once
2
3#include "KittyUtils.hpp"
4#include "KittyIOFile.hpp"
5#include "KittyMemoryEx.hpp"
6#include "KittyMemOp.hpp"
7#include "MemoryPatch.hpp"
8#include "MemoryBackup.hpp"
9#include "KittyScanner.hpp"
10#include "KittyTrace.hpp"
11#include "KittyAsm.hpp"
12#include "KittyPtrValidator.hpp"
13#include "KittyPerfEvent.hpp"
14
18
22class KittyMemoryMgr
23{
24private:
25 bool _init;
26 pid_t _pid;
27 std::string _process_name;
28 EKittyMemOP _eMemOp;
29 std::unique_ptr<IKittyMemOp> _pMemOp;
30 std::unique_ptr<IKittyMemOp> _pMemOpPatch;
31
32public:
41
42#ifdef __ANDROID__
47#endif
48
51
52 KittyMemoryMgr() : _init(false), _pid(0), _eMemOp(EK_MEM_OP_NONE)
53 {
54 }
55
63 bool initialize(pid_t pid, EKittyMemOP eMemOp, bool initMemPatch);
64
68 inline pid_t processID() const
69 {
70 return _pid;
71 }
72
77 inline std::string processName() const
78 {
79 return _process_name;
80 }
81
85 inline bool isMemValid() const
86 {
87 return _init && _pid && _pMemOp.get();
88 }
89
93 inline IKittyMemOp *memOp() const
94 {
95 return _pMemOp.get();
96 }
97
106 inline size_t readMem(uintptr_t address, void *buffer, size_t len, MemMode mode = MemMode::Normal) const
107 {
108 if (!isMemValid() || !buffer || !len)
109 return 0;
110
111 return _pMemOp->Read(address, buffer, len, mode);
112 }
113
122 inline size_t writeMem(uintptr_t address, void *buffer, size_t len, MemMode mode = MemMode::Normal) const
123 {
124 if (!isMemValid() || !buffer || !len)
125 return 0;
126
127 return _pMemOp->Write(address, buffer, len, mode);
128 }
129
141 std::string readMemUTF8(uintptr_t address, size_t maxLen)
142 {
143 if (!isMemValid() || !address || !maxLen)
144 return "";
145
146 return _pMemOp->ReadUTF8(address, maxLen);
147 }
148
159 std::u16string readMemUTF16(uintptr_t address, size_t maxLen)
160 {
161 if (!isMemValid() || !address || !maxLen)
162 return u"";
163
164 return _pMemOp->ReadUTF16(address, maxLen);
165 }
166
177 std::u32string readMemUTF32(uintptr_t address, size_t maxLen)
178 {
179 if (!isMemValid() || !address || !maxLen)
180 return U"";
181
182 return _pMemOp->ReadUTF32(address, maxLen);
183 }
184
195 std::wstring readMemWStr(uintptr_t address, size_t maxLen)
196 {
197 if (!isMemValid() || !address || !maxLen)
198 return L"";
199
200 return _pMemOp->ReadWStr(address, maxLen);
201 }
202
213 inline std::string readMemStr(uintptr_t address, size_t maxLen)
214 {
215 if (!isMemValid() || !address || !maxLen)
216 return "";
217
218 return _pMemOp->ReadStr(address, maxLen);
219 }
220
231 bool writeMemStr(uintptr_t address, std::string str) const
232 {
233 if (!isMemValid() || !address || str.empty())
234 return false;
235
236 return _pMemOp->WriteStr(address, str);
237 }
238
249 inline bool writeMemWStr(uintptr_t address, std::wstring str)
250 {
251 if (!isMemValid() || !address || str.empty())
252 return false;
253
254 return _pMemOp->WriteWStr(address, str);
255 }
256
265 bool dumpMemRange(uintptr_t start, uintptr_t end, const std::string &path) const;
266
277 bool dumpMemFileMappings(const std::string &memFile, const std::string &destination) const;
278
285 bool dumpMemELF(const ElfScanner &elf, const std::string &destination) const;
286};
Manager class for ELF scanners.
Definition KittyScanner.hpp:521
Represents a scanner for memory ELF files. This class is used to scan ELF files from memory and extra...
Definition KittyScanner.hpp:193
Interface class for memory operations.
Definition KittyMemOp.hpp:46
Represents a mapping of a memory region.
Definition KittyMemoryEx.hpp:15
Class to retrieve process status information.
Definition KittyMemoryEx.hpp:145
bool dumpMemRange(uintptr_t start, uintptr_t end, const std::string &path) const
Dumps a memory range from remote process to a file.
ElfScannerMgr elfScanner
Elf Scanner Manager.
Definition KittyMemoryMgr.hpp:40
pid_t processID() const
Returns the process ID.
Definition KittyMemoryMgr.hpp:68
bool initialize(pid_t pid, EKittyMemOP eMemOp, bool initMemPatch)
Initializes the memory manager.
KittyScannerMgr memScanner
Memory Scanner Manager.
Definition KittyMemoryMgr.hpp:38
MemoryBackupMgr memBackup
MemoryBackup Manager.
Definition KittyMemoryMgr.hpp:36
bool writeMemWStr(uintptr_t address, std::wstring str)
Writes a platform wchar_t string to remote process memory.
Definition KittyMemoryMgr.hpp:249
NativeBridgeScannerMgr nbScanner
NativeBridge Scanner Manager.
Definition KittyMemoryMgr.hpp:46
size_t writeMem(uintptr_t address, void *buffer, size_t len, MemMode mode=MemMode::Normal) const
Writes remote memory to a specified address.
Definition KittyMemoryMgr.hpp:122
std::u32string readMemUTF32(uintptr_t address, size_t maxLen)
Reads a UTF-32 encoded string from remote process memory.
Definition KittyMemoryMgr.hpp:177
LinkerScannerMgr linkerScanner
Linker Scanner Manager.
Definition KittyMemoryMgr.hpp:44
std::string readMemStr(uintptr_t address, size_t maxLen)
Reads a UTF-8 string from remote process memory.
Definition KittyMemoryMgr.hpp:213
bool writeMemStr(uintptr_t address, std::string str) const
Writes a UTF-8 string to remote process memory.
Definition KittyMemoryMgr.hpp:231
std::string processName() const
Returns the process name.
Definition KittyMemoryMgr.hpp:77
MemoryPatchMgr memPatch
MemoryPatch Manager.
Definition KittyMemoryMgr.hpp:34
std::string readMemUTF8(uintptr_t address, size_t maxLen)
Reads a UTF-8 encoded string from remote process memory.
Definition KittyMemoryMgr.hpp:141
KittyTraceMgr trace
Process Trace Manager.
Definition KittyMemoryMgr.hpp:50
size_t readMem(uintptr_t address, void *buffer, size_t len, MemMode mode=MemMode::Normal) const
Reads remote memory from a specified address.
Definition KittyMemoryMgr.hpp:106
std::u16string readMemUTF16(uintptr_t address, size_t maxLen)
Reads a UTF-16 encoded string from remote process memory.
Definition KittyMemoryMgr.hpp:159
IKittyMemOp * memOp() const
Returns memory operations pointer.
Definition KittyMemoryMgr.hpp:93
std::wstring readMemWStr(uintptr_t address, size_t maxLen)
Reads a platform wchar_t string from remote process memory.
Definition KittyMemoryMgr.hpp:195
bool dumpMemFileMappings(const std::string &memFile, const std::string &destination) const
Dumps all mappings of a mapped file from a remote process.
bool isMemValid() const
Checks if memory operations are valid.
Definition KittyMemoryMgr.hpp:85
bool dumpMemELF(const ElfScanner &elf, const std::string &destination) const
Dumps a memory mapped ELF file from a remote process.
Manager class for pattern scanning operations.
Definition KittyScanner.hpp:25
A class for tracing and controlling the execution of processes in a debugging environment.
Definition KittyTrace.hpp:218
Manager class for linker Elf.
Definition KittyScanner.hpp:728
The MemoryBackup manager class.
Definition MemoryBackup.hpp:65
The MemoryPatch manager class.
Definition MemoryPatch.hpp:94
Manager class for scanning native bridge.
Definition KittyScanner.hpp:968
EProcMapFilter
Enumerates the filter types for finding memory maps.
Definition KittyMemoryEx.hpp:260