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.

706 lines
19 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1990 - 2000
  3. All rights reserved.
  4. Module Name:
  5. dbgspl.c
  6. Abstract:
  7. This module provides all the Spooler Subsystem Debugger extensions.
  8. Author:
  9. Krishna Ganugapati (KrishnaG) 1-July-1993
  10. Revision History:
  11. KrishnaG: Created: 1-July-1993 (imported most of IanJa's stuff)
  12. KrishnaG: Added: 7-July-1993 (added AndrewBe's UnicodeAnsi conversion routines)
  13. KrishnaG Added: 3-Aug-1993 (added DevMode/SecurityDescriptor dumps)
  14. To do:
  15. Write a generic dump unicode string (reduce the code!!)
  16. --*/
  17. #include "precomp.h"
  18. #pragma hdrstop
  19. #include "dbglocal.h"
  20. #include "dbgsec.h"
  21. #define NULL_TERMINATED 0
  22. #define VERBOSE_ON 1
  23. #define VERBOSE_OFF 0
  24. #define MAX_SDC_FLAGS 7
  25. typedef struct _DBG_SED_CONTROL{
  26. unsigned short Flag;
  27. LPSTR String;
  28. }DBG_SED_CONTROL, *PDBG_SED_CONTROL;
  29. DBG_SED_CONTROL SDC_Table[] =
  30. {
  31. 0x0001, "SE_OWNER_DEFAULTED",
  32. 0x0002, "SE_GROUP_DEFAULTED",
  33. 0x0004, "SE_DACL_PRESENT",
  34. 0x0008, "SE_DACL_DEFAULTED",
  35. 0x0010, "SE_SACL_PRESENT",
  36. 0x0020, "SE_SACL_DEFAULTED",
  37. 0x8000, "SE_SELF_RELATIVE"
  38. };
  39. #define MAX_ACE_FLAGS 6
  40. typedef struct _DBG_ACE_FLAGS{
  41. UCHAR Flags;
  42. LPSTR String;
  43. }DBG_ACE_FLAGS, *PDBG_ACE_FLAGS;
  44. DBG_ACE_FLAGS AceFlagsTable[] =
  45. {
  46. 0x1, "OBJECT_INHERIT_ACE",
  47. 0x2, "CONTAINER_INHERIT_ACE",
  48. 0x4, "NO_PROPAGATE_INHERIT_ACE",
  49. 0x8, "INHERIT_ONLY_ACE",
  50. 0x40, "SUCCESSFUL_ACCESS_ACE_FLAG",
  51. 0x80, "FAILED_ACCESS_ACE_FLAG"
  52. };
  53. typedef struct _ACCESSMASKTAB{
  54. DWORD Flag;
  55. LPSTR String;
  56. }ACCESSMASKTAB, *PACCESSMASKTAB;
  57. ACCESSMASKTAB AccessMaskTable[33] =
  58. {
  59. 0x00000001, "SERVER_ACCESS_ADMINSTER",
  60. 0x00000002, "SERVER_ACCESS_ENUMERATE",
  61. 0x00000004, "PRINTER_ACCESS_ADMINSTER",
  62. 0x00000008, "PRINTER_ACCESS_USE",
  63. 0x00000010, "JOB_ACCESS_ADMINISTER",
  64. 0x00010000, "DELETE",
  65. 0x00020000, "READ_CONTROL",
  66. 0x00040000, "WRITE_DAC",
  67. 0x00080000, "WRITE_OWNER",
  68. 0x00100000, "SYNCHRONIZE",
  69. 0x01000000, "ACCESS_SYSTEM_SECURITY",
  70. 0x10000000, "GENERIC_ALL",
  71. 0x20000000, "GENERIC_EXECUTE",
  72. 0x40000000, "GENERIC_WRITE",
  73. 0x80000000, "GENERIC_READ",
  74. 0x0000FFFF, "SPECIFIC_RIGHTS_ALL",
  75. 0x000F0000, "STANDARD_RIGHTS_REQUIRED <D-R/C-W/DAC-W/O>",
  76. 0x001F0000, "STANDARD_RIGHTS_ALL <D-R/C-W/DAC-W/O-S>",
  77. READ_CONTROL, "STANDARD_RIGHTS_READ <R/C>",
  78. READ_CONTROL, "STANDARD_RIGHTS_WRITE <R/C>",
  79. READ_CONTROL, "STANDARD_RIGHTS_EXECUTE <R/C>",
  80. SERVER_ALL_ACCESS, "SERVER_ALL_ACCESS <SRREQ-SAA-SAE>",
  81. SERVER_READ, "SERVER_READ <SRR-SAE>",
  82. SERVER_WRITE, "SERVER_WRITE <SRW-SAA-SAE>",
  83. SERVER_EXECUTE, "SERVER_EXECUTE <SRE-SAE>",
  84. PRINTER_ALL_ACCESS, "PRINTER_ALL_ACCESS <SRREQ-PAA-PAU>",
  85. PRINTER_READ, "PRINTER_READ <SRR-PAU>",
  86. PRINTER_WRITE, "PRINTER_WRITE <SRW-PAU>",
  87. PRINTER_EXECUTE, "PRINTER_EXECUTE <SRE-PAU>",
  88. JOB_ALL_ACCESS, "JOB_ALL_ACCESS <SRREQ-JAA>",
  89. JOB_READ, "JOB_READ <SRR-JAA>",
  90. JOB_WRITE, "JOB_WRITE <SRW-JAA>",
  91. JOB_EXECUTE, "JOB_EXECUTE <SRE-JAA>"
  92. };
  93. BOOL
  94. DbgDumpSecurityDescriptor(
  95. HANDLE hCurrentProcess,
  96. PNTSD_OUTPUT_ROUTINE Print,
  97. PISECURITY_DESCRIPTOR pSecurityDescriptor
  98. )
  99. {
  100. BOOL bSe_Self_Relative = FALSE;
  101. DWORD i;
  102. UINT_PTR OwnerSidAddress, GroupSidAddress;
  103. UINT_PTR SaclAddress, DaclAddress;
  104. SECURITY_DESCRIPTOR SecurityDescriptor;
  105. memset(&SecurityDescriptor, 0, sizeof(SECURITY_DESCRIPTOR));
  106. movestruct(pSecurityDescriptor, &SecurityDescriptor, SECURITY_DESCRIPTOR);
  107. (*Print)("SecurityDescriptor\n");
  108. bSe_Self_Relative = SecurityDescriptor.Control & SE_SELF_RELATIVE;
  109. if (bSe_Self_Relative) {
  110. (*Print)("This Security Descriptor is a Self-Relative Security Descriptor\n");
  111. }
  112. (*Print)("UCHAR Revision 0x%x\n", SecurityDescriptor.Revision);
  113. (*Print)("UCHAR Sbz1 0x%x\n", SecurityDescriptor.Sbz1);
  114. (*Print)("USHORT Control 0x%x\n", SecurityDescriptor.Control);
  115. for (i = 0; i < MAX_SDC_FLAGS; i++ ) {
  116. if (SecurityDescriptor.Control & SDC_Table[i].Flag) {
  117. (*Print)("%s - ON (%.4x)\n", SDC_Table[i].String, SDC_Table[i].Flag);
  118. } else {
  119. (*Print)("%s - OFF (%.4x)\n", SDC_Table[i].String, SDC_Table[i].Flag);
  120. }
  121. }
  122. //
  123. // Now dumping out the owner's sid
  124. //
  125. if (SecurityDescriptor.Owner == NULL) {
  126. (*Print)("PSID Owner null -- no owner sid present in the security descriptor\n");
  127. }else {
  128. if (bSe_Self_Relative) {
  129. // (*Print)("PSID Owner Offset 0x%.8x\n",SecurityDescriptor.Owner);
  130. OwnerSidAddress = (UINT_PTR)pSecurityDescriptor + (UINT_PTR)SecurityDescriptor.Owner;
  131. }else {
  132. OwnerSidAddress = (UINT_PTR)SecurityDescriptor.Owner;
  133. }
  134. // (*Print)("PSID Owner 0x%.8x\n", OwnerSidAddress);
  135. }
  136. (*Print)("The owner's sid is:\t\n");
  137. DbgDumpSid(hCurrentProcess, Print, (PVOID)OwnerSidAddress);
  138. (*Print)("\n\n");
  139. //
  140. // Now dumping out the group's sid
  141. if (SecurityDescriptor.Group == NULL) {
  142. (*Print)("PSID Group null -- no group sid present in the security descriptor\n");
  143. }else {
  144. if (bSe_Self_Relative) {
  145. // (*Print)("PSID Group Offset 0x%.8x\n", SecurityDescriptor.Group);
  146. GroupSidAddress = (UINT_PTR)pSecurityDescriptor + (UINT_PTR)SecurityDescriptor.Group;
  147. }else {
  148. GroupSidAddress = (UINT_PTR)SecurityDescriptor.Group;
  149. }
  150. // (*Print)("PSID Group 0x%.8x\n", GroupSidAddress);
  151. }
  152. (*Print)("The group's sid is:\t\n");
  153. DbgDumpSid(hCurrentProcess, Print, (PVOID)GroupSidAddress);
  154. (*Print)("\n");
  155. if (SecurityDescriptor.Sacl == NULL) {
  156. (*Print)("PACL Sacl null -- no sacl present in this security descriptor\n");
  157. }else {
  158. if (bSe_Self_Relative) {
  159. // (*Print)("PACL Sacl Offset %.8x\n", SecurityDescriptor.Sacl);
  160. SaclAddress = (UINT_PTR)pSecurityDescriptor + (UINT_PTR)SecurityDescriptor.Sacl;
  161. }else{
  162. SaclAddress = (UINT_PTR)SecurityDescriptor.Sacl;
  163. }
  164. // (*Print)("PACL Sacl 0x%.8x\n", SaclAddress);
  165. }
  166. if (SecurityDescriptor.Dacl == NULL) {
  167. (*Print)("PACL Dacl null -- no dacl present in this security descriptor\n");
  168. }else {
  169. if (bSe_Self_Relative) {
  170. // (*Print)("PACL Dacl Offset %.8x\n", SecurityDescriptor.Dacl);
  171. DaclAddress = (UINT_PTR)pSecurityDescriptor + (UINT_PTR)SecurityDescriptor.Dacl;
  172. }else {
  173. DaclAddress = (UINT_PTR)SecurityDescriptor.Dacl;
  174. }
  175. // (*Print)("PACL Dacl 0x%.8x\n", DaclAddress);
  176. DbgDumpAcl(hCurrentProcess, Print,(PVOID)DaclAddress);
  177. }
  178. return TRUE;
  179. }
  180. BOOL
  181. DbgDumpSid(
  182. HANDLE hCurrentProcess,
  183. PNTSD_OUTPUT_ROUTINE Print,
  184. PVOID SidAddress
  185. )
  186. {
  187. BYTE Sid[256];
  188. CHAR SidString[256];
  189. SID_NAME_USE SidType = 1;
  190. // (*Print)("Size of a SID is %d\n", sizeof(SID));
  191. // movestruct(SidAddress, &Sid, SID);
  192. memset(Sid, 0, sizeof(Sid));
  193. movemem(SidAddress, Sid, sizeof(Sid));
  194. ConvertSidToAsciiString(Sid, SidString, COUNTOF(SidString));
  195. (*Print)("PSID %s\n", SidString);
  196. return TRUE;
  197. }
  198. BOOL
  199. DbgDumpAceHeader(
  200. HANDLE hCurrentProcess,
  201. PNTSD_OUTPUT_ROUTINE Print,
  202. PVOID AceHeaderAddress
  203. )
  204. {
  205. ACE_HEADER AceHeader;
  206. DWORD i = 0;
  207. memset(&AceHeader, 0, sizeof(ACE_HEADER));
  208. movestruct(AceHeaderAddress, &AceHeader, ACE_HEADER);
  209. (*Print)("UCHAR AceType %.2x\n", AceHeader.AceType);
  210. switch (AceHeader.AceType) {
  211. case ACCESS_ALLOWED_ACE_TYPE:
  212. (*Print)("This is an ace of type: ACCESS_ALLOWED_ACE_TYPE\n");
  213. break;
  214. case ACCESS_DENIED_ACE_TYPE:
  215. (*Print)("This is an ace of type: ACCESS_DENIED_ACE_TYPE\n");
  216. break;
  217. case SYSTEM_AUDIT_ACE_TYPE:
  218. (*Print)("This is an ace of type: SYSTEM_AUDIT_ACE_TYPE\n");
  219. break;
  220. case SYSTEM_ALARM_ACE_TYPE:
  221. (*Print)("This is an ace of type: SYSTEM_ALARM_ACE_TYPE\n");
  222. break;
  223. }
  224. (*Print)("UCHAR AceFlags %.2x\n", AceHeader.AceFlags);
  225. for (i = 0; i < MAX_ACE_FLAGS; i++ ) {
  226. if (AceFlagsTable[i].Flags & AceHeader.AceFlags) {
  227. (*Print)("%s - ON (%d)\n", AceFlagsTable[i].String, AceFlagsTable[i].Flags);
  228. }else {
  229. (*Print)("%s - OFF (%d)\n", AceFlagsTable[i].String, AceFlagsTable[i].Flags);
  230. }
  231. }
  232. (*Print)("USHORT AceSize %d\n", AceHeader.AceSize);
  233. return TRUE;
  234. }
  235. BOOL
  236. DbgDumpAcl(
  237. HANDLE hCurrentProcess,
  238. PNTSD_OUTPUT_ROUTINE Print,
  239. PVOID AclAddress
  240. )
  241. {
  242. ACL Acl;
  243. PVOID AceAddress;
  244. ACE_HEADER AceHeader;
  245. ACCESS_ALLOWED_ACE AccessAllowedAce;
  246. ACCESS_DENIED_ACE AccessDeniedAce;
  247. SYSTEM_AUDIT_ACE SystemAuditAce;
  248. SYSTEM_ALARM_ACE SystemAlarmAce;
  249. DWORD i;
  250. UINT_PTR SidAddress;
  251. // Pull the Acl across
  252. movestruct(AclAddress, &Acl, ACL);
  253. (*Print)("ACL\n");
  254. (*Print)("UCHAR AclRevision 0x%x\n", Acl.AclRevision);
  255. (*Print)("UCHAR Sbz1 0x%x\n", Acl.Sbz1);
  256. (*Print)("USHORT AclSize %d\n", Acl.AclSize);
  257. (*Print)("USHORT AceCount %d\n", Acl.AceCount);
  258. (*Print)("USHORT Sz2 0x%x\n", Acl.Sbz2);
  259. AceAddress = (LPBYTE)AclAddress + sizeof(ACL);
  260. for (i = 0; i < Acl.AceCount; i++ ) {
  261. (*Print)("\nAce # %d: ",i);
  262. DbgDumpAceHeader(hCurrentProcess, Print, AceAddress);
  263. movestruct(AceAddress, &AceHeader, ACE_HEADER);
  264. switch (AceHeader.AceType) {
  265. case ACCESS_ALLOWED_ACE_TYPE:
  266. memset(&AccessAllowedAce, 0, sizeof(ACCESS_ALLOWED_ACE));
  267. movestruct(AceAddress, &AccessAllowedAce, ACCESS_ALLOWED_ACE);
  268. (*Print)("ACCESSMASK AccessMask %.8x\n", AccessAllowedAce.Mask);
  269. SidAddress = (UINT_PTR)((LPBYTE)AceAddress + sizeof(ACE_HEADER) + sizeof(ACCESS_MASK));
  270. // (*Print)("The Address of the Sid is %.8x\n", SidAddress);
  271. DbgDumpSid(hCurrentProcess, Print, (PVOID)SidAddress);
  272. break;
  273. case ACCESS_DENIED_ACE_TYPE:
  274. memset(&AccessDeniedAce, 0, sizeof(ACCESS_DENIED_ACE));
  275. movestruct(AceAddress, &AccessDeniedAce, ACCESS_DENIED_ACE);
  276. (*Print)("ACCESSMASK AccessMask %.8x\n", AccessDeniedAce.Mask);
  277. SidAddress = (UINT_PTR)((LPBYTE)AceAddress + sizeof(ACE_HEADER) + sizeof(ACCESS_MASK));
  278. DbgDumpSid(hCurrentProcess, Print, (PVOID)SidAddress);
  279. break;
  280. case SYSTEM_AUDIT_ACE_TYPE:
  281. memset(&SystemAuditAce, 0, sizeof(SYSTEM_AUDIT_ACE));
  282. movestruct(AceAddress, &SystemAuditAce, SYSTEM_AUDIT_ACE);
  283. (*Print)("ACCESSMASK AccessMask %.8x\n", SystemAuditAce.Mask);
  284. SidAddress = (UINT_PTR)((LPBYTE)AceAddress + sizeof(ACE_HEADER) + sizeof(ACCESS_MASK));
  285. DbgDumpSid(hCurrentProcess, Print, (PVOID)SidAddress);
  286. break;
  287. case SYSTEM_ALARM_ACE_TYPE:
  288. memset(&SystemAlarmAce, 0, sizeof(SYSTEM_ALARM_ACE));
  289. movestruct(AceAddress, &SystemAlarmAce, SYSTEM_ALARM_ACE);
  290. (*Print)("ACCESSMASK AccessMask %.8x\n", SystemAlarmAce.Mask);
  291. SidAddress = (UINT_PTR)((LPBYTE)AceAddress + sizeof(ACE_HEADER) + sizeof(ACCESS_MASK));
  292. DbgDumpSid(hCurrentProcess, Print, (PVOID)SidAddress);
  293. break;
  294. }
  295. AceAddress = (PVOID)((UINT_PTR)AceAddress + AceHeader.AceSize);
  296. (*Print)("\n");
  297. }
  298. return TRUE;
  299. }
  300. BOOL
  301. dsd(
  302. HANDLE hCurrentProcess,
  303. HANDLE hCurrentThread,
  304. UINT_PTR dwCurrentPc,
  305. PNTSD_EXTENSION_APIS lpExtensionApis,
  306. LPSTR lpArgumentString)
  307. {
  308. PNTSD_OUTPUT_ROUTINE Print;
  309. PNTSD_GET_EXPRESSION EvalExpression;
  310. PNTSD_GET_SYMBOL GetSymbol;
  311. UINT_PTR Address = 0;
  312. DWORD dwCount = 0;
  313. BOOL bThereAreOptions = TRUE;
  314. UNREFERENCED_PARAMETER(hCurrentProcess);
  315. UNREFERENCED_PARAMETER(hCurrentThread);
  316. UNREFERENCED_PARAMETER(dwCurrentPc);
  317. Print = lpExtensionApis->lpOutputRoutine;
  318. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  319. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  320. while (bThereAreOptions) {
  321. while (isspace(*lpArgumentString)) {
  322. lpArgumentString++;
  323. }
  324. switch (*lpArgumentString) {
  325. case 'c':
  326. lpArgumentString++;
  327. dwCount = EvalValue(&lpArgumentString, EvalExpression, Print);
  328. break;
  329. default: // go get the address because there's nothing else
  330. bThereAreOptions = FALSE;
  331. break;
  332. }
  333. }
  334. if (*lpArgumentString != 0) {
  335. Address = EvalValue(&lpArgumentString, EvalExpression, Print);
  336. }
  337. // if we've got no address, then quit now - nothing we can do
  338. if (!Address) {
  339. Print("We have a Null address\n");
  340. return(0);
  341. }
  342. DbgDumpSecurityDescriptor(
  343. hCurrentProcess,
  344. Print,
  345. (PISECURITY_DESCRIPTOR)Address
  346. );
  347. // Add Command to the Command Queue
  348. return 0;
  349. DBG_UNREFERENCED_PARAMETER(hCurrentProcess);
  350. DBG_UNREFERENCED_PARAMETER(hCurrentThread);
  351. DBG_UNREFERENCED_PARAMETER(dwCurrentPc);
  352. }
  353. BOOL
  354. dsid(
  355. HANDLE hCurrentProcess,
  356. HANDLE hCurrentThread,
  357. UINT_PTR dwCurrentPc,
  358. PNTSD_EXTENSION_APIS lpExtensionApis,
  359. LPSTR lpArgumentString)
  360. {
  361. PNTSD_OUTPUT_ROUTINE Print;
  362. PNTSD_GET_EXPRESSION EvalExpression;
  363. PNTSD_GET_SYMBOL GetSymbol;
  364. UINT_PTR Address = 0;
  365. DWORD dwCount = 0;
  366. BOOL bThereAreOptions = TRUE;
  367. UNREFERENCED_PARAMETER(hCurrentProcess);
  368. UNREFERENCED_PARAMETER(hCurrentThread);
  369. UNREFERENCED_PARAMETER(dwCurrentPc);
  370. Print = lpExtensionApis->lpOutputRoutine;
  371. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  372. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  373. while (bThereAreOptions) {
  374. while (isspace(*lpArgumentString)) {
  375. lpArgumentString++;
  376. }
  377. switch (*lpArgumentString) {
  378. case 'c':
  379. lpArgumentString++;
  380. dwCount = EvalValue(&lpArgumentString, EvalExpression, Print);
  381. break;
  382. default: // go get the address because there's nothing else
  383. bThereAreOptions = FALSE;
  384. break;
  385. }
  386. }
  387. if (*lpArgumentString != 0) {
  388. Address = EvalValue(&lpArgumentString, EvalExpression, Print);
  389. }
  390. // if we've got no address, then quit now - nothing we can do
  391. if (!Address) {
  392. Print("We have a Null address\n");
  393. return(0);
  394. }
  395. DbgDumpSid(
  396. hCurrentProcess,
  397. Print,
  398. (PVOID)Address
  399. );
  400. // Add Command to the Command Queue
  401. return 0;
  402. DBG_UNREFERENCED_PARAMETER(hCurrentProcess);
  403. DBG_UNREFERENCED_PARAMETER(hCurrentThread);
  404. DBG_UNREFERENCED_PARAMETER(dwCurrentPc);
  405. }
  406. BOOL
  407. ddev(
  408. HANDLE hCurrentProcess,
  409. HANDLE hCurrentThread,
  410. UINT_PTR dwCurrentPc,
  411. PNTSD_EXTENSION_APIS lpExtensionApis,
  412. LPSTR lpArgumentString)
  413. {
  414. PNTSD_OUTPUT_ROUTINE Print;
  415. PNTSD_GET_EXPRESSION EvalExpression;
  416. PNTSD_GET_SYMBOL GetSymbol;
  417. UINT_PTR Address = 0;
  418. DWORD dwCount = 0;
  419. BOOL bThereAreOptions = TRUE;
  420. UNREFERENCED_PARAMETER(hCurrentProcess);
  421. UNREFERENCED_PARAMETER(hCurrentThread);
  422. UNREFERENCED_PARAMETER(dwCurrentPc);
  423. Print = lpExtensionApis->lpOutputRoutine;
  424. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  425. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  426. while (bThereAreOptions) {
  427. while (isspace(*lpArgumentString)) {
  428. lpArgumentString++;
  429. }
  430. switch (*lpArgumentString) {
  431. case 'c':
  432. lpArgumentString++;
  433. dwCount = EvalValue(&lpArgumentString, EvalExpression, Print);
  434. break;
  435. default: // go get the address because there's nothing else
  436. bThereAreOptions = FALSE;
  437. break;
  438. }
  439. }
  440. if (*lpArgumentString != 0) {
  441. Address = EvalValue(&lpArgumentString, EvalExpression, Print);
  442. }
  443. // if we've got no address, then quit now - nothing we can do
  444. if (!Address) {
  445. Print("We have a Null address\n");
  446. return(0);
  447. }
  448. DumpDevMode(
  449. hCurrentProcess,
  450. Print,
  451. (UINT_PTR)Address
  452. );
  453. // Add Command to the Command Queue
  454. return 0;
  455. DBG_UNREFERENCED_PARAMETER(hCurrentProcess);
  456. DBG_UNREFERENCED_PARAMETER(hCurrentThread);
  457. DBG_UNREFERENCED_PARAMETER(dwCurrentPc);
  458. }
  459. BOOL
  460. DbgDumpAccessMask(
  461. HANDLE hCurrentProcess,
  462. PNTSD_OUTPUT_ROUTINE Print,
  463. DWORD AccessMask
  464. )
  465. {
  466. DWORD i;
  467. for (i = 0; i < 33; i++) {
  468. if (AccessMask & AccessMaskTable[i].Flag) {
  469. (*Print)("%s\t\tON\n", AccessMaskTable[i].String);
  470. }else {
  471. (*Print)("%s\t\tOFF\n", AccessMaskTable[i].String);
  472. }
  473. }
  474. return TRUE;
  475. }
  476. BOOL
  477. dam(
  478. HANDLE hCurrentProcess,
  479. HANDLE hCurrentThread,
  480. UINT_PTR dwCurrentPc,
  481. PNTSD_EXTENSION_APIS lpExtensionApis,
  482. LPSTR lpArgumentString)
  483. {
  484. PNTSD_OUTPUT_ROUTINE Print;
  485. PNTSD_GET_EXPRESSION EvalExpression;
  486. PNTSD_GET_SYMBOL GetSymbol;
  487. DWORD AccessMask = 0;
  488. DWORD dwCount = 0;
  489. BOOL bThereAreOptions = TRUE;
  490. UNREFERENCED_PARAMETER(hCurrentProcess);
  491. UNREFERENCED_PARAMETER(hCurrentThread);
  492. UNREFERENCED_PARAMETER(dwCurrentPc);
  493. Print = lpExtensionApis->lpOutputRoutine;
  494. EvalExpression = lpExtensionApis->lpGetExpressionRoutine;
  495. GetSymbol = lpExtensionApis->lpGetSymbolRoutine;
  496. while (bThereAreOptions) {
  497. while (isspace(*lpArgumentString)) {
  498. lpArgumentString++;
  499. }
  500. switch (*lpArgumentString) {
  501. case 'c':
  502. lpArgumentString++;
  503. dwCount = EvalValue(&lpArgumentString, EvalExpression, Print);
  504. break;
  505. default: // go get the address because there's nothing else
  506. bThereAreOptions = FALSE;
  507. break;
  508. }
  509. }
  510. if (*lpArgumentString != 0) {
  511. AccessMask = EvalValue(&lpArgumentString, EvalExpression, Print);
  512. }
  513. // if we've got no address, then quit now - nothing we can do
  514. if (AccessMask == (UINT_PTR)NULL) {
  515. Print("We have a Null address\n");
  516. return(0);
  517. }
  518. DbgDumpAccessMask(
  519. hCurrentProcess,
  520. Print,
  521. AccessMask
  522. );
  523. // Add Command to the Command Queue
  524. return 0;
  525. DBG_UNREFERENCED_PARAMETER(hCurrentProcess);
  526. DBG_UNREFERENCED_PARAMETER(hCurrentThread);
  527. DBG_UNREFERENCED_PARAMETER(dwCurrentPc);
  528. }