Windows NT 4.0 source code leak
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.

569 lines
12 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. Author:
  6. Notes:
  7. Revision History:
  8. --*/
  9. #include <precomp.h>
  10. #pragma hdrstop
  11. //
  12. // Macro for setting up pointers to WinDbg routines
  13. //
  14. // This line currently causes a build warning, which I don't understand
  15. // Disassemble = p->lpDisasmRoutine;
  16. #define SETUP_WINDBG_POINTERS( p ) { \
  17. Print = p->lpOutputRoutine; \
  18. GetExpression = p->lpGetExpressionRoutine; \
  19. GetSymbol = p->lpGetSymbolRoutine; \
  20. CheckCtrlC = p->lpCheckControlCRoutine; \
  21. \
  22. if ( p->nSize >= sizeof(WINDBG_EXTENSION_APIS) ) { \
  23. fWinDbg = TRUE; \
  24. ReadProcessMemWinDbg = p->lpReadProcessMemoryRoutine; \
  25. WriteProcessMemWinDbg = p->lpWriteProcessMemoryRoutine; \
  26. GetThreadContextWinDbg = p->lpGetThreadContextRoutine; \
  27. SetThreadContextWinDbg = p->lpSetThreadContextRoutine; \
  28. } else { \
  29. fWinDbg = FALSE; \
  30. } \
  31. }
  32. VOID
  33. db(
  34. HANDLE CurrentProcess,
  35. HANDLE CurrentThread,
  36. DWORD CurrentPc,
  37. PWINDBG_EXTENSION_APIS ExtensionApis,
  38. LPSTR ArgumentString
  39. )
  40. /*++
  41. Routine Description:
  42. Arguments:
  43. CurrentProcess -- Supplies a handle to the current process
  44. CurrentThread -- Supplies a handle to the current thread
  45. CurrentPc -- Supplies the current program counter. (may be meaningless)
  46. ExtensionApis -- Supplies pointers to ntsd support routines
  47. ArgumentString -- Supplies the arguments passed to the command
  48. Return Value:
  49. None.
  50. --*/
  51. {
  52. UNREFERENCED_PARAMETER(CurrentPc);
  53. hCurrentProcess = CurrentProcess;
  54. hCurrentThread = CurrentThread;
  55. lpArgumentString = ArgumentString;
  56. SETUP_WINDBG_POINTERS(ExtensionApis);
  57. DumpMemory(1);
  58. }
  59. VOID
  60. dw(
  61. HANDLE CurrentProcess,
  62. HANDLE CurrentThread,
  63. DWORD CurrentPc,
  64. PWINDBG_EXTENSION_APIS ExtensionApis,
  65. LPSTR ArgumentString
  66. )
  67. /*++
  68. Routine Description:
  69. Arguments:
  70. CurrentProcess -- Supplies a handle to the current process
  71. CurrentThread -- Supplies a handle to the current thread
  72. CurrentPc -- Supplies the current program counter. (may be meaningless)
  73. ExtensionApis -- Supplies pointers to ntsd support routines
  74. ArgumentString -- Supplies the arguments passed to the command
  75. Return Value:
  76. None.
  77. --*/
  78. {
  79. UNREFERENCED_PARAMETER(CurrentPc);
  80. hCurrentProcess = CurrentProcess;
  81. hCurrentThread = CurrentThread;
  82. lpArgumentString = ArgumentString;
  83. SETUP_WINDBG_POINTERS(ExtensionApis);
  84. DumpMemory(2);
  85. }
  86. VOID
  87. dd(
  88. HANDLE CurrentProcess,
  89. HANDLE CurrentThread,
  90. DWORD CurrentPc,
  91. PWINDBG_EXTENSION_APIS ExtensionApis,
  92. LPSTR ArgumentString
  93. )
  94. /*++
  95. Routine Description:
  96. Arguments:
  97. CurrentProcess -- Supplies a handle to the current process
  98. CurrentThread -- Supplies a handle to the current thread
  99. CurrentPc -- Supplies the current program counter. (may be meaningless)
  100. ExtensionApis -- Supplies pointers to ntsd support routines
  101. ArgumentString -- Supplies the arguments passed to the command
  102. Return Value:
  103. None.
  104. --*/
  105. {
  106. UNREFERENCED_PARAMETER(CurrentPc);
  107. hCurrentProcess = CurrentProcess;
  108. hCurrentThread = CurrentThread;
  109. lpArgumentString = ArgumentString;
  110. SETUP_WINDBG_POINTERS(ExtensionApis);
  111. DumpMemory(4);
  112. }
  113. VOID
  114. dg(
  115. HANDLE CurrentProcess,
  116. HANDLE CurrentThread,
  117. DWORD CurrentPc,
  118. PWINDBG_EXTENSION_APIS ExtensionApis,
  119. LPSTR ArgumentString
  120. )
  121. /*++
  122. Routine Description:
  123. Arguments:
  124. CurrentProcess -- Supplies a handle to the current process
  125. CurrentThread -- Supplies a handle to the current thread
  126. CurrentPc -- Supplies the current program counter. (may be meaningless)
  127. ExtensionApis -- Supplies pointers to ntsd support routines
  128. ArgumentString -- Supplies the arguments passed to the command
  129. Return Value:
  130. None.
  131. --*/
  132. {
  133. UNREFERENCED_PARAMETER(CurrentPc);
  134. hCurrentProcess = CurrentProcess;
  135. hCurrentThread = CurrentThread;
  136. lpArgumentString = ArgumentString;
  137. SETUP_WINDBG_POINTERS(ExtensionApis);
  138. DumpDescriptor();
  139. }
  140. VOID
  141. dgh(
  142. HANDLE CurrentProcess,
  143. HANDLE CurrentThread,
  144. DWORD CurrentPc,
  145. PWINDBG_EXTENSION_APIS ExtensionApis,
  146. LPSTR ArgumentString
  147. )
  148. /*++
  149. Routine Description:
  150. Arguments:
  151. CurrentProcess -- Supplies a handle to the current process
  152. CurrentThread -- Supplies a handle to the current thread
  153. CurrentPc -- Supplies the current program counter. (may be meaningless)
  154. ExtensionApis -- Supplies pointers to ntsd support routines
  155. ArgumentString -- Supplies the arguments passed to the command
  156. Return Value:
  157. None.
  158. --*/
  159. {
  160. UNREFERENCED_PARAMETER(CurrentPc);
  161. hCurrentProcess = CurrentProcess;
  162. hCurrentThread = CurrentThread;
  163. lpArgumentString = ArgumentString;
  164. SETUP_WINDBG_POINTERS(ExtensionApis);
  165. DumpGHeap();
  166. }
  167. VOID
  168. es(
  169. HANDLE CurrentProcess,
  170. HANDLE CurrentThread,
  171. DWORD CurrentPc,
  172. PWINDBG_EXTENSION_APIS ExtensionApis,
  173. LPSTR ArgumentString
  174. )
  175. /*++
  176. Routine Description:
  177. Arguments:
  178. CurrentProcess -- Supplies a handle to the current process
  179. CurrentThread -- Supplies a handle to the current thread
  180. CurrentPc -- Supplies the current program counter. (may be meaningless)
  181. ExtensionApis -- Supplies pointers to ntsd support routines
  182. ArgumentString -- Supplies the arguments passed to the command
  183. Return Value:
  184. None.
  185. --*/
  186. {
  187. UNREFERENCED_PARAMETER(CurrentPc);
  188. hCurrentProcess = CurrentProcess;
  189. hCurrentThread = CurrentThread;
  190. lpArgumentString = ArgumentString;
  191. SETUP_WINDBG_POINTERS(ExtensionApis);
  192. if (!CheckGlobalHeap()) {
  193. return;
  194. }
  195. EvaluateSymbol();
  196. }
  197. VOID
  198. help(
  199. HANDLE CurrentProcess,
  200. HANDLE CurrentThread,
  201. DWORD CurrentPc,
  202. PWINDBG_EXTENSION_APIS ExtensionApis,
  203. LPSTR ArgumentString
  204. ) {
  205. SETUP_WINDBG_POINTERS(ExtensionApis);
  206. PRINTF("[db|dw|dd] addr - Dump 16-bit memory\n");
  207. PRINTF("dg <sel> - Dump info on a selector\n");
  208. PRINTF("dgh <sel> - Dump global heap\n");
  209. PRINTF("es <symbol> - Get symbol's value\n");
  210. PRINTF("k - Stack trace\n");
  211. PRINTF("kb - Stack trace with symbols\n");
  212. PRINTF("lm - List loaded modules\n");
  213. PRINTF("ln <addr> - Determine near symbols\n");
  214. PRINTF("r - Dump registers\n");
  215. PRINTF("ti <thrdid> - Dump WOW Task Info\n");
  216. PRINTF("u <addr> - Unassemble 16-bit code with symbols\n");
  217. PRINTF("\n");
  218. }
  219. VOID
  220. k(
  221. HANDLE CurrentProcess,
  222. HANDLE CurrentThread,
  223. DWORD CurrentPc,
  224. PWINDBG_EXTENSION_APIS ExtensionApis,
  225. LPSTR ArgumentString
  226. )
  227. /*++
  228. Routine Description:
  229. Arguments:
  230. CurrentProcess -- Supplies a handle to the current process
  231. CurrentThread -- Supplies a handle to the current thread
  232. CurrentPc -- Supplies the current program counter. (may be meaningless)
  233. ExtensionApis -- Supplies pointers to ntsd support routines
  234. ArgumentString -- Supplies the arguments passed to the command
  235. Return Value:
  236. None.
  237. --*/
  238. {
  239. UNREFERENCED_PARAMETER(CurrentPc);
  240. hCurrentProcess = CurrentProcess;
  241. hCurrentThread = CurrentThread;
  242. lpArgumentString = ArgumentString;
  243. SETUP_WINDBG_POINTERS(ExtensionApis);
  244. if (!CheckGlobalHeap()) {
  245. return;
  246. }
  247. WalkStack();
  248. }
  249. VOID
  250. kb(
  251. HANDLE CurrentProcess,
  252. HANDLE CurrentThread,
  253. DWORD CurrentPc,
  254. PWINDBG_EXTENSION_APIS ExtensionApis,
  255. LPSTR ArgumentString
  256. )
  257. /*++
  258. Routine Description:
  259. Arguments:
  260. CurrentProcess -- Supplies a handle to the current process
  261. CurrentThread -- Supplies a handle to the current thread
  262. CurrentPc -- Supplies the current program counter. (may be meaningless)
  263. ExtensionApis -- Supplies pointers to ntsd support routines
  264. ArgumentString -- Supplies the arguments passed to the command
  265. Return Value:
  266. None.
  267. --*/
  268. {
  269. UNREFERENCED_PARAMETER(CurrentPc);
  270. hCurrentProcess = CurrentProcess;
  271. hCurrentThread = CurrentThread;
  272. lpArgumentString = ArgumentString;
  273. SETUP_WINDBG_POINTERS(ExtensionApis);
  274. if (!CheckGlobalHeap()) {
  275. return;
  276. }
  277. WalkStackVerbose();
  278. }
  279. VOID
  280. lm(
  281. HANDLE CurrentProcess,
  282. HANDLE CurrentThread,
  283. DWORD CurrentPc,
  284. PWINDBG_EXTENSION_APIS ExtensionApis,
  285. LPSTR ArgumentString
  286. )
  287. /*++
  288. Routine Description:
  289. Arguments:
  290. CurrentProcess -- Supplies a handle to the current process
  291. CurrentThread -- Supplies a handle to the current thread
  292. CurrentPc -- Supplies the current program counter. (may be meaningless)
  293. ExtensionApis -- Supplies pointers to ntsd support routines
  294. ArgumentString -- Supplies the arguments passed to the command
  295. Return Value:
  296. None.
  297. --*/
  298. {
  299. UNREFERENCED_PARAMETER(CurrentPc);
  300. hCurrentProcess = CurrentProcess;
  301. hCurrentThread = CurrentThread;
  302. lpArgumentString = ArgumentString;
  303. SETUP_WINDBG_POINTERS(ExtensionApis);
  304. if (!CheckGlobalHeap()) {
  305. return;
  306. }
  307. ListModules();
  308. }
  309. VOID
  310. ln(
  311. HANDLE CurrentProcess,
  312. HANDLE CurrentThread,
  313. DWORD CurrentPc,
  314. PWINDBG_EXTENSION_APIS ExtensionApis,
  315. LPSTR ArgumentString
  316. )
  317. /*++
  318. Routine Description:
  319. Arguments:
  320. CurrentProcess -- Supplies a handle to the current process
  321. CurrentThread -- Supplies a handle to the current thread
  322. CurrentPc -- Supplies the current program counter. (may be meaningless)
  323. ExtensionApis -- Supplies pointers to ntsd support routines
  324. ArgumentString -- Supplies the arguments passed to the command
  325. Return Value:
  326. None.
  327. --*/
  328. {
  329. UNREFERENCED_PARAMETER(CurrentPc);
  330. hCurrentProcess = CurrentProcess;
  331. hCurrentThread = CurrentThread;
  332. lpArgumentString = ArgumentString;
  333. SETUP_WINDBG_POINTERS(ExtensionApis);
  334. ListNear();
  335. }
  336. VOID
  337. r(
  338. IN HANDLE CurrentProcess,
  339. IN HANDLE CurrentThread,
  340. IN DWORD CurrentPc,
  341. IN PWINDBG_EXTENSION_APIS ExtensionApis,
  342. IN LPSTR ArgumentString
  343. )
  344. /*++
  345. Routine Description:
  346. Arguments:
  347. CurrentProcess -- Supplies a handle to the current process
  348. CurrentThread -- Supplies a handle to the current thread
  349. CurrentPc -- Supplies the current program counter. (may be meaningless)
  350. ExtensionApis -- Supplies pointers to ntsd support routines
  351. ArgumentString -- Supplies the arguments passed to the command
  352. Return Value:
  353. None.
  354. --*/
  355. {
  356. UNREFERENCED_PARAMETER(CurrentPc);
  357. hCurrentProcess = CurrentProcess;
  358. hCurrentThread = CurrentThread;
  359. lpArgumentString = ArgumentString;
  360. SETUP_WINDBG_POINTERS(ExtensionApis);
  361. DumpRegs();
  362. }
  363. VOID
  364. ti(
  365. IN HANDLE CurrentProcess,
  366. IN HANDLE CurrentThread,
  367. IN DWORD CurrentPc,
  368. IN PWINDBG_EXTENSION_APIS ExtensionApis,
  369. IN LPSTR ArgumentString
  370. )
  371. /*++
  372. Routine Description:
  373. Arguments:
  374. CurrentProcess -- Supplies a handle to the current process
  375. CurrentThread -- Supplies a handle to the current thread
  376. CurrentPc -- Supplies the current program counter. (may be meaningless)
  377. ExtensionApis -- Supplies pointers to ntsd support routines
  378. ArgumentString -- Supplies the arguments passed to the command
  379. Return Value:
  380. None.
  381. --*/
  382. {
  383. UNREFERENCED_PARAMETER(CurrentPc);
  384. hCurrentProcess = CurrentProcess;
  385. hCurrentThread = CurrentThread;
  386. lpArgumentString = ArgumentString;
  387. SETUP_WINDBG_POINTERS(ExtensionApis);
  388. TaskInfo();
  389. }
  390. VOID
  391. u(
  392. IN HANDLE CurrentProcess,
  393. IN HANDLE CurrentThread,
  394. IN DWORD CurrentPc,
  395. IN PWINDBG_EXTENSION_APIS ExtensionApis,
  396. IN LPSTR ArgumentString
  397. )
  398. /*++
  399. Routine Description:
  400. Arguments:
  401. CurrentProcess -- Supplies a handle to the current process
  402. CurrentThread -- Supplies a handle to the current thread
  403. CurrentPc -- Supplies the current program counter. (may be meaningless)
  404. ExtensionApis -- Supplies pointers to ntsd support routines
  405. ArgumentString -- Supplies the arguments passed to the command
  406. Return Value:
  407. None.
  408. --*/
  409. {
  410. UNREFERENCED_PARAMETER(CurrentPc);
  411. hCurrentProcess = CurrentProcess;
  412. hCurrentThread = CurrentThread;
  413. lpArgumentString = ArgumentString;
  414. SETUP_WINDBG_POINTERS(ExtensionApis);
  415. Unassemble();
  416. }