Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1360 lines
38 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: oletype.cxx
  7. //
  8. // Contents: individual methods for priting OLE types
  9. //
  10. // Functions: see oleprint.hxx
  11. //
  12. // History: 11-Jul-95 t-stevan Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <windows.h>
  16. #include <ole2sp.h>
  17. #include <ole2com.h>
  18. #if DBG==1
  19. #include "oleprint.hxx"
  20. #include "sym.hxx"
  21. // temporary string buffer size
  22. #define TEMP_SIZE 64
  23. // our constant strings
  24. const char *pscNullString = "<NULL>";
  25. const char *pscTrue = "true";
  26. const char *pscTRUE = "TRUE";
  27. const char *pscFalse = "false";
  28. const char *pscFALSE = "FALSE";
  29. const char *pscHexPrefix = "0x";
  30. const char *pscPointerPrefix = "<";
  31. const char *pscBadPointerPrefix = "BAD PTR : ";
  32. const char *pscPointerSuffix = ">";
  33. const char *pscStructPrefix = "{ ";
  34. const char *pscStructDelim = " , ";
  35. const char *pscStructSuffix = " }";
  36. // These functions are in com\util\guid2str.c
  37. extern "C" void FormatHexNum( unsigned long ulValue, unsigned long chChars, char *pchStr);
  38. extern "C" int StrFromGUID(REFGUID rguid, char * lpsz, int cbMax);
  39. // *** Global Data ***
  40. CSym *g_pSym = NULL; // manage symbol stuff
  41. //+---------------------------------------------------------------------------
  42. //
  43. // Function: FormatHex
  44. //
  45. // Synopsis: Wrapper around FormatHexNum to control if leading zeros are printed
  46. //
  47. // Arguments: [ulValue] - DWORD value to print out
  48. // [chChars] - number of characters to print out, starting from right of number
  49. // [fLeadZeros] - whether or not to print leading zeros
  50. // [pchStr] - pointer of string to put printed out value, must have room for
  51. // chChars+1 chars (chChars digits and null byte)
  52. //
  53. // Returns: nothing
  54. //
  55. // History: 15-Jul-95 t-stevan Created
  56. //
  57. //----------------------------------------------------------------------------
  58. void FormatHex(unsigned long ulValue, unsigned long chChars, BOOL fLeadZeros, char *pchStr)
  59. {
  60. if(!fLeadZeros)
  61. {
  62. unsigned long ulmask = 0xf<<((chChars-1)<<4);
  63. // determine how many leading zeros there are
  64. while(!(ulValue & ulmask) && (chChars > 1))
  65. {
  66. chChars--;
  67. ulmask >>=4;
  68. }
  69. FormatHexNum(ulValue, chChars, pchStr);
  70. // tag on null byte
  71. pchStr[chChars] = '\0';
  72. }
  73. else
  74. {
  75. FormatHexNum(ulValue, chChars, pchStr);
  76. // tag on null byte
  77. pchStr[chChars] = '\0';
  78. }
  79. }
  80. //+---------------------------------------------------------------------------
  81. //
  82. // Function: IntToString
  83. //
  84. // Synopsis: Prints out a integer to a string (base 10)
  85. //
  86. // Arguments: [n] - integer to print out
  87. // [pStr] - pointer of string to put printed out value
  88. // [nMax] - maximum number of characters
  89. // [fUnsigned] - whether or not value is unsigned
  90. //
  91. // Returns: pStr
  92. //
  93. // History: 15-Jul-95 t-stevan Created
  94. //
  95. // NOtes: nMax should be enough to hold the printed out string
  96. //----------------------------------------------------------------------------
  97. char *IntToString(unsigned long n, char *pStr, int nMax, BOOL fUnsigned)
  98. {
  99. char *pChar;
  100. BOOL fSign= FALSE;
  101. int nCount;
  102. // Special case, n = 0
  103. if(n == 0)
  104. {
  105. *pStr = '0';
  106. *(pStr+1) = '\0';
  107. return pStr;
  108. }
  109. if(!fUnsigned)
  110. {
  111. // if the value is signed, figure out what the sign of it is, and
  112. // then take absolute value
  113. if((fSign = ((int) n) < 0))
  114. {
  115. n = -((int)n);
  116. }
  117. }
  118. // initialize pChar to point to the last character in pStr
  119. pChar = &(pStr[nMax-1]);
  120. // tag on null byte
  121. *pChar = '\0';
  122. pChar--;
  123. // null byte counts!
  124. nCount=1;
  125. // loop until n == 0
  126. while(n && nCount <= nMax)
  127. {
  128. // write digit
  129. *pChar = '0'+(char)(n%10);
  130. // move to next digit
  131. pChar--;
  132. // increase digit count
  133. nCount++;
  134. // divide n by 10
  135. n/=10;
  136. }
  137. if(nCount > nMax)
  138. {
  139. return pStr; // we failed, but still return pStr
  140. }
  141. if(fSign)
  142. {
  143. *pStr = '-'; // tag on sign
  144. memmove(pStr+1, pChar+1, nCount); // move string to front
  145. }
  146. else
  147. {
  148. memmove(pStr, pChar+1, nCount); // move string to front
  149. }
  150. return pStr;
  151. }
  152. //+---------------------------------------------------------------------------
  153. //
  154. // Function: WriteIntCommon
  155. //
  156. // Synopsis: Common functionality for printing out integer values
  157. //
  158. // Arguments: [buf] - text buffer to print text to
  159. // [param] - integer to print
  160. // [fUnsigned] - whether or not value is unsigned
  161. //
  162. // Returns: nothing
  163. //
  164. // History: 15-Jul-95 t-stevan Created
  165. //
  166. //----------------------------------------------------------------------------
  167. void WriteIntCommon(CTextBufferA &buf, unsigned int param, BOOL fUnsigned)
  168. {
  169. char temp[TEMP_SIZE];
  170. IntToString(param, temp, TEMP_SIZE, fUnsigned);
  171. // _ltoa((int) param, temp, 10);
  172. // do write op
  173. buf << temp;
  174. }
  175. //+---------------------------------------------------------------------------
  176. //
  177. // Function: WritePointerCommon
  178. //
  179. // Synopsis: Common functionality for printing pointers
  180. //
  181. // Arguments: [buf] - text buffer to print text to
  182. // [pPointer] - pointer to print out
  183. // [fCaps] - whether or not to use capitalized hex digits (ABCDEF)
  184. // [fKnownBad] - whether or not the pointer is known to be bad
  185. // [fXlatSym] - whether or not we should attempt to address->symbol
  186. //
  187. // Returns: nothing
  188. //
  189. // History: 15-Jul-95 t-stevan Created
  190. //
  191. //----------------------------------------------------------------------------
  192. void WritePointerCommon(CTextBufferA &buf, void *pPointer, BOOL fCaps, BOOL fKnownBad, BOOL fXlatSym)
  193. {
  194. char temp[TEMP_SIZE];
  195. if(pPointer == NULL)
  196. {
  197. buf << pscNullString;
  198. return;
  199. }
  200. if(fKnownBad)
  201. {
  202. // we know it's a bad pointer
  203. buf << pscPointerPrefix;
  204. buf << pscBadPointerPrefix;
  205. }
  206. else
  207. {
  208. buf << pscPointerPrefix;
  209. // validate pointer
  210. __try
  211. {
  212. // try a read operation
  213. temp[0] = *((char *)pPointer);
  214. }
  215. __except (ExceptionFilter(_exception_code()))
  216. {
  217. // bad pointer
  218. buf << pscBadPointerPrefix;
  219. fKnownBad = TRUE;
  220. }
  221. }
  222. if(!fKnownBad && fXlatSym)
  223. {
  224. // see if we can find a symbol for the pointer
  225. char symbol[MAXNAMELENGTH];
  226. DWORD64 dwDisplacement;
  227. if(g_pSym != NULL)
  228. {
  229. if (g_pSym->GetSymNameFromAddr((DWORD64) pPointer, &dwDisplacement, symbol, MAXNAMELENGTH))
  230. {
  231. // found a symbol. Woo hoo!
  232. WriteStringCommon(buf, symbol);
  233. if(dwDisplacement != 0)
  234. {
  235. buf << '+';
  236. buf << pscHexPrefix;
  237. // no leading zeros
  238. FormatHex((unsigned long) dwDisplacement, 8, FALSE, temp);
  239. buf << temp;
  240. }
  241. buf << pscPointerSuffix;
  242. return;
  243. }
  244. }
  245. }
  246. // add the hex prefix
  247. buf << pscHexPrefix;
  248. FormatHex((unsigned long) (ULONG_PTR) pPointer, 8, TRUE, temp);
  249. if(fCaps)
  250. {
  251. CharUpperBuffA (temp, lstrlenA (temp));
  252. }
  253. else
  254. {
  255. CharLowerBuffA (temp, lstrlenA (temp));
  256. }
  257. // do write op
  258. buf << temp;
  259. // write suffix
  260. buf << pscPointerSuffix;
  261. }
  262. //+---------------------------------------------------------------------------
  263. //
  264. // Function: WriteLargeCommon
  265. //
  266. // Synopsis: Common functionality for printing out a 64-bitinteger values
  267. //
  268. // Arguments: [buf] - text buffer to print text to
  269. // [param] - integer to print
  270. // [fUnsigned] - whether or not value is unsigned (currently ignored)
  271. //
  272. // Returns: nothing
  273. //
  274. // History: 15-Jul-95 t-stevan Created
  275. //
  276. // Note: currently 64-bit integers are printed out as unsigned hex numbers
  277. //----------------------------------------------------------------------------
  278. void WriteLargeCommon(CTextBufferA &buf, const __int64 *pInt, BOOL fUnsigned)
  279. {
  280. char temp[TEMP_SIZE];
  281. __try // catch bad pointers
  282. {
  283. // right now we ignore the fUnsigned parameter and print out
  284. // as an unsigned hex integer
  285. FormatHex((unsigned long) ((*pInt)>>32), 8, FALSE, temp);
  286. buf << pscHexPrefix;
  287. buf << temp;
  288. FormatHex((unsigned long) ((*pInt)&0xffffffff), 8, TRUE, temp);
  289. buf << temp;
  290. }
  291. __except (ExceptionFilter(_exception_code()))
  292. {
  293. // bad pointer, just print out the pointer passed
  294. WritePointerCommon(buf, (void *) pInt, FALSE, TRUE, FALSE);
  295. }
  296. }
  297. //+---------------------------------------------------------------------------
  298. //
  299. // Function: WriteHexCommon
  300. //
  301. // Synopsis: Common functionality for printing out hex integer values
  302. //
  303. // Arguments: [buf] - text buffer to print text to
  304. // [param] - integer to print
  305. // [fCaps] - whether or not to print capital hex digits (ABCDEF)
  306. //
  307. // Returns: nothing
  308. //
  309. // History: 15-Jul-95 t-stevan Created
  310. //
  311. //----------------------------------------------------------------------------
  312. void WriteHexCommon(CTextBufferA &buf, ULONG param, BOOL fCaps)
  313. {
  314. char temp[TEMP_SIZE];
  315. buf << pscHexPrefix;
  316. // write out number
  317. FormatHex((unsigned long) param, 8, TRUE, temp);
  318. if(fCaps)
  319. {
  320. CharUpperBuffA (temp, lstrlenA (temp));
  321. }
  322. else
  323. {
  324. CharLowerBuffA (temp, lstrlenA (temp));
  325. }
  326. // do write op
  327. buf << temp;
  328. }
  329. //+---------------------------------------------------------------------------
  330. //
  331. // Function: WriteBoolCommon
  332. //
  333. // Synopsis: Common functionality for printing out boolean values
  334. //
  335. // Arguments: [buf] - text buffer to print text to
  336. // [param] - integer to print
  337. // [fCaps] - whether or not to print capital characters
  338. //
  339. // Returns: nothing
  340. //
  341. // History: 15-Jul-95 t-stevan Created
  342. //
  343. //----------------------------------------------------------------------------
  344. void WriteBoolCommon(CTextBufferA &buf, BOOL param, BOOL fCaps)
  345. {
  346. const char *pTrue, *pFalse;
  347. if(fCaps)
  348. {
  349. pTrue = pscTRUE;
  350. pFalse = pscFALSE;
  351. }
  352. else
  353. {
  354. pTrue = pscTrue;
  355. pFalse = pscFalse;
  356. }
  357. if(param)
  358. {
  359. buf << pTrue;
  360. }
  361. else
  362. {
  363. buf << pFalse;
  364. }
  365. }
  366. //+---------------------------------------------------------------------------
  367. //
  368. // Function: WriteStringCommon
  369. //
  370. // Synopsis: Common functionality for printing out ASCII strings
  371. //
  372. // Arguments: [buf] - text buffer to print text to
  373. // [pString] - pointer to ASCII string
  374. // [fQuote] - whether or not to enclose the string in quotes
  375. //
  376. // Returns: nothing
  377. //
  378. // History: 15-Jul-95 t-stevan Created
  379. //
  380. //----------------------------------------------------------------------------
  381. void WriteStringCommon(CTextBufferA &buf, const char *pString, BOOL fQuote)
  382. {
  383. BufferContext bc;
  384. // take a snapshot of the buffer first
  385. buf.SnapShot(bc);
  386. __try
  387. {
  388. if(fQuote)
  389. {
  390. buf << '\"';
  391. }
  392. buf << pString;
  393. if(fQuote)
  394. {
  395. buf << '\"';
  396. }
  397. }
  398. __except (ExceptionFilter(_exception_code()))
  399. {
  400. // bad pointer
  401. // first try to rever the buffer
  402. buf.Revert(bc);
  403. WritePointerCommon(buf, (void *) pString, FALSE, TRUE, FALSE);
  404. }
  405. }
  406. //+---------------------------------------------------------------------------
  407. //
  408. // Function: WriteWideStringCommon
  409. //
  410. // Synopsis: Common functionality for printing out Unicode strings
  411. //
  412. // Arguments: [buf] - text buffer to print text to
  413. // [pwsStr] - pointer to Unicode string
  414. // [fQuote] - whether or not to enclose the string in quotes
  415. //
  416. // Returns: nothing
  417. //
  418. // History: 15-Jul-95 t-stevan Created
  419. //
  420. //----------------------------------------------------------------------------
  421. void WriteWideStringCommon(CTextBufferA& buf, const WCHAR *pwsStr, BOOL fQuote)
  422. {
  423. BufferContext bc;
  424. // take a snapshot of the buffer first
  425. buf.SnapShot(bc);
  426. __try
  427. {
  428. if(fQuote)
  429. {
  430. buf << '\"';
  431. }
  432. while(*pwsStr != 0)
  433. {
  434. if(*pwsStr & 0xff00)
  435. {
  436. // if high byte has info, set to
  437. // 0x13, which is two !'s
  438. buf << (char) 0x13;
  439. }
  440. else
  441. {
  442. buf << (char) (*pwsStr &0xff);
  443. }
  444. pwsStr++;
  445. }
  446. if(fQuote)
  447. {
  448. buf << '\"';
  449. }
  450. }
  451. __except (ExceptionFilter(_exception_code()))
  452. {
  453. // bad pointer
  454. // try to revert the buffer
  455. buf.Revert(bc);
  456. WritePointerCommon(buf, (void *) pwsStr, FALSE, TRUE, FALSE);
  457. }
  458. }
  459. //+---------------------------------------------------------------------------
  460. //
  461. // Function: WriteGUIDCommon
  462. //
  463. // Synopsis: Common functionality for printing out GUIDs
  464. //
  465. // Arguments: [buf] - text buffer to print text to
  466. // [pGUID] - pointer to GUID to print
  467. //
  468. // Returns: nothing
  469. //
  470. // History: 15-Jul-95 t-stevan Created
  471. //
  472. //----------------------------------------------------------------------------
  473. void WriteGUIDCommon(CTextBufferA& buf, const GUID *pGUID)
  474. {
  475. char temp[GUIDSTR_MAX+1];
  476. BufferContext bc;
  477. // take a snapshot of the buffer first
  478. buf.SnapShot(bc);
  479. __try
  480. {
  481. StrFromGUID(*pGUID, temp, GUIDSTR_MAX);
  482. // tack on null byte
  483. temp[GUIDSTR_MAX - 1] = '\0';
  484. // write the string out
  485. buf << temp;
  486. }
  487. __except (ExceptionFilter(_exception_code()))
  488. {
  489. // bad pointer
  490. // try to revert the buffer
  491. buf.Revert(bc);
  492. WritePointerCommon(buf, (void *) pGUID, FALSE, TRUE, FALSE);
  493. }
  494. }
  495. //+---------------------------------------------------------------------------
  496. //
  497. // Function: WriteFILETIME
  498. //
  499. // Synopsis: Prints out a FILETIME structure
  500. //
  501. // Arguments: [buf] - text buffer to print text to
  502. // [pFileTime] - pointer to FILETIME structure
  503. //
  504. // Returns: nothing
  505. //
  506. // History: 15-Jul-95 t-stevan Created
  507. //
  508. //----------------------------------------------------------------------------
  509. void WriteFILETIME(CTextBufferA& buf, FILETIME *pFileTime)
  510. {
  511. SYSTEMTIME sysTime;
  512. buf << pscStructPrefix;
  513. if(FileTimeToSystemTime(pFileTime, &sysTime))
  514. {
  515. char temp[TEMP_SIZE];
  516. IntToString(sysTime.wMonth, temp, TEMP_SIZE, TRUE);
  517. buf << temp;
  518. buf << '/';
  519. IntToString(sysTime.wDay, temp, TEMP_SIZE, TRUE);
  520. buf << temp;
  521. buf << '/';
  522. IntToString(sysTime.wYear, temp, TEMP_SIZE, TRUE);
  523. buf << temp;
  524. buf << ' ';
  525. IntToString(sysTime.wHour, temp, TEMP_SIZE, TRUE);
  526. buf << temp;
  527. buf << ':';
  528. if(sysTime.wMinute == 0)
  529. {
  530. buf << "00";
  531. }
  532. else
  533. {
  534. IntToString(sysTime.wMinute, temp, TEMP_SIZE, TRUE);
  535. buf << temp;
  536. }
  537. }
  538. else
  539. {
  540. buf << "dwLowDateTime= ";
  541. WriteHexCommon(buf, pFileTime->dwLowDateTime, FALSE);
  542. buf << pscStructDelim;
  543. buf << "dwHighDateTime= ";
  544. WriteHexCommon(buf, pFileTime->dwHighDateTime, FALSE);
  545. }
  546. buf << pscStructSuffix;
  547. }
  548. //+---------------------------------------------------------------------------
  549. //
  550. // Function: WriteRECT
  551. //
  552. // Synopsis: Prints out a RECT structure
  553. //
  554. // Arguments: [buf] - text buffer to print text to
  555. // [pRECT] - pointer to RECT structure
  556. //
  557. // Returns: nothing
  558. //
  559. // History: 15-Jul-95 t-stevan Created
  560. //
  561. //----------------------------------------------------------------------------
  562. void WriteRECT(CTextBufferA& buf, RECT *pRect)
  563. {
  564. buf << pscStructPrefix;
  565. buf << "left= ";
  566. WriteIntCommon(buf, pRect->left, FALSE);
  567. buf << pscStructDelim;
  568. buf << "top= ";
  569. WriteIntCommon(buf, pRect->top, FALSE);
  570. buf << pscStructDelim;
  571. buf << "right= ";
  572. WriteIntCommon(buf, pRect->right, FALSE);
  573. buf << pscStructDelim;
  574. buf << "bottom= ";
  575. WriteIntCommon(buf, pRect->bottom, FALSE);
  576. buf << pscStructSuffix;
  577. }
  578. //+---------------------------------------------------------------------------
  579. //
  580. // Function: WriteSIZE
  581. //
  582. // Synopsis: Prints out a SIZE structure
  583. //
  584. // Arguments: [buf] - text buffer to print text to
  585. // [pSIZE] - pointer to SIZE structure
  586. //
  587. // Returns: nothing
  588. //
  589. // History: 15-Jul-95 t-stevan Created
  590. //
  591. //----------------------------------------------------------------------------
  592. void WriteSIZE(CTextBufferA& buf, SIZE *pSize)
  593. {
  594. buf << pscStructPrefix;
  595. buf << "cx= ";
  596. WriteIntCommon(buf, pSize->cx, FALSE);
  597. buf << pscStructDelim;
  598. buf << "cy= ";
  599. WriteIntCommon(buf, pSize->cy, FALSE);
  600. buf << pscStructSuffix;
  601. }
  602. //+---------------------------------------------------------------------------
  603. //
  604. // Function: WriteLOGPALETTE
  605. //
  606. // Synopsis: Prints out a LOGPALETTE structure
  607. //
  608. // Arguments: [buf] - text buffer to print text to
  609. // [pLOGPALETTE] - pointer to LOGPALETTE structure
  610. //
  611. // Returns: nothing
  612. //
  613. // History: 15-Jul-95 t-stevan Created
  614. //
  615. //----------------------------------------------------------------------------
  616. void WriteLOGPALETTE(CTextBufferA& buf, LOGPALETTE *pPal)
  617. {
  618. buf << pscStructPrefix;
  619. buf << "palVersion= ";
  620. WriteHexCommon(buf, pPal->palVersion, TRUE);
  621. buf << pscStructDelim;
  622. buf << "palNumEntries= ";
  623. WriteIntCommon(buf, pPal->palNumEntries, TRUE);
  624. buf << pscStructDelim;
  625. buf << "palPalEntry[]= ";
  626. WritePointerCommon(buf, pPal->palPalEntry, FALSE, FALSE, FALSE);
  627. buf << pscStructSuffix;
  628. }
  629. //+---------------------------------------------------------------------------
  630. //
  631. // Function: WritePOINT
  632. //
  633. // Synopsis: Prints out a POINT structure
  634. //
  635. // Arguments: [buf] - text buffer to print text to
  636. // [pPOINT] - pointer to POINT structure
  637. //
  638. // Returns: nothing
  639. //
  640. // History: 15-Jul-95 t-stevan Created
  641. //
  642. //----------------------------------------------------------------------------
  643. void WritePOINT(CTextBufferA& buf, POINT *pPoint)
  644. {
  645. buf << pscStructPrefix;
  646. buf << "x= ";
  647. WriteIntCommon(buf, pPoint->x, FALSE);
  648. buf << pscStructDelim;
  649. buf << "y= ";
  650. WriteIntCommon(buf, pPoint->y, FALSE);
  651. buf << pscStructSuffix;
  652. }
  653. //+---------------------------------------------------------------------------
  654. //
  655. // Function: WriteMSG
  656. //
  657. // Synopsis: Prints out a MSG structure
  658. //
  659. // Arguments: [buf] - text buffer to print text to
  660. // [pMSG] - pointer to MSG structure
  661. //
  662. // Returns: nothing
  663. //
  664. // History: 15-Jul-95 t-stevan Created
  665. //
  666. //----------------------------------------------------------------------------
  667. void WriteMSG(CTextBufferA& buf, MSG *pMsg)
  668. {
  669. buf << pscStructPrefix;
  670. buf << "hwnd= ";
  671. WriteHexCommon(buf, (ULONG)(ULONG_PTR) pMsg->hwnd, FALSE);
  672. buf << pscStructDelim;
  673. buf << "message= ";
  674. WriteIntCommon(buf, pMsg->message, TRUE);
  675. buf << pscStructDelim;
  676. buf << "wParam= ";
  677. WriteHexCommon(buf, (ULONG)(ULONG_PTR)pMsg->wParam, FALSE);
  678. buf << pscStructDelim;
  679. buf << "lParam= ";
  680. WriteHexCommon(buf, (ULONG)(ULONG_PTR)pMsg->lParam, FALSE);
  681. buf << pscStructDelim;
  682. buf << "time= ";
  683. WriteIntCommon(buf, pMsg->time, TRUE);
  684. buf << pscStructDelim;
  685. buf << "pt= ";
  686. WritePOINT(buf, &(pMsg->pt));
  687. buf << pscStructSuffix;
  688. }
  689. //+---------------------------------------------------------------------------
  690. //
  691. // Function: WriteTYMED
  692. //
  693. // Synopsis: Prints out a TYMED enumeration
  694. //
  695. // Arguments: [buf] - text buffer to print text to
  696. // [tymed] - TYMED value
  697. //
  698. // Returns: nothing
  699. //
  700. // History: 15-Jul-95 t-stevan Created
  701. //
  702. //----------------------------------------------------------------------------
  703. void WriteTYMED(CTextBufferA &buf, DWORD tymed)
  704. {
  705. switch(tymed)
  706. {
  707. case TYMED_NULL:
  708. buf << "TYMED_NULL";
  709. break;
  710. case TYMED_GDI:
  711. buf << "TYMED_GDI";
  712. break;
  713. case TYMED_MFPICT:
  714. buf << "TYMED_MFPICT";
  715. break;
  716. case TYMED_ENHMF:
  717. buf << "TYMED_ENHMF";
  718. break;
  719. case TYMED_HGLOBAL:
  720. buf << "TYMED_HGLOBAL";
  721. break;
  722. case TYMED_FILE:
  723. buf << "TYMED_FILE";
  724. break;
  725. case TYMED_ISTREAM:
  726. buf << "TYMED_ISTREAM";
  727. break;
  728. case TYMED_ISTORAGE:
  729. buf << "TYMED_ISTORAGE";
  730. break;
  731. default:
  732. {
  733. char temp[TEMP_SIZE];
  734. _ultoa(tymed, temp, 10);
  735. buf << temp;
  736. }
  737. break;
  738. } // switch
  739. }
  740. //+---------------------------------------------------------------------------
  741. //
  742. // Function: WriteSTGMEDIUM
  743. //
  744. // Synopsis: Prints out a STGMEDIUM structure
  745. //
  746. // Arguments: [buf] - text buffer to print text to
  747. // [pSTGMEDIUM] - pointer to STGMEDIUM structure
  748. //
  749. // Returns: nothing
  750. //
  751. // History: 15-Jul-95 t-stevan Created
  752. //
  753. //----------------------------------------------------------------------------
  754. void WriteSTGMEDIUM(CTextBufferA& buf, STGMEDIUM *pStg)
  755. {
  756. buf << pscStructPrefix;
  757. buf << "tymed= ";
  758. WriteTYMED(buf, pStg->tymed);
  759. buf << pscStructDelim;
  760. switch(pStg->tymed)
  761. {
  762. case TYMED_GDI:
  763. buf << "hBitmap= ";
  764. WriteHexCommon(buf, (ULONG) (ULONG_PTR)pStg->hBitmap, FALSE);
  765. break;
  766. case TYMED_MFPICT:
  767. buf << "hMetaFilePict= ";
  768. WriteHexCommon(buf, (ULONG) (ULONG_PTR)pStg->hMetaFilePict, FALSE);
  769. break;
  770. case TYMED_ENHMF:
  771. buf << "hEnhMetaFile= ";
  772. WriteHexCommon(buf, (ULONG) (ULONG_PTR)pStg->hEnhMetaFile, FALSE);
  773. break;
  774. case TYMED_HGLOBAL:
  775. buf << "hGlobal= ";
  776. WriteHexCommon(buf, (ULONG) (ULONG_PTR)pStg->hGlobal, FALSE);
  777. break;
  778. case TYMED_FILE:
  779. buf << "lpszFileName= ";
  780. WriteWideStringCommon(buf, pStg->lpszFileName, TRUE);
  781. break;
  782. case TYMED_ISTREAM:
  783. buf << "pstm= ";
  784. WritePointerCommon(buf, (void *) pStg->pstm, FALSE, FALSE, FALSE);
  785. break;
  786. case TYMED_ISTORAGE:
  787. buf << "pstg= ";
  788. WritePointerCommon(buf, (void *) pStg->pstg, FALSE, FALSE, FALSE);
  789. break;
  790. default:
  791. buf << "?= ????????";
  792. break;
  793. } // switch
  794. buf << pscStructDelim;
  795. buf << "pUnkForRelease= ";
  796. WritePointerCommon(buf, (void *) pStg->pUnkForRelease, FALSE, FALSE, FALSE);
  797. buf << pscStructSuffix;
  798. }
  799. //+---------------------------------------------------------------------------
  800. //
  801. // Function: WriteFORMATETC
  802. //
  803. // Synopsis: Prints out a FORMATETC structure
  804. //
  805. // Arguments: [buf] - text buffer to print text to
  806. // [pFORMATETC] - pointer to FORMATETC structure
  807. //
  808. // Returns: nothing
  809. //
  810. // History: 15-Jul-95 t-stevan Created
  811. //
  812. //----------------------------------------------------------------------------
  813. void WriteFORMATETC(CTextBufferA& buf, FORMATETC *pETC)
  814. {
  815. buf << pscStructPrefix;
  816. // TODO: write out enum?
  817. buf << "cfFormat= ";
  818. if (NULL == pETC)
  819. {
  820. buf << "NULL";
  821. }
  822. else
  823. {
  824. WriteIntCommon(buf, pETC->cfFormat, FALSE);
  825. buf << pscStructDelim;
  826. buf << "ptd= ";
  827. WritePointerCommon(buf, (void *) pETC->ptd, FALSE, FALSE, FALSE);
  828. buf << pscStructDelim;
  829. buf << "dwAspect= ";
  830. WriteIntCommon(buf, pETC->dwAspect, TRUE);
  831. buf << pscStructDelim;
  832. buf << "lindex= ";
  833. WriteIntCommon(buf, pETC->lindex, FALSE);
  834. buf << pscStructDelim;
  835. buf << "tymed= ";
  836. WriteTYMED(buf, pETC->tymed);
  837. }
  838. buf << pscStructSuffix;
  839. }
  840. //+---------------------------------------------------------------------------
  841. //
  842. // Function: WriteDVTARGETDEVICE
  843. //
  844. // Synopsis: Prints out a DVTARGETDEVICE structure
  845. //
  846. // Arguments: [buf] - text buffer to print text to
  847. // [pDVTARGETDEVICE] - pointer to DVTARGETDEVICE structure
  848. //
  849. // Returns: nothing
  850. //
  851. // History: 15-Jul-95 t-stevan Created
  852. //
  853. //----------------------------------------------------------------------------
  854. void WriteDVTARGETDEVICE(CTextBufferA& buf, DVTARGETDEVICE *ptd)
  855. {
  856. buf << pscStructPrefix;
  857. buf << "tdSize= ";
  858. WriteIntCommon(buf, ptd->tdSize, TRUE);
  859. buf << pscStructDelim;
  860. if(ptd->tdDriverNameOffset != 0)
  861. {
  862. buf << "tdDriverName= ";
  863. WriteStringCommon(buf, (const char *) (((BYTE *)ptd)+ptd->tdDriverNameOffset), TRUE);
  864. }
  865. else
  866. {
  867. buf << "tdDriverNameOffset= 0";
  868. }
  869. buf << pscStructDelim;
  870. if(ptd->tdDeviceNameOffset != 0)
  871. {
  872. buf << "tdDeviceName= ";
  873. WriteStringCommon(buf, (const char *) (((BYTE *)ptd)+ptd->tdDeviceNameOffset), TRUE);
  874. }
  875. else
  876. {
  877. buf << "tdDeviceNameOffset= 0";
  878. }
  879. buf << pscStructDelim;
  880. if(ptd->tdPortNameOffset != 0)
  881. {
  882. buf << "tdPortName= ";
  883. WriteStringCommon(buf, (const char *) (((BYTE *)ptd)+ptd->tdPortNameOffset), TRUE);
  884. }
  885. else
  886. {
  887. buf << "tdPortNameOffset= 0";
  888. }
  889. buf << pscStructDelim;
  890. if(ptd->tdExtDevmodeOffset != 0)
  891. {
  892. buf << "&tdExtDevmode= ";
  893. WritePointerCommon(buf, (void *) (((BYTE *)ptd)+ptd->tdExtDevmodeOffset), FALSE, FALSE, FALSE);
  894. }
  895. else
  896. {
  897. buf << "tdExtDevmodeOffset= 0";
  898. }
  899. buf << pscStructSuffix;
  900. }
  901. //+---------------------------------------------------------------------------
  902. //
  903. // Function: WriteBIND_OPTS
  904. //
  905. // Synopsis: Prints out a BIND_OPTS structure
  906. //
  907. // Arguments: [buf] - text buffer to print text to
  908. // [pBIND_OPTS] - pointer to BIND_OPTS structure
  909. //
  910. // Returns: nothing
  911. //
  912. // History: 15-Jul-95 t-stevan Created
  913. //
  914. //----------------------------------------------------------------------------
  915. void WriteBIND_OPTS(CTextBufferA& buf, BIND_OPTS *pOpts)
  916. {
  917. buf << pscStructPrefix;
  918. buf << "cbStruct= ";
  919. WriteIntCommon(buf, pOpts->cbStruct, TRUE);
  920. buf << pscStructDelim;
  921. buf << "grfFlags= ";
  922. WriteHexCommon(buf, pOpts->grfFlags, FALSE);
  923. buf << pscStructDelim;
  924. buf << "grfMode= ";
  925. WriteHexCommon(buf, pOpts->grfMode, FALSE);
  926. buf << pscStructDelim;
  927. buf << "dwTickCountDeadLine= ";
  928. WriteIntCommon(buf, pOpts->dwTickCountDeadline, TRUE);
  929. buf << pscStructSuffix;
  930. }
  931. //+---------------------------------------------------------------------------
  932. //
  933. // Function: WriteSTATSTG
  934. //
  935. // Synopsis: Prints out a STATSTG structure
  936. //
  937. // Arguments: [buf] - text buffer to print text to
  938. // [pSTATSTG] - pointer to STATSTG structure
  939. //
  940. // Returns: nothing
  941. //
  942. // History: 15-Jul-95 t-stevan Created
  943. //
  944. //----------------------------------------------------------------------------
  945. void WriteSTATSTG(CTextBufferA& buf, STATSTG *pStat)
  946. {
  947. buf << pscStructPrefix;
  948. buf << "pwcsName= ";
  949. WriteWideStringCommon(buf, pStat->pwcsName, TRUE);
  950. buf << pscStructDelim;
  951. buf << "type= ";
  952. WriteHexCommon(buf, pStat->type, FALSE);
  953. buf << pscStructDelim;
  954. buf << "cbSize= ";
  955. WriteLargeCommon(buf, (__int64 *) &(pStat->cbSize), TRUE);
  956. buf << pscStructDelim;
  957. buf << "mtime= ";
  958. WriteFILETIME(buf, &(pStat->mtime));
  959. buf << pscStructDelim;
  960. buf << "ctime= ";
  961. WriteFILETIME(buf, &(pStat->ctime));
  962. buf << pscStructDelim;
  963. buf << "atime= ";
  964. WriteFILETIME(buf, &(pStat->atime));
  965. buf << pscStructDelim;
  966. buf << "grfMode= ";
  967. WriteHexCommon(buf, pStat->grfMode, FALSE);
  968. buf << pscStructDelim;
  969. buf << "grfLocksSupported= ";
  970. WriteHexCommon(buf, pStat->grfLocksSupported, FALSE);
  971. buf << pscStructDelim;
  972. buf << "clsid= ";
  973. WriteGUIDCommon(buf, (const GUID *) &(pStat->clsid));
  974. buf << pscStructDelim;
  975. buf << "grfStateBits= ";
  976. WriteHexCommon(buf, pStat->grfStateBits, FALSE);
  977. buf << pscStructDelim;
  978. buf << "Reserved= ";
  979. WriteHexCommon(buf, pStat->reserved, FALSE);
  980. buf << pscStructSuffix;
  981. }
  982. //+---------------------------------------------------------------------------
  983. //
  984. // Function: WriteOLEINPLACEFRAMEINFO
  985. //
  986. // Synopsis: Prints out a OLEINPLACEFRAMEINFO structure
  987. //
  988. // Arguments: [buf] - text buffer to print text to
  989. // [pOLEINPLACEFRAMEINFO] - pointer to OLEINPLACEFRAMEINFO structure
  990. //
  991. // Returns: nothing
  992. //
  993. // History: 15-Jul-95 t-stevan Created
  994. //
  995. //----------------------------------------------------------------------------
  996. void WriteOLEINPLACEFRAMEINFO(CTextBufferA& buf, OLEINPLACEFRAMEINFO *pInfo)
  997. {
  998. buf << pscStructPrefix;
  999. buf << "cb= ";
  1000. WriteIntCommon(buf, pInfo->cb, TRUE);
  1001. buf << pscStructDelim;
  1002. buf << "fMDIApp= ";
  1003. WriteBoolCommon(buf, pInfo->fMDIApp, TRUE);
  1004. buf << pscStructDelim;
  1005. buf << "hwndFrame= ";
  1006. WriteHexCommon(buf, (ULONG)(ULONG_PTR) pInfo->hwndFrame, FALSE);
  1007. buf << pscStructDelim;
  1008. buf << "haccel= ";
  1009. WriteHexCommon(buf, (ULONG)(ULONG_PTR) pInfo->haccel, FALSE);
  1010. buf << pscStructDelim,
  1011. buf << "cAccelEntries= ";
  1012. WriteIntCommon(buf, pInfo->cAccelEntries, TRUE);
  1013. buf << pscStructSuffix;
  1014. }
  1015. //+---------------------------------------------------------------------------
  1016. //
  1017. // Function: WriteOLEMENUGROUPWIDTHS
  1018. //
  1019. // Synopsis: Prints out a OLEMENUGROUPWIDTHS structure
  1020. //
  1021. // Arguments: [buf] - text buffer to print text to
  1022. // [pOLEMENUGROUPWIDTHS] - pointer to OLEMENUGROUPWIDTHS structure
  1023. //
  1024. // Returns: nothing
  1025. //
  1026. // History: 15-Jul-95 t-stevan Created
  1027. //
  1028. //----------------------------------------------------------------------------
  1029. void WriteOLEMENUGROUPWIDTHS(CTextBufferA& buf, OLEMENUGROUPWIDTHS *pWidths)
  1030. {
  1031. buf << pscStructPrefix;
  1032. for(int i = 0; i < 5; i++)
  1033. {
  1034. WriteIntCommon(buf, pWidths->width[i], FALSE);
  1035. buf << pscStructDelim;
  1036. }
  1037. WriteIntCommon(buf, pWidths->width[5], FALSE);
  1038. buf << pscStructSuffix;
  1039. }
  1040. //+---------------------------------------------------------------------------
  1041. //
  1042. // Function: WriteINTERFACEINFO
  1043. //
  1044. // Synopsis: Prints out a INTERFACEINFO structure
  1045. //
  1046. // Arguments: [buf] - text buffer to print text to
  1047. // [pINTERFACEINFO] - pointer to INTERFACEINFO structure
  1048. //
  1049. // Returns: nothing
  1050. //
  1051. // History: 15-Jul-95 t-stevan Created
  1052. //
  1053. //----------------------------------------------------------------------------
  1054. void WriteINTERFACEINFO(CTextBufferA &buf, INTERFACEINFO *pInfo)
  1055. {
  1056. buf << pscStructPrefix;
  1057. buf << "pUnk= ";
  1058. WritePointerCommon(buf, pInfo->pUnk, FALSE, FALSE, FALSE);
  1059. buf << pscStructDelim;
  1060. buf << "iid= ";
  1061. WriteGUIDCommon(buf, (const GUID *) &(pInfo->iid));
  1062. buf << pscStructDelim;
  1063. buf << "wMethod= ";
  1064. WriteIntCommon(buf, pInfo->wMethod, TRUE);
  1065. buf << pscStructSuffix;
  1066. }
  1067. #endif // DBG==1