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.

66 lines
1.5 KiB

  1. #include "bootini.h"
  2. #if DBG==1
  3. VOID LogTrace(ULONG trace,
  4. PCHAR str
  5. )
  6. {
  7. DWORD len;
  8. HANDLE fh = CreateFile("bootinstprov.log",
  9. GENERIC_READ|GENERIC_WRITE,
  10. 0,// Exclusive Access
  11. NULL,
  12. OPEN_ALWAYS,
  13. FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH,
  14. NULL
  15. );
  16. len = SetFilePointer(fh,
  17. 0,
  18. NULL,
  19. FILE_END
  20. );
  21. if (fh != INVALID_HANDLE_VALUE) {
  22. WriteFile(fh,
  23. str,
  24. strlen(str),
  25. &len,
  26. NULL
  27. );
  28. CloseHandle(fh);
  29. }
  30. return;
  31. }
  32. LPVOID BPAlloc(int len)
  33. {
  34. LPVOID mem = HeapAlloc(GetProcessHeap(),
  35. HEAP_ZERO_MEMORY,
  36. len);
  37. CHAR buffer[256];
  38. sprintf(buffer, "Allocated %d at memory 0x%x\n", len, mem);
  39. LogTrace(0, buffer);
  40. return mem;
  41. }
  42. VOID
  43. BPFree(LPVOID mem)
  44. {
  45. BOOL ret = HeapFree(GetProcessHeap(),
  46. 0,
  47. mem
  48. );
  49. CHAR buffer[256];
  50. if(ret){
  51. sprintf(buffer, "Freed at memory 0x%x with TRUE\n",mem);
  52. }
  53. else{
  54. sprintf(buffer, "Freed at memory 0x%x with FALSE\n",mem);
  55. }
  56. LogTrace(0, buffer);
  57. }
  58. #endif