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

  1. #include <bootdefs.h>
  2. #include <ntlmsspi.h>
  3. #define USE_BlAllocateHeap 1
  4. #ifndef MAC
  5. extern
  6. ULONG
  7. _cdecl
  8. DbgPrint(
  9. PCH Format,
  10. ...
  11. );
  12. #endif
  13. VOID DbgBreakPoint(VOID);
  14. #if USE_BlAllocateHeap
  15. PVOID
  16. BlAllocateHeap (
  17. ULONG Size
  18. );
  19. PVOID
  20. SspAlloc(
  21. int Size
  22. )
  23. {
  24. #ifndef MAC
  25. return BlAllocateHeap( Size );
  26. #else
  27. return malloc( Size );
  28. #endif
  29. }
  30. void
  31. SspFree(
  32. PVOID Buffer
  33. )
  34. {
  35. #pragma unused(Buffer)
  36. //
  37. // Loader heap never frees.
  38. //
  39. }
  40. #else // USE_BlAllocateHeap
  41. //
  42. // Do a memory allocator out of a static buffer, because the Bl memory
  43. // system gets reinitialized.
  44. //
  45. #define MEMORY_BUFFER_SIZE 2048
  46. #define MEMORY_BLOCK_SIZE 8 // must be power of 2
  47. #define MEMORY_BLOCK_MASK (((ULONG)-1) - (MEMORY_BLOCK_SIZE-1))
  48. static UCHAR MemoryBuffer[MEMORY_BUFFER_SIZE];
  49. static PUCHAR CurMemoryLoc = MemoryBuffer;
  50. PVOID
  51. SspAlloc(
  52. int Size
  53. )
  54. {
  55. int RoundedUpSize = (Size + (MEMORY_BLOCK_SIZE-1)) & MEMORY_BLOCK_MASK;
  56. PVOID NewAlloc;
  57. if (((CurMemoryLoc + RoundedUpSize) - MemoryBuffer) > MEMORY_BUFFER_SIZE) {
  58. DbgPrint("!!! SspAlloc: Could not allocate %d bytes !!!\n", Size);
  59. return NULL;
  60. }
  61. NewAlloc = CurMemoryLoc;
  62. CurMemoryLoc += RoundedUpSize;
  63. return NewAlloc;
  64. }
  65. void
  66. SspFree(
  67. PVOID Buffer
  68. )
  69. {
  70. //
  71. // Should eventually really free things for reallocation!
  72. //
  73. }
  74. #endif // else USE_BlAllocateHeap