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 Class Reference

Class that manages memory operations for a remote process. More...

#include <KittyMemoryMgr.hpp>

Collaboration diagram for KittyMemoryMgr:

Public Member Functions

bool initialize (pid_t pid, EKittyMemOP eMemOp, bool initMemPatch)
 Initializes the memory manager.
pid_t processID () const
 Returns the process ID.
std::string processName () const
 Returns the process name.
bool isMemValid () const
 Checks if memory operations are valid.
IKittyMemOp * memOp () const
 Returns memory operations pointer.
size_t readMem (uintptr_t address, void *buffer, size_t len, MemMode mode=MemMode::Normal) const
 Reads remote memory from a specified address.
size_t writeMem (uintptr_t address, void *buffer, size_t len, MemMode mode=MemMode::Normal) const
 Writes remote memory to a specified address.
std::string readMemUTF8 (uintptr_t address, size_t maxLen)
 Reads a UTF-8 encoded string from remote process memory.
std::u16string readMemUTF16 (uintptr_t address, size_t maxLen)
 Reads a UTF-16 encoded string from remote process memory.
std::u32string readMemUTF32 (uintptr_t address, size_t maxLen)
 Reads a UTF-32 encoded string from remote process memory.
std::wstring readMemWStr (uintptr_t address, size_t maxLen)
 Reads a platform wchar_t string from remote process memory.
std::string readMemStr (uintptr_t address, size_t maxLen)
 Reads a UTF-8 string from remote process memory.
bool writeMemStr (uintptr_t address, std::string str) const
 Writes a UTF-8 string to remote process memory.
bool writeMemWStr (uintptr_t address, std::wstring str)
 Writes a platform wchar_t string to remote process memory.
bool dumpMemRange (uintptr_t start, uintptr_t end, const std::string &path) const
 Dumps a memory range from remote process to a file.
bool dumpMemFileMappings (const std::string &memFile, const std::string &destination) const
 Dumps all mappings of a mapped file from a remote process.
bool dumpMemELF (const ElfScanner &elf, const std::string &destination) const
 Dumps a memory mapped ELF file from a remote process.

Public Attributes

MemoryPatchMgr memPatch
 MemoryPatch Manager.
MemoryBackupMgr memBackup
 MemoryBackup Manager.
KittyScannerMgr memScanner
 Memory Scanner Manager.
ElfScannerMgr elfScanner
 Elf Scanner Manager.
LinkerScannerMgr linkerScanner
 Linker Scanner Manager.
NativeBridgeScannerMgr nbScanner
 NativeBridge Scanner Manager.
KittyTraceMgr trace
 Process Trace Manager.

Detailed Description

Class that manages memory operations for a remote process.

Member Function Documentation

◆ dumpMemELF()

bool KittyMemoryMgr::dumpMemELF ( const ElfScanner & elf,
const std::string & destination ) const

Dumps a memory mapped ELF file from a remote process.

Parameters
elfThe ELF scanner to use for dumping the ELF file.
destinationThe path where the ELF file will be dumped.
Returns
True if the ELF file is dumped successfully, false otherwise.

◆ dumpMemFileMappings()

bool KittyMemoryMgr::dumpMemFileMappings ( const std::string & memFile,
const std::string & destination ) const

Dumps all mappings of a mapped file from a remote process.

If the file has multiple mappings, each mapping is written to a separate output file by appending an index to the destination filename.

Parameters
memFilePath of the mapped file to dump.
destinationDestination file or directory path.
Returns
True if at least one mapping was successfully dumped, false otherwise.

◆ dumpMemRange()

bool KittyMemoryMgr::dumpMemRange ( uintptr_t start,
uintptr_t end,
const std::string & path ) const

Dumps a memory range from remote process to a file.

Parameters
startThe start address of the memory range to dump.
endThe end address of the memory range to dump.
pathThe path to the file where the memory range will be dumped.
Returns
True if the memory range is dumped successfully, false otherwise.

◆ initialize()

bool KittyMemoryMgr::initialize ( pid_t pid,
EKittyMemOP eMemOp,
bool initMemPatch )

Initializes the memory manager.

Parameters
pidRemote process ID.
eMemOpMemory read & write operation type.
initMemPatchIf true, initializes MemoryPatch and MemoryBackup instances.
Returns
True if initialization is successful, false otherwise.

◆ processName()

std::string KittyMemoryMgr::processName ( ) const
inline

Returns the process name.

Returns
The name of the remote process.

◆ readMem()

size_t KittyMemoryMgr::readMem ( uintptr_t address,
void * buffer,
size_t len,
MemMode mode = MemMode::Normal ) const
inline

Reads remote memory from a specified address.

Parameters
addressThe address in remote memory to read.
bufferThe buffer to store the read data.
lenThe number of bytes to read.
modeMemory access strategy.
Returns
The number of bytes read.
Here is the call graph for this function:

◆ readMemStr()

std::string KittyMemoryMgr::readMemStr ( uintptr_t address,
size_t maxLen )
inline

Reads a UTF-8 string from remote process memory.

Convenience wrapper around ReadUTF8().

Parameters
addressRemote memory address containing the string.
maxLenMaximum number of bytes to read.
Returns
UTF-8 string stored in remote memory.
Here is the call graph for this function:

◆ readMemUTF16()

std::u16string KittyMemoryMgr::readMemUTF16 ( uintptr_t address,
size_t maxLen )
inline

Reads a UTF-16 encoded string from remote process memory.

Reads at most maxLen bytes and stops at the first UTF-16 null terminator.

Parameters
addressRemote memory address containing the string.
maxLenMaximum number of bytes to read.
Returns
UTF-16 string stored in remote memory.
Here is the call graph for this function:

◆ readMemUTF32()

std::u32string KittyMemoryMgr::readMemUTF32 ( uintptr_t address,
size_t maxLen )
inline

Reads a UTF-32 encoded string from remote process memory.

Reads at most maxLen bytes and stops at the first UTF-32 null terminator.

Parameters
addressRemote memory address containing the string.
maxLenMaximum number of bytes to read.
Returns
UTF-32 string stored in remote memory.
Here is the call graph for this function:

◆ readMemUTF8()

std::string KittyMemoryMgr::readMemUTF8 ( uintptr_t address,
size_t maxLen )
inline

Reads a UTF-8 encoded string from remote process memory.

Reads at most maxLen bytes starting at address and stops when the first null terminator is encountered.

Parameters
addressRemote memory address containing the string.
maxLenMaximum number of bytes to read.
Returns
UTF-8 string stored in remote memory.
Here is the call graph for this function:

◆ readMemWStr()

std::wstring KittyMemoryMgr::readMemWStr ( uintptr_t address,
size_t maxLen )
inline

Reads a platform wchar_t string from remote process memory.

Automatically selects the encoding based on the size of wchar_t:

Parameters
addressRemote memory address containing the string.
maxLenMaximum number of wchar_t characters to read.
Returns
Wide string stored in remote memory.
Here is the call graph for this function:

◆ writeMem()

size_t KittyMemoryMgr::writeMem ( uintptr_t address,
void * buffer,
size_t len,
MemMode mode = MemMode::Normal ) const
inline

Writes remote memory to a specified address.

Parameters
addressThe address in remote memory to write to.
bufferThe buffer containing the data to write.
lenThe number of bytes to write.
modeMemory access strategy.
Returns
The number of bytes written.
Here is the call graph for this function:

◆ writeMemStr()

bool KittyMemoryMgr::writeMemStr ( uintptr_t address,
std::string str ) const
inline

Writes a UTF-8 string to remote process memory.

Writes the string contents followed by a null terminator.

Parameters
addressRemote memory address where the string is written.
strUTF-8 string to write.
Returns
true if all bytes were written successfully.
Here is the call graph for this function:

◆ writeMemWStr()

bool KittyMemoryMgr::writeMemWStr ( uintptr_t address,
std::wstring str )
inline

Writes a platform wchar_t string to remote process memory.

Automatically selects the encoding based on the size of wchar_t:

Parameters
addressRemote memory address where the string is written.
strWide string to write.
Returns
true if all characters and the null terminator were written.
Here is the call graph for this function:

The documentation for this class was generated from the following file: