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.

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