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.

297 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. ntsdexts.c
  5. Abstract:
  6. This function contains miscellaneous VDMEXTS functions
  7. Author:
  8. Bob Day (bobday) 29-Feb-1992 Grabbed standard header
  9. Revision History:
  10. Neil Sandlin (NeilSa) 15-Jan-1996 Merged with vdmexts
  11. --*/
  12. #include <precomp.h>
  13. #pragma hdrstop
  14. #include <dpmi.h>
  15. VOID
  16. PrintOneFaultVector(
  17. int vector,
  18. ULONG pHandler
  19. )
  20. {
  21. VDM_FAULTHANDLER handler;
  22. char sym_text[255];
  23. ULONG dist;
  24. PRINTF("%02X: ", vector);
  25. if (!READMEM((LPVOID)pHandler, &handler, sizeof(VDM_FAULTHANDLER))) {
  26. PRINTF("<error reading memory>\n");
  27. return;
  28. }
  29. PRINTF("%04LX:%08lX ", handler.CsSelector, handler.Eip);
  30. if (FindSymbol(handler.CsSelector, handler.Eip, sym_text, &dist, BEFORE, PROT_MODE )) {
  31. if ( dist == 0 ) {
  32. PRINTF("%s", sym_text );
  33. } else {
  34. PRINTF("%s+0x%lx", sym_text, dist );
  35. }
  36. }
  37. PRINTF("\n");
  38. }
  39. VOID
  40. df(
  41. CMD_ARGLIST
  42. )
  43. {
  44. int vector = -1;
  45. LPVOID pHandlers;
  46. CMD_INIT();
  47. if (GetNextToken()) {
  48. vector = EvaluateToken();
  49. if ((vector < 0) || (vector > 0x1f)) {
  50. PRINTF("Invalid fault vector\n");
  51. return;
  52. }
  53. }
  54. pHandlers = (LPVOID) EXPRESSION("ntvdm!dpmifaulthandlers");
  55. if (!pHandlers) {
  56. PRINTF("Could get symbol ntvdm!dpmifaulthandlers\n");
  57. return;
  58. }
  59. if (vector >= 0) {
  60. PrintOneFaultVector(vector, (ULONG)pHandlers +
  61. vector*sizeof(VDM_FAULTHANDLER));
  62. } else for (vector = 0; vector < 0x20; vector++) {
  63. PrintOneFaultVector(vector, (ULONG)pHandlers +
  64. vector*sizeof(VDM_FAULTHANDLER));
  65. }
  66. }
  67. VOID
  68. PrintOneInterruptVector(
  69. int vector,
  70. ULONG pHandler
  71. )
  72. {
  73. VDM_INTERRUPTHANDLER handler;
  74. char sym_text[255];
  75. ULONG dist;
  76. PRINTF("%02X: ", vector);
  77. if (!READMEM((LPVOID)pHandler, &handler, sizeof(VDM_INTERRUPTHANDLER))) {
  78. PRINTF("<error reading memory>\n");
  79. return;
  80. }
  81. PRINTF("%04LX:%08lX ", handler.CsSelector, handler.Eip);
  82. if (FindSymbol(handler.CsSelector, handler.Eip, sym_text, &dist, BEFORE, PROT_MODE )) {
  83. if ( dist == 0 ) {
  84. PRINTF("%s", sym_text );
  85. } else {
  86. PRINTF("%s+0x%lx", sym_text, dist );
  87. }
  88. }
  89. PRINTF("\n");
  90. }
  91. VOID
  92. di(
  93. CMD_ARGLIST
  94. )
  95. {
  96. int vector = -1;
  97. LPVOID pHandlers;
  98. CMD_INIT();
  99. if (GetNextToken()) {
  100. vector = EvaluateToken();
  101. if ((vector < 0) || (vector > 0xff)) {
  102. PRINTF("Invalid interrupt vector\n");
  103. return;
  104. }
  105. }
  106. pHandlers = (LPVOID) EXPRESSION("ntvdm!dpmiinterrupthandlers");
  107. if (!pHandlers) {
  108. PRINTF("Could get symbol ntvdm!dpmiinterrupthandlers\n");
  109. return;
  110. }
  111. if (vector >= 0) {
  112. PrintOneInterruptVector(vector, (ULONG)pHandlers +
  113. vector*sizeof(VDM_INTERRUPTHANDLER));
  114. } else for (vector = 0; vector < 0x100; vector++) {
  115. PrintOneInterruptVector(vector, (ULONG)pHandlers +
  116. vector*sizeof(VDM_INTERRUPTHANDLER));
  117. }
  118. }
  119. VOID
  120. rmcb(
  121. CMD_ARGLIST
  122. )
  123. {
  124. RMCB_INFO Rmcb[MAX_RMCBS];
  125. USHORT RMCallBackBopSeg;
  126. USHORT RMCallBackBopOffset;
  127. int i;
  128. int count = 0;
  129. CMD_INIT();
  130. if (!ReadMemExpression("ntvdm!DpmiRmcb", &Rmcb, MAX_RMCBS*sizeof(RMCB_INFO))) {
  131. return;
  132. }
  133. if (!ReadMemExpression("ntvdm!RMCallBackBopSeg", &RMCallBackBopSeg, 2)) {
  134. return;
  135. }
  136. if (!ReadMemExpression("ntvdm!RMCallBackBopOffset", &RMCallBackBopOffset, 2)) {
  137. return;
  138. }
  139. for (i=0; i<MAX_RMCBS; i++) {
  140. if (Rmcb[i].bInUse) {
  141. if (!count++) {
  142. PRINTF("\n");
  143. PRINTF(" CallBack PM Proc RM Struct Stack Sel\n");
  144. }
  145. PRINTF("&%.4X:%.4X - ", RMCallBackBopSeg-i,
  146. RMCallBackBopOffset + (i*16));
  147. PRINTF("#%.4X:%.8X #%.4X:%.8X %.4X\n",
  148. Rmcb[i].ProcSeg,
  149. Rmcb[i].ProcOffset,
  150. Rmcb[i].StrucSeg,
  151. Rmcb[i].StrucOffset,
  152. Rmcb[i].StackSel);
  153. }
  154. }
  155. if (!count) {
  156. PRINTF("No dpmi real mode callbacks are defined\n");
  157. } else {
  158. PRINTF("\n");
  159. }
  160. }
  161. VOID
  162. DumpDpmiMemChain(
  163. ULONG Head
  164. )
  165. {
  166. MEM_DPMI MemBlock;
  167. ULONG pMem;
  168. ULONG Count = 0;
  169. if (!Head) {
  170. PRINTF("Error accessing ntvdm symbols\n");
  171. return;
  172. }
  173. if (!READMEM((LPVOID)(Head), &MemBlock, sizeof(MEM_DPMI))) {
  174. PRINTF("<Error Reading memory list head>\n");
  175. return;
  176. }
  177. pMem = (ULONG) MemBlock.Next;
  178. if (pMem == Head) {
  179. PRINTF("The list is empty.\n");
  180. } else {
  181. PRINTF("Address Length Owner Sel Cnt Next Prev\n");
  182. while (pMem != Head) {
  183. if (!READMEM((LPVOID)(pMem), &MemBlock, sizeof(MEM_DPMI))) {
  184. PRINTF("<Error Reading memory list block at %.08X>\n", pMem);
  185. return;
  186. }
  187. PRINTF("%.08X %.08X %.04X %.04X %.04X %.08X %.08X\n",
  188. MemBlock.Address, MemBlock.Length,
  189. MemBlock.Owner, MemBlock.Sel, MemBlock.SelCount,
  190. MemBlock.Next, MemBlock.Prev);
  191. pMem = (ULONG) MemBlock.Next;
  192. Count++;
  193. if (Count>100) {
  194. PRINTF("Possible Corruption\n");
  195. return;
  196. }
  197. }
  198. }
  199. }
  200. VOID
  201. dpx(
  202. CMD_ARGLIST
  203. )
  204. {
  205. CMD_INIT();
  206. PRINTF("\n*** Dpmi XMEM Allocation chain ***\n\n");
  207. DumpDpmiMemChain(EXPRESSION("ntvdm!XmemHead"));
  208. }
  209. VOID
  210. dpd(
  211. CMD_ARGLIST
  212. )
  213. {
  214. CMD_INIT();
  215. PRINTF("\n*** Dpmi DOSMEM Allocation chain ***\n\n");
  216. DumpDpmiMemChain(EXPRESSION("ntvdm!DosMemHead"));
  217. }