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.

4562 lines
127 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: oleexts.cpp
  7. //
  8. // Contents: ntsd and windbg debugger extension
  9. //
  10. // Classes: none
  11. //
  12. // Functions:
  13. // operator new (global)
  14. // operator delete (global)
  15. // sizeofstring
  16. // dprintfx
  17. // dump_saferefcount
  18. // dump_threadcheck
  19. //
  20. // History: dd-mmm-yy Author Comment
  21. // 02-Feb-95 t-ScottH author
  22. //
  23. //--------------------------------------------------------------------------
  24. #include <windows.h>
  25. #include <imagehlp.h>
  26. #include <ntsdexts.h>
  27. #include <le2int.h>
  28. #include <oaholder.h>
  29. #include <daholder.h>
  30. #include <olerem.h>
  31. #include <defhndlr.h>
  32. #include <deflink.h>
  33. #include <olecache.h>
  34. #include <cachenod.h>
  35. #include <clipdata.h>
  36. #include <mf.h>
  37. #include <emf.h>
  38. #include <gen.h>
  39. #include <defcf.h>
  40. #include <dbgdump.h>
  41. #include "oleexts.h"
  42. // structure of function pointers
  43. NTSD_EXTENSION_APIS ExtensionApis;
  44. //+-------------------------------------------------------------------------
  45. //
  46. // Function: operator new (global), internal
  47. //
  48. // Synopsis: allocate memory
  49. //
  50. // Effects:
  51. //
  52. // Arguments: [cb] - number of bytes to allocate
  53. //
  54. // Requires: CoTaskMemAlloc
  55. //
  56. // Returns: pointer to allocated memory
  57. //
  58. // Signals:
  59. //
  60. // Modifies:
  61. //
  62. // Algorithm:
  63. //
  64. // History: dd-mmm-yy Author Comment
  65. // 02-Feb-95 t-ScottH author
  66. //
  67. // Notes:
  68. // we define our own operator new so that we do not need to link
  69. // with the CRT library
  70. //
  71. // we must also define our own global operator delete
  72. //
  73. //--------------------------------------------------------------------------
  74. void * __cdecl
  75. ::operator new(unsigned int cb)
  76. {
  77. return CoTaskMemAlloc(cb);
  78. }
  79. //+-------------------------------------------------------------------------
  80. //
  81. // Function: operator delete (global), internal
  82. //
  83. // Synopsis: free memory
  84. //
  85. // Effects:
  86. //
  87. // Arguments: [p] - pointer to the memory to free
  88. //
  89. // Requires: CoTaskMemFree
  90. //
  91. // Returns:
  92. //
  93. // Signals:
  94. //
  95. // Modifies:
  96. //
  97. // Algorithm: check to see if pointer is valid
  98. //
  99. // History: dd-mmm-yy Author Comment
  100. // 02-Feb-95 t-ScottH author
  101. //
  102. // Notes:
  103. // we define our own operator delete so that we do not need
  104. // to link with the CRT library
  105. //
  106. // we must also define our own global operator new
  107. //
  108. //--------------------------------------------------------------------------
  109. void __cdecl
  110. ::operator delete (void *p)
  111. {
  112. // CoTaskMemFree takes care if the pointer is NULL
  113. CoTaskMemFree(p);
  114. return;
  115. }
  116. //+-------------------------------------------------------------------------
  117. //
  118. // Function: dprintfx, internal
  119. //
  120. // Synopsis: prints a formatted string in MAX_STRING_SIZE chunks
  121. //
  122. // Effects:
  123. //
  124. // Arguments: [pszString] - null terminated string
  125. //
  126. // Requires: sizeofstring to calculate length of given string
  127. // dprintf (NTSD Extension API)
  128. // MAX_STRING_SIZE
  129. //
  130. // !!!This requires the NTSD_EXTENSION_APIS global variable
  131. // ExtensionApis to be initialize with the function
  132. // pointers
  133. //
  134. // Returns:
  135. //
  136. // Signals:
  137. //
  138. // Modifies:
  139. //
  140. // Algorithm:
  141. //
  142. // History: dd-mmm-yy Author Comment
  143. // 02-Feb-95 t-ScottH author
  144. //
  145. // Notes:
  146. // NTSD has a limit of a 4K buffer...some of the character
  147. // arrays from Dump methods can be > 4K. this will
  148. // print a formatted string in chunks that NTSD can handle
  149. //
  150. //--------------------------------------------------------------------------
  151. #define MAX_STRING_SIZE 1000
  152. void dprintfx(char *pszString)
  153. {
  154. char *pszFront;
  155. int size;
  156. char x;
  157. for ( pszFront = pszString,
  158. size = strlen(pszString);
  159. size > 0;
  160. pszFront += (MAX_STRING_SIZE - 1),
  161. size -= (MAX_STRING_SIZE - 1 ) )
  162. {
  163. if ( size > (MAX_STRING_SIZE - 1) )
  164. {
  165. x = pszFront[MAX_STRING_SIZE - 1];
  166. pszFront[MAX_STRING_SIZE - 1] = '\0';
  167. dprintf("%s", pszFront);
  168. pszFront[MAX_STRING_SIZE - 1] = x;
  169. }
  170. else
  171. {
  172. dprintf("%s", pszFront);
  173. }
  174. }
  175. return;
  176. }
  177. //+-------------------------------------------------------------------------
  178. //
  179. // Function: help, exported
  180. //
  181. // Synopsis: print help message
  182. //
  183. // Effects:
  184. //
  185. // Arguments: see DECLARE_API in oleexts.h
  186. //
  187. // Requires:
  188. //
  189. // Returns: void
  190. //
  191. // Signals:
  192. //
  193. // Modifies: ExtensionApis (global)
  194. //
  195. // Algorithm:
  196. //
  197. // History: dd-mmm-yy Author Comment
  198. // 02-Feb-95 t-ScottH author
  199. //
  200. // Notes:
  201. //
  202. //--------------------------------------------------------------------------
  203. DECLARE_API( help )
  204. {
  205. ExtensionApis = *lpExtensionApis;
  206. if (*args == '\0') {
  207. dprintf("OLE DEBUGGER EXTENSIONS HELP:\n\n");
  208. dprintf("!symbol (<address>|<symbol name>) - Returns either the symbol name or address\n");
  209. dprintf("!dump_atom <address> - Dumps a ATOM structure\n");
  210. dprintf("!dump_clsid <address> - Dumps a CLSID structure\n");
  211. dprintf("!dump_clipformat <address> - Dumps a CLIPFORMAT structure\n");
  212. dprintf("!dump_mutexsem <address> - Dumps a CMutexSem class\n");
  213. dprintf("!dump_filetime <address> - Dumps a FILETIME structure\n");
  214. dprintf("!dump_cachelist_item <address> - Dumps a CACHELIST_ITEM struct\n");
  215. dprintf("!dump_cacheenum <address> - Dumps a CCacheEnum class\n");
  216. dprintf("!dump_cacheenumformatetc <address> - Dumps a CCacheEnumFormatEtc class\n");
  217. dprintf("!dump_cachenode <address> - Dumps a CCacheNode class\n");
  218. dprintf("!dump_clipdataobject <address> - Dumps a CClipDataObject class\n");
  219. dprintf("!dump_clipenumformatetc <address> - Dumps a CClipEnumFormatEtc class\n");
  220. dprintf("!dump_daholder <address> - Dumps a CDAHolder class\n");
  221. dprintf("!dump_dataadvisecache <address> - Dumps a CDataAdviseCache class\n");
  222. dprintf("!dump_defclassfactory <address> - Dumps a CDefClassFactory class\n");
  223. dprintf("!dump_deflink <address> - Dumps a CDefLink class\n");
  224. dprintf("!dump_defobject <address> - Dumps a CDefObject class\n");
  225. dprintf("!dump_emfobject <address> - Dumps a CEMfObject class\n");
  226. dprintf("!dump_enumfmt <address> - Dumps a CEnumFmt class\n");
  227. dprintf("!dump_enumfmt10 <address> - Dumps a CEnumFmt10 class\n");
  228. dprintf("!dump_enumstatdata <address> - Dumps a CEnumSTATDATA class\n");
  229. dprintf("!dump_enumverb <address> - Dumps a CEnumVerb class\n");
  230. dprintf("!dump_membytes <address> - Dumps a CMemBytes class\n");
  231. dprintf("!dump_cmemstm <address> - Dumps a CMemStm class\n");
  232. dprintf("!dump_mfobject <address> - Dumps a CMfObject class\n");
  233. dprintf("!dump_oaholder <address> - Dumps a COAHolder class\n");
  234. dprintf("!dump_olecache <address> - Dumps a COleCache class\n");
  235. dprintf("!dump_saferefcount <address> - Dumps a CSafeRefCount class\n");
  236. dprintf("!dump_threadcheck <address> - Dumps a CThreadCheck class\n");
  237. dprintf("!dump_formatetc <address> - Dumps a FORMATETC structure\n");
  238. dprintf("!dump_memstm <address> - Dumps a MEMSTM structure\n");
  239. dprintf("!dump_statdata <address> - Dumps a STATDATA structure\n");
  240. dprintf("!dump_stgmedium <address> - Dumps a STGMEDIUM\n");
  241. dprintf("\n");
  242. }
  243. }
  244. //+-------------------------------------------------------------------------
  245. //
  246. // Function: symbol, exported
  247. //
  248. // Synopsis: given an address to a symbol, dumps the symbol name and offset
  249. // (given a symbol name, dump address and offset)
  250. //
  251. // Effects:
  252. //
  253. // Arguments: see DECLARE_API in oleexts.h
  254. //
  255. // Requires:
  256. //
  257. // Returns: void
  258. //
  259. // Signals:
  260. //
  261. // Modifies: ExtensionApis (global)
  262. //
  263. // Algorithm:
  264. //
  265. // History: dd-mmm-yy Author Comment
  266. // 02-Feb-95 t-ScottH author
  267. //
  268. // Notes:
  269. //
  270. //--------------------------------------------------------------------------
  271. DECLARE_API( symbol )
  272. {
  273. DWORD dwAddr;
  274. CHAR Symbol[64];
  275. DWORD Displacement;
  276. ExtensionApis = *lpExtensionApis;
  277. dwAddr = GetExpression(args);
  278. if ( !dwAddr ) {
  279. return;
  280. }
  281. GetSymbol((LPVOID)dwAddr,(unsigned char *)Symbol,&Displacement);
  282. dprintf("%s+%lx at %lx\n", Symbol, Displacement, dwAddr);
  283. }
  284. //+-------------------------------------------------------------------------
  285. //
  286. // Function: dump_atom, exported
  287. //
  288. // Synopsis: dumps ATOM object
  289. //
  290. // Effects:
  291. //
  292. // Arguments: see DECLARE_API in oleexts.h
  293. //
  294. // Requires:
  295. //
  296. // Returns: void
  297. //
  298. // Signals:
  299. //
  300. // Modifies: ExtensionApis (global)
  301. //
  302. // Algorithm:
  303. //
  304. // History: dd-mmm-yy Author Comment
  305. // 02-Feb-95 t-ScottH author
  306. //
  307. // Notes:
  308. // The address of the object is passed in the arguments. This
  309. // address is in the debuggee's process memory. In order for
  310. // NTSD to view this memory, the debugger must copy the mem
  311. // using the WIN32 ReadProcessMemory API.
  312. //
  313. //--------------------------------------------------------------------------
  314. DECLARE_API(dump_atom)
  315. {
  316. // set up global function pointers
  317. ExtensionApis = *lpExtensionApis;
  318. dprintf("dump_atom not implemented\n");
  319. return;
  320. }
  321. //+-------------------------------------------------------------------------
  322. //
  323. // Function: dump_clsid, exported
  324. //
  325. // Synopsis: dumps CLSID object
  326. //
  327. // Effects:
  328. //
  329. // Arguments: see DECLARE_API in oleexts.h
  330. //
  331. // Requires:
  332. //
  333. // Returns: void
  334. //
  335. // Signals:
  336. //
  337. // Modifies: ExtensionApis (global)
  338. //
  339. // Algorithm:
  340. //
  341. // History: dd-mmm-yy Author Comment
  342. // 02-Feb-95 t-ScottH author
  343. //
  344. // Notes:
  345. // The address of the object is passed in the arguments. This
  346. // address is in the debuggee's process memory. In order for
  347. // NTSD to view this memory, the debugger must copy the mem
  348. // using the WIN32 ReadProcessMemory API.
  349. //
  350. //--------------------------------------------------------------------------
  351. DECLARE_API(dump_clsid)
  352. {
  353. // set up global function pointers
  354. ExtensionApis = *lpExtensionApis;
  355. dprintf("dump_clsid not implemented\n");
  356. return;
  357. }
  358. //+-------------------------------------------------------------------------
  359. //
  360. // Function: dump_clipformat, exported
  361. //
  362. // Synopsis: dumps CLIPFORMAT object
  363. //
  364. // Effects:
  365. //
  366. // Arguments: see DECLARE_API in oleexts.h
  367. //
  368. // Requires:
  369. //
  370. // Returns: void
  371. //
  372. // Signals:
  373. //
  374. // Modifies: ExtensionApis (global)
  375. //
  376. // Algorithm:
  377. //
  378. // History: dd-mmm-yy Author Comment
  379. // 02-Feb-95 t-ScottH author
  380. //
  381. // Notes:
  382. // The address of the object is passed in the arguments. This
  383. // address is in the debuggee's process memory. In order for
  384. // NTSD to view this memory, the debugger must copy the mem
  385. // using the WIN32 ReadProcessMemory API.
  386. //
  387. //--------------------------------------------------------------------------
  388. DECLARE_API(dump_clipformat)
  389. {
  390. // set up global function pointers
  391. ExtensionApis = *lpExtensionApis;
  392. dprintf("dump_clipformat not implemented\n");
  393. return;
  394. }
  395. //+-------------------------------------------------------------------------
  396. //
  397. // Function: dump_mutexsem, exported
  398. //
  399. // Synopsis: dumps CMutexSem object
  400. //
  401. // Effects:
  402. //
  403. // Arguments: see DECLARE_API in oleexts.h
  404. //
  405. // Requires:
  406. //
  407. // Returns: void
  408. //
  409. // Signals:
  410. //
  411. // Modifies: ExtensionApis (global)
  412. //
  413. // Algorithm:
  414. //
  415. // History: dd-mmm-yy Author Comment
  416. // 02-Feb-95 t-ScottH author
  417. //
  418. // Notes:
  419. // The address of the object is passed in the arguments. This
  420. // address is in the debuggee's process memory. In order for
  421. // NTSD to view this memory, the debugger must copy the mem
  422. // using the WIN32 ReadProcessMemory API.
  423. //
  424. //--------------------------------------------------------------------------
  425. DECLARE_API(dump_mutexsem)
  426. {
  427. // set up global function pointers
  428. ExtensionApis = *lpExtensionApis;
  429. dprintf("dump_mutexsem not implemented\n");
  430. return;
  431. }
  432. //+-------------------------------------------------------------------------
  433. //
  434. // Function: dump_filetime, exported
  435. //
  436. // Synopsis: dumps FILETIME object
  437. //
  438. // Effects:
  439. //
  440. // Arguments: see DECLARE_API in oleexts.h
  441. //
  442. // Requires:
  443. //
  444. // Returns: void
  445. //
  446. // Signals:
  447. //
  448. // Modifies: ExtensionApis (global)
  449. //
  450. // Algorithm:
  451. //
  452. // History: dd-mmm-yy Author Comment
  453. // 02-Feb-95 t-ScottH author
  454. //
  455. // Notes:
  456. // The address of the object is passed in the arguments. This
  457. // address is in the debuggee's process memory. In order for
  458. // NTSD to view this memory, the debugger must copy the mem
  459. // using the WIN32 ReadProcessMemory API.
  460. //
  461. //--------------------------------------------------------------------------
  462. DECLARE_API(dump_filetime)
  463. {
  464. // set up global function pointers
  465. ExtensionApis = *lpExtensionApis;
  466. dprintf("dump_filetime not implemented\n");
  467. return;
  468. }
  469. //+-------------------------------------------------------------------------
  470. //
  471. // Function: dump_cachelist_item, exported
  472. //
  473. // Synopsis: dumps CACHELIST_ITEM object
  474. //
  475. // Effects:
  476. //
  477. // Arguments: see DECLARE_API in oleexts.h
  478. //
  479. // Requires:
  480. //
  481. // Returns: void
  482. //
  483. // Signals:
  484. //
  485. // Modifies: ExtensionApis (global)
  486. //
  487. // Algorithm:
  488. //
  489. // History: dd-mmm-yy Author Comment
  490. // 02-Feb-95 t-ScottH author
  491. //
  492. // Notes:
  493. // The address of the object is passed in the arguments. This
  494. // address is in the debuggee's process memory. In order for
  495. // NTSD to view this memory, the debugger must copy the mem
  496. // using the WIN32 ReadProcessMemory API.
  497. //
  498. //--------------------------------------------------------------------------
  499. DECLARE_API(dump_cachelist_item)
  500. {
  501. BOOL fError;
  502. LPVOID dwAddr;
  503. DWORD dwReturnedCount;
  504. char *pszCacheListItem;
  505. char *blockCacheListItem = NULL;
  506. char *blockCacheNode = NULL;
  507. char *blockPresObj = NULL;
  508. char *blockPresObjAF = NULL;
  509. CACHELIST_ITEM *pCacheListItem = NULL;
  510. DWORD dwSizeOfPresObj;
  511. // set up global function pointers
  512. ExtensionApis = *lpExtensionApis;
  513. // get address of object from argument string
  514. dwAddr = (LPVOID)GetExpression( args );
  515. if (dwAddr == 0)
  516. {
  517. dprintf("Failed to get Address of CACEHLIST_ITEM\n");
  518. return;
  519. }
  520. // read the block of memory from the debugee's process
  521. blockCacheListItem = new char[sizeof(CACHELIST_ITEM)];
  522. fError = ReadProcessMemory(
  523. hCurrentProcess,
  524. dwAddr,
  525. blockCacheListItem,
  526. sizeof(CACHELIST_ITEM),
  527. &dwReturnedCount
  528. );
  529. if (fError == FALSE)
  530. {
  531. dprintf("Could not read debuggee's process memory: CACHELIST_ITEM \n");
  532. dprintf("at address %x\n", dwAddr);
  533. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  534. goto errRtn;
  535. }
  536. if (dwReturnedCount != sizeof(CACHELIST_ITEM))
  537. {
  538. dprintf("Size of process memory read != requested(CACHELIST_ITEM\n");
  539. goto errRtn;
  540. }
  541. pCacheListItem = (CACHELIST_ITEM *)blockCacheListItem;
  542. if (pCacheListItem->lpCacheNode != NULL)
  543. {
  544. blockCacheNode = new char[sizeof(CCacheNode)];
  545. fError = ReadProcessMemory(
  546. hCurrentProcess,
  547. pCacheListItem->lpCacheNode,
  548. blockCacheNode,
  549. sizeof(CCacheNode),
  550. &dwReturnedCount
  551. );
  552. if (fError == FALSE)
  553. {
  554. dprintf("Could not read debuggee's process memory: CCacheNode \n");
  555. dprintf("at address %x\n", pCacheListItem->lpCacheNode);
  556. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  557. goto errRtn;
  558. }
  559. if (dwReturnedCount != sizeof(CCacheNode))
  560. {
  561. dprintf("Size of process memory read != requested (CCacheNode)\n");
  562. goto errRtn;
  563. }
  564. pCacheListItem->lpCacheNode = (CCacheNode*)blockCacheNode;
  565. // need to get the OlePresObjs for the CCacheNode
  566. if (pCacheListItem->lpCacheNode->m_pPresObj != NULL)
  567. {
  568. switch (pCacheListItem->lpCacheNode->m_dwPresFlag)
  569. {
  570. case CN_PRESOBJ_GEN:
  571. dwSizeOfPresObj = sizeof(CGenObject);
  572. break;
  573. case CN_PRESOBJ_MF:
  574. dwSizeOfPresObj = sizeof(CMfObject);
  575. break;
  576. case CN_PRESOBJ_EMF:
  577. dwSizeOfPresObj = sizeof(CEMfObject);
  578. break;
  579. default:
  580. dprintf("Error: can not determine size of IOlePresObj\n");
  581. return;
  582. }
  583. blockPresObj = new char[dwSizeOfPresObj];
  584. fError = ReadProcessMemory(
  585. hCurrentProcess,
  586. pCacheListItem->lpCacheNode->m_pPresObj,
  587. blockPresObj,
  588. dwSizeOfPresObj,
  589. &dwReturnedCount
  590. );
  591. if (fError == FALSE)
  592. {
  593. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  594. dprintf("at address %x\n", pCacheListItem->lpCacheNode->m_pPresObj);
  595. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  596. goto errRtn;
  597. }
  598. if (dwReturnedCount != dwSizeOfPresObj)
  599. {
  600. dprintf("Size of process memory read != requested (IPresObj)\n");
  601. goto errRtn;
  602. }
  603. pCacheListItem->lpCacheNode->m_pPresObj = (IOlePresObj *)blockPresObj;
  604. }
  605. if (pCacheListItem->lpCacheNode->m_pPresObjAfterFreeze != NULL)
  606. {
  607. switch (pCacheListItem->lpCacheNode->m_dwPresFlag)
  608. {
  609. case CN_PRESOBJ_GEN:
  610. dwSizeOfPresObj = sizeof(CGenObject);
  611. break;
  612. case CN_PRESOBJ_MF:
  613. dwSizeOfPresObj = sizeof(CMfObject);
  614. break;
  615. case CN_PRESOBJ_EMF:
  616. dwSizeOfPresObj = sizeof(CEMfObject);
  617. break;
  618. default:
  619. dprintf("Error: can not determine size of IOlePresObj\n");
  620. return;
  621. }
  622. blockPresObjAF = new char[dwSizeOfPresObj];
  623. fError = ReadProcessMemory(
  624. hCurrentProcess,
  625. pCacheListItem->lpCacheNode->m_pPresObjAfterFreeze,
  626. blockPresObjAF,
  627. dwSizeOfPresObj,
  628. &dwReturnedCount
  629. );
  630. if (fError == FALSE)
  631. {
  632. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  633. dprintf("at address %x\n", pCacheListItem->lpCacheNode->m_pPresObjAfterFreeze);
  634. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  635. goto errRtn;
  636. }
  637. if (dwReturnedCount != dwSizeOfPresObj)
  638. {
  639. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  640. goto errRtn;
  641. }
  642. pCacheListItem->lpCacheNode->m_pPresObjAfterFreeze = (IOlePresObj *)blockPresObjAF;
  643. }
  644. }
  645. // dump the structure
  646. pszCacheListItem = DumpCACHELIST_ITEM(pCacheListItem, NO_PREFIX, 1);
  647. dprintf("CACHELIST_ITEM @ 0x%x\n", dwAddr);
  648. dprintfx(pszCacheListItem);
  649. CoTaskMemFree(pszCacheListItem);
  650. errRtn:
  651. // delete the blocks and not the pointers
  652. delete[] blockPresObj;
  653. delete[] blockPresObjAF;
  654. delete[] blockCacheNode;
  655. delete[] blockCacheListItem;
  656. return;
  657. }
  658. //+-------------------------------------------------------------------------
  659. //
  660. // Function: dump_cacheenum, exported
  661. //
  662. // Synopsis: dumps CCacheEnum object
  663. //
  664. // Effects:
  665. //
  666. // Arguments: see DECLARE_API in oleexts.h
  667. //
  668. // Requires:
  669. //
  670. // Returns: void
  671. //
  672. // Signals:
  673. //
  674. // Modifies: ExtensionApis (global)
  675. //
  676. // Algorithm:
  677. //
  678. // History: dd-mmm-yy Author Comment
  679. // 02-Feb-95 t-ScottH author
  680. //
  681. // Notes:
  682. // The address of the object is passed in the arguments. This
  683. // address is in the debuggee's process memory. In order for
  684. // NTSD to view this memory, the debugger must copy the mem
  685. // using the WIN32 ReadProcessMemory API.
  686. //
  687. //--------------------------------------------------------------------------
  688. DECLARE_API(dump_cacheenum)
  689. {
  690. BOOL fError;
  691. LPVOID dwAddr;
  692. DWORD dwReturnedCount;
  693. char *pszCE;
  694. char *blockCE = NULL;
  695. CCacheEnum *pCE = NULL;
  696. // set up global function pointers
  697. ExtensionApis = *lpExtensionApis;
  698. // get address of object from argument string
  699. dwAddr = (LPVOID)GetExpression( args );
  700. if (dwAddr == 0)
  701. {
  702. dprintf("Failed to get Address of CCacheEnum\n");
  703. return;
  704. }
  705. // read the block of memory from the debugee's process
  706. blockCE = new char[sizeof(CCacheEnum)];
  707. fError = ReadProcessMemory(
  708. hCurrentProcess,
  709. dwAddr,
  710. blockCE,
  711. sizeof(CCacheEnum),
  712. &dwReturnedCount
  713. );
  714. if (fError == FALSE)
  715. {
  716. dprintf("Could not read debuggee's process memory: CCacheEnum \n");
  717. dprintf("at address %x\n", dwAddr);
  718. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  719. goto errRtn;
  720. }
  721. if (dwReturnedCount != sizeof(CCacheEnum))
  722. {
  723. dprintf("Size of process memory read != requested\n");
  724. goto errRtn;
  725. }
  726. pCE = (CCacheEnum *)blockCE;
  727. // dump the structure
  728. pszCE = DumpCCacheEnum(pCE, NO_PREFIX, 1);
  729. dprintf("CCacheEnum @ 0x%x\n", dwAddr);
  730. dprintfx(pszCE);
  731. CoTaskMemFree(pszCE);
  732. errRtn:
  733. // delete the blocks and not the pointers
  734. delete[] blockCE;
  735. return;
  736. }
  737. //+-------------------------------------------------------------------------
  738. //
  739. // Function: dump_cacheenumformatetc, exported
  740. //
  741. // Synopsis: dumps CCacheEnumFormatEtc object
  742. //
  743. // Effects:
  744. //
  745. // Arguments: see DECLARE_API in oleexts.h
  746. //
  747. // Requires:
  748. //
  749. // Returns: void
  750. //
  751. // Signals:
  752. //
  753. // Modifies: ExtensionApis (global)
  754. //
  755. // Algorithm:
  756. //
  757. // History: dd-mmm-yy Author Comment
  758. // 02-Feb-95 t-ScottH author
  759. //
  760. // Notes:
  761. // The address of the object is passed in the arguments. This
  762. // address is in the debuggee's process memory. In order for
  763. // NTSD to view this memory, the debugger must copy the mem
  764. // using the WIN32 ReadProcessMemory API.
  765. //
  766. //--------------------------------------------------------------------------
  767. DECLARE_API(dump_cacheenumformatetc)
  768. {
  769. BOOL fError;
  770. LPVOID dwAddr;
  771. DWORD dwReturnedCount;
  772. char *pszCacheEnumFormatEtc;
  773. char *blockCacheEnumFormatEtc = NULL;
  774. CCacheEnumFormatEtc *pCacheEnumFormatEtc = NULL;
  775. // set up global function pointers
  776. ExtensionApis = *lpExtensionApis;
  777. // get address of object from argument string
  778. dwAddr = (LPVOID)GetExpression( args );
  779. if (dwAddr == 0)
  780. {
  781. dprintf("Failed to get Address of CCacheEnumFormatEtc\n");
  782. return;
  783. }
  784. // read the block of memory from the debugee's process
  785. blockCacheEnumFormatEtc = new char[sizeof(CCacheEnumFormatEtc)];
  786. fError = ReadProcessMemory(
  787. hCurrentProcess,
  788. dwAddr,
  789. blockCacheEnumFormatEtc,
  790. sizeof(CCacheEnumFormatEtc),
  791. &dwReturnedCount
  792. );
  793. if (fError == FALSE)
  794. {
  795. dprintf("Could not read debuggee's process memory CacheEnumFormatEtc");
  796. dprintf("at address %x\n", dwAddr);
  797. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  798. goto errRtn;
  799. }
  800. if (dwReturnedCount != sizeof(CCacheEnumFormatEtc))
  801. {
  802. dprintf("Size of process memory read != requested\n");
  803. goto errRtn;
  804. }
  805. pCacheEnumFormatEtc = (CCacheEnumFormatEtc *)blockCacheEnumFormatEtc;
  806. // dump the structure
  807. pszCacheEnumFormatEtc = DumpCCacheEnumFormatEtc(pCacheEnumFormatEtc, NO_PREFIX, 1);
  808. dprintf("CCacheEnumFormatEtc @ 0x%x\n", dwAddr);
  809. dprintfx(pszCacheEnumFormatEtc);
  810. CoTaskMemFree(pszCacheEnumFormatEtc);
  811. errRtn:
  812. delete[] blockCacheEnumFormatEtc;
  813. return;
  814. }
  815. //+-------------------------------------------------------------------------
  816. //
  817. // Function: dump_cachenode, exported
  818. //
  819. // Synopsis: dumps CCacheNode object
  820. //
  821. // Effects:
  822. //
  823. // Arguments: see DECLARE_API in oleexts.h
  824. //
  825. // Requires:
  826. //
  827. // Returns: void
  828. //
  829. // Signals:
  830. //
  831. // Modifies: ExtensionApis (global)
  832. //
  833. // Algorithm:
  834. //
  835. // History: dd-mmm-yy Author Comment
  836. // 02-Feb-95 t-ScottH author
  837. //
  838. // Notes:
  839. // The address of the object is passed in the arguments. This
  840. // address is in the debuggee's process memory. In order for
  841. // NTSD to view this memory, the debugger must copy the mem
  842. // using the WIN32 ReadProcessMemory API.
  843. //
  844. //--------------------------------------------------------------------------
  845. DECLARE_API(dump_cachenode)
  846. {
  847. BOOL fError;
  848. LPVOID dwAddr;
  849. DWORD dwReturnedCount = 0;
  850. char *pszCacheNode = NULL;
  851. char *blockCacheNode = NULL;
  852. char *blockPresObj = NULL;
  853. char *blockPresObjAF = NULL;
  854. CCacheNode *pCacheNode = NULL;
  855. DWORD dwSizeOfPresObj;
  856. // set up global function pointers
  857. ExtensionApis = *lpExtensionApis;
  858. // get address of object from argument string
  859. dwAddr = (LPVOID)GetExpression( args );
  860. if (dwAddr == 0)
  861. {
  862. dprintf("Failed to get Address of CCacheNode\n");
  863. return;
  864. }
  865. // get the CCacheNode block of mem
  866. blockCacheNode = new char[sizeof(CCacheNode)];
  867. fError = ReadProcessMemory(
  868. hCurrentProcess,
  869. dwAddr,
  870. blockCacheNode,
  871. sizeof(CCacheNode),
  872. &dwReturnedCount
  873. );
  874. if (fError == FALSE)
  875. {
  876. dprintf("Could not read debuggee's process memory: CCacheNode \n");
  877. dprintf("at address %x\n", dwAddr);
  878. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  879. goto errRtn;
  880. }
  881. if (dwReturnedCount != sizeof(CCacheNode))
  882. {
  883. dprintf("Size of process memory read != requested (CCacheNode)\n");
  884. goto errRtn;
  885. }
  886. pCacheNode = (CCacheNode*)blockCacheNode;
  887. // need to get the OlePresObjs for the CCacheNode
  888. if (pCacheNode->m_pPresObj != NULL)
  889. {
  890. switch (pCacheNode->m_dwPresFlag)
  891. {
  892. case CN_PRESOBJ_GEN:
  893. dwSizeOfPresObj = sizeof(CGenObject);
  894. break;
  895. case CN_PRESOBJ_MF:
  896. dwSizeOfPresObj = sizeof(CMfObject);
  897. break;
  898. case CN_PRESOBJ_EMF:
  899. dwSizeOfPresObj = sizeof(CEMfObject);
  900. break;
  901. default:
  902. dprintf("Error: can not determine size of IOlePresObj\n");
  903. return;
  904. }
  905. blockPresObj = new char[dwSizeOfPresObj];
  906. fError = ReadProcessMemory(
  907. hCurrentProcess,
  908. pCacheNode->m_pPresObj,
  909. blockPresObj,
  910. dwSizeOfPresObj,
  911. &dwReturnedCount
  912. );
  913. if (fError == FALSE)
  914. {
  915. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  916. dprintf("at address %x\n", pCacheNode->m_pPresObj);
  917. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  918. goto errRtn;
  919. }
  920. if (dwReturnedCount != dwSizeOfPresObj)
  921. {
  922. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  923. goto errRtn;
  924. }
  925. // pass off pointer
  926. pCacheNode->m_pPresObj = (IOlePresObj *)blockPresObj;
  927. }
  928. if (pCacheNode->m_pPresObjAfterFreeze != NULL)
  929. {
  930. switch (pCacheNode->m_dwPresFlag)
  931. {
  932. case CN_PRESOBJ_GEN:
  933. dwSizeOfPresObj = sizeof(CGenObject);
  934. break;
  935. case CN_PRESOBJ_MF:
  936. dwSizeOfPresObj = sizeof(CMfObject);
  937. break;
  938. case CN_PRESOBJ_EMF:
  939. dwSizeOfPresObj = sizeof(CEMfObject);
  940. break;
  941. default:
  942. dprintf("Error: can not determine size of IOlePresObj\n");
  943. return;
  944. }
  945. blockPresObjAF = new char[dwSizeOfPresObj];
  946. fError = ReadProcessMemory(
  947. hCurrentProcess,
  948. pCacheNode->m_pPresObjAfterFreeze,
  949. blockPresObjAF,
  950. dwSizeOfPresObj,
  951. &dwReturnedCount
  952. );
  953. if (fError == FALSE)
  954. {
  955. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  956. dprintf("at address %x\n", pCacheNode->m_pPresObjAfterFreeze);
  957. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  958. goto errRtn;
  959. }
  960. if (dwReturnedCount != dwSizeOfPresObj)
  961. {
  962. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  963. goto errRtn;
  964. }
  965. // pass off pointer
  966. pCacheNode->m_pPresObjAfterFreeze = (IOlePresObj *)blockPresObjAF;
  967. }
  968. // dump the structure
  969. pszCacheNode = DumpCCacheNode(pCacheNode, NO_PREFIX, 1);
  970. dprintf("CCacheNode @ 0x%x\n", dwAddr);
  971. dprintfx(pszCacheNode);
  972. CoTaskMemFree(pszCacheNode);
  973. errRtn:
  974. // delete the blocks and not the pointers
  975. delete[] blockPresObj;
  976. delete[] blockPresObjAF;
  977. delete[] blockCacheNode;
  978. return;
  979. }
  980. //+-------------------------------------------------------------------------
  981. //
  982. // Function: dump_clipdataobject, exported
  983. //
  984. // Synopsis: dumps CClipDataObject object
  985. //
  986. // Effects:
  987. //
  988. // Arguments: see DECLARE_API in oleexts.h
  989. //
  990. // Requires:
  991. //
  992. // Returns: void
  993. //
  994. // Signals:
  995. //
  996. // Modifies: ExtensionApis (global)
  997. //
  998. // Algorithm:
  999. //
  1000. // History: dd-mmm-yy Author Comment
  1001. // 02-Feb-95 t-ScottH author
  1002. //
  1003. // Notes:
  1004. // The address of the object is passed in the arguments. This
  1005. // address is in the debuggee's process memory. In order for
  1006. // NTSD to view this memory, the debugger must copy the mem
  1007. // using the WIN32 ReadProcessMemory API.
  1008. //
  1009. //--------------------------------------------------------------------------
  1010. DECLARE_API(dump_clipdataobject)
  1011. {
  1012. BOOL fError;
  1013. LPVOID dwAddr;
  1014. DWORD dwReturnedCount;
  1015. char *pszCDO;
  1016. char *blockCDO = NULL;
  1017. char *blockFE = NULL;
  1018. CClipDataObject *pCDO = NULL;
  1019. // set up global function pointers
  1020. ExtensionApis = *lpExtensionApis;
  1021. // get address of object from argument string
  1022. dwAddr = (LPVOID)GetExpression( args );
  1023. if (dwAddr == 0)
  1024. {
  1025. dprintf("Failed to get Address of CClipDataObject\n");
  1026. return;
  1027. }
  1028. // read the block of memory from the debugee's process
  1029. blockCDO = new char[sizeof(CClipDataObject)];
  1030. fError = ReadProcessMemory(
  1031. hCurrentProcess,
  1032. dwAddr,
  1033. blockCDO,
  1034. sizeof(CClipDataObject),
  1035. &dwReturnedCount
  1036. );
  1037. if (fError == FALSE)
  1038. {
  1039. dprintf("Could not read debuggee's process memory: CClipDataObject \n");
  1040. dprintf("at address %x\n", dwAddr);
  1041. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1042. goto errRtn;
  1043. }
  1044. if (dwReturnedCount != sizeof(CClipDataObject))
  1045. {
  1046. dprintf("Size of process memory read != requested\n");
  1047. goto errRtn;
  1048. }
  1049. pCDO = (CClipDataObject *)blockCDO;
  1050. // read the block of mem for the FORMATETC array
  1051. blockFE = new char[sizeof(FORMATETC)*pCDO->m_cFormats];
  1052. fError = ReadProcessMemory(
  1053. hCurrentProcess,
  1054. pCDO->m_rgFormats,
  1055. blockFE,
  1056. sizeof(FORMATETC)*pCDO->m_cFormats,
  1057. &dwReturnedCount
  1058. );
  1059. if (fError == FALSE)
  1060. {
  1061. dprintf("Could not read debuggee's process memory: FORMATETC array \n");
  1062. dprintf("at address %x\n", pCDO->m_rgFormats);
  1063. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1064. goto errRtn;
  1065. }
  1066. if (dwReturnedCount != (sizeof(FORMATETC)*pCDO->m_cFormats))
  1067. {
  1068. dprintf("Size of process memory read != requested\n");
  1069. goto errRtn;
  1070. }
  1071. pCDO->m_rgFormats = (FORMATETC *)blockFE;
  1072. // dump the structure
  1073. pszCDO = DumpCClipDataObject(pCDO, NO_PREFIX, 1);
  1074. dprintf("CClipDataObject @ 0x%x\n", dwAddr);
  1075. dprintfx(pszCDO);
  1076. CoTaskMemFree(pszCDO);
  1077. errRtn:
  1078. // delete the blocks and not the pointers
  1079. delete[] blockFE;
  1080. delete[] blockCDO;
  1081. return;
  1082. }
  1083. //+-------------------------------------------------------------------------
  1084. //
  1085. // Function: dump_clipenumformatetc, exported
  1086. //
  1087. // Synopsis: dumps CClipEnumFormatEtc object
  1088. //
  1089. // Effects:
  1090. //
  1091. // Arguments: see DECLARE_API in oleexts.h
  1092. //
  1093. // Requires:
  1094. //
  1095. // Returns: void
  1096. //
  1097. // Signals:
  1098. //
  1099. // Modifies: ExtensionApis (global)
  1100. //
  1101. // Algorithm:
  1102. //
  1103. // History: dd-mmm-yy Author Comment
  1104. // 02-Feb-95 t-ScottH author
  1105. //
  1106. // Notes:
  1107. // The address of the object is passed in the arguments. This
  1108. // address is in the debuggee's process memory. In order for
  1109. // NTSD to view this memory, the debugger must copy the mem
  1110. // using the WIN32 ReadProcessMemory API.
  1111. //
  1112. //--------------------------------------------------------------------------
  1113. DECLARE_API(dump_clipenumformatetc)
  1114. {
  1115. BOOL fError;
  1116. LPVOID dwAddr;
  1117. DWORD dwReturnedCount;
  1118. char *pszCEFE;
  1119. char *blockCEFE = NULL;
  1120. char *blockFE = NULL;
  1121. CClipEnumFormatEtc *pCEFE = NULL;
  1122. // set up global function pointers
  1123. ExtensionApis = *lpExtensionApis;
  1124. // get address of object from argument string
  1125. dwAddr = (LPVOID)GetExpression( args );
  1126. if (dwAddr == 0)
  1127. {
  1128. dprintf("Failed to get Address of CClipEnumFormatEtc\n");
  1129. return;
  1130. }
  1131. // read the block of memory from the debugee's process
  1132. blockCEFE = new char[sizeof(CClipEnumFormatEtc)];
  1133. fError = ReadProcessMemory(
  1134. hCurrentProcess,
  1135. dwAddr,
  1136. blockCEFE,
  1137. sizeof(CClipEnumFormatEtc),
  1138. &dwReturnedCount
  1139. );
  1140. if (fError == FALSE)
  1141. {
  1142. dprintf("Could not read debuggee's process memory: CClipEnumFormatEtc \n");
  1143. dprintf("at address %x\n", dwAddr);
  1144. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1145. goto errRtn;
  1146. }
  1147. if (dwReturnedCount != sizeof(CClipEnumFormatEtc))
  1148. {
  1149. dprintf("Size of process memory read != requested\n");
  1150. goto errRtn;
  1151. }
  1152. pCEFE = (CClipEnumFormatEtc *)blockCEFE;
  1153. // read the block of mem for the FORMATETC array
  1154. blockFE = new char[sizeof(FORMATETC)*pCEFE->m_cTotal];
  1155. fError = ReadProcessMemory(
  1156. hCurrentProcess,
  1157. pCEFE->m_rgFormats,
  1158. blockFE,
  1159. sizeof(FORMATETC)*pCEFE->m_cTotal,
  1160. &dwReturnedCount
  1161. );
  1162. if (fError == FALSE)
  1163. {
  1164. dprintf("Could not read debuggee's process memory: FORMATETC array \n");
  1165. dprintf("at address %x\n", pCEFE->m_rgFormats);
  1166. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1167. goto errRtn;
  1168. }
  1169. if (dwReturnedCount != (sizeof(FORMATETC)*pCEFE->m_cTotal))
  1170. {
  1171. dprintf("Size of process memory read != requested\n");
  1172. goto errRtn;
  1173. }
  1174. pCEFE->m_rgFormats = (FORMATETC *)blockFE;
  1175. // dump the structure
  1176. pszCEFE = DumpCClipEnumFormatEtc(pCEFE, NO_PREFIX, 1);
  1177. dprintf("CClipEnumFormatEtc @ 0x%x\n", dwAddr);
  1178. dprintfx(pszCEFE);
  1179. CoTaskMemFree(pszCEFE);
  1180. errRtn:
  1181. // delete the blocks and not the pointers
  1182. delete[] blockFE;
  1183. delete[] blockCEFE;
  1184. return;
  1185. }
  1186. //+-------------------------------------------------------------------------
  1187. //
  1188. // Function: dump_daholder, exported
  1189. //
  1190. // Synopsis: dumps CDAHolder object
  1191. //
  1192. // Effects:
  1193. //
  1194. // Arguments: see DECLARE_API in oleexts.h
  1195. //
  1196. // Requires:
  1197. //
  1198. // Returns: void
  1199. //
  1200. // Signals:
  1201. //
  1202. // Modifies: ExtensionApis (global)
  1203. //
  1204. // Algorithm:
  1205. //
  1206. // History: dd-mmm-yy Author Comment
  1207. // 02-Feb-95 t-ScottH author
  1208. //
  1209. // Notes:
  1210. // The address of the object is passed in the arguments. This
  1211. // address is in the debuggee's process memory. In order for
  1212. // NTSD to view this memory, the debugger must copy the mem
  1213. // using the WIN32 ReadProcessMemory API.
  1214. //
  1215. //--------------------------------------------------------------------------
  1216. DECLARE_API(dump_daholder)
  1217. {
  1218. DWORD dwReturnedCount;
  1219. BOOL fError;
  1220. LPVOID dwAddr;
  1221. char *pszDAH;
  1222. char *blockDAH = NULL;
  1223. char *blockStatDataArray = NULL;
  1224. CDAHolder *pDAH = NULL;
  1225. // set up global function pointers
  1226. ExtensionApis = *lpExtensionApis;
  1227. // get address of object from argument string
  1228. dwAddr = (LPVOID)GetExpression( args );
  1229. if (dwAddr == 0)
  1230. {
  1231. dprintf("Failed to get Address of CDAHolder\n");
  1232. return;
  1233. }
  1234. // read the block of memory from the debugee's process
  1235. blockDAH = new char[sizeof(CDAHolder)];
  1236. fError = ReadProcessMemory(
  1237. hCurrentProcess,
  1238. dwAddr,
  1239. blockDAH,
  1240. sizeof(CDAHolder),
  1241. &dwReturnedCount
  1242. );
  1243. if (fError == FALSE)
  1244. {
  1245. dprintf("Could not read debuggee's process memory: CDAHolder \n");
  1246. dprintf("at address %x\n", dwAddr);
  1247. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1248. goto errRtn;
  1249. }
  1250. if (dwReturnedCount != sizeof(CDAHolder))
  1251. {
  1252. dprintf("Size of process memory read != requested (CDAHolder)\n");
  1253. goto errRtn;
  1254. }
  1255. pDAH = (CDAHolder *)blockDAH;
  1256. // read the block of mem for the STATDATA array
  1257. blockStatDataArray = new char[sizeof(STATDATA) * pDAH->m_iSize];
  1258. fError = ReadProcessMemory(
  1259. hCurrentProcess,
  1260. pDAH->m_pSD,
  1261. blockStatDataArray,
  1262. sizeof(STATDATA) * pDAH->m_iSize,
  1263. &dwReturnedCount
  1264. );
  1265. if (fError == FALSE)
  1266. {
  1267. dprintf("Could not read debuggee's process memory: STATDATA array \n");
  1268. dprintf("at address %x\n", pDAH->m_pSD);
  1269. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1270. goto errRtn;
  1271. }
  1272. if (dwReturnedCount != (sizeof(STATDATA) * pDAH->m_iSize))
  1273. {
  1274. dprintf("Size of process memory read != requested (STATDATA array)\n");
  1275. goto errRtn;
  1276. }
  1277. pDAH->m_pSD = (STATDATA *)blockStatDataArray;
  1278. // dump the structure
  1279. pszDAH = DumpCDAHolder(pDAH, NO_PREFIX, 1);
  1280. dprintf("CDAHolder @ 0x%x\n", dwAddr);
  1281. dprintfx(pszDAH);
  1282. CoTaskMemFree(pszDAH);
  1283. errRtn:
  1284. delete[] blockDAH;
  1285. delete[] blockStatDataArray;
  1286. return;
  1287. }
  1288. //+-------------------------------------------------------------------------
  1289. //
  1290. // Function: dump_dataadvisecache, exported
  1291. //
  1292. // Synopsis: dumps CDataAdviseCache object
  1293. //
  1294. // Effects:
  1295. //
  1296. // Arguments: see DECLARE_API in oleexts.h
  1297. //
  1298. // Requires:
  1299. //
  1300. // Returns: void
  1301. //
  1302. // Signals:
  1303. //
  1304. // Modifies: ExtensionApis (global)
  1305. //
  1306. // Algorithm:
  1307. //
  1308. // History: dd-mmm-yy Author Comment
  1309. // 02-Feb-95 t-ScottH author
  1310. //
  1311. // Notes:
  1312. // The address of the object is passed in the arguments. This
  1313. // address is in the debuggee's process memory. In order for
  1314. // NTSD to view this memory, the debugger must copy the mem
  1315. // using the WIN32 ReadProcessMemory API.
  1316. //
  1317. //--------------------------------------------------------------------------
  1318. DECLARE_API(dump_dataadvisecache)
  1319. {
  1320. BOOL fError;
  1321. LPVOID dwAddr;
  1322. DWORD dwReturnedCount;
  1323. char *pszDataAdviseCache;
  1324. char *blockDataAdviseCache = NULL;
  1325. char *blockDAH = NULL;
  1326. CDataAdviseCache *pDataAdviseCache = NULL;
  1327. // set up global function pointers
  1328. ExtensionApis = *lpExtensionApis;
  1329. // get address of object from argument string
  1330. dwAddr = (LPVOID)GetExpression( args );
  1331. if (dwAddr == 0)
  1332. {
  1333. dprintf("Failed to get Address of CDataAdviseCache\n");
  1334. return;
  1335. }
  1336. // read the block of memory from the debugee's process
  1337. blockDataAdviseCache = new char[sizeof(CDataAdviseCache)];
  1338. fError = ReadProcessMemory(
  1339. hCurrentProcess,
  1340. dwAddr,
  1341. blockDataAdviseCache,
  1342. sizeof(CDataAdviseCache),
  1343. &dwReturnedCount
  1344. );
  1345. if (fError == FALSE)
  1346. {
  1347. dprintf("Could not read debuggee's process memory DataAdviseCache");
  1348. dprintf("at address %x\n", dwAddr);
  1349. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  1350. goto errRtn;
  1351. }
  1352. if (dwReturnedCount != sizeof(CDataAdviseCache))
  1353. {
  1354. dprintf("Size of process memory read != requested\n");
  1355. goto errRtn;
  1356. }
  1357. pDataAdviseCache = (CDataAdviseCache *)blockDataAdviseCache;
  1358. // get the mem for CDAHolder
  1359. if (pDataAdviseCache->m_pDAH != NULL)
  1360. {
  1361. blockDAH = new char[sizeof(CDAHolder)];
  1362. fError = ReadProcessMemory(
  1363. hCurrentProcess,
  1364. pDataAdviseCache->m_pDAH,
  1365. blockDAH,
  1366. sizeof(CDAHolder),
  1367. &dwReturnedCount
  1368. );
  1369. if (fError == FALSE)
  1370. {
  1371. dprintf("Could not read debuggee's process memory CDAHolder");
  1372. dprintf("at address %x\n", pDataAdviseCache->m_pDAH);
  1373. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  1374. goto errRtn;
  1375. }
  1376. if (dwReturnedCount != sizeof(CDAHolder))
  1377. {
  1378. dprintf("Size of process memory read != requested (CDAHolder)\n");
  1379. goto errRtn;
  1380. }
  1381. pDataAdviseCache->m_pDAH = (CDAHolder *)blockDAH;
  1382. }
  1383. // dump the structure
  1384. pszDataAdviseCache = DumpCDataAdviseCache(pDataAdviseCache, NO_PREFIX, 1);
  1385. dprintf("CDataAdviseCache @ 0x%x\n", dwAddr);
  1386. dprintfx(pszDataAdviseCache);
  1387. CoTaskMemFree(pszDataAdviseCache);
  1388. errRtn:
  1389. delete[] blockDAH;
  1390. delete[] blockDataAdviseCache;
  1391. return;
  1392. }
  1393. //+-------------------------------------------------------------------------
  1394. //
  1395. // Function: dump_defclassfactory, exported
  1396. //
  1397. // Synopsis: dumps CDefClassFactory object
  1398. //
  1399. // Effects:
  1400. //
  1401. // Arguments: see DECLARE_API in oleexts.h
  1402. //
  1403. // Requires:
  1404. //
  1405. // Returns: void
  1406. //
  1407. // Signals:
  1408. //
  1409. // Modifies: ExtensionApis (global)
  1410. //
  1411. // Algorithm:
  1412. //
  1413. // History: dd-mmm-yy Author Comment
  1414. // 02-Feb-95 t-ScottH author
  1415. //
  1416. // Notes:
  1417. // The address of the object is passed in the arguments. This
  1418. // address is in the debuggee's process memory. In order for
  1419. // NTSD to view this memory, the debugger must copy the mem
  1420. // using the WIN32 ReadProcessMemory API.
  1421. //
  1422. //--------------------------------------------------------------------------
  1423. DECLARE_API(dump_defclassfactory)
  1424. {
  1425. BOOL fError;
  1426. LPVOID dwAddr;
  1427. DWORD dwReturnedCount;
  1428. char *pszDefClassFactory;
  1429. char *blockDefClassFactory = NULL;
  1430. CDefClassFactory *pDefClassFactory = NULL;
  1431. // set up global function pointers
  1432. ExtensionApis = *lpExtensionApis;
  1433. // get address of object from argument string
  1434. dwAddr = (LPVOID)GetExpression( args );
  1435. if (dwAddr == 0)
  1436. {
  1437. dprintf("Failed to get Address of CDefClassFactory\n");
  1438. return;
  1439. }
  1440. // read the block of memory from the debugee's process
  1441. blockDefClassFactory = new char[sizeof(CDefClassFactory)];
  1442. fError = ReadProcessMemory(
  1443. hCurrentProcess,
  1444. dwAddr,
  1445. blockDefClassFactory,
  1446. sizeof(CDefClassFactory),
  1447. &dwReturnedCount
  1448. );
  1449. if (fError == FALSE)
  1450. {
  1451. dprintf("Could not read debuggee's process memory DefClassFactory");
  1452. dprintf("at address %x\n", dwAddr);
  1453. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  1454. goto errRtn;
  1455. }
  1456. if (dwReturnedCount != sizeof(CDefClassFactory))
  1457. {
  1458. dprintf("Size of process memory read != requested\n");
  1459. goto errRtn;
  1460. }
  1461. pDefClassFactory = (CDefClassFactory *)blockDefClassFactory;
  1462. // dump the structure
  1463. pszDefClassFactory = DumpCDefClassFactory(pDefClassFactory, NO_PREFIX, 1);
  1464. dprintf("CDefClassFactory @ 0x%x\n", dwAddr);
  1465. dprintfx(pszDefClassFactory);
  1466. CoTaskMemFree(pszDefClassFactory);
  1467. errRtn:
  1468. delete[] blockDefClassFactory;
  1469. return;
  1470. }
  1471. //+-------------------------------------------------------------------------
  1472. //
  1473. // Function: dump_deflink, exported
  1474. //
  1475. // Synopsis: dumps CDefLink object
  1476. //
  1477. // Effects:
  1478. //
  1479. // Arguments: see DECLARE_API in oleexts.h
  1480. //
  1481. // Requires:
  1482. //
  1483. // Returns: void
  1484. //
  1485. // Signals:
  1486. //
  1487. // Modifies: ExtensionApis (global)
  1488. //
  1489. // Algorithm:
  1490. //
  1491. // History: dd-mmm-yy Author Comment
  1492. // 02-Feb-95 t-ScottH author
  1493. //
  1494. // Notes:
  1495. // The address of the object is passed in the arguments. This
  1496. // address is in the debuggee's process memory. In order for
  1497. // NTSD to view this memory, the debugger must copy the mem
  1498. // using the WIN32 ReadProcessMemory API.
  1499. //
  1500. //--------------------------------------------------------------------------
  1501. DECLARE_API(dump_deflink)
  1502. {
  1503. unsigned int ui;
  1504. BOOL fError;
  1505. LPVOID dwAddr;
  1506. DWORD dwReturnedCount = 0;
  1507. char *pszDL = NULL;
  1508. char *blockDefLink = NULL;
  1509. char *blockCOleCache = NULL;
  1510. char *blockDataAdvCache = NULL;
  1511. char *blockOAHolder = NULL;
  1512. char *blockpIAS = NULL;
  1513. char *blockDAHolder = NULL;
  1514. char *blockSTATDATA = NULL;
  1515. char *blockCACHELIST = NULL;
  1516. char *blockCacheNode = NULL;
  1517. char *blockPresObj = NULL;
  1518. CDefLink *pDL = NULL;
  1519. CDAHolder *pDAH = NULL;
  1520. COAHolder *pOAH = NULL;
  1521. DWORD dwSizeOfPresObj;
  1522. // set up global function pointers
  1523. ExtensionApis = *lpExtensionApis;
  1524. // get address of object from argument string
  1525. dwAddr = (LPVOID)GetExpression( args );
  1526. if (dwAddr == 0)
  1527. {
  1528. dprintf("Failed to get Address of CDefLink\n");
  1529. return;
  1530. }
  1531. // read the block of memory from the debugee's process
  1532. blockDefLink = new char[sizeof(CDefLink)];
  1533. fError = ReadProcessMemory(
  1534. hCurrentProcess,
  1535. dwAddr,
  1536. blockDefLink,
  1537. sizeof(CDefLink),
  1538. &dwReturnedCount
  1539. );
  1540. if (fError == FALSE)
  1541. {
  1542. dprintf("Could not read debuggee's process memory: CDefLink \n");
  1543. dprintf("at address %x\n", dwAddr);
  1544. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1545. goto errRtn;
  1546. }
  1547. if (dwReturnedCount != sizeof(CDefLink))
  1548. {
  1549. dprintf("Size of process memory read != requested (CDefLink)\n");
  1550. goto errRtn;
  1551. }
  1552. pDL = (CDefLink *)blockDefLink;
  1553. // we need to NULL the monikers since we can't use GetDisplayName in this process
  1554. pDL->m_pMonikerAbs = NULL;
  1555. pDL->m_pMonikerRel = NULL;
  1556. // get the block of mem for the COAHolder
  1557. if (pDL->m_pCOAHolder != NULL)
  1558. {
  1559. blockOAHolder = new char[sizeof(COAHolder)];
  1560. fError = ReadProcessMemory(
  1561. hCurrentProcess,
  1562. pDL->m_pCOAHolder,
  1563. blockOAHolder,
  1564. sizeof(COAHolder),
  1565. &dwReturnedCount
  1566. );
  1567. if (fError == FALSE)
  1568. {
  1569. dprintf("Could not read debuggee's process memory: COAHolder \n");
  1570. dprintf("at address %x\n", pDL->m_pCOAHolder);
  1571. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1572. goto errRtn;
  1573. }
  1574. if (dwReturnedCount != sizeof(COAHolder))
  1575. {
  1576. dprintf("Size of process memory read != requested (COAHolder)\n");
  1577. goto errRtn;
  1578. }
  1579. pDL->m_pCOAHolder = (COAHolder *)blockOAHolder;
  1580. pOAH = (COAHolder *)blockOAHolder;
  1581. // need to copy the array of IAdviseSink pointers
  1582. if (pOAH->m_iSize > 0)
  1583. {
  1584. blockpIAS = new char[pOAH->m_iSize * sizeof(IAdviseSink *)];
  1585. fError = ReadProcessMemory(
  1586. hCurrentProcess,
  1587. pOAH->m_ppIAS,
  1588. blockpIAS,
  1589. sizeof(IAdviseSink *) * pOAH->m_iSize,
  1590. &dwReturnedCount
  1591. );
  1592. if (fError == FALSE)
  1593. {
  1594. dprintf("Could not read debuggee's process memory: IAdviseSink Array \n");
  1595. dprintf("at address %x\n", pOAH->m_ppIAS);
  1596. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1597. goto errRtn;
  1598. }
  1599. if (dwReturnedCount != (sizeof(IAdviseSink *) * pOAH->m_iSize))
  1600. {
  1601. dprintf("Size of process memory read != requested(IAdviseSink Array)\n");
  1602. goto errRtn;
  1603. }
  1604. pOAH->m_ppIAS = (IAdviseSink **)blockpIAS;
  1605. }
  1606. }
  1607. // get block of mem for CDataAdviseCache (only if m_pDataAdvCache != NULL)
  1608. if (pDL->m_pDataAdvCache != NULL)
  1609. {
  1610. blockDataAdvCache = new char[sizeof(CDataAdviseCache)];
  1611. fError = ReadProcessMemory(
  1612. hCurrentProcess,
  1613. pDL->m_pDataAdvCache,
  1614. blockDataAdvCache,
  1615. sizeof(CDataAdviseCache),
  1616. &dwReturnedCount
  1617. );
  1618. if (fError == FALSE)
  1619. {
  1620. dprintf("Could not read debuggee's process memory: CDataAdviseCache \n");
  1621. dprintf("at address %x\n", pDL->m_pDataAdvCache);
  1622. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1623. goto errRtn;
  1624. }
  1625. if (dwReturnedCount != sizeof(CDataAdviseCache))
  1626. {
  1627. dprintf("Size of process memory read != requested (CDataAdviseCache)\n");
  1628. goto errRtn;
  1629. }
  1630. pDL->m_pDataAdvCache = (CDataAdviseCache *)blockDataAdvCache;
  1631. if (pDL->m_pDataAdvCache->m_pDAH != NULL)
  1632. {
  1633. blockDAHolder = new char[sizeof(CDAHolder)];
  1634. fError = ReadProcessMemory(
  1635. hCurrentProcess,
  1636. pDL->m_pDataAdvCache->m_pDAH,
  1637. blockDAHolder,
  1638. sizeof(CDAHolder),
  1639. &dwReturnedCount
  1640. );
  1641. if (fError == FALSE)
  1642. {
  1643. dprintf("Could not read debuggee's process memory: CDAHolder \n");
  1644. dprintf("at address %x\n", pDL->m_pDataAdvCache->m_pDAH);
  1645. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1646. goto errRtn;
  1647. }
  1648. if (dwReturnedCount != sizeof(CDAHolder))
  1649. {
  1650. dprintf("Size of process memory read != requested (CDAHolder)\n");
  1651. goto errRtn;
  1652. }
  1653. pDL->m_pDataAdvCache->m_pDAH = (IDataAdviseHolder *)blockDAHolder;
  1654. pDAH = (CDAHolder *)blockDAHolder;
  1655. if (pDAH->m_pSD != NULL)
  1656. {
  1657. blockSTATDATA = new char[sizeof(STATDATA)*pDAH->m_iSize];
  1658. fError = ReadProcessMemory(
  1659. hCurrentProcess,
  1660. pDAH->m_pSD,
  1661. blockSTATDATA,
  1662. sizeof(STATDATA)*pDAH->m_iSize,
  1663. &dwReturnedCount
  1664. );
  1665. if (fError == FALSE)
  1666. {
  1667. dprintf("Could not read debuggee's process memory: STATDATA \n");
  1668. dprintf("at address %x\n", pDAH->m_pSD);
  1669. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1670. goto errRtn;
  1671. }
  1672. if (dwReturnedCount != (sizeof(STATDATA)*pDAH->m_iSize))
  1673. {
  1674. dprintf("Size of process memory read != requested (STATDATA)\n");
  1675. goto errRtn;
  1676. }
  1677. pDAH->m_pSD = (STATDATA *)blockSTATDATA;
  1678. }
  1679. }
  1680. }
  1681. // get block of mem for COleCache (only if m_pCOleCache != NULL)
  1682. if (pDL->m_pCOleCache != NULL)
  1683. {
  1684. blockCOleCache = new char[sizeof(COleCache)];
  1685. fError = ReadProcessMemory(
  1686. hCurrentProcess,
  1687. pDL->m_pCOleCache,
  1688. blockCOleCache,
  1689. sizeof(COleCache),
  1690. &dwReturnedCount
  1691. );
  1692. if (fError == FALSE)
  1693. {
  1694. dprintf("Could not read debuggee's process memory: COleCache \n");
  1695. dprintf("at address %x\n", pDL->m_pCOleCache);
  1696. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1697. goto errRtn;
  1698. }
  1699. if (dwReturnedCount != sizeof(COleCache))
  1700. {
  1701. dprintf("Size of process memory read != requested (COleCache)\n");
  1702. goto errRtn;
  1703. }
  1704. pDL->m_pCOleCache = (COleCache *)blockCOleCache;
  1705. // get block of mem for CACHELIST
  1706. if (pDL->m_pCOleCache->m_pCacheList != NULL)
  1707. {
  1708. blockCACHELIST = new char[sizeof(CACHELIST_ITEM) * pDL->m_pCOleCache->m_uCacheNodeMax];
  1709. fError = ReadProcessMemory(
  1710. hCurrentProcess,
  1711. pDL->m_pCOleCache->m_pCacheList,
  1712. blockCACHELIST,
  1713. sizeof(CACHELIST_ITEM) * pDL->m_pCOleCache->m_uCacheNodeMax,
  1714. &dwReturnedCount
  1715. );
  1716. if (fError == FALSE)
  1717. {
  1718. dprintf("Could not read debuggee's process memory: CACHELIST \n");
  1719. dprintf("at address %x\n", pDL->m_pCOleCache->m_pCacheList);
  1720. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1721. goto errRtn;
  1722. }
  1723. if (dwReturnedCount != (sizeof(CACHELIST_ITEM) * pDL->m_pCOleCache->m_uCacheNodeMax))
  1724. {
  1725. dprintf("Size of process memory read != requestedi (CACHELIST)\n");
  1726. goto errRtn;
  1727. }
  1728. pDL->m_pCOleCache->m_pCacheList = (LPCACHELIST) blockCACHELIST;
  1729. }
  1730. // need to copy the memory of the CCacheNode's in the CACHELIST
  1731. for (ui = 0; ui < pDL->m_pCOleCache->m_uCacheNodeMax; ui++)
  1732. {
  1733. if (pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode != NULL)
  1734. {
  1735. blockCacheNode = new char[sizeof(CCacheNode)];
  1736. fError = ReadProcessMemory(
  1737. hCurrentProcess,
  1738. pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode,
  1739. blockCacheNode,
  1740. sizeof(CCacheNode),
  1741. &dwReturnedCount
  1742. );
  1743. if (fError == FALSE)
  1744. {
  1745. dprintf("Could not read debuggee's process memory: CCacheNode \n");
  1746. dprintf("at address %x\n", pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode);
  1747. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1748. goto errRtn;
  1749. }
  1750. if (dwReturnedCount != sizeof(CCacheNode))
  1751. {
  1752. dprintf("Size of process memory read != requested (CCacheNode)\n");
  1753. goto errRtn;
  1754. }
  1755. // pass off pointer
  1756. pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode = (CCacheNode*)blockCacheNode;
  1757. blockCacheNode = NULL;
  1758. // need to get the OlePresObjs for the CCacheNode
  1759. if (pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj != NULL)
  1760. {
  1761. switch (pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_dwPresFlag)
  1762. {
  1763. case CN_PRESOBJ_GEN:
  1764. dwSizeOfPresObj = sizeof(CGenObject);
  1765. break;
  1766. case CN_PRESOBJ_MF:
  1767. dwSizeOfPresObj = sizeof(CMfObject);
  1768. break;
  1769. case CN_PRESOBJ_EMF:
  1770. dwSizeOfPresObj = sizeof(CEMfObject);
  1771. break;
  1772. default:
  1773. dprintf("Error: can not determine size of IOlePresObj\n");
  1774. return;
  1775. }
  1776. blockPresObj = new char[dwSizeOfPresObj];
  1777. fError = ReadProcessMemory(
  1778. hCurrentProcess,
  1779. pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj,
  1780. blockPresObj,
  1781. dwSizeOfPresObj,
  1782. &dwReturnedCount
  1783. );
  1784. if (fError == FALSE)
  1785. {
  1786. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  1787. dprintf("at address %x\n", pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj);
  1788. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1789. goto errRtn;
  1790. }
  1791. if (dwReturnedCount != dwSizeOfPresObj)
  1792. {
  1793. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  1794. goto errRtn;
  1795. }
  1796. // pass off pointer
  1797. pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj = (IOlePresObj *)blockPresObj;
  1798. blockPresObj = NULL;
  1799. }
  1800. if (pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze != NULL)
  1801. {
  1802. switch (pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_dwPresFlag)
  1803. {
  1804. case CN_PRESOBJ_GEN:
  1805. dwSizeOfPresObj = sizeof(CGenObject);
  1806. break;
  1807. case CN_PRESOBJ_MF:
  1808. dwSizeOfPresObj = sizeof(CMfObject);
  1809. break;
  1810. case CN_PRESOBJ_EMF:
  1811. dwSizeOfPresObj = sizeof(CEMfObject);
  1812. break;
  1813. default:
  1814. dprintf("Error: can not determine size of IOlePresObj\n");
  1815. return;
  1816. }
  1817. blockPresObj = new char[dwSizeOfPresObj];
  1818. fError = ReadProcessMemory(
  1819. hCurrentProcess,
  1820. pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze,
  1821. blockPresObj,
  1822. dwSizeOfPresObj,
  1823. &dwReturnedCount
  1824. );
  1825. if (fError == FALSE)
  1826. {
  1827. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  1828. dprintf("at address %x\n", pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze);
  1829. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1830. goto errRtn;
  1831. }
  1832. if (dwReturnedCount != dwSizeOfPresObj)
  1833. {
  1834. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  1835. goto errRtn;
  1836. }
  1837. // pass off pointer
  1838. pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze = (IOlePresObj *)blockPresObj;
  1839. blockPresObj = NULL;
  1840. }
  1841. }
  1842. }
  1843. }
  1844. // dump the structure
  1845. pszDL = DumpCDefLink(pDL, NO_PREFIX, 1);
  1846. dprintf("CDefLink @ 0x%x\n", dwAddr);
  1847. dprintfx(pszDL);
  1848. CoTaskMemFree(pszDL);
  1849. errRtn:
  1850. // delete the blocks and not the pointers
  1851. if ( (pDL != NULL)&&(blockCACHELIST != NULL)&&(blockCOleCache != NULL) )
  1852. {
  1853. for (ui = 0; ui < pDL->m_pCOleCache->m_uCacheNodeMax; ui++)
  1854. {
  1855. if (pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode != NULL)
  1856. {
  1857. delete[] ((char *)pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj);
  1858. delete[] ((char *)pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze);
  1859. delete[] ((char *)pDL->m_pCOleCache->m_pCacheList[ui].lpCacheNode);
  1860. }
  1861. }
  1862. }
  1863. delete[] blockCACHELIST;
  1864. delete[] blockCOleCache;
  1865. delete[] blockDAHolder;
  1866. delete[] blockSTATDATA;
  1867. delete[] blockDataAdvCache;
  1868. delete[] blockpIAS;
  1869. delete[] blockOAHolder;
  1870. delete[] blockDefLink;
  1871. return;
  1872. }
  1873. //+-------------------------------------------------------------------------
  1874. //
  1875. // Function: dump_defobject, exported
  1876. //
  1877. // Synopsis: dumps CDefObject object
  1878. //
  1879. // Effects:
  1880. //
  1881. // Arguments: see DECLARE_API in oleexts.h
  1882. //
  1883. // Requires:
  1884. //
  1885. // Returns: void
  1886. //
  1887. // Signals:
  1888. //
  1889. // Modifies: ExtensionApis (global)
  1890. //
  1891. // Algorithm:
  1892. //
  1893. // History: dd-mmm-yy Author Comment
  1894. // 02-Feb-95 t-ScottH author
  1895. //
  1896. // Notes:
  1897. // The address of the object is passed in the arguments. This
  1898. // address is in the debuggee's process memory. In order for
  1899. // NTSD to view this memory, the debugger must copy the mem
  1900. // using the WIN32 ReadProcessMemory API.
  1901. //
  1902. //--------------------------------------------------------------------------
  1903. DECLARE_API(dump_defobject)
  1904. {
  1905. unsigned int ui;
  1906. BOOL fError;
  1907. LPVOID dwAddr;
  1908. DWORD dwReturnedCount = 0;
  1909. char *pszDO = NULL;
  1910. char *blockDefObject = NULL;
  1911. char *blockCOleCache = NULL;
  1912. char *blockDataAdvCache = NULL;
  1913. char *blockOAHolder = NULL;
  1914. char *blockpIAS = NULL;
  1915. char *blockDAHolder = NULL;
  1916. char *blockSTATDATA = NULL;
  1917. char *blockCACHELIST = NULL;
  1918. char *blockCacheNode = NULL;
  1919. char *blockPresObj = NULL;
  1920. CDefObject *pDO = NULL;
  1921. CDAHolder *pDAH = NULL;
  1922. COAHolder *pOAH = NULL;
  1923. DWORD dwSizeOfPresObj;
  1924. // set up global function pointers
  1925. ExtensionApis = *lpExtensionApis;
  1926. // get address of object from argument string
  1927. dwAddr = (LPVOID)GetExpression( args );
  1928. if (dwAddr == 0)
  1929. {
  1930. dprintf("Failed to get Address of CDefObject\n");
  1931. return;
  1932. }
  1933. // read the block of memory from the debugee's process
  1934. blockDefObject = new char[sizeof(CDefObject)];
  1935. fError = ReadProcessMemory(
  1936. hCurrentProcess,
  1937. dwAddr,
  1938. blockDefObject,
  1939. sizeof(CDefObject),
  1940. &dwReturnedCount
  1941. );
  1942. if (fError == FALSE)
  1943. {
  1944. dprintf("Could not read debuggee's process memory: CDefObject \n");
  1945. dprintf("at address %x\n", dwAddr);
  1946. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1947. goto errRtn;
  1948. }
  1949. if (dwReturnedCount != sizeof(CDefObject))
  1950. {
  1951. dprintf("Size of process memory read != requested (CDefObject)\n");
  1952. goto errRtn;
  1953. }
  1954. pDO = (CDefObject *)blockDefObject;
  1955. // get the block of mem for the COAHolder
  1956. if (pDO->m_pOAHolder != NULL)
  1957. {
  1958. blockOAHolder = new char[sizeof(COAHolder)];
  1959. fError = ReadProcessMemory(
  1960. hCurrentProcess,
  1961. pDO->m_pOAHolder,
  1962. blockOAHolder,
  1963. sizeof(COAHolder),
  1964. &dwReturnedCount
  1965. );
  1966. if (fError == FALSE)
  1967. {
  1968. dprintf("Could not read debuggee's process memory: COAHolder \n");
  1969. dprintf("at address %x\n", pDO->m_pOAHolder);
  1970. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1971. goto errRtn;
  1972. }
  1973. if (dwReturnedCount != sizeof(COAHolder))
  1974. {
  1975. dprintf("Size of process memory read != requested (COAHolder)\n");
  1976. goto errRtn;
  1977. }
  1978. pDO->m_pOAHolder = (COAHolder *)blockOAHolder;
  1979. pOAH = (COAHolder *)blockOAHolder;
  1980. // need to copy the array of IAdviseSink pointers
  1981. if (pOAH->m_iSize > 0)
  1982. {
  1983. blockpIAS = new char[pOAH->m_iSize * sizeof(IAdviseSink *)];
  1984. fError = ReadProcessMemory(
  1985. hCurrentProcess,
  1986. pOAH->m_ppIAS,
  1987. blockpIAS,
  1988. sizeof(IAdviseSink *) * pOAH->m_iSize,
  1989. &dwReturnedCount
  1990. );
  1991. if (fError == FALSE)
  1992. {
  1993. dprintf("Could not read debuggee's process memory: IAdviseSink Array \n");
  1994. dprintf("at address %x\n", pOAH->m_ppIAS);
  1995. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  1996. goto errRtn;
  1997. }
  1998. if (dwReturnedCount != (sizeof(IAdviseSink *) * pOAH->m_iSize))
  1999. {
  2000. dprintf("Size of process memory read != requested(IAdviseSink Array)\n");
  2001. goto errRtn;
  2002. }
  2003. pOAH->m_ppIAS = (IAdviseSink **)blockpIAS;
  2004. }
  2005. }
  2006. // get block of mem for CDataAdviseCache (only if m_pDataAdvCache != NULL)
  2007. if (pDO->m_pDataAdvCache != NULL)
  2008. {
  2009. blockDataAdvCache = new char[sizeof(CDataAdviseCache)];
  2010. fError = ReadProcessMemory(
  2011. hCurrentProcess,
  2012. pDO->m_pDataAdvCache,
  2013. blockDataAdvCache,
  2014. sizeof(CDataAdviseCache),
  2015. &dwReturnedCount
  2016. );
  2017. if (fError == FALSE)
  2018. {
  2019. dprintf("Could not read debuggee's process memory: CDataAdviseCache \n");
  2020. dprintf("at address %x\n", pDO->m_pDataAdvCache);
  2021. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2022. goto errRtn;
  2023. }
  2024. if (dwReturnedCount != sizeof(CDataAdviseCache))
  2025. {
  2026. dprintf("Size of process memory read != requested (CDataAdviseCache)\n");
  2027. goto errRtn;
  2028. }
  2029. pDO->m_pDataAdvCache = (CDataAdviseCache *)blockDataAdvCache;
  2030. // get the mem for CDAHolder
  2031. if (pDO->m_pDataAdvCache->m_pDAH != NULL)
  2032. {
  2033. blockDAHolder = new char[sizeof(CDAHolder)];
  2034. fError = ReadProcessMemory(
  2035. hCurrentProcess,
  2036. pDO->m_pDataAdvCache->m_pDAH,
  2037. blockDAHolder,
  2038. sizeof(CDAHolder),
  2039. &dwReturnedCount
  2040. );
  2041. if (fError == FALSE)
  2042. {
  2043. dprintf("Could not read debuggee's process memory: CDAHolder \n");
  2044. dprintf("at address %x\n", pDO->m_pDataAdvCache->m_pDAH);
  2045. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2046. goto errRtn;
  2047. }
  2048. if (dwReturnedCount != sizeof(CDAHolder))
  2049. {
  2050. dprintf("Size of process memory read != requested (CDAHolder)\n");
  2051. goto errRtn;
  2052. }
  2053. pDO->m_pDataAdvCache->m_pDAH = (IDataAdviseHolder *)blockDAHolder;
  2054. pDAH = (CDAHolder *)blockDAHolder;
  2055. // get the STATDATA array
  2056. if (pDAH->m_pSD != NULL)
  2057. {
  2058. blockSTATDATA = new char[sizeof(STATDATA)*pDAH->m_iSize];
  2059. fError = ReadProcessMemory(
  2060. hCurrentProcess,
  2061. pDAH->m_pSD,
  2062. blockSTATDATA,
  2063. sizeof(STATDATA)*pDAH->m_iSize,
  2064. &dwReturnedCount
  2065. );
  2066. if (fError == FALSE)
  2067. {
  2068. dprintf("Could not read debuggee's process memory: STATDATA \n");
  2069. dprintf("at address %x\n", pDAH->m_pSD);
  2070. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2071. goto errRtn;
  2072. }
  2073. if (dwReturnedCount != (sizeof(STATDATA)*pDAH->m_iSize))
  2074. {
  2075. dprintf("Size of process memory read != requested (STATDATA)\n");
  2076. goto errRtn;
  2077. }
  2078. pDAH->m_pSD = (STATDATA *)blockSTATDATA;
  2079. }
  2080. }
  2081. }
  2082. // get block of mem for COleCache (only if m_pCOleCache != NULL)
  2083. if (pDO->m_pCOleCache != NULL)
  2084. {
  2085. blockCOleCache = new char[sizeof(COleCache)];
  2086. fError = ReadProcessMemory(
  2087. hCurrentProcess,
  2088. pDO->m_pCOleCache,
  2089. blockCOleCache,
  2090. sizeof(COleCache),
  2091. &dwReturnedCount
  2092. );
  2093. if (fError == FALSE)
  2094. {
  2095. dprintf("Could not read debuggee's process memory: COleCache \n");
  2096. dprintf("at address %x\n", pDO->m_pCOleCache);
  2097. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2098. goto errRtn;
  2099. }
  2100. if (dwReturnedCount != sizeof(COleCache))
  2101. {
  2102. dprintf("Size of process memory read != requested (COleCache)\n");
  2103. goto errRtn;
  2104. }
  2105. pDO->m_pCOleCache = (COleCache *)blockCOleCache;
  2106. // get block of mem for CACHELIST
  2107. if (pDO->m_pCOleCache->m_pCacheList != NULL)
  2108. {
  2109. blockCACHELIST = new char[sizeof(CACHELIST_ITEM) * pDO->m_pCOleCache->m_uCacheNodeMax];
  2110. fError = ReadProcessMemory(
  2111. hCurrentProcess,
  2112. pDO->m_pCOleCache->m_pCacheList,
  2113. blockCACHELIST,
  2114. sizeof(CACHELIST_ITEM) * pDO->m_pCOleCache->m_uCacheNodeMax,
  2115. &dwReturnedCount
  2116. );
  2117. if (fError == FALSE)
  2118. {
  2119. dprintf("Could not read debuggee's process memory: CACHELIST \n");
  2120. dprintf("at address %x\n", pDO->m_pCOleCache->m_pCacheList);
  2121. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2122. goto errRtn;
  2123. }
  2124. if (dwReturnedCount != (sizeof(CACHELIST_ITEM) * pDO->m_pCOleCache->m_uCacheNodeMax))
  2125. {
  2126. dprintf("Size of process memory read != requested(CACHELIST_ITEM\n");
  2127. goto errRtn;
  2128. }
  2129. pDO->m_pCOleCache->m_pCacheList = (LPCACHELIST) blockCACHELIST;
  2130. }
  2131. // need to copy the memory of the CCacheNode's in the CACHELIST
  2132. for (ui = 0; ui < pDO->m_pCOleCache->m_uCacheNodeMax; ui++)
  2133. {
  2134. if (pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode != NULL)
  2135. {
  2136. blockCacheNode = new char[sizeof(CCacheNode)];
  2137. fError = ReadProcessMemory(
  2138. hCurrentProcess,
  2139. pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode,
  2140. blockCacheNode,
  2141. sizeof(CCacheNode),
  2142. &dwReturnedCount
  2143. );
  2144. if (fError == FALSE)
  2145. {
  2146. dprintf("Could not read debuggee's process memory: CCacheNode \n");
  2147. dprintf("at address %x\n", pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode);
  2148. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2149. goto errRtn;
  2150. }
  2151. if (dwReturnedCount != sizeof(CCacheNode))
  2152. {
  2153. dprintf("Size of process memory read != requested (CCacheNode)\n");
  2154. goto errRtn;
  2155. }
  2156. // pass off pointer
  2157. pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode = (CCacheNode*)blockCacheNode;
  2158. blockCacheNode = NULL;
  2159. // need to get the OlePresObjs for the CCacheNode
  2160. if (pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj != NULL)
  2161. {
  2162. switch (pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_dwPresFlag)
  2163. {
  2164. case CN_PRESOBJ_GEN:
  2165. dwSizeOfPresObj = sizeof(CGenObject);
  2166. break;
  2167. case CN_PRESOBJ_MF:
  2168. dwSizeOfPresObj = sizeof(CMfObject);
  2169. break;
  2170. case CN_PRESOBJ_EMF:
  2171. dwSizeOfPresObj = sizeof(CEMfObject);
  2172. break;
  2173. default:
  2174. dprintf("Error: can not determine size of IOlePresObj\n");
  2175. return;
  2176. }
  2177. blockPresObj = new char[dwSizeOfPresObj];
  2178. fError = ReadProcessMemory(
  2179. hCurrentProcess,
  2180. pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj,
  2181. blockPresObj,
  2182. dwSizeOfPresObj,
  2183. &dwReturnedCount
  2184. );
  2185. if (fError == FALSE)
  2186. {
  2187. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  2188. dprintf("at address %x\n", pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj);
  2189. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2190. goto errRtn;
  2191. }
  2192. if (dwReturnedCount != dwSizeOfPresObj)
  2193. {
  2194. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  2195. goto errRtn;
  2196. }
  2197. // pass off pointer
  2198. pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj = (IOlePresObj *)blockPresObj;
  2199. blockPresObj = NULL;
  2200. }
  2201. if (pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze != NULL)
  2202. {
  2203. switch (pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_dwPresFlag)
  2204. {
  2205. case CN_PRESOBJ_GEN:
  2206. dwSizeOfPresObj = sizeof(CGenObject);
  2207. break;
  2208. case CN_PRESOBJ_MF:
  2209. dwSizeOfPresObj = sizeof(CMfObject);
  2210. break;
  2211. case CN_PRESOBJ_EMF:
  2212. dwSizeOfPresObj = sizeof(CEMfObject);
  2213. break;
  2214. default:
  2215. dprintf("Error: can not determine size of IOlePresObj\n");
  2216. return;
  2217. }
  2218. blockPresObj = new char[dwSizeOfPresObj];
  2219. fError = ReadProcessMemory(
  2220. hCurrentProcess,
  2221. pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze,
  2222. blockPresObj,
  2223. dwSizeOfPresObj,
  2224. &dwReturnedCount
  2225. );
  2226. if (fError == FALSE)
  2227. {
  2228. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  2229. dprintf("at address %x\n", pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze);
  2230. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2231. goto errRtn;
  2232. }
  2233. if (dwReturnedCount != dwSizeOfPresObj)
  2234. {
  2235. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  2236. goto errRtn;
  2237. }
  2238. // pass off pointer
  2239. pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze = (IOlePresObj *)blockPresObj;
  2240. blockPresObj = NULL;
  2241. }
  2242. }
  2243. }
  2244. }
  2245. // dump the structure
  2246. pszDO = DumpCDefObject(pDO, NO_PREFIX, 1);
  2247. dprintf("CDefObject @ 0x%x\n", dwAddr);
  2248. dprintfx(pszDO);
  2249. CoTaskMemFree(pszDO);
  2250. errRtn:
  2251. // delete the blocks and not the pointers
  2252. if ( (pDO != NULL)&&(blockCACHELIST != NULL)&&(blockCOleCache != NULL) )
  2253. {
  2254. for (ui = 0; ui < pDO->m_pCOleCache->m_uCacheNodeMax; ui++)
  2255. {
  2256. if (pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode != NULL)
  2257. {
  2258. delete[] ((char *)pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObj);
  2259. delete[] ((char *)pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze);
  2260. delete[] ((char *)pDO->m_pCOleCache->m_pCacheList[ui].lpCacheNode);
  2261. }
  2262. }
  2263. }
  2264. delete[] blockCACHELIST;
  2265. delete[] blockCOleCache;
  2266. delete[] blockDAHolder;
  2267. delete[] blockSTATDATA;
  2268. delete[] blockDataAdvCache;
  2269. delete[] blockpIAS;
  2270. delete[] blockOAHolder;
  2271. delete[] blockDefObject;
  2272. return;
  2273. }
  2274. //+-------------------------------------------------------------------------
  2275. //
  2276. // Function: dump_emfobject, exported
  2277. //
  2278. // Synopsis: dumps CEMfObject object
  2279. //
  2280. // Effects:
  2281. //
  2282. // Arguments: see DECLARE_API in oleexts.h
  2283. //
  2284. // Requires:
  2285. //
  2286. // Returns: void
  2287. //
  2288. // Signals:
  2289. //
  2290. // Modifies: ExtensionApis (global)
  2291. //
  2292. // Algorithm:
  2293. //
  2294. // History: dd-mmm-yy Author Comment
  2295. // 02-Feb-95 t-ScottH author
  2296. //
  2297. // Notes:
  2298. // The address of the object is passed in the arguments. This
  2299. // address is in the debuggee's process memory. In order for
  2300. // NTSD to view this memory, the debugger must copy the mem
  2301. // using the WIN32 ReadProcessMemory API.
  2302. //
  2303. //--------------------------------------------------------------------------
  2304. DECLARE_API(dump_emfobject)
  2305. {
  2306. BOOL fError;
  2307. LPVOID dwAddr;
  2308. DWORD dwReturnedCount;
  2309. char *pszEMfObject;
  2310. char *blockEMfObject = NULL;
  2311. CEMfObject *pEMfObject = NULL;
  2312. // set up global function pointers
  2313. ExtensionApis = *lpExtensionApis;
  2314. // get address of object from argument string
  2315. dwAddr = (LPVOID)GetExpression( args );
  2316. if (dwAddr == 0)
  2317. {
  2318. dprintf("Failed to get Address of CEMfObject\n");
  2319. return;
  2320. }
  2321. // read the block of memory from the debugee's process
  2322. blockEMfObject = new char[sizeof(CEMfObject)];
  2323. fError = ReadProcessMemory(
  2324. hCurrentProcess,
  2325. dwAddr,
  2326. blockEMfObject,
  2327. sizeof(CEMfObject),
  2328. &dwReturnedCount
  2329. );
  2330. if (fError == FALSE)
  2331. {
  2332. dprintf("Could not read debuggee's process memory EMfObject");
  2333. dprintf("at address %x\n", dwAddr);
  2334. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  2335. goto errRtn;
  2336. }
  2337. if (dwReturnedCount != sizeof(CEMfObject))
  2338. {
  2339. dprintf("Size of process memory read != requested\n");
  2340. goto errRtn;
  2341. }
  2342. pEMfObject = (CEMfObject *)blockEMfObject;
  2343. // dump the structure
  2344. pszEMfObject = DumpCEMfObject(pEMfObject, NO_PREFIX, 1);
  2345. dprintf("CEMfObject @ 0x%x\n", dwAddr);
  2346. dprintfx(pszEMfObject);
  2347. CoTaskMemFree(pszEMfObject);
  2348. errRtn:
  2349. delete[] blockEMfObject;
  2350. return;
  2351. }
  2352. //+-------------------------------------------------------------------------
  2353. //
  2354. // Function: dump_enumfmt, exported
  2355. //
  2356. // Synopsis: dumps CEnumFmt object
  2357. //
  2358. // Effects:
  2359. //
  2360. // Arguments: see DECLARE_API in oleexts.h
  2361. //
  2362. // Requires:
  2363. //
  2364. // Returns: void
  2365. //
  2366. // Signals:
  2367. //
  2368. // Modifies: ExtensionApis (global)
  2369. //
  2370. // Algorithm:
  2371. //
  2372. // History: dd-mmm-yy Author Comment
  2373. // 02-Feb-95 t-ScottH author
  2374. //
  2375. // Notes:
  2376. // The address of the object is passed in the arguments. This
  2377. // address is in the debuggee's process memory. In order for
  2378. // NTSD to view this memory, the debugger must copy the mem
  2379. // using the WIN32 ReadProcessMemory API.
  2380. //
  2381. //--------------------------------------------------------------------------
  2382. DECLARE_API(dump_enumfmt)
  2383. {
  2384. // set up global function pointers
  2385. ExtensionApis = *lpExtensionApis;
  2386. dprintf("dump_enumfmt not implemented\n");
  2387. return;
  2388. }
  2389. //+-------------------------------------------------------------------------
  2390. //
  2391. // Function: dump_enumfmt10, exported
  2392. //
  2393. // Synopsis: dumps CEnumFmt10 object
  2394. //
  2395. // Effects:
  2396. //
  2397. // Arguments: see DECLARE_API in oleexts.h
  2398. //
  2399. // Requires:
  2400. //
  2401. // Returns: void
  2402. //
  2403. // Signals:
  2404. //
  2405. // Modifies: ExtensionApis (global)
  2406. //
  2407. // Algorithm:
  2408. //
  2409. // History: dd-mmm-yy Author Comment
  2410. // 02-Feb-95 t-ScottH author
  2411. //
  2412. // Notes:
  2413. // The address of the object is passed in the arguments. This
  2414. // address is in the debuggee's process memory. In order for
  2415. // NTSD to view this memory, the debugger must copy the mem
  2416. // using the WIN32 ReadProcessMemory API.
  2417. //
  2418. //--------------------------------------------------------------------------
  2419. DECLARE_API(dump_enumfmt10)
  2420. {
  2421. // set up global function pointers
  2422. ExtensionApis = *lpExtensionApis;
  2423. dprintf("dump_enumfmt10 not implemented\n");
  2424. return;
  2425. }
  2426. //+-------------------------------------------------------------------------
  2427. //
  2428. // Function: dump_enumstatdata, exported
  2429. //
  2430. // Synopsis: dumps CEnumSTATDATA object
  2431. //
  2432. // Effects:
  2433. //
  2434. // Arguments: see DECLARE_API in oleexts.h
  2435. //
  2436. // Requires:
  2437. //
  2438. // Returns: void
  2439. //
  2440. // Signals:
  2441. //
  2442. // Modifies: ExtensionApis (global)
  2443. //
  2444. // Algorithm:
  2445. //
  2446. // History: dd-mmm-yy Author Comment
  2447. // 02-Feb-95 t-ScottH author
  2448. //
  2449. // Notes:
  2450. // The address of the object is passed in the arguments. This
  2451. // address is in the debuggee's process memory. In order for
  2452. // NTSD to view this memory, the debugger must copy the mem
  2453. // using the WIN32 ReadProcessMemory API.
  2454. //
  2455. //--------------------------------------------------------------------------
  2456. DECLARE_API(dump_enumstatdata)
  2457. {
  2458. DWORD dwReturnedCount;
  2459. BOOL fError;
  2460. LPVOID dwAddr;
  2461. char *pszESD;
  2462. char *blockEnumStatData = NULL;
  2463. char *blockDAH = NULL;
  2464. char *blockStatDataArray = NULL;
  2465. CEnumSTATDATA *pESD = NULL;
  2466. // set up global function pointers
  2467. ExtensionApis = *lpExtensionApis;
  2468. // get address of object from argument string
  2469. dwAddr = (LPVOID)GetExpression( args );
  2470. if (dwAddr == 0)
  2471. {
  2472. dprintf("Failed to get Address of CEnumSTATDATA\n");
  2473. return;
  2474. }
  2475. // read the mem for the CEnumSTATDATA
  2476. blockEnumStatData = new char[sizeof(CEnumSTATDATA)];
  2477. fError = ReadProcessMemory(
  2478. hCurrentProcess,
  2479. dwAddr,
  2480. blockEnumStatData,
  2481. sizeof(CEnumSTATDATA),
  2482. &dwReturnedCount
  2483. );
  2484. if (fError == FALSE)
  2485. {
  2486. dprintf("Could not read debuggee's process memory: CEnumSTATDATA \n");
  2487. dprintf("at address %x\n", dwAddr);
  2488. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2489. goto errRtn;
  2490. }
  2491. if (dwReturnedCount != sizeof(CEnumSTATDATA))
  2492. {
  2493. dprintf("Size of process memory read != requested (CEnumSTATDATA)\n");
  2494. goto errRtn;
  2495. }
  2496. pESD = (CEnumSTATDATA *)blockEnumStatData;
  2497. // read the block of memory for the CDAHolder
  2498. if (pESD->m_pHolder != NULL)
  2499. {
  2500. blockDAH = new char[sizeof(CDAHolder)];
  2501. fError = ReadProcessMemory(
  2502. hCurrentProcess,
  2503. pESD->m_pHolder,
  2504. blockDAH,
  2505. sizeof(CDAHolder),
  2506. &dwReturnedCount
  2507. );
  2508. if (fError == FALSE)
  2509. {
  2510. dprintf("Could not read debuggee's process memory: CDAHolder \n");
  2511. dprintf("at address %x\n", pESD->m_pHolder);
  2512. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2513. goto errRtn;
  2514. }
  2515. if (dwReturnedCount != sizeof(CDAHolder))
  2516. {
  2517. dprintf("Size of process memory read != requested (CDAHolder)\n");
  2518. goto errRtn;
  2519. }
  2520. pESD->m_pHolder = (CDAHolder *)blockDAH;
  2521. // read the block of mem for the STATDATA array
  2522. if (pESD->m_pHolder->m_pSD != NULL)
  2523. {
  2524. blockStatDataArray = new char[sizeof(STATDATA) * pESD->m_pHolder->m_iSize];
  2525. fError = ReadProcessMemory(
  2526. hCurrentProcess,
  2527. pESD->m_pHolder->m_pSD,
  2528. blockStatDataArray,
  2529. sizeof(STATDATA) * pESD->m_pHolder->m_iSize,
  2530. &dwReturnedCount
  2531. );
  2532. if (fError == FALSE)
  2533. {
  2534. dprintf("Could not read debuggee's process memory: STATDATA array \n");
  2535. dprintf("at address %x\n", pESD->m_pHolder->m_pSD);
  2536. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2537. goto errRtn;
  2538. }
  2539. if (dwReturnedCount != (sizeof(STATDATA) * pESD->m_pHolder->m_iSize))
  2540. {
  2541. dprintf("Size of process memory read != requested (STATDATA array)\n");
  2542. goto errRtn;
  2543. }
  2544. pESD->m_pHolder->m_pSD = (STATDATA *)blockStatDataArray;
  2545. }
  2546. }
  2547. // dump the structure
  2548. pszESD = DumpCEnumSTATDATA(pESD, NO_PREFIX, 1);
  2549. dprintf("CEnumSTATDATA @ 0x%x\n", dwAddr);
  2550. dprintfx(pszESD);
  2551. CoTaskMemFree(pszESD);
  2552. errRtn:
  2553. delete[] blockEnumStatData;
  2554. delete[] blockDAH;
  2555. delete[] blockStatDataArray;
  2556. return;
  2557. }
  2558. //+-------------------------------------------------------------------------
  2559. //
  2560. // Function: dump_enumverb, exported
  2561. //
  2562. // Synopsis: dumps CEnumVerb object
  2563. //
  2564. // Effects:
  2565. //
  2566. // Arguments: see DECLARE_API in oleexts.h
  2567. //
  2568. // Requires:
  2569. //
  2570. // Returns: void
  2571. //
  2572. // Signals:
  2573. //
  2574. // Modifies: ExtensionApis (global)
  2575. //
  2576. // Algorithm:
  2577. //
  2578. // History: dd-mmm-yy Author Comment
  2579. // 02-Feb-95 t-ScottH author
  2580. //
  2581. // Notes:
  2582. // The address of the object is passed in the arguments. This
  2583. // address is in the debuggee's process memory. In order for
  2584. // NTSD to view this memory, the debugger must copy the mem
  2585. // using the WIN32 ReadProcessMemory API.
  2586. //
  2587. //--------------------------------------------------------------------------
  2588. DECLARE_API(dump_enumverb)
  2589. {
  2590. // set up global function pointers
  2591. ExtensionApis = *lpExtensionApis;
  2592. dprintf("dump_enumverb not implemented\n");
  2593. return;
  2594. }
  2595. //+-------------------------------------------------------------------------
  2596. //
  2597. // Function: dump_genobject, exported
  2598. //
  2599. // Synopsis: dumps CGenObject object
  2600. //
  2601. // Effects:
  2602. //
  2603. // Arguments: see DECLARE_API in oleexts.h
  2604. //
  2605. // Requires:
  2606. //
  2607. // Returns: void
  2608. //
  2609. // Signals:
  2610. //
  2611. // Modifies: ExtensionApis (global)
  2612. //
  2613. // Algorithm:
  2614. //
  2615. // History: dd-mmm-yy Author Comment
  2616. // 02-Feb-95 t-ScottH author
  2617. //
  2618. // Notes:
  2619. // The address of the object is passed in the arguments. This
  2620. // address is in the debuggee's process memory. In order for
  2621. // NTSD to view this memory, the debugger must copy the mem
  2622. // using the WIN32 ReadProcessMemory API.
  2623. //
  2624. //--------------------------------------------------------------------------
  2625. DECLARE_API(dump_genobject)
  2626. {
  2627. BOOL fError;
  2628. LPVOID dwAddr;
  2629. DWORD dwReturnedCount;
  2630. char *pszGenObject;
  2631. char *blockGenObject = NULL;
  2632. CGenObject *pGenObject = NULL;
  2633. // set up global function pointers
  2634. ExtensionApis = *lpExtensionApis;
  2635. // get address of object from argument string
  2636. dwAddr = (LPVOID)GetExpression( args );
  2637. if (dwAddr == 0)
  2638. {
  2639. dprintf("Failed to get Address of CGenObject\n");
  2640. return;
  2641. }
  2642. // read the block of memory from the debugee's process
  2643. blockGenObject = new char[sizeof(CGenObject)];
  2644. fError = ReadProcessMemory(
  2645. hCurrentProcess,
  2646. dwAddr,
  2647. blockGenObject,
  2648. sizeof(CGenObject),
  2649. &dwReturnedCount
  2650. );
  2651. if (fError == FALSE)
  2652. {
  2653. dprintf("Could not read debuggee's process memory GenObject");
  2654. dprintf("at address %x\n", dwAddr);
  2655. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  2656. goto errRtn;
  2657. }
  2658. if (dwReturnedCount != sizeof(CGenObject))
  2659. {
  2660. dprintf("Size of process memory read != requested\n");
  2661. goto errRtn;
  2662. }
  2663. pGenObject = (CGenObject *)blockGenObject;
  2664. // dump the structure
  2665. pszGenObject = DumpCGenObject(pGenObject, NO_PREFIX, 1);
  2666. dprintf("CGenObject @ 0x%x\n", dwAddr);
  2667. dprintfx(pszGenObject);
  2668. CoTaskMemFree(pszGenObject);
  2669. errRtn:
  2670. delete[] blockGenObject;
  2671. return;
  2672. }
  2673. //+-------------------------------------------------------------------------
  2674. //
  2675. // Function: dump_membytes, exported
  2676. //
  2677. // Synopsis: dumps CMemBytes object
  2678. //
  2679. // Effects:
  2680. //
  2681. // Arguments: see DECLARE_API in oleexts.h
  2682. //
  2683. // Requires:
  2684. //
  2685. // Returns: void
  2686. //
  2687. // Signals:
  2688. //
  2689. // Modifies: ExtensionApis (global)
  2690. //
  2691. // Algorithm:
  2692. //
  2693. // History: dd-mmm-yy Author Comment
  2694. // 02-Feb-95 t-ScottH author
  2695. //
  2696. // Notes:
  2697. // The address of the object is passed in the arguments. This
  2698. // address is in the debuggee's process memory. In order for
  2699. // NTSD to view this memory, the debugger must copy the mem
  2700. // using the WIN32 ReadProcessMemory API.
  2701. //
  2702. //--------------------------------------------------------------------------
  2703. DECLARE_API(dump_membytes)
  2704. {
  2705. BOOL fError;
  2706. LPVOID dwAddr;
  2707. DWORD dwReturnedCount;
  2708. char *pszMB;
  2709. char *blockMB = NULL;
  2710. CMemBytes *pMB = NULL;
  2711. char *blockMEMSTM = NULL;
  2712. // set up global function pointers
  2713. ExtensionApis = *lpExtensionApis;
  2714. // get address of object from argument string
  2715. dwAddr = (LPVOID)GetExpression( args );
  2716. if (dwAddr == 0)
  2717. {
  2718. dprintf("Failed to get Address of CMemBytes\n");
  2719. return;
  2720. }
  2721. // read the block of memory from the debugee's process
  2722. blockMB = new char[sizeof(CMemBytes)];
  2723. fError = ReadProcessMemory(
  2724. hCurrentProcess,
  2725. dwAddr,
  2726. blockMB,
  2727. sizeof(CMemBytes),
  2728. &dwReturnedCount
  2729. );
  2730. if (fError == FALSE)
  2731. {
  2732. dprintf("Could not read debuggee's process memory: CMemBytes \n");
  2733. dprintf("at address %x\n", dwAddr);
  2734. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2735. goto errRtn;
  2736. }
  2737. if (dwReturnedCount != sizeof(CMemBytes))
  2738. {
  2739. dprintf("Size of process memory read != requested(CMemBytes)\n");
  2740. goto errRtn;
  2741. }
  2742. pMB = (CMemBytes *)blockMB;
  2743. // copy the MEMSTM structure
  2744. if (pMB->m_pData != NULL)
  2745. {
  2746. blockMEMSTM = new char[sizeof(MEMSTM)];
  2747. fError = ReadProcessMemory(
  2748. hCurrentProcess,
  2749. pMB->m_pData,
  2750. blockMEMSTM,
  2751. sizeof(MEMSTM),
  2752. &dwReturnedCount
  2753. );
  2754. if (fError == FALSE)
  2755. {
  2756. dprintf("Could not read debuggee's process memory: MEMSTM \n");
  2757. dprintf("at address %x\n", pMB->m_pData);
  2758. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2759. goto errRtn;
  2760. }
  2761. if (dwReturnedCount != sizeof(MEMSTM))
  2762. {
  2763. dprintf("Size of process memory read != requested(MEMSTM)\n");
  2764. goto errRtn;
  2765. }
  2766. pMB->m_pData = (MEMSTM *)blockMEMSTM;
  2767. }
  2768. // dump the structure
  2769. pszMB = DumpCMemBytes(pMB, NO_PREFIX, 1);
  2770. dprintf("CMemBytes @ 0x%x\n", dwAddr);
  2771. dprintfx(pszMB);
  2772. CoTaskMemFree(pszMB);
  2773. errRtn:
  2774. // delete the blocks and not the pointers
  2775. delete[] blockMB;
  2776. delete[] blockMEMSTM;
  2777. return;
  2778. }
  2779. //+-------------------------------------------------------------------------
  2780. //
  2781. // Function: dump_cmemstm, exported
  2782. //
  2783. // Synopsis: dumps CMemStm object
  2784. //
  2785. // Effects:
  2786. //
  2787. // Arguments: see DECLARE_API in oleexts.h
  2788. //
  2789. // Requires:
  2790. //
  2791. // Returns: void
  2792. //
  2793. // Signals:
  2794. //
  2795. // Modifies: ExtensionApis (global)
  2796. //
  2797. // Algorithm:
  2798. //
  2799. // History: dd-mmm-yy Author Comment
  2800. // 02-Feb-95 t-ScottH author
  2801. //
  2802. // Notes:
  2803. // The address of the object is passed in the arguments. This
  2804. // address is in the debuggee's process memory. In order for
  2805. // NTSD to view this memory, the debugger must copy the mem
  2806. // using the WIN32 ReadProcessMemory API.
  2807. //
  2808. //--------------------------------------------------------------------------
  2809. DECLARE_API(dump_cmemstm)
  2810. {
  2811. BOOL fError;
  2812. LPVOID dwAddr;
  2813. DWORD dwReturnedCount;
  2814. char *pszMS;
  2815. char *blockMS = NULL;
  2816. CMemStm *pMS = NULL;
  2817. char *blockMEMSTM = NULL;
  2818. // set up global function pointers
  2819. ExtensionApis = *lpExtensionApis;
  2820. // get address of object from argument string
  2821. dwAddr = (LPVOID)GetExpression( args );
  2822. if (dwAddr == 0)
  2823. {
  2824. dprintf("Failed to get Address of CMemStm\n");
  2825. return;
  2826. }
  2827. // read the block of memory from the debugee's process
  2828. blockMS = new char[sizeof(CMemStm)];
  2829. fError = ReadProcessMemory(
  2830. hCurrentProcess,
  2831. dwAddr,
  2832. blockMS,
  2833. sizeof(CMemStm),
  2834. &dwReturnedCount
  2835. );
  2836. if (fError == FALSE)
  2837. {
  2838. dprintf("Could not read debuggee's process memory: CMemStm \n");
  2839. dprintf("at address %x\n", dwAddr);
  2840. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2841. goto errRtn;
  2842. }
  2843. if (dwReturnedCount != sizeof(CMemStm))
  2844. {
  2845. dprintf("Size of process memory read != requested(CMemStm)\n");
  2846. goto errRtn;
  2847. }
  2848. pMS = (CMemStm *)blockMS;
  2849. // copy the MEMSTM structure
  2850. if (pMS->m_pData != NULL)
  2851. {
  2852. blockMEMSTM = new char[sizeof(MEMSTM)];
  2853. fError = ReadProcessMemory(
  2854. hCurrentProcess,
  2855. pMS->m_pData,
  2856. blockMEMSTM,
  2857. sizeof(MEMSTM),
  2858. &dwReturnedCount
  2859. );
  2860. if (fError == FALSE)
  2861. {
  2862. dprintf("Could not read debuggee's process memory: MEMSTM \n");
  2863. dprintf("at address %x\n", pMS->m_pData);
  2864. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  2865. goto errRtn;
  2866. }
  2867. if (dwReturnedCount != sizeof(MEMSTM))
  2868. {
  2869. dprintf("Size of process memory read != requested(MEMSTM)\n");
  2870. goto errRtn;
  2871. }
  2872. pMS->m_pData = (MEMSTM *)blockMEMSTM;
  2873. }
  2874. // dump the structure
  2875. pszMS = DumpCMemStm(pMS, NO_PREFIX, 1);
  2876. dprintf("CMemStm @ 0x%x\n", dwAddr);
  2877. dprintfx(pszMS);
  2878. CoTaskMemFree(pszMS);
  2879. errRtn:
  2880. // delete the blocks and not the pointers
  2881. delete[] blockMS;
  2882. delete[] blockMEMSTM;
  2883. return;
  2884. }
  2885. //+-------------------------------------------------------------------------
  2886. //
  2887. // Function: dump_mfobject, exported
  2888. //
  2889. // Synopsis: dumps CMfObject object
  2890. //
  2891. // Effects:
  2892. //
  2893. // Arguments: see DECLARE_API in oleexts.h
  2894. //
  2895. // Requires:
  2896. //
  2897. // Returns: void
  2898. //
  2899. // Signals:
  2900. //
  2901. // Modifies: ExtensionApis (global)
  2902. //
  2903. // Algorithm:
  2904. //
  2905. // History: dd-mmm-yy Author Comment
  2906. // 02-Feb-95 t-ScottH author
  2907. //
  2908. // Notes:
  2909. // The address of the object is passed in the arguments. This
  2910. // address is in the debuggee's process memory. In order for
  2911. // NTSD to view this memory, the debugger must copy the mem
  2912. // using the WIN32 ReadProcessMemory API.
  2913. //
  2914. //--------------------------------------------------------------------------
  2915. DECLARE_API(dump_mfobject)
  2916. {
  2917. BOOL fError;
  2918. LPVOID dwAddr;
  2919. DWORD dwReturnedCount;
  2920. char *pszMfObject;
  2921. char *blockMfObject = NULL;
  2922. CMfObject *pMfObject = NULL;
  2923. // set up global function pointers
  2924. ExtensionApis = *lpExtensionApis;
  2925. // get address of object from argument string
  2926. dwAddr = (LPVOID)GetExpression( args );
  2927. if (dwAddr == 0)
  2928. {
  2929. dprintf("Failed to get Address of CMfObject\n");
  2930. return;
  2931. }
  2932. // read the block of memory from the debugee's process
  2933. blockMfObject = new char[sizeof(CMfObject)];
  2934. fError = ReadProcessMemory(
  2935. hCurrentProcess,
  2936. dwAddr,
  2937. blockMfObject,
  2938. sizeof(CMfObject),
  2939. &dwReturnedCount
  2940. );
  2941. if (fError == FALSE)
  2942. {
  2943. dprintf("Could not read debuggee's process memory MfObject");
  2944. dprintf("at address %x\n", dwAddr);
  2945. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  2946. goto errRtn;
  2947. }
  2948. if (dwReturnedCount != sizeof(CMfObject))
  2949. {
  2950. dprintf("Size of process memory read != requested\n");
  2951. goto errRtn;
  2952. }
  2953. pMfObject = (CMfObject *)blockMfObject;
  2954. // dump the structure
  2955. pszMfObject = DumpCMfObject(pMfObject, NO_PREFIX, 1);
  2956. dprintf("CMfObject @ 0x%x\n", dwAddr);
  2957. dprintfx(pszMfObject);
  2958. CoTaskMemFree(pszMfObject);
  2959. errRtn:
  2960. delete[] blockMfObject;
  2961. return;
  2962. }
  2963. //+-------------------------------------------------------------------------
  2964. //
  2965. // Function: dump_oaholder, exported
  2966. //
  2967. // Synopsis: dumps COAHolder object
  2968. //
  2969. // Effects:
  2970. //
  2971. // Arguments: see DECLARE_API in oleexts.h
  2972. //
  2973. // Requires:
  2974. //
  2975. // Returns: void
  2976. //
  2977. // Signals:
  2978. //
  2979. // Modifies: ExtensionApis (global)
  2980. //
  2981. // Algorithm:
  2982. //
  2983. // History: dd-mmm-yy Author Comment
  2984. // 02-Feb-95 t-ScottH author
  2985. //
  2986. // Notes:
  2987. // The address of the object is passed in the arguments. This
  2988. // address is in the debuggee's process memory. In order for
  2989. // NTSD to view this memory, the debugger must copy the mem
  2990. // using the WIN32 ReadProcessMemory API.
  2991. //
  2992. //--------------------------------------------------------------------------
  2993. DECLARE_API(dump_oaholder)
  2994. {
  2995. BOOL fError;
  2996. LPVOID dwAddr;
  2997. DWORD dwReturnedCount;
  2998. char *pszOAH;
  2999. char *blockOAH = NULL;
  3000. char *blockpIAS = NULL;
  3001. COAHolder *pOAH = NULL;
  3002. // set up global function pointers
  3003. ExtensionApis = *lpExtensionApis;
  3004. // get address of object from argument string
  3005. dwAddr = (LPVOID)GetExpression( args );
  3006. if (dwAddr == 0)
  3007. {
  3008. dprintf("Failed to get Address of COAHolder\n");
  3009. return;
  3010. }
  3011. // read the block of memory from the debugee's process
  3012. blockOAH = new char[sizeof(COAHolder)];
  3013. fError = ReadProcessMemory(
  3014. hCurrentProcess,
  3015. dwAddr,
  3016. blockOAH,
  3017. sizeof(COAHolder),
  3018. &dwReturnedCount
  3019. );
  3020. if (fError == FALSE)
  3021. {
  3022. dprintf("Could not read debuggee's process memory: COAHolder \n");
  3023. dprintf("at address %x\n", dwAddr);
  3024. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3025. goto errRtn;
  3026. }
  3027. if (dwReturnedCount != sizeof(COAHolder))
  3028. {
  3029. dprintf("Size of process memory read != requested\n");
  3030. goto errRtn;
  3031. }
  3032. pOAH = (COAHolder *)blockOAH;
  3033. // need to copy the array of IAdviseSink pointers
  3034. if (pOAH->m_iSize > 0)
  3035. {
  3036. blockpIAS = new char[pOAH->m_iSize * sizeof(IAdviseSink *)];
  3037. fError = ReadProcessMemory(
  3038. hCurrentProcess,
  3039. pOAH->m_ppIAS,
  3040. blockpIAS,
  3041. sizeof(IAdviseSink *) * pOAH->m_iSize,
  3042. &dwReturnedCount
  3043. );
  3044. if (fError == FALSE)
  3045. {
  3046. dprintf("Could not read debuggee's process memory: IAdviseSink Array \n");
  3047. dprintf("at address %x\n", pOAH->m_ppIAS);
  3048. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3049. goto errRtn;
  3050. }
  3051. if (dwReturnedCount != (sizeof(IAdviseSink *) * pOAH->m_iSize))
  3052. {
  3053. dprintf("Size of process memory read != requested\n");
  3054. goto errRtn;
  3055. }
  3056. pOAH->m_ppIAS = (IAdviseSink **)blockpIAS;
  3057. }
  3058. // dump the structure
  3059. pszOAH = DumpCOAHolder(pOAH, NO_PREFIX, 1);
  3060. dprintf("COAHolder @ 0x%x\n", dwAddr);
  3061. dprintfx(pszOAH);
  3062. CoTaskMemFree(pszOAH);
  3063. errRtn:
  3064. // delete the blocks and not the pointers
  3065. delete[] blockOAH;
  3066. delete[] blockpIAS;
  3067. return;
  3068. }
  3069. //+-------------------------------------------------------------------------
  3070. //
  3071. // Function: dump_olecache, exported
  3072. //
  3073. // Synopsis: dumps COleCache object
  3074. //
  3075. // Effects:
  3076. //
  3077. // Arguments: see DECLARE_API in oleexts.h
  3078. //
  3079. // Requires:
  3080. //
  3081. // Returns: void
  3082. //
  3083. // Signals:
  3084. //
  3085. // Modifies: ExtensionApis (global)
  3086. //
  3087. // Algorithm:
  3088. //
  3089. // History: dd-mmm-yy Author Comment
  3090. // 02-Feb-95 t-ScottH author
  3091. //
  3092. // Notes:
  3093. // The address of the object is passed in the arguments. This
  3094. // address is in the debuggee's process memory. In order for
  3095. // NTSD to view this memory, the debugger must copy the mem
  3096. // using the WIN32 ReadProcessMemory API.
  3097. //
  3098. //--------------------------------------------------------------------------
  3099. DECLARE_API(dump_olecache)
  3100. {
  3101. unsigned int ui;
  3102. BOOL fError;
  3103. LPVOID dwAddr;
  3104. DWORD dwReturnedCount;
  3105. char *pszOC;
  3106. char *blockOC = NULL;
  3107. COleCache *pOC = NULL;
  3108. char *blockCCacheEnum = NULL;
  3109. char *blockCACHELIST = NULL;
  3110. char *blockCacheNode = NULL;
  3111. char *blockPresObj = NULL;
  3112. DWORD dwSizeOfPresObj;
  3113. // set up global function pointers
  3114. ExtensionApis = *lpExtensionApis;
  3115. // get address of object from argument string
  3116. dwAddr = (LPVOID)GetExpression( args );
  3117. if (dwAddr == 0)
  3118. {
  3119. dprintf("Failed to get Address of COleCache\n");
  3120. return;
  3121. }
  3122. // read the block of memory from the debugee's process
  3123. blockOC = new char[sizeof(COleCache)];
  3124. fError = ReadProcessMemory(
  3125. hCurrentProcess,
  3126. dwAddr,
  3127. blockOC,
  3128. sizeof(COleCache),
  3129. &dwReturnedCount
  3130. );
  3131. if (fError == FALSE)
  3132. {
  3133. dprintf("Could not read debuggee's process memory: COleCache \n");
  3134. dprintf("at address %x\n", dwAddr);
  3135. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3136. goto errRtn;
  3137. }
  3138. if (dwReturnedCount != sizeof(COleCache))
  3139. {
  3140. dprintf("Size of process memory read != requested (COleCache)\n");
  3141. goto errRtn;
  3142. }
  3143. pOC = (COleCache *)blockOC;
  3144. // get block of mem for CCacheEnum (only if m_pCacheEnum != NULL)
  3145. if (pOC->m_pCacheEnum != NULL)
  3146. {
  3147. blockCCacheEnum = new char[sizeof(CCacheEnum)];
  3148. fError = ReadProcessMemory(
  3149. hCurrentProcess,
  3150. pOC->m_pCacheEnum,
  3151. blockCCacheEnum,
  3152. sizeof(CCacheEnum),
  3153. &dwReturnedCount
  3154. );
  3155. if (fError == FALSE)
  3156. {
  3157. dprintf("Could not read debuggee's process memory: CCacheEnum \n");
  3158. dprintf("at address %x\n", pOC->m_pCacheEnum);
  3159. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3160. goto errRtn;
  3161. }
  3162. if (dwReturnedCount != sizeof(CCacheEnum))
  3163. {
  3164. dprintf("Size of process memory read != requested (CCacheEnum)\n");
  3165. goto errRtn;
  3166. }
  3167. pOC->m_pCacheEnum = (CCacheEnum *)blockCCacheEnum;
  3168. }
  3169. // get block of mem for CACHELIST
  3170. if (pOC->m_pCacheList != NULL)
  3171. {
  3172. blockCACHELIST = new char[sizeof(CACHELIST_ITEM) * pOC->m_uCacheNodeMax];
  3173. fError = ReadProcessMemory(
  3174. hCurrentProcess,
  3175. pOC->m_pCacheList,
  3176. blockCACHELIST,
  3177. sizeof(CACHELIST_ITEM) * pOC->m_uCacheNodeMax,
  3178. &dwReturnedCount
  3179. );
  3180. if (fError == FALSE)
  3181. {
  3182. dprintf("Could not read debuggee's process memory: CACHELIST \n");
  3183. dprintf("at address %x\n", pOC->m_pCacheList);
  3184. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3185. goto errRtn;
  3186. }
  3187. if (dwReturnedCount != (sizeof(CACHELIST_ITEM) * pOC->m_uCacheNodeMax))
  3188. {
  3189. dprintf("Size of process memory read != requested\n");
  3190. goto errRtn;
  3191. }
  3192. pOC->m_pCacheList = (LPCACHELIST) blockCACHELIST;
  3193. }
  3194. // need to copy the memory of the CCacheNode's in the CACHELIST
  3195. for (ui = 0; ui < pOC->m_uCacheNodeMax; ui++)
  3196. {
  3197. if (pOC->m_pCacheList[ui].lpCacheNode != NULL)
  3198. {
  3199. blockCacheNode = new char[sizeof(CCacheNode)];
  3200. fError = ReadProcessMemory(
  3201. hCurrentProcess,
  3202. pOC->m_pCacheList[ui].lpCacheNode,
  3203. blockCacheNode,
  3204. sizeof(CCacheNode),
  3205. &dwReturnedCount
  3206. );
  3207. if (fError == FALSE)
  3208. {
  3209. dprintf("Could not read debuggee's process memory: CCacheNode \n");
  3210. dprintf("at address %x\n", pOC->m_pCacheList[ui].lpCacheNode);
  3211. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3212. goto errRtn;
  3213. }
  3214. if (dwReturnedCount != sizeof(CCacheNode))
  3215. {
  3216. dprintf("Size of process memory read != requested (CCacheNode)\n");
  3217. goto errRtn;
  3218. }
  3219. // pass off pointer
  3220. pOC->m_pCacheList[ui].lpCacheNode = (CCacheNode*)blockCacheNode;
  3221. blockCacheNode = NULL;
  3222. // need to get the OlePresObjs for the CCacheNode
  3223. if (pOC->m_pCacheList[ui].lpCacheNode->m_pPresObj != NULL)
  3224. {
  3225. switch (pOC->m_pCacheList[ui].lpCacheNode->m_dwPresFlag)
  3226. {
  3227. case CN_PRESOBJ_GEN:
  3228. dwSizeOfPresObj = sizeof(CGenObject);
  3229. break;
  3230. case CN_PRESOBJ_MF:
  3231. dwSizeOfPresObj = sizeof(CMfObject);
  3232. break;
  3233. case CN_PRESOBJ_EMF:
  3234. dwSizeOfPresObj = sizeof(CEMfObject);
  3235. break;
  3236. default:
  3237. dprintf("Error: can not determine size of IOlePresObj\n");
  3238. return;
  3239. }
  3240. blockPresObj = new char[dwSizeOfPresObj];
  3241. fError = ReadProcessMemory(
  3242. hCurrentProcess,
  3243. pOC->m_pCacheList[ui].lpCacheNode->m_pPresObj,
  3244. blockPresObj,
  3245. dwSizeOfPresObj,
  3246. &dwReturnedCount
  3247. );
  3248. if (fError == FALSE)
  3249. {
  3250. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  3251. dprintf("at address %x\n", pOC->m_pCacheList[ui].lpCacheNode->m_pPresObj);
  3252. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3253. goto errRtn;
  3254. }
  3255. if (dwReturnedCount != dwSizeOfPresObj)
  3256. {
  3257. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  3258. goto errRtn;
  3259. }
  3260. // pass off pointer
  3261. pOC->m_pCacheList[ui].lpCacheNode->m_pPresObj = (IOlePresObj *)blockPresObj;
  3262. blockPresObj = NULL;
  3263. }
  3264. if (pOC->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze != NULL)
  3265. {
  3266. switch (pOC->m_pCacheList[ui].lpCacheNode->m_dwPresFlag)
  3267. {
  3268. case CN_PRESOBJ_GEN:
  3269. dwSizeOfPresObj = sizeof(CGenObject);
  3270. break;
  3271. case CN_PRESOBJ_MF:
  3272. dwSizeOfPresObj = sizeof(CMfObject);
  3273. break;
  3274. case CN_PRESOBJ_EMF:
  3275. dwSizeOfPresObj = sizeof(CEMfObject);
  3276. break;
  3277. default:
  3278. dprintf("Error: can not determine size of IOlePresObj\n");
  3279. return;
  3280. }
  3281. blockPresObj = new char[dwSizeOfPresObj];
  3282. fError = ReadProcessMemory(
  3283. hCurrentProcess,
  3284. pOC->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze,
  3285. blockPresObj,
  3286. dwSizeOfPresObj,
  3287. &dwReturnedCount
  3288. );
  3289. if (fError == FALSE)
  3290. {
  3291. dprintf("Could not read debuggee's process memory: IOlePresObj \n");
  3292. dprintf("at address %x\n", pOC->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze);
  3293. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3294. goto errRtn;
  3295. }
  3296. if (dwReturnedCount != dwSizeOfPresObj)
  3297. {
  3298. dprintf("Size of process memory read != requested (IOlePresObj)\n");
  3299. goto errRtn;
  3300. }
  3301. // pass off pointer
  3302. pOC->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze = (IOlePresObj *)blockPresObj;
  3303. blockPresObj = NULL;
  3304. }
  3305. }
  3306. }
  3307. // dump the structure
  3308. pszOC = DumpCOleCache(pOC, NO_PREFIX, 1);
  3309. dprintf("COleCache @ 0x%x\n", dwAddr);
  3310. dprintfx(pszOC);
  3311. CoTaskMemFree(pszOC);
  3312. errRtn:
  3313. // delete the blocks and not the pointers
  3314. if ( (pOC != NULL) && (blockCACHELIST != NULL))
  3315. {
  3316. for (ui = 0; ui < pOC->m_uCacheNodeMax; ui++)
  3317. {
  3318. if (pOC->m_pCacheList[ui].lpCacheNode != NULL)
  3319. {
  3320. delete[] ((char *)pOC->m_pCacheList[ui].lpCacheNode->m_pPresObj);
  3321. delete[] ((char *)pOC->m_pCacheList[ui].lpCacheNode->m_pPresObjAfterFreeze);
  3322. delete[] ((char *)pOC->m_pCacheList[ui].lpCacheNode);
  3323. }
  3324. }
  3325. }
  3326. delete[] blockCACHELIST;
  3327. delete[] blockCCacheEnum;
  3328. delete[] blockOC;
  3329. return;
  3330. }
  3331. //+-------------------------------------------------------------------------
  3332. //
  3333. // Function: dump_saferefcount, exported
  3334. //
  3335. // Synopsis: dumps CSafeRefCount object
  3336. //
  3337. // Effects:
  3338. //
  3339. // Arguments: see DECLARE_API in oleexts.h
  3340. //
  3341. // Requires:
  3342. //
  3343. // Returns: void
  3344. //
  3345. // Signals:
  3346. //
  3347. // Modifies: ExtensionApis (global)
  3348. //
  3349. // Algorithm:
  3350. //
  3351. // History: dd-mmm-yy Author Comment
  3352. // 02-Feb-95 t-ScottH author
  3353. //
  3354. // Notes:
  3355. // The address of the object is passed in the arguments. This
  3356. // address is in the debuggee's process memory. In order for
  3357. // NTSD to view this memory, the debugger must copy the mem
  3358. // using the WIN32 ReadProcessMemory API.
  3359. //
  3360. //--------------------------------------------------------------------------
  3361. DECLARE_API( dump_saferefcount )
  3362. {
  3363. BOOL fError;
  3364. LPVOID dwAddr;
  3365. DWORD dwReturnedCount;
  3366. char *pszSRC;
  3367. char *blockSRC = NULL;
  3368. CSafeRefCount *pSRC = NULL;
  3369. // set up global function pointers
  3370. ExtensionApis = *lpExtensionApis;
  3371. // get address of object from argument string
  3372. dwAddr = (LPVOID)GetExpression( args );
  3373. if (dwAddr == 0)
  3374. {
  3375. dprintf("Failed to get Address of CSafeRefCount\n");
  3376. return;
  3377. }
  3378. // read the block of memory from the debugee's process
  3379. blockSRC = new char[sizeof(CSafeRefCount)];
  3380. fError = ReadProcessMemory(
  3381. hCurrentProcess,
  3382. dwAddr,
  3383. blockSRC,
  3384. sizeof(CSafeRefCount),
  3385. &dwReturnedCount
  3386. );
  3387. if (fError == FALSE)
  3388. {
  3389. dprintf("Could not read debuggee's process memory \n");
  3390. dprintf("at address %x\n", dwAddr);
  3391. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  3392. goto errRtn;
  3393. }
  3394. if (dwReturnedCount != sizeof(CSafeRefCount))
  3395. {
  3396. dprintf("Size of process memory read != requested\n");
  3397. goto errRtn;
  3398. }
  3399. pSRC = (CSafeRefCount *)blockSRC;
  3400. // dump the structure
  3401. pszSRC = DumpCSafeRefCount(pSRC, NO_PREFIX, 1);
  3402. dprintf("CSafeRefCount @ 0x%x\n", dwAddr);
  3403. dprintfx(pszSRC);
  3404. CoTaskMemFree(pszSRC);
  3405. errRtn:
  3406. delete[] blockSRC;
  3407. return;
  3408. }
  3409. //+-------------------------------------------------------------------------
  3410. //
  3411. // Function: dump_threadcheck, exported
  3412. //
  3413. // Synopsis: dumps CThreadCheck object
  3414. //
  3415. // Effects:
  3416. //
  3417. // Arguments: see DECLARE_API in oleexts.h
  3418. //
  3419. // Requires:
  3420. //
  3421. // Returns: void
  3422. //
  3423. // Signals:
  3424. //
  3425. // Modifies: ExtensionApis (global)
  3426. //
  3427. // Algorithm:
  3428. //
  3429. // History: dd-mmm-yy Author Comment
  3430. // 02-Feb-95 t-ScottH author
  3431. //
  3432. // Notes:
  3433. // The address of the object is passed in the arguments. This
  3434. // address is in the debuggee's process memory. In order for
  3435. // NTSD to view this memory, the debugger must copy the mem
  3436. // using the WIN32 ReadProcessMemory API.
  3437. //
  3438. //--------------------------------------------------------------------------
  3439. DECLARE_API(dump_threadcheck)
  3440. {
  3441. DWORD dwReturnedCount;
  3442. BOOL fError;
  3443. LPVOID dwAddr;
  3444. char *pszTC;
  3445. char *blockTC = NULL;
  3446. CThreadCheck *pTC = NULL;
  3447. // set up global function pointers
  3448. ExtensionApis = *lpExtensionApis;
  3449. // get address of object from argument string
  3450. dwAddr = (LPVOID)GetExpression( args );
  3451. if (dwAddr == 0)
  3452. {
  3453. dprintf("Failed to get Address of CThreadCheck\n");
  3454. return;
  3455. }
  3456. // read the block of memory from the debugee's process
  3457. blockTC = new char[sizeof(CThreadCheck)];
  3458. fError = ReadProcessMemory(
  3459. hCurrentProcess,
  3460. dwAddr,
  3461. blockTC,
  3462. sizeof(CThreadCheck),
  3463. &dwReturnedCount
  3464. );
  3465. if (fError == FALSE)
  3466. {
  3467. dprintf("Could not read debuggee's process memory \n");
  3468. dprintf("at address %x\n", dwAddr);
  3469. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3470. goto errRtn;
  3471. }
  3472. if (dwReturnedCount != sizeof(CThreadCheck))
  3473. {
  3474. dprintf("Size of process memory read != requested\n");
  3475. goto errRtn;
  3476. }
  3477. pTC = (CThreadCheck *)blockTC;
  3478. // dump the structure
  3479. pszTC = DumpCThreadCheck(pTC, NO_PREFIX, 1);
  3480. dprintf("CThreadCheck @ 0x%x\n", dwAddr);
  3481. dprintfx(pszTC);
  3482. CoTaskMemFree(pszTC);
  3483. errRtn:
  3484. delete[] blockTC;
  3485. return;
  3486. }
  3487. //+-------------------------------------------------------------------------
  3488. //
  3489. // Function: dump_formatetc, exported
  3490. //
  3491. // Synopsis: dumps FORMATETC object
  3492. //
  3493. // Effects:
  3494. //
  3495. // Arguments: see DECLARE_API in oleexts.h
  3496. //
  3497. // Requires:
  3498. //
  3499. // Returns: void
  3500. //
  3501. // Signals:
  3502. //
  3503. // Modifies: ExtensionApis (global)
  3504. //
  3505. // Algorithm:
  3506. //
  3507. // History: dd-mmm-yy Author Comment
  3508. // 02-Feb-95 t-ScottH author
  3509. //
  3510. // Notes:
  3511. // The address of the object is passed in the arguments. This
  3512. // address is in the debuggee's process memory. In order for
  3513. // NTSD to view this memory, the debugger must copy the mem
  3514. // using the WIN32 ReadProcessMemory API.
  3515. //
  3516. //--------------------------------------------------------------------------
  3517. DECLARE_API(dump_formatetc)
  3518. {
  3519. BOOL fError;
  3520. LPVOID dwAddr;
  3521. DWORD dwReturnedCount;
  3522. char *pszFE;
  3523. char *blockFE = NULL;
  3524. FORMATETC *pFE = NULL;
  3525. // set up global function pointers
  3526. ExtensionApis = *lpExtensionApis;
  3527. // get address of object from argument string
  3528. dwAddr = (LPVOID)GetExpression( args );
  3529. if (dwAddr == 0)
  3530. {
  3531. dprintf("Failed to get Address of FORMATETC\n");
  3532. return;
  3533. }
  3534. // read the block of memory from the debugee's process
  3535. blockFE = new char[sizeof(FORMATETC)];
  3536. fError = ReadProcessMemory(
  3537. hCurrentProcess,
  3538. dwAddr,
  3539. blockFE,
  3540. sizeof(FORMATETC),
  3541. &dwReturnedCount
  3542. );
  3543. if (fError == FALSE)
  3544. {
  3545. dprintf("Could not read debuggee's process memory: FORMATETC \n");
  3546. dprintf("at address %x\n", dwAddr);
  3547. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3548. goto errRtn;
  3549. }
  3550. if (dwReturnedCount != sizeof(FORMATETC))
  3551. {
  3552. dprintf("Size of process memory read != requested\n");
  3553. goto errRtn;
  3554. }
  3555. pFE = (FORMATETC *)blockFE;
  3556. // dump the structure
  3557. pszFE = DumpFORMATETC(pFE, NO_PREFIX, 1);
  3558. dprintf("FORMATETC @ 0x%x\n", dwAddr);
  3559. dprintfx(pszFE);
  3560. CoTaskMemFree(pszFE);
  3561. errRtn:
  3562. // delete the blocks and not the pointers
  3563. delete[] blockFE;
  3564. return;
  3565. }
  3566. //+-------------------------------------------------------------------------
  3567. //
  3568. // Function: dump_memstm, exported
  3569. //
  3570. // Synopsis: dumps MEMSTM object
  3571. //
  3572. // Effects:
  3573. //
  3574. // Arguments: see DECLARE_API in oleexts.h
  3575. //
  3576. // Requires:
  3577. //
  3578. // Returns: void
  3579. //
  3580. // Signals:
  3581. //
  3582. // Modifies: ExtensionApis (global)
  3583. //
  3584. // Algorithm:
  3585. //
  3586. // History: dd-mmm-yy Author Comment
  3587. // 02-Feb-95 t-ScottH author
  3588. //
  3589. // Notes:
  3590. // The address of the object is passed in the arguments. This
  3591. // address is in the debuggee's process memory. In order for
  3592. // NTSD to view this memory, the debugger must copy the mem
  3593. // using the WIN32 ReadProcessMemory API.
  3594. //
  3595. //--------------------------------------------------------------------------
  3596. DECLARE_API(dump_memstm)
  3597. {
  3598. BOOL fError;
  3599. LPVOID dwAddr;
  3600. DWORD dwReturnedCount;
  3601. char *pszMS;
  3602. char *blockMS = NULL;
  3603. MEMSTM *pMS = NULL;
  3604. // set up global function pointers
  3605. ExtensionApis = *lpExtensionApis;
  3606. // get address of object from argument string
  3607. dwAddr = (LPVOID)GetExpression( args );
  3608. if (dwAddr == 0)
  3609. {
  3610. dprintf("Failed to get Address of MEMSTM\n");
  3611. return;
  3612. }
  3613. // read the block of memory from the debugee's process
  3614. blockMS = new char[sizeof(MEMSTM)];
  3615. fError = ReadProcessMemory(
  3616. hCurrentProcess,
  3617. dwAddr,
  3618. blockMS,
  3619. sizeof(MEMSTM),
  3620. &dwReturnedCount
  3621. );
  3622. if (fError == FALSE)
  3623. {
  3624. dprintf("Could not read debuggee's process memory: MEMSTM \n");
  3625. dprintf("at address %x\n", dwAddr);
  3626. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3627. goto errRtn;
  3628. }
  3629. if (dwReturnedCount != sizeof(MEMSTM))
  3630. {
  3631. dprintf("Size of process memory read != requested\n");
  3632. goto errRtn;
  3633. }
  3634. pMS = (MEMSTM *)blockMS;
  3635. // dump the structure
  3636. pszMS = DumpMEMSTM(pMS, NO_PREFIX, 1);
  3637. dprintf("MEMSTM @ 0x%x\n", dwAddr);
  3638. dprintfx(pszMS);
  3639. CoTaskMemFree(pszMS);
  3640. errRtn:
  3641. // delete the blocks and not the pointers
  3642. delete[] blockMS;
  3643. return;
  3644. }
  3645. //+-------------------------------------------------------------------------
  3646. //
  3647. // Function: dump_statdata, exported
  3648. //
  3649. // Synopsis: dumps STATDATA object
  3650. //
  3651. // Effects:
  3652. //
  3653. // Arguments: see DECLARE_API in oleexts.h
  3654. //
  3655. // Requires:
  3656. //
  3657. // Returns: void
  3658. //
  3659. // Signals:
  3660. //
  3661. // Modifies: ExtensionApis (global)
  3662. //
  3663. // Algorithm:
  3664. //
  3665. // History: dd-mmm-yy Author Comment
  3666. // 02-Feb-95 t-ScottH author
  3667. //
  3668. // Notes:
  3669. // The address of the object is passed in the arguments. This
  3670. // address is in the debuggee's process memory. In order for
  3671. // NTSD to view this memory, the debugger must copy the mem
  3672. // using the WIN32 ReadProcessMemory API.
  3673. //
  3674. //--------------------------------------------------------------------------
  3675. DECLARE_API(dump_statdata)
  3676. {
  3677. BOOL fError;
  3678. LPVOID dwAddr;
  3679. DWORD dwReturnedCount;
  3680. char *pszSD;
  3681. char *blockSD = NULL;
  3682. STATDATA *pSD = NULL;
  3683. // set up global function pointers
  3684. ExtensionApis = *lpExtensionApis;
  3685. // get address of object from argument string
  3686. dwAddr = (LPVOID)GetExpression( args );
  3687. if (dwAddr == 0)
  3688. {
  3689. dprintf("Failed to get Address of STATDATA\n");
  3690. return;
  3691. }
  3692. // read the block of memory from the debugee's process
  3693. blockSD = new char[sizeof(STATDATA)];
  3694. fError = ReadProcessMemory(
  3695. hCurrentProcess,
  3696. dwAddr,
  3697. blockSD,
  3698. sizeof(STATDATA),
  3699. &dwReturnedCount
  3700. );
  3701. if (fError == FALSE)
  3702. {
  3703. dprintf("Could not read debuggee's process memory: STATDATA \n");
  3704. dprintf("at address %x\n", dwAddr);
  3705. dprintf("Last Error Code = %d (0x%x)\n", GetLastError(), GetLastError());
  3706. goto errRtn;
  3707. }
  3708. if (dwReturnedCount != sizeof(STATDATA))
  3709. {
  3710. dprintf("Size of process memory read != requested\n");
  3711. goto errRtn;
  3712. }
  3713. pSD = (STATDATA *)blockSD;
  3714. // dump the structure
  3715. pszSD = DumpSTATDATA(pSD, NO_PREFIX, 1);
  3716. dprintf("STATDATA @ 0x%x\n", dwAddr);
  3717. dprintfx(pszSD);
  3718. CoTaskMemFree(pszSD);
  3719. errRtn:
  3720. // delete the blocks and not the pointers
  3721. delete[] blockSD;
  3722. return;
  3723. }
  3724. //+-------------------------------------------------------------------------
  3725. //
  3726. // Function: dump_stgmedium, exported
  3727. //
  3728. // Synopsis: dumps STGMEDIUM object
  3729. //
  3730. // Effects:
  3731. //
  3732. // Arguments: see DECLARE_API in oleexts.h
  3733. //
  3734. // Requires:
  3735. //
  3736. // Returns: void
  3737. //
  3738. // Signals:
  3739. //
  3740. // Modifies: ExtensionApis (global)
  3741. //
  3742. // Algorithm:
  3743. //
  3744. // History: dd-mmm-yy Author Comment
  3745. // 02-Feb-95 t-ScottH author
  3746. //
  3747. // Notes:
  3748. // The address of the object is passed in the arguments. This
  3749. // address is in the debuggee's process memory. In order for
  3750. // NTSD to view this memory, the debugger must copy the mem
  3751. // using the WIN32 ReadProcessMemory API.
  3752. //
  3753. //--------------------------------------------------------------------------
  3754. DECLARE_API(dump_stgmedium)
  3755. {
  3756. BOOL fError;
  3757. LPVOID dwAddr;
  3758. DWORD dwReturnedCount;
  3759. char *pszSTGMEDIUM;
  3760. char *blockSTGMEDIUM = NULL;
  3761. STGMEDIUM *pSTGMEDIUM = NULL;
  3762. // set up global function pointers
  3763. ExtensionApis = *lpExtensionApis;
  3764. // get address of object from argument string
  3765. dwAddr = (LPVOID)GetExpression( args );
  3766. if (dwAddr == 0)
  3767. {
  3768. dprintf("Failed to get Address of STGMEDIUM\n");
  3769. return;
  3770. }
  3771. // read the block of memory from the debugee's process
  3772. blockSTGMEDIUM = new char[sizeof(STGMEDIUM)];
  3773. fError = ReadProcessMemory(
  3774. hCurrentProcess,
  3775. dwAddr,
  3776. blockSTGMEDIUM,
  3777. sizeof(STGMEDIUM),
  3778. &dwReturnedCount
  3779. );
  3780. if (fError == FALSE)
  3781. {
  3782. dprintf("Could not read debuggee's process memory STGMEDIUM");
  3783. dprintf("at address %x\n", dwAddr);
  3784. dprintf("Last Error Code = %d (%x)\n", GetLastError(), GetLastError());
  3785. goto errRtn;
  3786. }
  3787. if (dwReturnedCount != sizeof(STGMEDIUM))
  3788. {
  3789. dprintf("Size of process memory read != requested\n");
  3790. goto errRtn;
  3791. }
  3792. pSTGMEDIUM = (STGMEDIUM *)blockSTGMEDIUM;
  3793. // dump the structure
  3794. pszSTGMEDIUM = DumpSTGMEDIUM(pSTGMEDIUM, NO_PREFIX, 1);
  3795. dprintf("STGMEDIUM @ 0x%x\n", dwAddr);
  3796. dprintfx(pszSTGMEDIUM);
  3797. CoTaskMemFree(pszSTGMEDIUM);
  3798. errRtn:
  3799. delete[] blockSTGMEDIUM;
  3800. return;
  3801. }