Leaked source code of windows server 2003
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.
 
 
 
 
 
 

93 lines
1.5 KiB

#include <bootdefs.h>
#include <ntlmsspi.h>
#define USE_BlAllocateHeap 1
#ifndef MAC
extern
ULONG
_cdecl
DbgPrint(
PCH Format,
...
);
#endif
VOID DbgBreakPoint(VOID);
#if USE_BlAllocateHeap
PVOID
BlAllocateHeap (
ULONG Size
);
PVOID
SspAlloc(
int Size
)
{
#ifndef MAC
return BlAllocateHeap( Size );
#else
return malloc( Size );
#endif
}
void
SspFree(
PVOID Buffer
)
{
#pragma unused(Buffer)
//
// Loader heap never frees.
//
}
#else // USE_BlAllocateHeap
//
// Do a memory allocator out of a static buffer, because the Bl memory
// system gets reinitialized.
//
#define MEMORY_BUFFER_SIZE 2048
#define MEMORY_BLOCK_SIZE 8 // must be power of 2
#define MEMORY_BLOCK_MASK (((ULONG)-1) - (MEMORY_BLOCK_SIZE-1))
static UCHAR MemoryBuffer[MEMORY_BUFFER_SIZE];
static PUCHAR CurMemoryLoc = MemoryBuffer;
PVOID
SspAlloc(
int Size
)
{
int RoundedUpSize = (Size + (MEMORY_BLOCK_SIZE-1)) & MEMORY_BLOCK_MASK;
PVOID NewAlloc;
if (((CurMemoryLoc + RoundedUpSize) - MemoryBuffer) > MEMORY_BUFFER_SIZE) {
DbgPrint("!!! SspAlloc: Could not allocate %d bytes !!!\n", Size);
return NULL;
}
NewAlloc = CurMemoryLoc;
CurMemoryLoc += RoundedUpSize;
return NewAlloc;
}
void
SspFree(
PVOID Buffer
)
{
//
// Should eventually really free things for reallocation!
//
}
#endif // else USE_BlAllocateHeap