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.

1145 lines
26 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1995
  5. //
  6. // File: ole.cxx
  7. //
  8. // Contents: Implements ntsd extensions to dump ole tables
  9. //
  10. // Functions:
  11. //
  12. //
  13. // History: 06-01-95 BruceMa Created
  14. //
  15. //
  16. //--------------------------------------------------------------------------
  17. #include <ole2int.h>
  18. #include <windows.h>
  19. #include <ole2.h>
  20. #include "ole.h"
  21. #include "ddllcach.h"
  22. #include "dshrdmem.h"
  23. #define OLE_VERSION "1.0"
  24. void getArgument(LPSTR *lpArgumentString, LPSTR a);
  25. void checkForScm(PNTSD_EXTENSION_APIS lpExtensionApis);
  26. void NotInScm(PNTSD_EXTENSION_APIS lpExtensionApis);
  27. void NotInOle(PNTSD_EXTENSION_APIS lpExtensionApis);
  28. ULONG ScanAddr(char *lpsz);
  29. void channelHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  30. void displayChannel(HANDLE hProcess,
  31. PNTSD_EXTENSION_APIS lpExtensionApis,
  32. ULONG pChannel,
  33. char *arg);
  34. void classCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  35. void displayClassCache(HANDLE hProcess,
  36. PNTSD_EXTENSION_APIS lpExtensionApis);
  37. void displayClassCacheCk(HANDLE hProcess,
  38. PNTSD_EXTENSION_APIS lpExtensionApis);
  39. void classInfoHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  40. BOOL displayClassInfo(HANDLE hProcess,
  41. PNTSD_EXTENSION_APIS lpExtensionApis,
  42. CLSID *clsid);
  43. void dllCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  44. void displayDllCache(HANDLE hProcess,
  45. PNTSD_EXTENSION_APIS lpExtensionApis,
  46. SDllCache *p);
  47. void displayHr(HANDLE hProcess,
  48. PNTSD_EXTENSION_APIS lpExtensionApis,
  49. char *arg);
  50. void fileExtHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  51. void displayFileExtTbl(HANDLE hProcess,
  52. PNTSD_EXTENSION_APIS lpExtensionApis,
  53. SDllShrdTbl *pShrdTbl,
  54. CLSID *pClsid,
  55. WCHAR *wszExt);
  56. void filePatHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  57. void displayFilePatTbl(HANDLE hProcess,
  58. PNTSD_EXTENSION_APIS lpExtensionApis,
  59. SDllShrdTbl *pShrdTbl,
  60. CLSID *pClsid);
  61. void stdidHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  62. void displayStdidEntry(HANDLE hProcess,
  63. PNTSD_EXTENSION_APIS lpExtensionApis,
  64. ULONG p,
  65. char *arg);
  66. void displayStdid(HANDLE hProcess,
  67. PNTSD_EXTENSION_APIS lpExtensionApis,
  68. ULONG p);
  69. void infoLevelHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  70. void displayInfoLevel(HANDLE hProcess,
  71. PNTSD_EXTENSION_APIS lpExtensionApis,
  72. LPSTR lpArgumentString);
  73. void monikerHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  74. BOOL displayMoniker(HANDLE hProcess,
  75. PNTSD_EXTENSION_APIS lpExtensionApis,
  76. ULONG pMoniker);
  77. void psClsidHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  78. void displayPsClsidTbl(HANDLE hProcess,
  79. PNTSD_EXTENSION_APIS lpExtensionApis,
  80. SDllShrdTbl *pShrdTbl,
  81. CLSID *clisd);
  82. void ipidHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  83. void displayIpid(HANDLE hProcess,
  84. PNTSD_EXTENSION_APIS lpExtensionApis);
  85. void displayIpidEntry(HANDLE hProcess,
  86. PNTSD_EXTENSION_APIS lpExtensionApis,
  87. char *arg);
  88. void oxidHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  89. void displayOxid(HANDLE hProcess,
  90. PNTSD_EXTENSION_APIS lpExtensionApis);
  91. void displayOxidEntry(HANDLE hProcess,
  92. PNTSD_EXTENSION_APIS lpExtensionApis,
  93. char *arg);
  94. void displayCliRot(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis);
  95. void displayScmRot(HANDLE hProcess, PNTSD_EXTENSION_APIS lpExtensionApis);
  96. void cliRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  97. void scmRotHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  98. void vtblHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  99. void displayVtbl(HANDLE hProcess,
  100. PNTSD_EXTENSION_APIS lpExtensionApis,
  101. void *lpObj);
  102. void treatAsCacheHelp(PNTSD_EXTENSION_APIS lpExtensionApis);
  103. void displayTreatAsCache(HANDLE hProcess,
  104. PNTSD_EXTENSION_APIS lpExtensionApis,
  105. CLSID *clsid);
  106. void determineIfScm(void);
  107. BOOL ScanCLSID(LPSTR lpsz, LPGUID pguid);
  108. void FormatCLSID(REFGUID rguid, LPSTR lpsz);
  109. BOOL fScmNeedsInit = TRUE;
  110. BOOL fInScm = FALSE;
  111. //+-------------------------------------------------------------------------
  112. //
  113. // Extension: !ole.help
  114. //
  115. // Synopsis: Display a help menu of all the supported extensions
  116. // in this dll
  117. //
  118. // History: 01-Jun-95 BruceMa Created
  119. //
  120. //--------------------------------------------------------------------------
  121. DEFINE_EXT(help)
  122. {
  123. Arg arg;
  124. // Check whether debuggee is the scm
  125. CheckForScm();
  126. // Help menu for an OLE client or server
  127. if (!fInScm)
  128. {
  129. // Check for any argument
  130. GetArg(arg);
  131. // CRpcChannelBuffer help
  132. if (lstrcmpA(arg, "ch") == 0)
  133. {
  134. channelHelp(lpExtensionApis);
  135. }
  136. // Class information help
  137. else if (lstrcmpA(arg, "ci") == 0)
  138. {
  139. classInfoHelp(lpExtensionApis);
  140. }
  141. // DllCache help
  142. else if (lstrcmpA(arg, "ds") == 0 || lstrcmpA(arg, "dh") == 0)
  143. {
  144. dllCacheHelp(lpExtensionApis);
  145. }
  146. // File extension cache help
  147. else if (lstrcmpA(arg, "fe") == 0)
  148. {
  149. fileExtHelp(lpExtensionApis);
  150. }
  151. // File type patterns cache help
  152. else if (lstrcmpA(arg, "ft") == 0)
  153. {
  154. filePatHelp(lpExtensionApis);
  155. }
  156. // Standard identity table
  157. else if (lstrcmpA(arg, "id") == 0)
  158. {
  159. stdidHelp(lpExtensionApis);
  160. }
  161. // Debug info levels
  162. else if (lstrcmpA(arg, "in") == 0)
  163. {
  164. infoLevelHelp(lpExtensionApis);
  165. }
  166. // IPID table
  167. else if (lstrcmpA(arg, "ip") == 0)
  168. {
  169. ipidHelp(lpExtensionApis);
  170. }
  171. // A moniker
  172. else if (lstrcmpA(arg, "mk") == 0)
  173. {
  174. monikerHelp(lpExtensionApis);
  175. }
  176. // OXID table
  177. else if (lstrcmpA(arg, "ox") == 0)
  178. {
  179. oxidHelp(lpExtensionApis);
  180. }
  181. // IID to class mapping
  182. else if (lstrcmpA(arg, "ps") == 0)
  183. {
  184. psClsidHelp(lpExtensionApis);
  185. }
  186. // ROT help
  187. else if (lstrcmpA(arg, "rt") == 0)
  188. {
  189. cliRotHelp(lpExtensionApis);
  190. }
  191. // TreatAs help
  192. else if (lstrcmpA(arg, "ta") == 0)
  193. {
  194. treatAsCacheHelp(lpExtensionApis);
  195. }
  196. // Vtbl help
  197. else if (lstrcmpA(arg, "vt") == 0)
  198. {
  199. vtblHelp(lpExtensionApis);
  200. }
  201. // Print the full help menu
  202. else
  203. {
  204. Printf("Ole32 NTSD extensions - Version %s\n\n", OLE_VERSION);
  205. Printf("ch addr - Decode addr as an RPC channel\n");
  206. Printf("ci [clsid] - Display registry class information\n");
  207. Printf("ck - Is this a checked or retail version of ole32?\n");
  208. Printf("dh - Display Inproc Handler dll/class cache\n");
  209. Printf("ds - Display Inproc Server dll/class cache\n");
  210. Printf("ep - Display current RPC endpoints\n");
  211. Printf("er err - Display the message for error number err \n");
  212. Printf("fe [e|c] - Display file extensions cache\n");
  213. Printf("ft [clsid] - Display file type pattern(s)\n");
  214. Printf("help [cmd] - Display this menu or specific help\n");
  215. Printf("id - Display CStdIdentity table\n");
  216. Printf("in - Set/reset debug info level\n");
  217. Printf("ip - Display IPID table information\n");
  218. Printf("mk addr - Decode addr as a moniker\n");
  219. Printf("ox - Display OXID table information\n");
  220. Printf("pg addr - Display addr as a guid\n");
  221. Printf("pl - Display platform information\n");
  222. Printf("ps - Display proxy/stub clsid cache\n");
  223. Printf("rh addr - Decode addr as a remote handler\n");
  224. Printf("rt - Display Running Object Table\n");
  225. Printf("ta [clsid] - Display TreatAs cache\n");
  226. Printf("vt obj - Interpret vtbl for object obj\n");
  227. }
  228. }
  229. // Help menu for the scm
  230. else
  231. {
  232. // Check for any argument
  233. GetArg(arg);
  234. if (lstrcmp(arg, "rt") == 0)
  235. {
  236. scmRotHelp(lpExtensionApis);
  237. }
  238. if (lstrcmp(arg, "cc") == 0)
  239. {
  240. classCacheHelp(lpExtensionApis);
  241. }
  242. // Print the full help menu
  243. else
  244. {
  245. Printf("Ole32 NTSD extensions - Version %s\n\n", OLE_VERSION);
  246. Printf("cc - Display class cache info\n");
  247. Printf("ck - Is this a checked or retail version of scm?\n");
  248. Printf("ep - Display current RPC endpoints\n");
  249. Printf("er err - Display the message for error number err \n");
  250. Printf("help [cmd] - Display this menu or specific help\n");
  251. Printf("in - Set/reset debug info level\n");
  252. Printf("mk addr - Decode addr as a moniker\n");
  253. Printf("pg addr - Display addr as a guid\n");
  254. Printf("rh - Display active remote handlers\n");
  255. Printf("rt - Display Running Object Table\n");
  256. Printf("ts - Display thread information\n");
  257. Printf("vt obj - Interpret vtbl for object obj\n");
  258. }
  259. }
  260. }
  261. //+-------------------------------------------------------------------------
  262. //
  263. // Extension: !ole.cc
  264. //
  265. // Synopsis: Display the scm class cache
  266. //
  267. // History: 01-Jun-95 BruceMa Created
  268. //
  269. //--------------------------------------------------------------------------
  270. DEFINE_EXT(cc)
  271. {
  272. ULONG padr;
  273. // Check whether debuggee is the scm
  274. CheckForScm();
  275. NOTINOLE
  276. // Determine if thisis checked or retail scm
  277. padr = GetExpression("scm!_CairoleInfoLevel");
  278. // Display the scm's class cache
  279. if (padr == NULL)
  280. {
  281. displayClassCache(hProcess, lpExtensionApis);
  282. }
  283. else
  284. {
  285. displayClassCacheCk(hProcess, lpExtensionApis);
  286. }
  287. }
  288. //+-------------------------------------------------------------------------
  289. //
  290. // Extension: !ole.ch
  291. //
  292. // Synopsis: Display a channel controller
  293. //
  294. // History: 01-Jun-95 BruceMa Created
  295. //
  296. //--------------------------------------------------------------------------
  297. DEFINE_EXT(ch)
  298. {
  299. Arg arg;
  300. ULONG addr;
  301. // Check whether debuggee is the scm
  302. CheckForScm();
  303. NOTINSCM
  304. // Fetch the argument
  305. GetArg(arg);
  306. if (!arg[0])
  307. {
  308. Printf("...use !ole.ch <address CRpcChannelBuffer>\n");
  309. return;
  310. }
  311. // Parse it as a hexadecimal address
  312. if (arg[0] != '?')
  313. {
  314. addr = ScanAddr(arg);
  315. if (addr == NULL)
  316. {
  317. Printf("...%s is not a valid address\n", arg);
  318. return;
  319. }
  320. }
  321. // DOLATERIFEVER: Check that this is indeed an CRpcChannelBuffer
  322. // Display the parsed address as a CRpcChannelBuffer
  323. displayChannel(hProcess, lpExtensionApis, addr, arg);
  324. }
  325. //+-------------------------------------------------------------------------
  326. //
  327. // Extension: !ole.ci
  328. //
  329. // Synopsis: Display registry class information
  330. //
  331. // History: 01-Jun-95 BruceMa Created
  332. //
  333. //--------------------------------------------------------------------------
  334. DEFINE_EXT(ci)
  335. {
  336. Arg arg;
  337. CLSID clsid;
  338. // Check whether debuggee is the scm
  339. CheckForScm();
  340. // Fetch the argument
  341. GetArg(arg);
  342. // Parse it as a clsid
  343. if (arg[0])
  344. {
  345. if (!ScanCLSID(arg, &clsid))
  346. {
  347. Printf("...%s is not a valid clsid\n", arg);
  348. return;
  349. }
  350. }
  351. // Display all or particular registry class information
  352. if (arg[0])
  353. {
  354. displayClassInfo(hProcess, lpExtensionApis, &clsid);
  355. }
  356. else
  357. {
  358. displayClassInfo(hProcess, lpExtensionApis, NULL);
  359. }
  360. }
  361. //+-------------------------------------------------------------------------
  362. //
  363. // Extension: !ole.ck
  364. //
  365. // Synopsis: Is this the checked or retail version of OLE?
  366. //
  367. // History: 01-Jun-95 BruceMa Created
  368. //
  369. //--------------------------------------------------------------------------
  370. DEFINE_EXT(ck)
  371. {
  372. ULONG padr;
  373. // Check whether debuggee is the scm
  374. CheckForScm();
  375. if (fInScm)
  376. {
  377. padr = GetExpression("scm!_CairoleInfoLevel");
  378. }
  379. else
  380. {
  381. padr = GetExpression("ole32!_CairoleInfoLevel");
  382. }
  383. if (padr == NULL)
  384. {
  385. Printf("Retail\n");
  386. }
  387. else
  388. {
  389. Printf("Checked\n");
  390. }
  391. }
  392. //+-------------------------------------------------------------------------
  393. //
  394. // Extension: !ole.dh
  395. //
  396. // Synopsis: Display the dll/class cache for inproc handlers
  397. //
  398. // History: 01-Jun-95 BruceMa Created
  399. //
  400. //--------------------------------------------------------------------------
  401. DEFINE_EXT(dh)
  402. {
  403. SDllCache dllCache;
  404. ULONG padr;
  405. // Check whether debuggee is the scm
  406. CheckForScm();
  407. NOTINSCM
  408. // Fetch the dll/class cache object
  409. padr = GetExpression("ole32!gdllcacheHandler");
  410. ReadMem((void *) &dllCache, padr, sizeof(SDllCache));
  411. Printf("Dll/class cache for in-process handlers\n\n");
  412. displayDllCache(hProcess, lpExtensionApis, &dllCache);
  413. }
  414. //+-------------------------------------------------------------------------
  415. //
  416. // Extension: !ole.ds
  417. //
  418. // Synopsis: Display the dll/class cache for inproc servers
  419. //
  420. // History: 01-Jun-95 BruceMa Created
  421. //
  422. //--------------------------------------------------------------------------
  423. DEFINE_EXT(ds)
  424. {
  425. SDllCache dllCache;
  426. ULONG padr;
  427. // Check whether debuggee is the scm
  428. CheckForScm();
  429. padr = GetExpression("ole32!gdllcacheInprocSrv");
  430. ReadMem(&dllCache, padr, sizeof(SDllCache));
  431. Printf("Dll/class cache for in-process servers\n\n");
  432. displayDllCache(hProcess, lpExtensionApis, &dllCache);
  433. }
  434. //+-------------------------------------------------------------------------
  435. //
  436. // Extension: !ole.er
  437. //
  438. // Synopsis: Display a Win32 or OLE error message
  439. //
  440. // History: 01-Jun-95 BruceMa Created
  441. //
  442. //--------------------------------------------------------------------------
  443. DEFINE_EXT(er)
  444. {
  445. Arg arg;
  446. // Check whether debuggee is the scm
  447. CheckForScm();
  448. GetArg(arg);
  449. displayHr(hProcess, lpExtensionApis, arg);
  450. }
  451. //+-------------------------------------------------------------------------
  452. //
  453. // Extension: !ole.fe
  454. //
  455. // Synopsis: Display file extension information
  456. //
  457. // History: 01-Jun-95 BruceMa Created
  458. //
  459. //--------------------------------------------------------------------------
  460. DEFINE_EXT(fe)
  461. {
  462. Arg arg;
  463. ULONG pAdr;
  464. SDllShrdTbl *pShrdTbl;
  465. CLSID clsid;
  466. WCHAR wszExt[16];
  467. // Check whether debuggee is the scm
  468. CheckForScm();
  469. NOTINSCM
  470. // Check for any argument
  471. GetArg(arg);
  472. if (arg[0])
  473. {
  474. if (arg[0] == '{')
  475. {
  476. if(!ScanCLSID(arg, &clsid))
  477. {
  478. Printf("...%s is not a valid CLSID\n", arg);
  479. return;
  480. }
  481. }
  482. else if (arg[0] == '.')
  483. {
  484. if (!MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, arg, -1, wszExt,
  485. 16 * sizeof(WCHAR)))
  486. {
  487. Printf("..%ws\n", wszExt);
  488. Printf("...invalid extension %s\n", arg);
  489. return;
  490. }
  491. }
  492. else
  493. {
  494. Printf("...can't understand argument\n");
  495. }
  496. }
  497. // Fetch the address of the shared memory table
  498. pAdr = GetExpression("ole32!g_pShrdTbl");
  499. ReadMem(&pShrdTbl, pAdr, sizeof(ULONG));
  500. if (arg[0])
  501. {
  502. if (arg[0] == '{')
  503. {
  504. displayFileExtTbl(hProcess, lpExtensionApis, pShrdTbl, &clsid,
  505. NULL);
  506. }
  507. else
  508. {
  509. displayFileExtTbl(hProcess, lpExtensionApis, pShrdTbl, NULL,
  510. wszExt);
  511. }
  512. }
  513. else
  514. {
  515. displayFileExtTbl(hProcess, lpExtensionApis, pShrdTbl, NULL, NULL);
  516. }
  517. }
  518. //+-------------------------------------------------------------------------
  519. //
  520. // Extension: !ole.ft
  521. //
  522. // Synopsis: Display file type patterns
  523. //
  524. // History: 01-Jun-95 BruceMa Created
  525. //
  526. //--------------------------------------------------------------------------
  527. DEFINE_EXT(ft)
  528. {
  529. Arg arg;
  530. ULONG pAdr;
  531. SDllShrdTbl *pShrdTbl;
  532. CLSID clsid;
  533. // Check whether debuggee is the scm
  534. CheckForScm();
  535. NOTINSCM
  536. // Check for an argument
  537. GetArg(arg);
  538. if (arg[0])
  539. {
  540. if (arg[0] == '{')
  541. {
  542. if(!ScanCLSID(arg, &clsid))
  543. {
  544. Printf("...%s is not a valid CLSID\n", arg);
  545. return;
  546. }
  547. }
  548. else
  549. {
  550. Printf("...%s is not a valid CLSID\n", arg);
  551. return;
  552. }
  553. }
  554. // Fetch the address of the shared memory table
  555. pAdr = GetExpression("ole32!g_pShrdTbl");
  556. ReadMem(&pShrdTbl, pAdr, sizeof(ULONG));
  557. if (arg[0] == '{')
  558. {
  559. displayFilePatTbl(hProcess, lpExtensionApis, pShrdTbl, &clsid);
  560. }
  561. else
  562. {
  563. displayFilePatTbl(hProcess, lpExtensionApis, pShrdTbl, NULL);
  564. }
  565. }
  566. //+-------------------------------------------------------------------------
  567. //
  568. // Extension: !ole.id
  569. //
  570. // Synopsis: Display the CStdIdentity taable
  571. //
  572. // History: 01-Jun-95 BruceMa Created
  573. //
  574. //--------------------------------------------------------------------------
  575. DEFINE_EXT(id)
  576. {
  577. ULONG pAdr;
  578. Arg arg;
  579. // Check whether debuggee is the scm
  580. CheckForScm();
  581. NOTINSCM
  582. // Fetch the address of the standard identity table
  583. pAdr = GetExpression("ole32!sg_idtable");
  584. // Check for any argument
  585. GetArg(arg);
  586. // Display all or one entry
  587. if (arg[0])
  588. {
  589. displayStdidEntry(hProcess, lpExtensionApis, pAdr, arg);
  590. }
  591. else
  592. {
  593. displayStdid(hProcess, lpExtensionApis, pAdr);
  594. }
  595. }
  596. //+-------------------------------------------------------------------------
  597. //
  598. // Extension: !ole.in
  599. //
  600. // Synopsis: Display/change debug info levels
  601. //
  602. // History: 01-Jun-95 BruceMa Created
  603. //
  604. //--------------------------------------------------------------------------
  605. DEFINE_EXT(in)
  606. {
  607. // Check whether debuggee is the scm
  608. CheckForScm();
  609. // Set/display an info level
  610. displayInfoLevel(hProcess, lpExtensionApis, lpArgumentString);
  611. }
  612. //+-------------------------------------------------------------------------
  613. //
  614. // Extension: !ole.ip
  615. //
  616. // Synopsis: Display IPID table
  617. //
  618. // History: 11-Aug-95 BruceMa Created
  619. //
  620. //--------------------------------------------------------------------------
  621. DEFINE_EXT(ip)
  622. {
  623. Arg arg;
  624. // Check whether debuggee is the scm
  625. CheckForScm();
  626. NOTINSCM
  627. // Check for an argument
  628. GetArg(arg);
  629. // The whole table or a single entry
  630. if (arg[0])
  631. {
  632. displayIpidEntry(hProcess, lpExtensionApis, arg);
  633. }
  634. else
  635. {
  636. displayIpid(hProcess, lpExtensionApis);
  637. }
  638. }
  639. //+-------------------------------------------------------------------------
  640. //
  641. // Extension: !ole.mk
  642. //
  643. // Synopsis: Interpret a moniker object
  644. //
  645. // History: 01-Jun-95 BruceMa Created
  646. //
  647. //--------------------------------------------------------------------------
  648. DEFINE_EXT(mk)
  649. {
  650. Arg arg;
  651. ULONG pAdr;
  652. // Check whether debuggee is the scm
  653. CheckForScm();
  654. // Scan the argument
  655. GetArg(arg);
  656. if (!arg[0])
  657. {
  658. Printf("...use !ole.mk <moniker address>\n");
  659. return;
  660. }
  661. pAdr = ScanAddr(arg);
  662. // Interpret this address as a moniker
  663. if (!displayMoniker(hProcess, lpExtensionApis, pAdr))
  664. {
  665. Printf("...%08x isn't a system moniker\n", pAdr);
  666. }
  667. }
  668. //+-------------------------------------------------------------------------
  669. //
  670. // Extension: !ole.ox
  671. //
  672. // Synopsis: Display OXID table
  673. //
  674. // History: 11-Aug-95 BruceMa Created
  675. //
  676. //--------------------------------------------------------------------------
  677. DEFINE_EXT(ox)
  678. {
  679. Arg arg;
  680. // Check whether debuggee is the scm
  681. CheckForScm();
  682. NOTINSCM
  683. // Check for an argument
  684. GetArg(arg);
  685. // The whole table or a single entry
  686. if (arg[0])
  687. {
  688. displayOxidEntry(hProcess, lpExtensionApis, arg);
  689. }
  690. else
  691. {
  692. displayOxid(hProcess, lpExtensionApis);
  693. }
  694. }
  695. //+-------------------------------------------------------------------------
  696. //
  697. // Extension: !ole.pg
  698. //
  699. // Synopsis: Pretty print a guid
  700. //
  701. // History: 01-Jun-95 BruceMa Created
  702. //
  703. //--------------------------------------------------------------------------
  704. DEFINE_EXT(pg)
  705. {
  706. Arg arg;
  707. ULONG addr;
  708. GUID guid;
  709. char szGuid[CLSIDSTR_MAX];
  710. // Fetch the argument
  711. GetArg(arg);
  712. if (!arg[0])
  713. {
  714. Printf("...requires an addr argument\n");
  715. return;
  716. }
  717. addr = ScanAddr(arg);
  718. // Fetch the guid
  719. ReadMem(&guid, addr, sizeof(GUID));
  720. // Format and print the guid
  721. FormatCLSID((GUID &) guid, szGuid);
  722. Printf("%s\n", szGuid);
  723. }
  724. //+-------------------------------------------------------------------------
  725. //
  726. // Extension: !ole.pl
  727. //
  728. // Synopsis: Display platform information
  729. //
  730. // History: 01-Jun-95 BruceMa Created
  731. //
  732. //--------------------------------------------------------------------------
  733. DEFINE_EXT(pl)
  734. {
  735. OSVERSIONINFO osInfo;
  736. osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  737. if (GetVersionEx(&osInfo))
  738. {
  739. Printf("Cairo %d.%d Build %d\n",
  740. osInfo.dwMajorVersion,
  741. osInfo.dwMinorVersion,
  742. osInfo.dwBuildNumber);
  743. }
  744. else
  745. {
  746. Printf("...Unable to get version/platform info\n");
  747. }
  748. }
  749. //+-------------------------------------------------------------------------
  750. //
  751. // Extension: !ole.ps
  752. //
  753. // Synopsis: Display CLSID of proxy/stub handler dll for given IID
  754. //
  755. // History: 01-Jun-95 BruceMa Created
  756. //
  757. //--------------------------------------------------------------------------
  758. DEFINE_EXT(ps)
  759. {
  760. Arg arg;
  761. ULONG pAdr;
  762. SDllShrdTbl *pShrdTbl;
  763. IID iid;
  764. WCHAR wszExt[16];
  765. // Check whether debuggee is the scm
  766. CheckForScm();
  767. NOTINSCM
  768. // Check for any argument
  769. GetArg(arg);
  770. if (arg[0])
  771. {
  772. if(!ScanCLSID(arg, &iid))
  773. {
  774. Printf("...%s is not a valid CLSID\n", arg);
  775. return;
  776. }
  777. }
  778. // Fetch the address of the shared memory table
  779. pAdr = GetExpression("ole32!g_pShrdTbl");
  780. ReadMem(&pShrdTbl, pAdr, sizeof(ULONG));
  781. if (arg[0])
  782. {
  783. displayPsClsidTbl(hProcess, lpExtensionApis, pShrdTbl, &iid);
  784. }
  785. else
  786. {
  787. displayPsClsidTbl(hProcess, lpExtensionApis, pShrdTbl, NULL);
  788. }
  789. }
  790. //+-------------------------------------------------------------------------
  791. //
  792. // Extension: !ole.rt
  793. //
  794. // Synopsis: Display the ROT
  795. //
  796. // History: 01-Jun-95 BruceMa Created
  797. //
  798. //--------------------------------------------------------------------------
  799. DEFINE_EXT(rt)
  800. {
  801. // Check whether debuggee is the scm
  802. CheckForScm();
  803. if (fInScm)
  804. {
  805. displayScmRot(hProcess, lpExtensionApis);
  806. }
  807. else
  808. {
  809. displayCliRot(hProcess, lpExtensionApis);
  810. }
  811. }
  812. //+-------------------------------------------------------------------------
  813. //
  814. // Extension: !ole.ta
  815. //
  816. // Synopsis: Display TreatAs cache
  817. //
  818. // History: 01-Jun-95 BruceMa Created
  819. //
  820. //--------------------------------------------------------------------------
  821. DEFINE_EXT(ta)
  822. {
  823. Arg arg;
  824. CLSID clsid;
  825. // Check whether debuggee is the scm
  826. CheckForScm();
  827. // Check whether a clsid was supplied
  828. GetArg(arg);
  829. if (arg[0])
  830. {
  831. if (!ScanCLSID(arg, &clsid))
  832. {
  833. Printf("..%s is not a valid CLSID\n", arg);
  834. return;
  835. }
  836. displayTreatAsCache(hProcess, lpExtensionApis, &clsid);
  837. }
  838. // Display the entire TreatAs class cache
  839. else
  840. {
  841. displayTreatAsCache(hProcess, lpExtensionApis, NULL);
  842. }
  843. }
  844. //+-------------------------------------------------------------------------
  845. //
  846. // Extension: !ole.ts
  847. //
  848. // Synopsis: Display thread information
  849. //
  850. // History: 01-Jun-95 BruceMa Created
  851. //
  852. //--------------------------------------------------------------------------
  853. DEFINE_EXT(ts)
  854. {
  855. // Check whether debuggee is the scm
  856. CheckForScm();
  857. Printf("...NOT IMPLEMENTED YET\n");
  858. }
  859. //+-------------------------------------------------------------------------
  860. //
  861. // Extension: !ole.vt
  862. //
  863. // Synopsis: Display a vtbl
  864. //
  865. // History: 01-Jun-95 BruceMa Created
  866. //
  867. //--------------------------------------------------------------------------
  868. DEFINE_EXT(vt)
  869. {
  870. Arg arg;
  871. DWORD dwObj = NULL;
  872. char *s;
  873. // Check whether debuggee is the scm
  874. CheckForScm();
  875. // Get the object
  876. GetArg(arg);
  877. for (s = arg; *s; s++)
  878. {
  879. dwObj = 16 * dwObj + *s - '0';
  880. if ('A' <= *s && *s <= 'F')
  881. {
  882. dwObj -= 7;
  883. }
  884. if ('a' <= *s && *s <= 'f')
  885. {
  886. dwObj -= 39;
  887. }
  888. }
  889. // Display the vtbl
  890. if (dwObj != NULL)
  891. {
  892. displayVtbl(hProcess, lpExtensionApis, (LPVOID) dwObj);
  893. }
  894. else
  895. {
  896. Printf("...vtbl address of NULL is not meaningful\n");
  897. }
  898. }