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.

151 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. vmem.cpp
  5. Abstract:
  6. !vprot using the debug engine virtual query interface.
  7. --*/
  8. #include "precomp.h"
  9. #pragma hdrstop
  10. #define PAGE_ALL (PAGE_READONLY|\
  11. PAGE_READWRITE|\
  12. PAGE_WRITECOPY|\
  13. PAGE_EXECUTE|\
  14. PAGE_EXECUTE_READ|\
  15. PAGE_EXECUTE_READWRITE|\
  16. PAGE_EXECUTE_WRITECOPY|\
  17. PAGE_NOACCESS)
  18. VOID
  19. PrintPageFlags(
  20. DWORD Flags
  21. )
  22. {
  23. switch (Flags & PAGE_ALL)
  24. {
  25. case PAGE_READONLY:
  26. dprintf("PAGE_READONLY");
  27. break;
  28. case PAGE_READWRITE:
  29. dprintf("PAGE_READWRITE");
  30. break;
  31. case PAGE_WRITECOPY:
  32. dprintf("PAGE_WRITECOPY");
  33. break;
  34. case PAGE_EXECUTE:
  35. dprintf("PAGE_EXECUTE");
  36. break;
  37. case PAGE_EXECUTE_READ:
  38. dprintf("PAGE_EXECUTE_READ");
  39. break;
  40. case PAGE_EXECUTE_READWRITE:
  41. dprintf("PAGE_EXECUTE_READWRITE");
  42. break;
  43. case PAGE_EXECUTE_WRITECOPY:
  44. dprintf("PAGE_EXECUTE_WRITECOPY");
  45. break;
  46. case PAGE_NOACCESS:
  47. if ((Flags & ~PAGE_NOACCESS) == 0)
  48. {
  49. dprintf("PAGE_NOACCESS");
  50. break;
  51. } // else fall through
  52. default:
  53. dprintf("*** Invalid page protection ***\n");
  54. return;
  55. }
  56. if (Flags & PAGE_NOCACHE)
  57. {
  58. dprintf(" + PAGE_NOCACHE");
  59. }
  60. if (Flags & PAGE_GUARD)
  61. {
  62. dprintf(" + PAGE_GUARD");
  63. }
  64. dprintf("\n");
  65. }
  66. DECLARE_API( vprot )
  67. /*++
  68. Routine Description:
  69. This debugger extension dumps the virtual memory info for the
  70. address specified.
  71. Arguments:
  72. Return Value:
  73. --*/
  74. {
  75. ULONG64 Address;
  76. MEMORY_BASIC_INFORMATION64 Basic;
  77. INIT_API();
  78. Address = GetExpression( args );
  79. if ((Status = g_ExtData->QueryVirtual(Address, &Basic)) != S_OK)
  80. {
  81. dprintf("vprot: QueryVirtual failed, error = 0x%08X\n", Status);
  82. goto Exit;
  83. }
  84. dprintf("BaseAddress: %p\n", Basic.BaseAddress);
  85. dprintf("AllocationBase: %p\n", Basic.AllocationBase);
  86. dprintf("AllocationProtect: %08x ", Basic.AllocationProtect);
  87. PrintPageFlags(Basic.AllocationProtect);
  88. dprintf("RegionSize: %p\n", Basic.RegionSize);
  89. dprintf("State: %08x ", Basic.State);
  90. switch (Basic.State)
  91. {
  92. case MEM_COMMIT:
  93. dprintf("MEM_COMMIT\n");
  94. break;
  95. case MEM_FREE:
  96. dprintf("MEM_FREE\n");
  97. break;
  98. case MEM_RESERVE:
  99. dprintf("MEM_RESERVE\n");
  100. break;
  101. default:
  102. dprintf("*** Invalid page state ***\n");
  103. break;
  104. }
  105. dprintf("Protect: %08x ", Basic.Protect);
  106. PrintPageFlags(Basic.Protect);
  107. dprintf("Type: %08x ", Basic.Type);
  108. switch(Basic.Type)
  109. {
  110. case MEM_IMAGE:
  111. dprintf("MEM_IMAGE\n");
  112. break;
  113. case MEM_MAPPED:
  114. dprintf("MEM_MAPPED\n");
  115. break;
  116. case MEM_PRIVATE:
  117. dprintf("MEM_PRIVATE\n");
  118. break;
  119. default:
  120. dprintf("*** Invalid page type ***\n");
  121. break;
  122. }
  123. Exit:
  124. EXIT_API();
  125. return S_OK;
  126. }