BlackBone
Windows memory hacking library
 All Classes Functions
blackbone::ProcessMemory Class Reference
Inheritance diagram for blackbone::ProcessMemory:
blackbone::RemoteMemory

Public Member Functions

BLACKBONE_API ProcessMemory (class Process *process)
 
BLACKBONE_API MemBlock Allocate (size_t size, DWORD protection=PAGE_EXECUTE_READWRITE, ptr_t desired=0)
 Allocate new memory block More...
 
BLACKBONE_API NTSTATUS Free (ptr_t pAddr, size_t size=0, DWORD freeType=MEM_RELEASE)
 Free memory More...
 
BLACKBONE_API NTSTATUS Query (ptr_t pAddr, PMEMORY_BASIC_INFORMATION64 pInfo)
 Get memory region info More...
 
BLACKBONE_API NTSTATUS Protect (ptr_t pAddr, size_t size, DWORD flProtect, DWORD *pOld=NULL)
 Change memory protection More...
 
BLACKBONE_API NTSTATUS Read (ptr_t dwAddress, size_t dwSize, PVOID pResult, bool handleHoles=false)
 Read data More...
 
BLACKBONE_API NTSTATUS Write (ptr_t pAddress, size_t dwSize, const void *pData)
 Write data More...
 
template<class T >
T Read (ptr_t dwAddress)
 Read data More...
 
template<class T >
NTSTATUS Read (ptr_t dwAddress, T &result)
 Read data More...
 
template<class T >
NTSTATUS Write (ptr_t dwAddress, const T &data)
 Write data More...
 
BLACKBONE_API size_t EnumRegions (std::list< MEMORY_BASIC_INFORMATION64 > &results, bool includeFree=false)
 Enumerate valid memory regions More...
 
BLACKBONE_API class ProcessCore & core ()
 
BLACKBONE_API class Process * process ()
 
- Public Member Functions inherited from blackbone::RemoteMemory
BLACKBONE_API RemoteMemory (class Process *process)
 
BLACKBONE_API NTSTATUS Map (bool mapSections)
 Map entire process address space More...
 
BLACKBONE_API NTSTATUS Map (ptr_t base, uint32_t size)
 Map specific memory region More...
 
BLACKBONE_API NTSTATUS Unmap ()
 Unmap process address space from current process More...
 
BLACKBONE_API NTSTATUS Unmap (ptr_t base, uint32_t size)
 Unmap specific memory region from current process More...
 
BLACKBONE_API ptr_t TranslateAddress (ptr_t address, bool resolveFault=true)
 Translate target address accordingly to current address space More...
 
BLACKBONE_API NTSTATUS SetupHook (OperationType hkType)
 Setup one of the 4 possible memory hooks: More...
 
BLACKBONE_API bool RestoreHook (OperationType hkType)
 Restore previously hooked function More...
 
BLACKBONE_API void reset ()
 Unmap any mapped memory, restore hooks and free resources More...
 

Additional Inherited Members

- Public Types inherited from blackbone::RemoteMemory
enum  OperationType { MemVirtualAlloc = 0, MemVirtualFree, MemMapSection, MemUnmapSection }
 

Member Function Documentation

MemBlock blackbone::ProcessMemory::Allocate ( size_t  size,
DWORD  protection = PAGE_EXECUTE_READWRITE,
ptr_t  desired = 0 
)

Allocate new memory block

Parameters
sizeBlock size
protectionMemory protection
desiredDesired base address of new block
Returns
Memory block. If failed - returned block will be invalid
size_t blackbone::ProcessMemory::EnumRegions ( std::list< MEMORY_BASIC_INFORMATION64 > &  results,
bool  includeFree = false 
)

Enumerate valid memory regions

Parameters
resultsFound regions
includeFreeIf true - non-allocated regions will be included in list
Returns
Number of regions found
NTSTATUS blackbone::ProcessMemory::Free ( ptr_t  pAddr,
size_t  size = 0,
DWORD  freeType = MEM_RELEASE 
)

Free memory

Parameters
pAddrMemory address to release.
sizeRegion size
freeTypeRelease/decommit
Returns
Status
NTSTATUS blackbone::ProcessMemory::Protect ( ptr_t  pAddr,
size_t  size,
DWORD  flProtect,
DWORD *  pOld = NULL 
)

Change memory protection

Parameters
pAddrMemory address
sizeRegion size
flProtectNew memory protection flags
pOldOld protection flags
Returns
Status
NTSTATUS blackbone::ProcessMemory::Query ( ptr_t  pAddr,
PMEMORY_BASIC_INFORMATION64  pInfo 
)

Get memory region info

Parameters
pAddrMemory address
pInfoRetrieved info
Returns
Status
NTSTATUS blackbone::ProcessMemory::Read ( ptr_t  dwAddress,
size_t  dwSize,
PVOID  pResult,
bool  handleHoles = false 
)

Read data

Parameters
dwAddressMemoey address to read from
dwSizeSize of data to read
pResultOutput buffer
handleHolesIf true, function will try to read all committed pages in range ignoring uncommitted ones. Otherwise function will fail if there is at least one non-committed page in region.
Returns
Status
template<class T >
T blackbone::ProcessMemory::Read ( ptr_t  dwAddress)
inline

Read data

Parameters
dwAddressAddress to read from
Returns
Read data
template<class T >
NTSTATUS blackbone::ProcessMemory::Read ( ptr_t  dwAddress,
T &  result 
)
inline

Read data

Parameters
dwAddressAddress to read from
resultRead data
Returns
Status code
NTSTATUS blackbone::ProcessMemory::Write ( ptr_t  pAddress,
size_t  dwSize,
const void *  pData 
)

Write data

Parameters
pAddressMemory address to write to
dwSizeSize of data to write
pDataBuffer to write
Returns
Status
template<class T >
NTSTATUS blackbone::ProcessMemory::Write ( ptr_t  dwAddress,
const T &  data 
)
inline

Write data

Parameters
dwSizeSize of data to write
dataData to write
Returns
Status

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