#include <windows.h> | |
#include <nt.h> | |
//extern void *ProcessHeap; | |
static void *ProcessHeap(){ | |
PROCESS_BASIC_INFORMATION pbi; | |
NtQueryInformationProcess((void *)-1, ProcessBasicInformation, &pbi, sizeof(pbi), NULL); | |
return pbi.PebBaseAddress->ProcessHeap; | |
} | |
void *malloc(size_t size){ | |
return RtlAllocateHeap(ProcessHeap(), 0, size); | |
} | |
void *realloc(void *ptr, size_t size){ | |
return RtlReAllocateHeap(ProcessHeap(), 0, ptr, size); | |
} | |
void free(void *ptr){ | |
RtlFreeHeap(ProcessHeap(), 0, ptr); | |
} |