Source code of Windows XP (NT5)
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.

186 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1990-2002 Microsoft Corporation
  3. Module Name:
  4. dump.c
  5. Abstract:
  6. This module supplies support for building a mini-dump file.
  7. Author:
  8. Oleg Kagan (olegk) Jun. 2002
  9. Environment:
  10. kernel mode only
  11. Revision History:
  12. --*/
  13. #include "videoprt.h"
  14. #define TRIAGE_DUMP_DATA_SIZE (TRIAGE_DUMP_SIZE - sizeof(ULONG))
  15. ULONG
  16. pVpAppendSecondaryMinidumpData(
  17. PVOID pvSecondaryData,
  18. ULONG ulSecondaryDataSize,
  19. PVOID pvDump
  20. )
  21. /*++
  22. Routine Description:
  23. Adds precollected video driver specific data
  24. Arguments:
  25. pvDump - points to the begiinig of the dump buffer
  26. pvSecondaryDumpData - points to the secondary data buffer
  27. ulSecondaryDataSize - size of the secondary data buffer
  28. Return Value:
  29. Resulting length of the minidump
  30. --*/
  31. {
  32. PMEMORY_DUMP pDump = (PMEMORY_DUMP)pvDump;
  33. ULONG_PTR DumpDataEnd = (ULONG_PTR)pDump + TRIAGE_DUMP_DATA_SIZE;
  34. PDUMP_HEADER pdh = &(pDump->Header);
  35. PVOID pBuffer = (PVOID)((ULONG_PTR)pvDump + TRIAGE_DUMP_SIZE);
  36. PDUMP_BLOB_FILE_HEADER BlobFileHdr = (PDUMP_BLOB_FILE_HEADER)(pBuffer);
  37. PDUMP_BLOB_HEADER BlobHdr = (PDUMP_BLOB_HEADER)(BlobFileHdr + 1);
  38. if (!pvDump) return 0;
  39. if (pvSecondaryData && ulSecondaryDataSize) {
  40. if (ulSecondaryDataSize > MAX_SECONDARY_DUMP_SIZE)
  41. ulSecondaryDataSize = MAX_SECONDARY_DUMP_SIZE;
  42. pdh->RequiredDumpSpace.QuadPart = TRIAGE_DUMP_SIZE + ulSecondaryDataSize;
  43. BlobFileHdr->Signature1 = DUMP_BLOB_SIGNATURE1;
  44. BlobFileHdr->Signature2 = DUMP_BLOB_SIGNATURE2;
  45. BlobFileHdr->HeaderSize = sizeof(*BlobFileHdr);
  46. BlobFileHdr->BuildNumber = NtBuildNumber;
  47. BlobHdr->HeaderSize = sizeof(*BlobHdr);
  48. BlobHdr->Tag = VpBugcheckGUID;
  49. BlobHdr->PrePad = 0;
  50. BlobHdr->PostPad = MAX_SECONDARY_DUMP_SIZE - ulSecondaryDataSize;
  51. BlobHdr->DataSize = ulSecondaryDataSize;
  52. RtlCopyMemory((PVOID)(BlobHdr + 1), pvSecondaryData, ulSecondaryDataSize);
  53. }
  54. return (ULONG)pdh->RequiredDumpSpace.QuadPart;
  55. }
  56. VOID
  57. VpNotifyEaData(
  58. PDEVICE_OBJECT DeviceObject,
  59. PVOID pvDump
  60. )
  61. {
  62. PDEVICE_OBJECT pPdo = IoGetDeviceAttachmentBaseRef(DeviceObject);
  63. if (pPdo) {
  64. //
  65. // Find the FDO that matches this PDO
  66. //
  67. PFDO_EXTENSION CurrFdo = FdoHead;
  68. while (CurrFdo) {
  69. if (CurrFdo->PhysicalDeviceObject == pPdo) {
  70. VpBugcheckDeviceObject = CurrFdo->FunctionalDeviceObject;
  71. }
  72. CurrFdo = CurrFdo->NextFdoExtension;
  73. }
  74. ASSERT(VpBugcheckDeviceObject != NULL);
  75. if (pvDump) {
  76. if (!VpDump) {
  77. VpDump = ExAllocatePoolWithTag(PagedPool,
  78. TRIAGE_DUMP_SIZE + 0x1000, // XXX olegk - why 1000? why not 2*TRIAGE_DUMP_SIZE?
  79. VP_TAG);
  80. }
  81. if (VpDump) memcpy(VpDump, pvDump, TRIAGE_DUMP_SIZE + 0x1000);
  82. }
  83. ObDereferenceObject(pPdo);
  84. }
  85. }
  86. PRTL_PROCESS_MODULES
  87. WdpGetLoadedModuleList(
  88. VOID
  89. )
  90. /*++
  91. Routine Description:
  92. This routine returns a pointer to a list of loaded modules.
  93. Arguments:
  94. None.
  95. Return Value:
  96. A pointer to memory with the loaded module list.
  97. Notes:
  98. The caller is responsible for freeing the memory when no longer needed.
  99. --*/
  100. {
  101. PRTL_PROCESS_MODULES Buffer = NULL;
  102. ULONG BufferSize;
  103. ULONG ReturnLength = 4096;
  104. NTSTATUS Status;
  105. do
  106. {
  107. if (Buffer)
  108. {
  109. ExFreePool(Buffer);
  110. }
  111. BufferSize = ReturnLength;
  112. Buffer = ExAllocatePoolWithTag(NonPagedPool, BufferSize, VP_TAG);
  113. if (Buffer == NULL)
  114. {
  115. break;
  116. }
  117. Status = ZwQuerySystemInformation(SystemModuleInformation,
  118. Buffer,
  119. BufferSize,
  120. &ReturnLength);
  121. } while (Status == STATUS_INFO_LENGTH_MISMATCH);
  122. return Buffer;
  123. }