|
HyperDbg Debugger
|
Implementation of cross APIs for different platforms for memory allocation. More...
#include "pch.h"Functions | |
| INT | PlatformSprintf (char *Buffer, SIZE_T BufferSize, const char *Format,...) |
| Platform independent wrapper for sprintf_s / snprintf. | |
| PVOID | PlatformAllocateMemory (SIZE_T Size) |
| ... New Unified API ... | |
| VOID | PlatformFreeMemory (PVOID Memory) |
| Frees a previously allocated memory block. | |
| VOID | PlatformWriteMemory (PVOID Address, PVOID Buffer, SIZE_T Size) |
| Writes data from a buffer to a memory address. | |
| VOID | PlatformSetMemory (PVOID Destination, int Value, SIZE_T Size) |
| Sets a memory block to a specific value. | |
| VOID | PlatformZeroMemory (PVOID Destination, SIZE_T Size) |
| Zeros a memory block. | |
| PVOID | PlatformMemAllocateContiguousZeroedMemory (SIZE_T NumberOfBytes) |
| ... Backward Compatibility / Specific APIs ... | |
| PVOID | PlatformMemAllocateNonPagedPool (SIZE_T NumberOfBytes) |
| Allocates non-paged pool memory. | |
| PVOID | PlatformMemAllocateNonPagedPoolWithQuota (SIZE_T NumberOfBytes) |
| Allocates non-paged pool memory with quota charging. | |
| PVOID | PlatformMemAllocateZeroedNonPagedPool (SIZE_T NumberOfBytes) |
| Allocates zeroed non-paged pool memory. | |
| PVOID | PlatformMemFreePool (PVOID BufferAddress) |
| Frees a memory pool. | |
Implementation of cross APIs for different platforms for memory allocation.
| PVOID PlatformAllocateMemory | ( | SIZE_T | Size | ) |
... New Unified API ...
Allocates a block of memory in the kernel pool.
On Windows: Allocates from NonPagedPool and zeroes it. On Linux: Uses kzalloc (GFP_KERNEL) which zeroes memory.
| Size | The number of bytes to allocate. |
| VOID PlatformFreeMemory | ( | PVOID | Memory | ) |
Frees a previously allocated memory block.
| Memory | Pointer to the memory block. Handles NULL safely. |
| PVOID PlatformMemAllocateContiguousZeroedMemory | ( | SIZE_T | NumberOfBytes | ) |
... Backward Compatibility / Specific APIs ...
Allocates contiguous zeroed physical memory.
On Windows: Uses MmAllocateContiguousMemory. On Linux: Uses kmalloc (which is usually physically contiguous) or dma_alloc_coherent. For simplicity in this driver, we map to kzalloc.
| NumberOfBytes | Size in bytes. |
| PVOID PlatformMemAllocateNonPagedPool | ( | SIZE_T | NumberOfBytes | ) |
Allocates non-paged pool memory.
| NumberOfBytes | Size in bytes. |
| PVOID PlatformMemAllocateNonPagedPoolWithQuota | ( | SIZE_T | NumberOfBytes | ) |
Allocates non-paged pool memory with quota charging.
| NumberOfBytes | Size in bytes. |
| PVOID PlatformMemAllocateZeroedNonPagedPool | ( | SIZE_T | NumberOfBytes | ) |
Allocates zeroed non-paged pool memory.
| NumberOfBytes | Size in bytes. |
Frees a memory pool.
| BufferAddress | Pointer to the memory to free. |
| VOID PlatformSetMemory | ( | PVOID | Destination, |
| int | Value, | ||
| SIZE_T | Size ) |
Sets a memory block to a specific value.
| Destination | Memory address. |
| Value | Value to set. |
| Size | Number of bytes. |
| INT PlatformSprintf | ( | char * | Buffer, |
| SIZE_T | BufferSize, | ||
| const char * | Format, | ||
| ... ) |
Platform independent wrapper for sprintf_s / snprintf.
| Buffer | output buffer |
| BufferSize | size of the output buffer |
| Format | format string |
Writes data from a buffer to a memory address.
| Process | Reserved (unused). |
| Address | Destination address. |
| Buffer | Source buffer. |
| Size | Number of bytes to copy. |
| VOID PlatformZeroMemory | ( | PVOID | Destination, |
| SIZE_T | Size ) |
Zeros a memory block.
| Destination | Memory address. |
| Size | Number of bytes. |