Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

53 lines
930 B

#include <windows.h>
#include <winbase.h>
#ifdef HeapDump
#include <stdio.h>
#endif
class Heap {
Heap()
{
hheap = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
dassert(hheap);
}
static Heap theHeap;
public:
~Heap()
{
BOOL bool = HeapDestroy(hheap);
dassert(bool);
}
static HANDLE hheap;
};
inline void* __cdecl operator new (size_t size)
{
#ifdef HeapDump
printf("Allocation size = %d\n", size);
#endif
return HeapAlloc(Heap::hheap, HEAP_NO_SERIALIZE, size);
}
enum FILL { zeroed = 0 };
inline void* __cdecl operator new(size_t size, FILL fill) {
#ifdef HeapDump
printf("Allocation size = %d\n", size);
#endif
return HeapAlloc(Heap::hheap, HEAP_NO_SERIALIZE | HEAP_ZERO_MEMORY, size);
}
inline void __cdecl operator delete (void *pv)
{
BOOL bool;
// operator delete allows NULL parameter... must not pass to OS
if (!pv)
return;
bool = HeapFree(Heap::hheap, HEAP_NO_SERIALIZE, pv);
dassert(bool);
}