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.

485 lines
13 KiB

  1. //
  2. // Debug dump functions for common ADTs
  3. //
  4. // This file should be #included by your DLL. It is not part of
  5. // stocklib.lib because it requires linking to certain guid libs,
  6. // and DLLs like COMCTL32 do not do this. (Therefore, COMCTL32
  7. // doesn't #include this file, but still links to stocklib.)
  8. //
  9. //
  10. #include <intshcut.h> // For error values
  11. #include <sherror.h>
  12. #ifdef DEBUG
  13. /*
  14. * macro for simplifying result to string translation, assumes result string
  15. * pointer pcsz
  16. */
  17. #define STRING_CASE(val) case val: pcsz = TEXT(#val); break
  18. //
  19. // Debug value-to-string mapping functions
  20. //
  21. /*----------------------------------------------------------
  22. Purpose: Return the string form of the clipboard format.
  23. Returns: pointer to a static string
  24. Cond: --
  25. */
  26. LPCTSTR
  27. Dbg_GetCFName(
  28. UINT ucf)
  29. {
  30. LPCTSTR pcsz;
  31. static TCHAR s_szCFName[MAX_PATH];
  32. switch (ucf)
  33. {
  34. STRING_CASE(CF_TEXT);
  35. STRING_CASE(CF_BITMAP);
  36. STRING_CASE(CF_METAFILEPICT);
  37. STRING_CASE(CF_SYLK);
  38. STRING_CASE(CF_DIF);
  39. STRING_CASE(CF_TIFF);
  40. STRING_CASE(CF_OEMTEXT);
  41. STRING_CASE(CF_DIB);
  42. STRING_CASE(CF_PALETTE);
  43. STRING_CASE(CF_PENDATA);
  44. STRING_CASE(CF_RIFF);
  45. STRING_CASE(CF_WAVE);
  46. STRING_CASE(CF_UNICODETEXT);
  47. STRING_CASE(CF_ENHMETAFILE);
  48. STRING_CASE(CF_HDROP);
  49. STRING_CASE(CF_LOCALE);
  50. STRING_CASE(CF_MAX);
  51. STRING_CASE(CF_OWNERDISPLAY);
  52. STRING_CASE(CF_DSPTEXT);
  53. STRING_CASE(CF_DSPBITMAP);
  54. STRING_CASE(CF_DSPMETAFILEPICT);
  55. STRING_CASE(CF_DSPENHMETAFILE);
  56. default:
  57. if (! GetClipboardFormatName(ucf, s_szCFName, SIZECHARS(s_szCFName)))
  58. lstrcpy(s_szCFName, TEXT("UNKNOWN CLIPBOARD FORMAT"));
  59. pcsz = s_szCFName;
  60. break;
  61. }
  62. ASSERT(pcsz);
  63. return(pcsz);
  64. }
  65. LPCTSTR
  66. Dbg_GetHRESULTName(
  67. HRESULT hr)
  68. {
  69. LPCTSTR pcsz;
  70. static TCHAR s_rgchHRESULT[] = TEXT("0x12345678");
  71. switch (hr)
  72. {
  73. STRING_CASE(S_OK);
  74. STRING_CASE(S_FALSE);
  75. STRING_CASE(DRAGDROP_S_CANCEL);
  76. STRING_CASE(DRAGDROP_S_DROP);
  77. STRING_CASE(DRAGDROP_S_USEDEFAULTCURSORS);
  78. STRING_CASE(E_UNEXPECTED);
  79. STRING_CASE(E_NOTIMPL);
  80. STRING_CASE(E_OUTOFMEMORY);
  81. STRING_CASE(E_INVALIDARG);
  82. STRING_CASE(E_NOINTERFACE);
  83. STRING_CASE(E_POINTER);
  84. STRING_CASE(E_HANDLE);
  85. STRING_CASE(E_ABORT);
  86. STRING_CASE(E_FAIL);
  87. STRING_CASE(E_ACCESSDENIED);
  88. STRING_CASE(CLASS_E_NOAGGREGATION);
  89. STRING_CASE(CO_E_NOTINITIALIZED);
  90. STRING_CASE(CO_E_ALREADYINITIALIZED);
  91. STRING_CASE(CO_E_INIT_ONLY_SINGLE_THREADED);
  92. STRING_CASE(DV_E_DVASPECT);
  93. STRING_CASE(DV_E_LINDEX);
  94. STRING_CASE(DV_E_TYMED);
  95. STRING_CASE(DV_E_FORMATETC);
  96. STRING_CASE(E_FLAGS);
  97. STRING_CASE(URL_E_INVALID_SYNTAX);
  98. STRING_CASE(URL_E_UNREGISTERED_PROTOCOL);
  99. STRING_CASE(IS_E_EXEC_FAILED);
  100. STRING_CASE(E_FILE_NOT_FOUND);
  101. STRING_CASE(E_PATH_NOT_FOUND);
  102. default:
  103. wsprintf(s_rgchHRESULT, TEXT("%#lx"), hr);
  104. pcsz = s_rgchHRESULT;
  105. break;
  106. }
  107. ASSERT(IS_VALID_STRING_PTR(pcsz, -1));
  108. return(pcsz);
  109. }
  110. /*----------------------------------------------------------
  111. Purpose: Dump propvariant types
  112. Returns:
  113. Cond: --
  114. */
  115. LPCTSTR
  116. Dbg_GetVTName(
  117. VARTYPE vt)
  118. {
  119. LPCTSTR pcsz;
  120. static TCHAR s_szT[] = TEXT("0x12345678");
  121. switch (vt)
  122. {
  123. STRING_CASE(VT_EMPTY);
  124. STRING_CASE(VT_NULL);
  125. STRING_CASE(VT_I2);
  126. STRING_CASE(VT_I4);
  127. STRING_CASE(VT_R4);
  128. STRING_CASE(VT_R8);
  129. STRING_CASE(VT_CY);
  130. STRING_CASE(VT_DATE);
  131. STRING_CASE(VT_BSTR);
  132. STRING_CASE(VT_ERROR);
  133. STRING_CASE(VT_BOOL);
  134. STRING_CASE(VT_VARIANT);
  135. STRING_CASE(VT_UI1);
  136. STRING_CASE(VT_UI2);
  137. STRING_CASE(VT_UI4);
  138. STRING_CASE(VT_I8);
  139. STRING_CASE(VT_UI8);
  140. STRING_CASE(VT_LPSTR);
  141. STRING_CASE(VT_LPWSTR);
  142. STRING_CASE(VT_FILETIME);
  143. STRING_CASE(VT_BLOB);
  144. STRING_CASE(VT_STREAM);
  145. STRING_CASE(VT_STORAGE);
  146. STRING_CASE(VT_STREAMED_OBJECT);
  147. STRING_CASE(VT_STORED_OBJECT);
  148. STRING_CASE(VT_BLOB_OBJECT);
  149. STRING_CASE(VT_CLSID);
  150. STRING_CASE(VT_ILLEGAL);
  151. STRING_CASE(VT_CF);
  152. default:
  153. wsprintf(s_szT, TEXT("%#lx"), vt);
  154. pcsz = s_szT;
  155. break;
  156. }
  157. ASSERT(IS_VALID_STRING_PTR(pcsz, -1));
  158. return(pcsz);
  159. }
  160. #define STRING_RIID(val) { &val, TEXT(#val) }
  161. //
  162. // Alphabetical order, please.
  163. //
  164. struct
  165. {
  166. REFIID riid;
  167. LPCTSTR psz;
  168. } const c_mpriid[] =
  169. {
  170. #ifdef __IAddressList_INTERFACE_DEFINED__
  171. STRING_RIID(IID_IAddressList),
  172. #endif
  173. STRING_RIID(IID_IAdviseSink),
  174. #ifdef __IAddressList_INTERFACE_DEFINED__
  175. STRING_RIID(IID_IAddressList),
  176. #endif
  177. #ifdef __IAugmentedShellFolder_INTERFACE_DEFINED__
  178. STRING_RIID(IID_IAugmentedShellFolder),
  179. #endif
  180. #ifdef __IAugmentedShellFolder2_INTERFACE_DEFINED__
  181. STRING_RIID(IID_IAugmentedShellFolder2),
  182. #endif
  183. #ifdef __IAuthenticate_INTERFACE_DEFINED__
  184. STRING_RIID(IID_IAuthenticate),
  185. #endif
  186. #ifdef __IBandSiteHelper_INTERFACE_DEFINED__
  187. STRING_RIID(IID_IBandSiteHelper),
  188. #endif
  189. #ifdef __IBandProxy_INTERFACE_DEFINED__
  190. STRING_RIID(IID_IBandProxy),
  191. #endif
  192. #ifdef __IBindStatusCallback_INTERFACE_DEFINED__
  193. STRING_RIID(IID_IBindStatusCallback),
  194. #endif
  195. #ifdef __IBrowserBand_INTERFACE_DEFINED__
  196. STRING_RIID(IID_IBrowserBand),
  197. #endif
  198. #ifdef __IBrowserService_INTERFACE_DEFINED__
  199. STRING_RIID(IID_IBrowserService),
  200. #endif
  201. #ifdef __IBrowserService2_INTERFACE_DEFINED__
  202. STRING_RIID(IID_IBrowserService2),
  203. #endif
  204. STRING_RIID(IID_IConnectionPoint),
  205. #ifdef __IConnectionPointCB_INTERFACE_DEFINED__
  206. STRING_RIID(IID_IConnectionPointCB),
  207. #endif
  208. STRING_RIID(IID_IConnectionPointContainer),
  209. STRING_RIID(IID_IContextMenu),
  210. STRING_RIID(IID_IContextMenu2),
  211. #ifdef __IContextMenuCB_INTERFACE_DEFINED__
  212. STRING_RIID(IID_IContextMenuCB),
  213. #endif
  214. #ifdef __IContextMenuSire_INTERFACE_DEFINED__
  215. STRING_RIID(IID_IContextMenuSite),
  216. #endif
  217. STRING_RIID(IID_IDataObject),
  218. STRING_RIID(IID_IDeskBand),
  219. STRING_RIID(IID_IDispatch),
  220. #ifdef __IDocHostUIHandler_INTERFACE_DEFINED__
  221. STRING_RIID(IID_IDocHostUIHandler),
  222. #endif
  223. STRING_RIID(IID_IDockingWindowFrame),
  224. STRING_RIID(IID_IDockingWindow),
  225. STRING_RIID(IID_IDockingWindowSite),
  226. #ifdef __IDocNavigate_INTERFACE_DEFINED__
  227. STRING_RIID(IID_IDocNavigate),
  228. #endif
  229. STRING_RIID(IID_IDocViewSite),
  230. STRING_RIID(IID_IDropTarget),
  231. #ifdef __IDropTargetBackground_INTERFACE_DEFINED__
  232. STRING_RIID(IID_IDropTargetBackground),
  233. #endif
  234. #ifdef __IEFrameAuto_INTERFACE_DEFINED__
  235. STRING_RIID(IID_IEFrameAuto),
  236. #endif
  237. STRING_RIID(IID_IEnumUnknown),
  238. STRING_RIID(IID_IErrorInfo),
  239. #ifdef __IExpDispSupport_INTERFACE_DEFINED__
  240. STRING_RIID(IID_IExpDispSupport),
  241. #endif
  242. #ifdef __IExpDispSupportOC_INTERFACE_DEFINED__
  243. STRING_RIID(IID_IExpDispSupportOC),
  244. #endif
  245. #ifdef __IExplorerToolbar_INTERFACE_DEFINED__
  246. STRING_RIID(IID_IExplorerToolbar),
  247. #endif
  248. STRING_RIID(IID_IExtractIcon),
  249. STRING_RIID(IID_IExternalConnection),
  250. #ifdef __FavoriteMenu_INTERFACE_DEFINED__
  251. STRING_RIID(IID_FavoriteMenu),
  252. #endif
  253. #ifdef __IHistSFPrivate_INTERFACE_DEFINED__
  254. STRING_RIID(IID_IHistSFPrivate),
  255. #endif
  256. #ifdef __IHlink_INTERFACE_DEFINED__
  257. STRING_RIID(IID_IHlink),
  258. #endif
  259. #ifdef __IHlinkFrame_INTERFACE_DEFINED__
  260. STRING_RIID(IID_IHlinkFrame),
  261. #endif
  262. #ifdef __IHlinkSite_INTERFACE_DEFINED__
  263. STRING_RIID(IID_IHlinkSite),
  264. #endif
  265. #ifdef __IHlinkTarget_INTERFACE_DEFINED__
  266. STRING_RIID(IID_IHlinkTarget),
  267. #endif
  268. #ifdef __IHttpNegotiate_INTERFACE_DEFINED__
  269. STRING_RIID(IID_IHttpNegotiate),
  270. #endif
  271. #ifdef __IHttpSecurity_INTERFACE_DEFINED__
  272. STRING_RIID(IID_IHttpSecurity),
  273. #endif
  274. STRING_RIID(IID_IInputObject),
  275. STRING_RIID(IID_IInputObjectSite),
  276. #ifdef __IIsWebBrowserSB_INTERFACE_DEFINED__
  277. STRING_RIID(IID_IIsWebBrowserSB),
  278. #endif
  279. STRING_RIID(IID_IMenuBand),
  280. #ifdef __IMRU_INTERFACE_DEFINED__
  281. STRING_RIID(IID_IMRU),
  282. #endif
  283. #ifdef __INavigationStack_INTERFACE_DEFINED__
  284. STRING_RIID(IID_INavigationStack),
  285. #endif
  286. #ifdef __INavigationStackItem_INTERFACE_DEFINED__
  287. STRING_RIID(IID_INavigationStackItem),
  288. #endif
  289. STRING_RIID(IID_INewShortcutHook),
  290. #ifdef __IObjectCache_INTERFACE_DEFINED__
  291. STRING_RIID(IID_IObjectCache),
  292. #endif
  293. #ifdef __IObjectSafety_INTERFACE_DEFINED__
  294. STRING_RIID(IID_IObjectSafety),
  295. #endif
  296. STRING_RIID(IID_IOleClientSite),
  297. STRING_RIID(IID_IOleCommandTarget),
  298. STRING_RIID(IID_IOleContainer),
  299. STRING_RIID(IID_IOleControl),
  300. STRING_RIID(IID_IOleControlSite),
  301. STRING_RIID(IID_IOleDocument),
  302. STRING_RIID(IID_IOleDocumentSite),
  303. STRING_RIID(IID_IOleDocumentView),
  304. STRING_RIID(IID_IOleInPlaceActiveObject),
  305. STRING_RIID(IID_IOleInPlaceFrame),
  306. STRING_RIID(IID_IOleInPlaceSite),
  307. STRING_RIID(IID_IOleInPlaceObject),
  308. STRING_RIID(IID_IOleInPlaceUIWindow),
  309. STRING_RIID(IID_IOleObject),
  310. STRING_RIID(IID_IOleWindow),
  311. STRING_RIID(IID_IPersist),
  312. STRING_RIID(IID_IPersistFolder),
  313. #ifdef __IPersistMoniker_INTERFACE_DEFINED__
  314. STRING_RIID(IID_IPersistMoniker),
  315. #endif
  316. STRING_RIID(IID_IPersistPropertyBag),
  317. STRING_RIID(IID_IPersistStorage),
  318. STRING_RIID(IID_IPersistStream),
  319. STRING_RIID(IID_IPersistStreamInit),
  320. #ifdef __IPersistString_INTERFACE_DEFINED__
  321. STRING_RIID(IID_IPersistString),
  322. #endif
  323. STRING_RIID(IID_IProvideClassInfo),
  324. STRING_RIID(IID_IPropertyNotifySink),
  325. STRING_RIID(IID_IPropertySetStorage),
  326. STRING_RIID(IID_IPropertyStorage),
  327. #ifdef __IProxyShellFolder_INTERFACE_DEFINED__
  328. STRING_RIID(IID_IProxyShellFolder),
  329. #endif
  330. STRING_RIID(IID_IServiceProvider),
  331. #ifdef __ISetWinHandler_INTERFACE_DEFINED__
  332. STRING_RIID(IID_ISetWinHandler),
  333. #endif
  334. STRING_RIID(IID_IShellBrowser),
  335. STRING_RIID(IID_IShellChangeNotify),
  336. STRING_RIID(IID_IShellDetails),
  337. #ifdef __IShellDetails2_INTERFACE_DEFINED__
  338. STRING_RIID(IID_IShellDetails2),
  339. #endif
  340. STRING_RIID(IID_IShellExtInit),
  341. STRING_RIID(IID_IShellFolder),
  342. STRING_RIID(IID_IShellIcon),
  343. STRING_RIID(IID_IShellLink),
  344. STRING_RIID(IID_IShellLinkDataList),
  345. STRING_RIID(IID_IShellMenu),
  346. STRING_RIID(IID_IShellMenuCallback),
  347. STRING_RIID(IID_IShellPropSheetExt),
  348. #ifdef __IShellService_INTERFACE_DEFINED__
  349. STRING_RIID(IID_IShellService),
  350. #endif
  351. STRING_RIID(IID_IShellView),
  352. STRING_RIID(IID_IShellView2),
  353. #ifdef __ITargetEmbedding_INTERFACE_DEFINED__
  354. STRING_RIID(IID_ITargetEmbedding),
  355. #endif
  356. #ifdef __ITargetFrame2_INTERFACE_DEFINED__
  357. STRING_RIID(IID_ITargetFrame2),
  358. #endif
  359. #ifdef __ITargetFramePriv_INTERFACE_DEFINED__
  360. STRING_RIID(IID_ITargetFramePriv),
  361. #endif
  362. STRING_RIID(IID_ITravelEntry),
  363. STRING_RIID(IID_ITravelLog),
  364. STRING_RIID(IID_IUniformResourceLocator),
  365. STRING_RIID(IID_IUnknown),
  366. STRING_RIID(IID_IViewObject),
  367. STRING_RIID(IID_IViewObject2),
  368. STRING_RIID(IID_IWebBrowser),
  369. STRING_RIID(IID_IWebBrowser2),
  370. STRING_RIID(IID_IWebBrowserApp),
  371. #ifdef __IWinEventHandler_INTERFACE_DEFINED__
  372. STRING_RIID(IID_IWinEventHandler),
  373. #endif
  374. };
  375. struct
  376. {
  377. IID iid;
  378. TCHAR szGuid[GUIDSTR_MAX];
  379. } s_guid[50] = {0};
  380. LPCTSTR
  381. Dbg_GetREFIIDName(
  382. REFIID riid)
  383. {
  384. int i;
  385. // search the known list
  386. for (i = 0; i < ARRAYSIZE(c_mpriid); i++)
  387. {
  388. if (IsEqualIID(riid, c_mpriid[i].riid))
  389. return c_mpriid[i].psz;
  390. }
  391. // get a display name for the the first few unknown requests
  392. for (i = 0; i < ARRAYSIZE(s_guid); i++)
  393. {
  394. if (TEXT('{') /*}*/ == s_guid[i].szGuid[0])
  395. {
  396. if (IsEqualIID(riid, &s_guid[i].iid))
  397. return s_guid[i].szGuid;
  398. }
  399. else
  400. {
  401. s_guid[i].iid = *riid;
  402. SHStringFromGUID(riid, s_guid[i].szGuid, ARRAYSIZE(s_guid[0].szGuid));
  403. return s_guid[i].szGuid;
  404. }
  405. }
  406. return TEXT("Unknown REFIID");
  407. }
  408. //***
  409. // NOTE
  410. // must be called *after* Dbg_GetREFIIDName (since that is what creates entry)
  411. void *
  412. Dbg_GetREFIIDAtom(
  413. REFIID riid)
  414. {
  415. int i;
  416. for (i = 0; i < ARRAYSIZE(c_mpriid); i++)
  417. {
  418. if (IsEqualIID(riid, c_mpriid[i].riid))
  419. return (void *) c_mpriid[i].riid;
  420. }
  421. // get a display name for the the first few unknown requests
  422. for (i = 0; i < ARRAYSIZE(s_guid); i++)
  423. {
  424. if (TEXT('{') /*}*/ == s_guid[i].szGuid[0])
  425. {
  426. if (IsEqualIID(riid, &s_guid[i].iid))
  427. return (void *) &s_guid[i].iid;
  428. }
  429. else
  430. {
  431. return NULL;
  432. }
  433. }
  434. return NULL;
  435. }
  436. #endif // DEBUG