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.

349 lines
7.5 KiB

  1. /*
  2. *
  3. * actdbg.c
  4. *
  5. * This file contains ntsd debugger extensions for DCOM Activation
  6. *
  7. */
  8. #include "actdbg.hxx"
  9. DWORD MajorVersion = 0;
  10. DWORD MinorVersion = 1;
  11. void
  12. help(
  13. HANDLE hProcess,
  14. HANDLE hThread,
  15. DWORD PC,
  16. PNTSD_EXTENSION_APIS pExtApis,
  17. LPSTR pArgString
  18. )
  19. {
  20. APIPREAMBLE
  21. (*pfnPrint)( " RPCSS activation debug extention for ntsd (version %d.%d) :\n\n", MajorVersion, MinorVersion );
  22. (*pfnPrint)( " help Displays this help\n" );
  23. (*pfnPrint)( " ap <addr> Dumps ACTIVATION_PARAMS\n" );
  24. (*pfnPrint)( " sd <addr> Dumps SECURITY_DESCRIPTOR\n" );
  25. (*pfnPrint)( " clsid <addr> Dumps CClsidData\n" );
  26. (*pfnPrint)( " process <addr> Dumps CProcess\n" );
  27. (*pfnPrint)( " dsa <addr> Dumps DUALSTRINGARRAY\n");
  28. (*pfnPrint)( " surrogates Dumps info about all registered surrogates (old style servers)\n" );
  29. (*pfnPrint)( " servers <gpProcessTable | gpClassTable> Dumps the list of registered servers\n" );
  30. (*pfnPrint)( " remlist Dumps the cache of bindings to remote machines\n" );
  31. (*pfnPrint)( "\n");
  32. }
  33. //
  34. // Dumps the activation parameters struct.
  35. //
  36. // ap <address of activation params>
  37. //
  38. void
  39. ap(
  40. HANDLE hProcess,
  41. HANDLE hThread,
  42. DWORD PC,
  43. PNTSD_EXTENSION_APIS pExtApis,
  44. LPSTR pArgString
  45. )
  46. {
  47. ACTIVATION_PARAMS ActParams;
  48. APIPREAMBLE
  49. RpcTryExcept
  50. bStatus = ReadMemory( pExtApis, hProcess, Argv[0], (void *)&ActParams, sizeof(ActParams) );
  51. if ( bStatus )
  52. DumpActivationParams( pExtApis, hProcess, &ActParams );
  53. RpcExcept( TRUE )
  54. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  55. RpcEndExcept
  56. }
  57. //
  58. // Dumps a security descriptor.
  59. //
  60. // sd <address of security descriptor>
  61. //
  62. void
  63. sd(
  64. HANDLE hProcess,
  65. HANDLE hThread,
  66. DWORD PC,
  67. PNTSD_EXTENSION_APIS pExtApis,
  68. LPSTR pArgString
  69. )
  70. {
  71. SECURITY_DESCRIPTOR SD;
  72. DWORD_PTR Address;
  73. APIPREAMBLE
  74. RpcTryExcept
  75. Address = (*pExtApis->lpGetExpressionRoutine)( Argv[0] );
  76. bStatus = ReadMemory( pExtApis, hProcess, Address, (void *)&SD, sizeof(SD) );
  77. if ( bStatus )
  78. {
  79. if ( SD.Control & SE_SELF_RELATIVE ) {
  80. DWORD OwnerOffset = ((SECURITY_DESCRIPTOR_RELATIVE *)&SD)->Owner;
  81. DWORD GroupOffset = ((SECURITY_DESCRIPTOR_RELATIVE *)&SD)->Group;
  82. DWORD SaclOffset = ((SECURITY_DESCRIPTOR_RELATIVE *)&SD)->Sacl;
  83. DWORD DaclOffset = ((SECURITY_DESCRIPTOR_RELATIVE *)&SD)->Dacl;
  84. SD.Owner = (PSID)(Address + OwnerOffset);
  85. SD.Group = (PSID)(Address + GroupOffset);
  86. SD.Sacl = (PACL)(Address + SaclOffset);
  87. SD.Dacl = (PACL)(Address + DaclOffset);
  88. }
  89. DumpSecurityDescriptor( pExtApis, hProcess, &SD );
  90. }
  91. RpcExcept( TRUE )
  92. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  93. RpcEndExcept
  94. }
  95. //
  96. // Dumps an CLSID's settings.
  97. //
  98. // clsid <address of CClsidData>
  99. //
  100. void
  101. clsid(
  102. HANDLE hProcess,
  103. HANDLE hThread,
  104. DWORD PC,
  105. PNTSD_EXTENSION_APIS pExtApis,
  106. LPSTR pArgString
  107. )
  108. {
  109. CClsidData * pClsidData;
  110. APIPREAMBLE
  111. RpcTryExcept
  112. pClsidData = (CClsidData *) Alloc( sizeof(CClsidData) );
  113. bStatus = ReadMemory( pExtApis, hProcess, Argv[0], (void *)pClsidData, sizeof(CClsidData) );
  114. if ( bStatus )
  115. DumpClsid( pExtApis, hProcess, pClsidData );
  116. Free( pClsidData );
  117. RpcExcept( TRUE )
  118. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  119. RpcEndExcept
  120. }
  121. //
  122. // Dumps info about all registered surrogates (old style servers).
  123. //
  124. // surrogates
  125. //
  126. void
  127. surrogates(
  128. HANDLE hProcess,
  129. HANDLE hThread,
  130. DWORD PC,
  131. PNTSD_EXTENSION_APIS pExtApis,
  132. LPSTR pArgString
  133. )
  134. {
  135. APIPREAMBLE
  136. RpcTryExcept
  137. DumpSurrogates( pExtApis, hProcess );
  138. RpcExcept( TRUE )
  139. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  140. RpcEndExcept
  141. }
  142. //
  143. // Dumps info about all registered servers.
  144. //
  145. // servers
  146. //
  147. void
  148. servers(
  149. HANDLE hProcess,
  150. HANDLE hThread,
  151. DWORD PC,
  152. PNTSD_EXTENSION_APIS pExtApis,
  153. LPSTR pArgString
  154. )
  155. {
  156. APIPREAMBLE
  157. RpcTryExcept
  158. DumpServers( pExtApis, hProcess, Argv[0] );
  159. RpcExcept( TRUE )
  160. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  161. RpcEndExcept
  162. }
  163. //
  164. // Dumps CProcess identity information.
  165. //
  166. // process
  167. //
  168. void
  169. process(
  170. HANDLE hProcess,
  171. HANDLE hThread,
  172. DWORD PC,
  173. PNTSD_EXTENSION_APIS pExtApis,
  174. LPSTR pArgString
  175. )
  176. {
  177. CProcess * pProcess;
  178. APIPREAMBLE
  179. RpcTryExcept
  180. pProcess = (CProcess *) Alloc( sizeof(CProcess) );
  181. bStatus = ReadMemory( pExtApis, hProcess, Argv[0], (void *)pProcess, sizeof(CProcess) );
  182. if ( bStatus )
  183. DumpProcess( pExtApis, hProcess, pProcess, Argv[0]);
  184. Free( pProcess );
  185. RpcExcept( TRUE )
  186. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  187. RpcEndExcept
  188. }
  189. //
  190. // Dumps the list of cached binding handles to remote machines.
  191. //
  192. // remlist
  193. //
  194. void
  195. remlist(
  196. HANDLE hProcess,
  197. HANDLE hThread,
  198. DWORD PC,
  199. PNTSD_EXTENSION_APIS pExtApis,
  200. LPSTR pArgString
  201. )
  202. {
  203. APIPREAMBLE
  204. RpcTryExcept
  205. DumpRemoteList( pExtApis, hProcess );
  206. RpcExcept( TRUE )
  207. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  208. RpcEndExcept
  209. }
  210. //
  211. // Dumps the contents of a DUALSTRINGARRAY structure
  212. //
  213. // dsa
  214. //
  215. void
  216. dsa(
  217. HANDLE hProcess,
  218. HANDLE hThread,
  219. DWORD PC,
  220. PNTSD_EXTENSION_APIS pExtApis,
  221. LPSTR pArgString
  222. )
  223. {
  224. APIPREAMBLE
  225. RpcTryExcept
  226. DUALSTRINGARRAY dsaStub;
  227. bStatus = ReadMemory( pExtApis, hProcess, Argv[0], (void *)&dsaStub, sizeof(DUALSTRINGARRAY));
  228. if (bStatus)
  229. {
  230. // The first read gives us the stub structure; need to calculate the size of the entire
  231. // marshalled thing, then read in the whole thing
  232. DWORD dwSize;
  233. DUALSTRINGARRAY* pdsaReal;
  234. dwSize = sizeof(unsigned short) * (2 + dsaStub.wNumEntries);
  235. //(*pfnPrint)("dwSize = %d\n", dwSize);
  236. pdsaReal = (DUALSTRINGARRAY*)alloca(dwSize);
  237. bStatus = ReadMemory(pExtApis, hProcess, Argv[0], (void*)pdsaReal, dwSize);
  238. if (bStatus)
  239. {
  240. DumpDUALSTRINGARRAY(pExtApis, hProcess, pdsaReal, " ");
  241. }
  242. }
  243. RpcExcept( TRUE )
  244. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  245. RpcEndExcept
  246. }
  247. //
  248. // Dumps the contents of a CBList of CServerOxids
  249. //
  250. // blsoxids
  251. //
  252. void
  253. blsoxids(
  254. HANDLE hProcess,
  255. HANDLE hThread,
  256. DWORD PC,
  257. PNTSD_EXTENSION_APIS pExtApis,
  258. LPSTR pArgString
  259. )
  260. {
  261. APIPREAMBLE
  262. RpcTryExcept
  263. CBList* plist = (CBList*)_alloca(sizeof(CBList));
  264. bStatus = ReadMemory( pExtApis, hProcess, Argv[0], (void *)plist, sizeof(CBList));
  265. if (bStatus)
  266. DumpBListSOxids(pExtApis, hProcess, plist);
  267. RpcExcept( TRUE )
  268. (*pfnPrint)( "Oops, I've faulted and I can't get up!\n" );
  269. RpcEndExcept
  270. }