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.

1206 lines
38 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1995.
  5. //
  6. // File: urldll.cxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 10-25-95 JohannP (Johann Posch) Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include <mon.h>
  18. #include "urlcf.hxx"
  19. #include "selfreg.hxx"
  20. #include <delaydll.h>
  21. #include <tls.h>
  22. #include <commctrl.h>
  23. #include <shfusion.h>
  24. #define MLUI_INIT
  25. #include "mluisupp.h"
  26. #ifdef _SBS_
  27. #include "sbsclsid.hxx"
  28. #else
  29. #include "clsid.hxx"
  30. #endif //_SBS_
  31. //
  32. // Downlevel delay load support (we forward to shlwapi)
  33. //
  34. #include <delayimp.h>
  35. PfnDliHook __pfnDliFailureHook;
  36. #ifdef unix
  37. #define DllMain DllMainInternal
  38. #endif /* unix */
  39. COleAutDll g_OleAutDll;
  40. PerfDbgTag(tagUrlDll, "Urlmon", "Log DllMain", DEB_URLMON);
  41. DECLARE_INFOLEVEL(UrlMk)
  42. DECLARE_INFOLEVEL(Trans)
  43. DECLARE_INFOLEVEL(PProt)
  44. DECLARE_INFOLEVEL(Notf)
  45. DECLARE_INFOLEVEL(EProt)
  46. DECLARE_INFOLEVEL(TNotf)
  47. extern HINSTANCE g_hInst;
  48. extern HMODULE g_hLibPluginOcx;
  49. extern HMODULE g_hLibMlang;
  50. extern ULONG Win4AssertLevel;
  51. extern IEnumFORMATETC *g_pEFmtETC;
  52. DWORD g_dwSettings = 0;
  53. BOOL g_bCanUseSimpleBinding = TRUE;
  54. BOOL CanUseSimpleBinding();
  55. BOOL g_bHasMimeHandlerForTextHtml = TRUE;
  56. LONG g_cTransLevelHandler = 0;
  57. BOOL g_bGlobalUTF8Enabled = FALSE;
  58. BOOL g_bGlobalUTF8hackEnabled = TRUE;
  59. BOOL GlobalUTF8Enabled();
  60. BOOL GlobalUTF8hackEnabled();
  61. BOOL g_bNT5OrGreater = FALSE;
  62. URLMON_TS* g_pHeadURLMONTSList;
  63. HRESULT CleanupTSOnProcessDetach();
  64. BOOL g_bUseImprovedZoneCheck;
  65. BOOL CanUseImprovedZoneCheck();
  66. // defined in calldatax.c
  67. EXTERN_C HRESULT PrxDllGetClassObject(REFCLSID clsid, REFIID iid, void **ppv);
  68. EXTERN_C HRESULT PrxDllRegisterServer();
  69. EXTERN_C HRESULT PrxDllUnregisterServer();
  70. EXTERN_C HRESULT PrxDllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID lpvReserved);
  71. // defined in zoneutil.c
  72. EXTERN_C HRESULT ZonesDllInstall(BOOL bInstall, LPCWSTR pwStr);
  73. // global variables
  74. CRefCount g_cRef(0); // global dll refcount
  75. CMutexSem g_mxsMedia; // single access to media holder
  76. LPSTR g_pszUserAgentString = NULL; // Per-process configurable User Agent string
  77. IInternetSecurityManager *g_pSecurityManager = NULL;
  78. LPSTR g_pszUAInfoString = NULL;
  79. LPSTR GetUAInfoString(void);
  80. STDAPI_(BOOL) TlsDllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpvReserved);
  81. #define STDCOURIER_CLSID "{c733e4af-576e-11d0-b28c-00c04fd7cd22}"
  82. #define STDCOURIER_CLSID_REGKEY "CLSID\\"STDCOURIER_CLSID
  83. #define STDCOURIER_CLSID_REGKEY "CLSID\\"STDCOURIER_CLSID
  84. #define STDCOURIER_DESCRIP "Thread NotificationMgr"
  85. const REGENTRY rgStdNotificationMgr[] =
  86. {
  87. //***** STDCOURIER ENTRIES *****
  88. STD_ENTRY(STDCOURIER_CLSID_REGKEY, STDCOURIER_DESCRIP),
  89. STD_ENTRY(STDCOURIER_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  90. { KEYTYPE_STRING, STDCOURIER_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  91. };
  92. ///* Registration of urlmon class
  93. // HKEY_CLASSES_ROOT
  94. const REGENTRY rgClassesRoot[] =
  95. {
  96. //***** URLMONIKER ENTRIES *****
  97. STD_ENTRY(URLMONIKER_CLSID_REGKEY, URLMONIKER_DESCRIP),
  98. STD_ENTRY(URLMONIKER_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  99. { KEYTYPE_STRING, URLMONIKER_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  100. };
  101. const REGENTRY rgClassesSoftDist[] =
  102. {
  103. //***** SOFTDIST ENTRIES *****
  104. STD_ENTRY(SOFTDIST_CLSID_REGKEY, SOFTDIST_DESCRIP),
  105. STD_ENTRY(SOFTDIST_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  106. { KEYTYPE_STRING, SOFTDIST_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  107. };
  108. const REGENTRY rgClassesSecMgr[] =
  109. {
  110. //***** SECMGR ENTRIES *****
  111. STD_ENTRY(SECMGR_CLSID_REGKEY, SECMGR_DESCRIP),
  112. STD_ENTRY(SECMGR_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  113. { KEYTYPE_STRING, SECMGR_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Both" },
  114. };
  115. const REGENTRY rgClassesZoneMgr[] =
  116. {
  117. //***** ZONEMGR ENTRIES *****
  118. STD_ENTRY(ZONEMGR_CLSID_REGKEY, ZONEMGR_DESCRIP),
  119. STD_ENTRY(ZONEMGR_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  120. { KEYTYPE_STRING, ZONEMGR_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Both" },
  121. };
  122. const REGENTRY rgClassesBindCtx[] =
  123. {
  124. //***** URLBINDCTX ENTRIES *****
  125. STD_ENTRY(URLBINDCTX_CLSID_REGKEY, URLBINDCTX_DESCRIP),
  126. STD_ENTRY(URLBINDCTX_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  127. { KEYTYPE_STRING, URLBINDCTX_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  128. };
  129. // Registration of proxy/stub class id
  130. const REGENTRY rgPSFactory[] =
  131. {
  132. //***** URLMONIKER PS ENTRIES *****
  133. STD_ENTRY(URLMONIKER_PS_CLSID_REGKEY, URLMONIKER_PS_DESCRIP),
  134. STD_ENTRY(URLMONIKER_PS_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  135. { KEYTYPE_STRING, URLMONIKER_PS_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  136. };
  137. // protocols
  138. const REGENTRY rgClassesHttp[] =
  139. {
  140. //***** PROTOCOL_HTTP ENTRIES *****
  141. STD_ENTRY(PROTOCOL_HTTP_CLSID_REGKEY, PROTOCOL_HTTP_DESCRIP),
  142. STD_ENTRY(PROTOCOL_HTTP_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  143. { KEYTYPE_STRING, PROTOCOL_HTTP_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  144. };
  145. const REGENTRY rgClassesFtp[] =
  146. {
  147. //***** PROTOCOL_FTP ENTRIES *****
  148. STD_ENTRY(PROTOCOL_FTP_CLSID_REGKEY, PROTOCOL_FTP_DESCRIP),
  149. STD_ENTRY(PROTOCOL_FTP_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  150. { KEYTYPE_STRING, PROTOCOL_FTP_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  151. };
  152. const REGENTRY rgClassesGopher[] =
  153. {
  154. //***** PROTOCOL_GOPHER ENTRIES *****
  155. STD_ENTRY(PROTOCOL_GOPHER_CLSID_REGKEY, PROTOCOL_GOPHER_DESCRIP),
  156. STD_ENTRY(PROTOCOL_GOPHER_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  157. { KEYTYPE_STRING, PROTOCOL_GOPHER_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  158. };
  159. const REGENTRY rgClassesHttpS[] =
  160. {
  161. //***** PROTOCOL_HTTPS ENTRIES *****
  162. STD_ENTRY(PROTOCOL_HTTPS_CLSID_REGKEY, PROTOCOL_HTTPS_DESCRIP),
  163. STD_ENTRY(PROTOCOL_HTTPS_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  164. { KEYTYPE_STRING, PROTOCOL_HTTPS_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  165. };
  166. const REGENTRY rgClassesMk[] =
  167. {
  168. //***** PROTOCOL_MK ENTRIES *****
  169. STD_ENTRY(PROTOCOL_MK_CLSID_REGKEY, PROTOCOL_MK_DESCRIP),
  170. STD_ENTRY(PROTOCOL_MK_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  171. { KEYTYPE_STRING, PROTOCOL_MK_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  172. };
  173. const REGENTRY rgClassesFile[] =
  174. {
  175. //***** PROTOCOL_FILE ENTRIES *****
  176. STD_ENTRY(PROTOCOL_FILE_CLSID_REGKEY, PROTOCOL_FILE_DESCRIP),
  177. STD_ENTRY(PROTOCOL_FILE_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  178. { KEYTYPE_STRING, PROTOCOL_FILE_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  179. };
  180. #define HANDLER_HTTP SZPROTOCOLROOT"http"
  181. #define HANDLER_FTP SZPROTOCOLROOT"ftp"
  182. #define HANDLER_GOPHER SZPROTOCOLROOT"gopher"
  183. #define HANDLER_HTTPS SZPROTOCOLROOT"https"
  184. #define HANDLER_MK SZPROTOCOLROOT"mk"
  185. #define HANDLER_FILE SZPROTOCOLROOT"file"
  186. #define HANDLER_LOCAL SZPROTOCOLROOT"local"
  187. //const REGENTRY rgHandler[] = { STD_ENTRY(HANDLER_HTTP, PROTOCOL_HTTP_DESCRIP), { KEYTYPE_STRING, HANDLER_HTTP, "CLSID", REG_SZ, (BYTE*)PROTOCOL_HTTP_CLSID } };
  188. const REGENTRY rgHandlerHttp [] = { STD_ENTRY(HANDLER_HTTP , PROTOCOL_HTTP_DESCRIP ), { KEYTYPE_STRING, HANDLER_HTTP , "CLSID", REG_SZ, (BYTE*)PROTOCOL_HTTP_CLSID } };
  189. const REGENTRY rgHandlerFtp [] = { STD_ENTRY(HANDLER_FTP , PROTOCOL_FTP_DESCRIP ), { KEYTYPE_STRING, HANDLER_FTP , "CLSID", REG_SZ, (BYTE*)PROTOCOL_FTP_CLSID } };
  190. const REGENTRY rgHandlerGopher [] = { STD_ENTRY(HANDLER_GOPHER, PROTOCOL_GOPHER_DESCRIP), { KEYTYPE_STRING, HANDLER_GOPHER, "CLSID", REG_SZ, (BYTE*)PROTOCOL_GOPHER_CLSID } };
  191. const REGENTRY rgHandlerHttpS [] = { STD_ENTRY(HANDLER_HTTPS , PROTOCOL_HTTPS_DESCRIP ), { KEYTYPE_STRING, HANDLER_HTTPS , "CLSID", REG_SZ, (BYTE*)PROTOCOL_HTTPS_CLSID } };
  192. const REGENTRY rgHandlerMk [] = { STD_ENTRY(HANDLER_MK , PROTOCOL_MK_DESCRIP ), { KEYTYPE_STRING, HANDLER_MK , "CLSID", REG_SZ, (BYTE*)PROTOCOL_MK_CLSID } };
  193. const REGENTRY rgHandlerFile [] = { STD_ENTRY(HANDLER_FILE , PROTOCOL_FILE_DESCRIP ), { KEYTYPE_STRING, HANDLER_FILE , "CLSID", REG_SZ, (BYTE*)PROTOCOL_FILE_CLSID } };
  194. const REGENTRY rgHandlerLocal [] = { STD_ENTRY(HANDLER_LOCAL , PROTOCOL_FILE_DESCRIP ), { KEYTYPE_STRING, HANDLER_LOCAL , "CLSID", REG_SZ, (BYTE*)PROTOCOL_FILE_CLSID } };
  195. // From PlugProt.dll (merge)
  196. #define SZFILTERROOT "PROTOCOLS\\Filter\\"
  197. #define SZPROTOCOLROOT "PROTOCOLS\\Handler\\"
  198. #define SZCLASS "CLSID"
  199. #define SZHANDLER "HANDLER"
  200. EXTERN_C const GUID CLSID_StdEncodingFilterFac;
  201. EXTERN_C const GUID CLSID_DeCompMimeFilter;
  202. EXTERN_C const GUID CLSID_CdlProtocol;
  203. EXTERN_C const GUID CLSID_ClassInstallFilter;
  204. //*************************** Registry keys for CDL protocol handler
  205. const REGENTRY rgHandlerCdl[] =
  206. {
  207. STD_ENTRY(HANDLER_CDL , PROTOCOL_CDL_DESCRIP ),
  208. { KEYTYPE_STRING, HANDLER_CDL , "CLSID", REG_SZ, (BYTE*)PROTOCOL_CDL_CLSID }
  209. };
  210. const REGENTRY rgClassesCdl[] =
  211. {
  212. STD_ENTRY(PROTOCOL_CDL_CLSID_REGKEY, PROTOCOL_CDL_DESCRIP),
  213. STD_ENTRY(PROTOCOL_CDL_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  214. { KEYTYPE_STRING, PROTOCOL_CDL_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  215. };
  216. //*************************** Registry keys for Class Install Handler protocol filter
  217. const REGENTRY rgClassesMimeInstallHandler[] =
  218. {
  219. STD_ENTRY(PROT_FILTER_CLASS_CLSID_REGKEY, PROT_FILTER_CLASS_DESCRIP),
  220. STD_ENTRY(PROT_FILTER_CLASS_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  221. { KEYTYPE_STRING, PROT_FILTER_CLASS_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  222. };
  223. const REGENTRY rgMimeInstallHandler[] =
  224. {
  225. STD_ENTRY(PROT_FILTER_CLASS , PROT_FILTER_CLASS_DESCRIP ),
  226. { KEYTYPE_STRING, PROT_FILTER_CLASS, "CLSID", REG_SZ, (BYTE*)PROT_FILTER_CLASS_CLSID }
  227. };
  228. //*************************** Registry keys for ENC & Deflate protocol filters
  229. const REGENTRY rgClassesMimeHandlerEnc[] =
  230. {
  231. STD_ENTRY(PROT_FILTER_ENC_CLSID_REGKEY, PROT_FILTER_ENC_DESCRIP),
  232. STD_ENTRY(PROT_FILTER_ENC_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  233. { KEYTYPE_STRING, PROT_FILTER_ENC_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  234. };
  235. const REGENTRY rgMimeHandlerEnc [] =
  236. {
  237. STD_ENTRY(PROT_FILTER_ENC , PROT_FILTER_ENC_DESCRIP ),
  238. { KEYTYPE_STRING, PROT_FILTER_ENC , "CLSID", REG_SZ, (BYTE*)PROT_FILTER_ENC_CLSID }
  239. };
  240. const REGENTRY rgDeflateEnc [] =
  241. {
  242. STD_ENTRY(PROT_FILTER_DEFLATE , PROT_FILTER_DEFLATE_DESCRIP ),
  243. { KEYTYPE_STRING, PROT_FILTER_DEFLATE , "CLSID", REG_SZ, (BYTE*)PROT_FILTER_DEFLATE_CLSID }
  244. };
  245. const REGENTRY rgGZIPEnc [] =
  246. {
  247. STD_ENTRY(PROT_FILTER_GZIP , PROT_FILTER_GZIP_DESCRIP ),
  248. { KEYTYPE_STRING, PROT_FILTER_GZIP , "CLSID", REG_SZ, (BYTE*)PROT_FILTER_GZIP_CLSID }
  249. };
  250. const REGENTRY rgClassesStdEncFac[] =
  251. {
  252. STD_ENTRY(STD_ENC_FAC_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  253. { KEYTYPE_STRING, STD_ENC_FAC_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  254. };
  255. const REGENTRYGROUP rgRegEntryGroups[] = {
  256. { HKEY_CLASSES_ROOT, rgStdNotificationMgr, ARRAYSIZE(rgStdNotificationMgr) },
  257. { HKEY_CLASSES_ROOT, rgClassesRoot, ARRAYSIZE(rgClassesRoot) },
  258. { HKEY_CLASSES_ROOT, rgClassesSoftDist, ARRAYSIZE(rgClassesSoftDist) },
  259. { HKEY_CLASSES_ROOT, rgClassesSecMgr, ARRAYSIZE(rgClassesSecMgr) },
  260. { HKEY_CLASSES_ROOT, rgClassesZoneMgr, ARRAYSIZE(rgClassesZoneMgr) },
  261. { HKEY_CLASSES_ROOT, rgClassesBindCtx, ARRAYSIZE(rgClassesBindCtx) },
  262. { HKEY_CLASSES_ROOT, rgPSFactory, ARRAYSIZE(rgPSFactory) },
  263. { HKEY_CLASSES_ROOT, rgClassesHttp, ARRAYSIZE(rgClassesHttp) },
  264. { HKEY_CLASSES_ROOT, rgClassesFtp, ARRAYSIZE(rgClassesFtp) },
  265. { HKEY_CLASSES_ROOT, rgClassesGopher, ARRAYSIZE(rgClassesGopher) },
  266. { HKEY_CLASSES_ROOT, rgClassesHttpS, ARRAYSIZE(rgClassesHttpS) },
  267. { HKEY_CLASSES_ROOT, rgClassesMk, ARRAYSIZE(rgClassesMk) },
  268. { HKEY_CLASSES_ROOT, rgClassesFile, ARRAYSIZE(rgClassesFile) },
  269. { HKEY_CLASSES_ROOT, rgHandlerHttp , ARRAYSIZE(rgHandlerHttp ) },
  270. { HKEY_CLASSES_ROOT, rgHandlerFtp , ARRAYSIZE(rgHandlerFtp ) },
  271. { HKEY_CLASSES_ROOT, rgHandlerGopher, ARRAYSIZE(rgHandlerGopher) },
  272. { HKEY_CLASSES_ROOT, rgHandlerHttpS , ARRAYSIZE(rgHandlerHttpS ) },
  273. { HKEY_CLASSES_ROOT, rgHandlerMk , ARRAYSIZE(rgHandlerMk ) },
  274. { HKEY_CLASSES_ROOT, rgHandlerFile , ARRAYSIZE(rgHandlerFile ) },
  275. { HKEY_CLASSES_ROOT, rgHandlerLocal , ARRAYSIZE(rgHandlerLocal ) },
  276. { HKEY_CLASSES_ROOT, rgMimeHandlerEnc, ARRAYSIZE(rgMimeHandlerEnc) },
  277. { HKEY_CLASSES_ROOT, rgClassesMimeHandlerEnc, ARRAYSIZE(rgClassesMimeHandlerEnc) },
  278. { HKEY_CLASSES_ROOT, rgDeflateEnc, ARRAYSIZE(rgDeflateEnc) },
  279. { HKEY_CLASSES_ROOT, rgGZIPEnc, ARRAYSIZE(rgGZIPEnc) },
  280. { HKEY_CLASSES_ROOT, rgClassesStdEncFac, ARRAYSIZE(rgClassesStdEncFac) },
  281. { HKEY_CLASSES_ROOT, rgClassesMimeInstallHandler, ARRAYSIZE(rgClassesMimeInstallHandler) },
  282. { HKEY_CLASSES_ROOT, rgMimeInstallHandler, ARRAYSIZE(rgMimeInstallHandler) },
  283. { HKEY_CLASSES_ROOT, rgClassesCdl, ARRAYSIZE(rgClassesCdl) },
  284. { HKEY_CLASSES_ROOT, rgHandlerCdl , ARRAYSIZE(rgHandlerCdl) },
  285. #ifdef TEST_JOHANNP
  286. #if DBG==1
  287. { HKEY_CLASSES_ROOT, rgNameSpaceTest1 , ARRAYSIZE(rgNameSpaceTest1 ) },
  288. { HKEY_CLASSES_ROOT, rgNameSpaceTest2 , ARRAYSIZE(rgNameSpaceTest2 ) },
  289. #endif // DBG
  290. #endif //TEST_JOHANNP
  291. { NULL, NULL, 0 } // terminator
  292. };
  293. const REGENTRYGROUP rgRegEntryGroupsDel[] = {
  294. { HKEY_CLASSES_ROOT, rgStdNotificationMgr, ARRAYSIZE(rgStdNotificationMgr) },
  295. { HKEY_CLASSES_ROOT, rgClassesRoot, ARRAYSIZE(rgClassesRoot) },
  296. { HKEY_CLASSES_ROOT, rgClassesSoftDist, ARRAYSIZE(rgClassesSoftDist) },
  297. { HKEY_CLASSES_ROOT, rgClassesSecMgr, ARRAYSIZE(rgClassesSecMgr) },
  298. { HKEY_CLASSES_ROOT, rgClassesZoneMgr, ARRAYSIZE(rgClassesZoneMgr) },
  299. { HKEY_CLASSES_ROOT, rgClassesBindCtx, ARRAYSIZE(rgClassesBindCtx) },
  300. { HKEY_CLASSES_ROOT, rgPSFactory, ARRAYSIZE(rgPSFactory) },
  301. { HKEY_CLASSES_ROOT, rgClassesHttp, ARRAYSIZE(rgClassesHttp) },
  302. { HKEY_CLASSES_ROOT, rgClassesFtp, ARRAYSIZE(rgClassesFtp) },
  303. { HKEY_CLASSES_ROOT, rgClassesGopher, ARRAYSIZE(rgClassesGopher) },
  304. { HKEY_CLASSES_ROOT, rgClassesHttpS, ARRAYSIZE(rgClassesHttpS) },
  305. { HKEY_CLASSES_ROOT, rgClassesMk, ARRAYSIZE(rgClassesMk) },
  306. { HKEY_CLASSES_ROOT, rgClassesFile, ARRAYSIZE(rgClassesFile) },
  307. { HKEY_CLASSES_ROOT, rgHandlerFtp , ARRAYSIZE(rgHandlerFtp ) },
  308. { HKEY_CLASSES_ROOT, rgHandlerGopher, ARRAYSIZE(rgHandlerGopher) },
  309. { HKEY_CLASSES_ROOT, rgHandlerMk , ARRAYSIZE(rgHandlerMk ) },
  310. { HKEY_CLASSES_ROOT, rgHandlerFile , ARRAYSIZE(rgHandlerFile ) },
  311. { HKEY_CLASSES_ROOT, rgHandlerLocal , ARRAYSIZE(rgHandlerLocal ) },
  312. { HKEY_CLASSES_ROOT, rgMimeHandlerEnc, ARRAYSIZE(rgMimeHandlerEnc) },
  313. { HKEY_CLASSES_ROOT, rgClassesMimeHandlerEnc, ARRAYSIZE(rgClassesMimeHandlerEnc) },
  314. { HKEY_CLASSES_ROOT, rgDeflateEnc, ARRAYSIZE(rgDeflateEnc) },
  315. { HKEY_CLASSES_ROOT, rgGZIPEnc, ARRAYSIZE(rgGZIPEnc) },
  316. { HKEY_CLASSES_ROOT, rgClassesStdEncFac, ARRAYSIZE(rgClassesStdEncFac) },
  317. { HKEY_CLASSES_ROOT, rgClassesMimeInstallHandler, ARRAYSIZE(rgClassesMimeInstallHandler) },
  318. { HKEY_CLASSES_ROOT, rgMimeInstallHandler, ARRAYSIZE(rgMimeInstallHandler) },
  319. { HKEY_CLASSES_ROOT, rgClassesCdl, ARRAYSIZE(rgClassesCdl) },
  320. { HKEY_CLASSES_ROOT, rgHandlerCdl , ARRAYSIZE(rgHandlerCdl) },
  321. #ifdef TEST_JOHANNP
  322. #if DBG==1
  323. { HKEY_CLASSES_ROOT, rgNameSpaceTest1 , ARRAYSIZE(rgNameSpaceTest1 ) },
  324. { HKEY_CLASSES_ROOT, rgNameSpaceTest2 , ARRAYSIZE(rgNameSpaceTest2 ) },
  325. #endif // DBG
  326. #endif //TEST_JOHANNP
  327. { NULL, NULL, 0 } // terminator
  328. };
  329. //+---------------------------------------------------------------------------
  330. //
  331. // Function: DllAddRef
  332. //
  333. // Synopsis:
  334. //
  335. // Arguments: [void] --
  336. //
  337. // Returns:
  338. //
  339. // History: 12-10-95 JohannP (Johann Posch) Created
  340. //
  341. // Notes:
  342. //
  343. //----------------------------------------------------------------------------
  344. void DllAddRef(void)
  345. {
  346. g_cRef++;
  347. }
  348. //+---------------------------------------------------------------------------
  349. //
  350. // Function: DllRelease
  351. //
  352. // Synopsis:
  353. //
  354. // Arguments: [void] --
  355. //
  356. // Returns:
  357. //
  358. // History: 12-10-95 JohannP (Johann Posch) Created
  359. //
  360. // Notes:
  361. //
  362. //----------------------------------------------------------------------------
  363. void DllRelease(void)
  364. {
  365. UrlMkAssert((g_cRef > 0));
  366. if (g_cRef > 0)
  367. {
  368. g_cRef--;
  369. }
  370. }
  371. //+---------------------------------------------------------------------------
  372. //
  373. // Operator: new
  374. //
  375. // Synopsis:
  376. //
  377. // Arguments: [size] --
  378. //
  379. // Returns:
  380. //
  381. // History: 12-10-95 JohannP (Johann Posch) Created
  382. //
  383. // Notes: BUBUG: get and use IMalloc
  384. //
  385. //----------------------------------------------------------------------------
  386. void * _cdecl operator new(size_t size)
  387. {
  388. void * pBuffer;
  389. pBuffer = CoTaskMemAlloc(size);
  390. if (pBuffer)
  391. {
  392. memset(pBuffer,0, size);
  393. }
  394. return pBuffer;
  395. }
  396. void * _cdecl operator new(size_t sizeEl, ULONG cEl)
  397. {
  398. void * pBuffer;
  399. size_t size = sizeEl * cEl;
  400. pBuffer = CoTaskMemAlloc(size);
  401. if (pBuffer)
  402. {
  403. memset(pBuffer,0, size);
  404. }
  405. return pBuffer;
  406. }
  407. //+---------------------------------------------------------------------------
  408. //
  409. // Operator: delete
  410. //
  411. // Synopsis:
  412. //
  413. // Arguments: [lpv] --
  414. //
  415. // Returns:
  416. //
  417. // History: 2-14-96 JohannP (Johann Posch) Created
  418. //
  419. // Notes: BUBUG: get and use IMalloc
  420. //
  421. //----------------------------------------------------------------------------
  422. void _cdecl operator delete(void *lpv)
  423. {
  424. //UrlMkAssert((lpv != NULL));
  425. if (lpv == NULL)
  426. {
  427. return;
  428. }
  429. CoTaskMemFree(lpv);
  430. }
  431. #ifdef UNUSED
  432. //
  433. int _cdecl _purecall( void )
  434. {
  435. UrlMkAssert(FALSE);
  436. return 0;
  437. }
  438. #endif //UNUSED
  439. //+-------------------------------------------------------------------------
  440. //
  441. // Function: DllGetClassObject
  442. //
  443. // Synopsis: Dll entry point
  444. //
  445. // Arguments: [clsid] - class id for new class
  446. // [iid] - interface required of class
  447. // [ppv] - where to put new interface
  448. //
  449. // Returns: S_OK - class object created successfully created.
  450. //
  451. //
  452. //--------------------------------------------------------------------------
  453. STDAPI DllGetClassObject(REFCLSID clsid, REFIID iid, void **ppv)
  454. {
  455. UrlMkDebugOut((DEB_URLMON, "API _IN DllGetClassObject\n"));
  456. HRESULT hr = E_NOTIMPL;
  457. if ( (clsid == CLSID_StdURLMoniker)
  458. || (clsid == CLSID_UrlMkBindCtx)
  459. || (clsid == CLSID_HttpSProtocol )
  460. || (clsid == CLSID_HttpProtocol )
  461. || (clsid == CLSID_FtpProtocol )
  462. || (clsid == CLSID_GopherProtocol)
  463. || (clsid == CLSID_FileProtocol )
  464. || (clsid == CLSID_MkProtocol )
  465. || (clsid == CLSID_SoftDistExt )
  466. || (clsid == CLSID_InternetSecurityManager )
  467. || (clsid == CLSID_InternetZoneManager )
  468. || (clsid == CLSID_DeCompMimeFilter)
  469. || (clsid == CLSID_StdEncodingFilterFac)
  470. || (clsid == CLSID_CdlProtocol)
  471. || (clsid == CLSID_ClassInstallFilter)
  472. )
  473. {
  474. CUrlClsFact *pCF = NULL;
  475. hr = CUrlClsFact::Create(clsid, &pCF);
  476. if (hr == NOERROR)
  477. {
  478. UrlMkAssert((pCF != NULL));
  479. hr = pCF->QueryInterface(iid, ppv);
  480. pCF->Release();
  481. }
  482. }
  483. else
  484. {
  485. hr = PrxDllGetClassObject(clsid, iid, ppv);
  486. }
  487. DumpIID(clsid);
  488. UrlMkDebugOut((DEB_URLMON, "API OUT DllGetClassObject (hr:%lx, ppv:%p)\n",hr,*ppv));
  489. return hr;
  490. }
  491. void SetupDelayloadErrorHandler()
  492. {
  493. __pfnDliFailureHook = (PfnDliHook)GetProcAddress(GetModuleHandleA("shlwapi.dll"), "DelayLoadFailureHook");
  494. }
  495. //+-------------------------------------------------------------------------
  496. //
  497. // Function: DllMain
  498. //
  499. // Synopsis:
  500. //
  501. // Arguments: [hDll] - a handle to the dll instance
  502. // [dwReason] - the reason LibMain was called
  503. // [lpvReserved] - NULL - called due to FreeLibrary
  504. // - non-NULL - called due to process exit
  505. //
  506. // Returns: TRUE on success, FALSE otherwise
  507. //
  508. // Notes:
  509. //
  510. // The officially approved DLL entrypoint name is DllMain. This
  511. // entry point will be called by the CRT Init function.
  512. //
  513. //
  514. //--------------------------------------------------------------------------
  515. BOOL WINAPI DllMain(HINSTANCE hInstance,DWORD dwReason,LPVOID lpvReserved)
  516. {
  517. BOOL fResult = TRUE;
  518. UrlMkDebugOut((DEB_DLL,"DllMain:%lx\n", dwReason));
  519. PrxDllMain(hInstance, dwReason, lpvReserved);
  520. switch (dwReason)
  521. {
  522. case DLL_PROCESS_ATTACH:
  523. #if DBG==1
  524. {
  525. UrlMkInfoLevel = (DWORD) GetProfileIntA("UrlMon","UrlMk", (DEB_ERROR | DEB_WARN)) & DEB_LEVEL_MASK;
  526. TransInfoLevel = (DWORD) GetProfileIntA("UrlMon","Trans", (DEB_ERROR | DEB_WARN)) & DEB_LEVEL_MASK;
  527. PProtInfoLevel = (DWORD) GetProfileIntA("UrlMon","PProt", (DEB_ERROR | DEB_WARN)) & DEB_LEVEL_MASK;
  528. NotfInfoLevel = (DWORD) GetProfileIntA("UrlMon","Notf", (DEB_ERROR | DEB_WARN)) & DEB_LEVEL_MASK;
  529. EProtInfoLevel = (DWORD) GetProfileIntA("UrlMon","EProt", (DEB_ERROR | DEB_WARN)) & DEB_LEVEL_MASK;
  530. TNotfInfoLevel = (DWORD) GetProfileIntA("UrlMon","TNotf", (DEB_ERROR | DEB_WARN)) & DEB_LEVEL_MASK;
  531. g_dwSettings = (DWORD) GetProfileIntA("UrlMon","Global", (DEB_ERROR | DEB_WARN));
  532. Win4AssertLevel= (ULONG) GetProfileIntA("UrlMon","AssertLevel", 0);
  533. // enable encoding handler
  534. // g_dwSettings |= 0x00100000;
  535. }
  536. #endif //DBG==1
  537. SHFusionInitializeFromModule((HMODULE)hInstance);
  538. SetupDelayloadErrorHandler();
  539. PerfDbgLog(tagUrlDll, NULL, "+URLMON DLL_PROCESS_ATTACH");
  540. g_pszUserAgentString = NULL;
  541. g_pszUAInfoString = GetUAInfoString();
  542. // We ignore the return code of ZonesInit because other parts of urlmon
  543. // could still function fine if we can't init zones.
  544. ZonesInit( );
  545. g_bCanUseSimpleBinding = CanUseSimpleBinding();
  546. g_bGlobalUTF8Enabled = GlobalUTF8Enabled();
  547. g_bGlobalUTF8hackEnabled = GlobalUTF8hackEnabled();
  548. g_bUseImprovedZoneCheck = CanUseImprovedZoneCheck();
  549. g_pHeadURLMONTSList = NULL;
  550. OSVERSIONINFO osvi;
  551. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  552. if (GetVersionEx(&osvi))
  553. {
  554. g_bNT5OrGreater = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && (osvi.dwMajorVersion >= 5);
  555. }
  556. fResult = TlsDllMain(hInstance, dwReason, lpvReserved);
  557. MLLoadResources(hInstance, TEXT("inetcplc.dll"));
  558. //debug log related stuff
  559. INET_DEBUG_START();
  560. PerfDbgLog(tagUrlDll, NULL, "-URLMON DLL_PROCESS_ATTACH");
  561. break;
  562. case DLL_PROCESS_DETACH:
  563. if (g_pszUserAgentString != NULL)
  564. {
  565. delete g_pszUserAgentString;
  566. g_pszUserAgentString = NULL;
  567. }
  568. if (g_pSecurityManager)
  569. {
  570. g_pSecurityManager->Release();
  571. g_pSecurityManager = NULL;
  572. }
  573. if (g_pszUAInfoString != NULL)
  574. {
  575. delete g_pszUAInfoString;
  576. g_pszUAInfoString = NULL;
  577. }
  578. if (g_hLibPluginOcx)
  579. {
  580. FreeLibrary(g_hLibPluginOcx);
  581. }
  582. if (g_hLibMlang)
  583. {
  584. FreeLibrary(g_hLibMlang);
  585. }
  586. ZonesUnInit( );
  587. g_bCanUseSimpleBinding = TRUE;
  588. if (g_pEFmtETC)
  589. {
  590. g_pEFmtETC->Release();
  591. }
  592. if(g_pHeadURLMONTSList)
  593. {
  594. //
  595. // if lpvReserved == NULL - called due to FreeLibrary
  596. // else - called due to process Terminate
  597. //
  598. // Since we are using SendMessage to kill the thread notification
  599. // window, we should only do that when FreeLibraray() happens
  600. //
  601. if( !lpvReserved )
  602. {
  603. CleanupTSOnProcessDetach();
  604. }
  605. }
  606. MLFreeResources(hInstance);
  607. //debug log related stuff
  608. INET_DEBUG_FINISH();
  609. // Fall through
  610. case DLL_THREAD_ATTACH:
  611. case DLL_THREAD_DETACH:
  612. fResult = TlsDllMain(hInstance, dwReason, lpvReserved);
  613. if (dwReason==DLL_PROCESS_DETACH)
  614. {
  615. SHFusionUninitialize();
  616. }
  617. }
  618. UrlMkDebugOut((DEB_DLL,"DllMain: done\n"));
  619. return fResult;
  620. }
  621. //+---------------------------------------------------------------------------
  622. //
  623. // Function: DllCanUnloadNow
  624. //
  625. // Synopsis:
  626. //
  627. // Arguments: [void] --
  628. //
  629. // Returns:
  630. //
  631. // Notes:
  632. //
  633. //----------------------------------------------------------------------------
  634. STDAPI DllCanUnloadNow(void)
  635. {
  636. return (g_cRef ? S_FALSE : S_OK);
  637. }
  638. //+---------------------------------------------------------------------------
  639. //
  640. // Function: DllRegisterServer
  641. //
  642. // Synopsis:
  643. //
  644. // Arguments: (none)
  645. //
  646. // Returns:
  647. //
  648. // History: 5-03-96 JohannP (Johann Posch) Created
  649. //
  650. // Notes:
  651. //
  652. //----------------------------------------------------------------------------
  653. STDAPI DllRegisterServer()
  654. {
  655. UrlMkDebugOut((DEB_URLMON, "API _IN DllRegisterServer\n"));
  656. HRESULT hr;
  657. // don't register the proxies now
  658. // PrxDllRegisterServer();
  659. PrxDllRegisterServer();
  660. hr = HrDllRegisterServer(rgRegEntryGroups, g_hInst, NULL /*pfnLoadString*/);
  661. UrlMkDebugOut((DEB_URLMON, "API OUT DllRegisterServer (hr:%lx)\n",hr));
  662. return hr;
  663. }
  664. //+---------------------------------------------------------------------------
  665. //
  666. // Function: DllUnregisterServer
  667. //
  668. // Synopsis:
  669. //
  670. // Arguments: (none)
  671. //
  672. // Returns:
  673. //
  674. // History: 5-03-96 JohannP (Johann Posch) Created
  675. //
  676. // Notes:
  677. //
  678. //----------------------------------------------------------------------------
  679. STDAPI DllUnregisterServer()
  680. {
  681. UrlMkDebugOut((DEB_URLMON, "API _IN DllUnregisterServer\n"));
  682. HRESULT hr;
  683. // don't register the proxies now
  684. //PrxDllUnregisterServer();
  685. hr = HrDllUnregisterServer(rgRegEntryGroupsDel, g_hInst, NULL /*pfnLoadString*/);
  686. UrlMkDebugOut((DEB_URLMON, "API OUT DllUnregisterServer (hr:%lx)\n",hr));
  687. return hr;
  688. }
  689. //+---------------------------------------------------------------------------
  690. //
  691. // Function: DllRegisterServerEx
  692. //
  693. // Synopsis:
  694. //
  695. // Arguments: (none)
  696. //
  697. // Returns:
  698. //
  699. // History: 5-03-96 JohannP (Johann Posch) Created
  700. //
  701. // Notes:
  702. //
  703. //----------------------------------------------------------------------------
  704. STDAPI DllRegisterServerEx()
  705. {
  706. UrlMkDebugOut((DEB_URLMON, "API _IN DllRegisterServerEx\n"));
  707. HRESULT hr = E_NOTIMPL;
  708. UrlMkDebugOut((DEB_URLMON, "API OUT DllRegisterServerEx (hr:%lx)\n",hr));
  709. return hr;
  710. }
  711. //+---------------------------------------------------------------------------
  712. //
  713. // Function: DllInstall
  714. //
  715. // Synopsis:
  716. //
  717. // Arguments: (none)
  718. //
  719. // Returns:
  720. //
  721. // History: 6-17-97 SanjayS (Sanjay Shenoy) Created
  722. //
  723. // Notes:
  724. //
  725. //----------------------------------------------------------------------------
  726. STDAPI DllInstall(BOOL bInstall, LPCWSTR pwStr)
  727. {
  728. UrlMkDebugOut((DEB_URLMON, "API _IN DllInstall\n"));
  729. #ifdef UNIX
  730. /*
  731. * On Unix, regsetup always passes in L"" for pwStr.
  732. */
  733. HRESULT hr;
  734. if (pwStr && !wcscmp(pwStr, L""))
  735. hr = ZonesDllInstall(bInstall, L"HKCU");
  736. else
  737. hr = ZonesDllInstall(bInstall, pwStr);
  738. #else
  739. HRESULT hr = ZonesDllInstall(bInstall, pwStr);
  740. #endif /* UNIX */
  741. UrlMkDebugOut((DEB_URLMON, "API OUT DllInstall (hr:%lx)\n", hr));
  742. return hr;
  743. }
  744. //+-------------------------------------------------------------------------
  745. //
  746. // Function: CoBuildVersion
  747. //
  748. // Synopsis: Return build version DWORD
  749. //
  750. // Returns: DWORD hiword = 23
  751. // DWORD loword = build number
  752. //
  753. // Notes: The high word must always be constant for a given platform.
  754. // For Win16 it must be exactly 23 (because that's what 16-bit
  755. // OLE 2.01 shipped with). We can choose a different high word
  756. // for other platforms. The low word must be greater than 639
  757. // (also because that's what 16-bit OLE 2.01 shipped with).
  758. //
  759. //--------------------------------------------------------------------------
  760. STDAPI_(DWORD) UrlMkBuildVersion( VOID )
  761. {
  762. WORD wLowWord;
  763. WORD wHighWord;
  764. wHighWord = 23;
  765. //wLowWord = rmm; // from ih\verole.h
  766. wLowWord = 1; // from ih\verole.h
  767. //Win4Assert(wHighWord == 23 && "CoBuildVersion high word magic number");
  768. //Win4Assert(wLowWord > 639 && "CoBuildVersion low word not large enough");
  769. DWORD dwVersion;
  770. dwVersion = MAKELONG(wLowWord, wHighWord);
  771. return dwVersion;
  772. }
  773. //+---------------------------------------------------------------------------
  774. //
  775. // Function: GetUAInfoString
  776. //
  777. // Synopsis: Creates the extra UA header string
  778. //
  779. // Arguments:
  780. //
  781. // Returns: pointer to newly allocated string
  782. //
  783. // History: 5-27-96 JoeS (Joe Souza) Created
  784. //
  785. // Notes:
  786. //
  787. //----------------------------------------------------------------------------
  788. LPSTR GetUAInfoString(void)
  789. {
  790. BOOL bRet;
  791. CHAR szINTEL[] = "x86";
  792. CHAR szMIPS[] = "MIPS";
  793. CHAR szALPHA[] = "Alpha";
  794. CHAR szPPC[] = "PPC";
  795. CHAR *pszProcessorString = szINTEL;
  796. CHAR szExtraUAInfo[] = "UA-CPU: %s\r\n";
  797. #define SZUSERAGENTMAX 256
  798. static char vszBuffer[SZUSERAGENTMAX] = "";
  799. LPSTR pszTmp;
  800. BOOL fIsNT = FALSE;
  801. // Get all needed info.
  802. OSVERSIONINFO osvi;
  803. SYSTEM_INFO si;
  804. {
  805. memset(&osvi, 0, sizeof(osvi));
  806. osvi.dwOSVersionInfoSize = sizeof(osvi);
  807. GetVersionEx(&osvi);
  808. if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
  809. {
  810. // We are running on NT
  811. fIsNT = TRUE;
  812. memset(&si, 0, sizeof(si));
  813. GetSystemInfo(&si);
  814. switch (si.wProcessorArchitecture)
  815. {
  816. case PROCESSOR_ARCHITECTURE_MIPS:
  817. pszProcessorString = szMIPS;
  818. break;
  819. case PROCESSOR_ARCHITECTURE_ALPHA:
  820. pszProcessorString = szALPHA;
  821. break;
  822. case PROCESSOR_ARCHITECTURE_PPC:
  823. pszProcessorString = szPPC;
  824. break;
  825. }
  826. }
  827. }
  828. // Build header string.
  829. wsprintf(vszBuffer, szExtraUAInfo, pszProcessorString);
  830. pszTmp = new CHAR [strlen(vszBuffer) + 1];
  831. if (pszTmp )
  832. {
  833. if(fIsNT && si.wProcessorArchitecture != PROCESSOR_ARCHITECTURE_INTEL )
  834. strcpy(pszTmp, vszBuffer);
  835. else
  836. pszTmp[0] = '\0';
  837. }
  838. return pszTmp;
  839. }
  840. #if DBG==1
  841. #include <sem.hxx>
  842. CMutexSem mxs;
  843. IDebugOut *v_pPProtDbgOut = NULL;
  844. IDebugOut *v_pTransDbgOut = NULL;
  845. IDebugOut *v_pUrlMkDbgOut = NULL;
  846. IDebugOut *v_pNotfDbgOut = NULL;
  847. IDebugOut *v_pEProtDbgOut = NULL;
  848. IDebugOut *v_pTNotfDbgOut = NULL;
  849. void UrlSpyFn(int iOption, const char *pscFormat, ...)
  850. {
  851. CLock lck(mxs);
  852. static char szOutBuffer[2048];
  853. static DWORD * apiLevel[] = { &UrlMkInfoLevel, &TransInfoLevel, &PProtInfoLevel, &NotfInfoLevel, &EProtInfoLevel, &TNotfInfoLevel };
  854. static IDebugOut ** apDbgOut[] = { &v_pUrlMkDbgOut, &v_pTransDbgOut, &v_pPProtDbgOut,&v_pNotfDbgOut, &v_pEProtDbgOut, &v_pTNotfDbgOut };
  855. int iIndex = iOption >> DEB_LEVEL_SHIFT;
  856. int iLevel = *apiLevel[iIndex];
  857. if ((iOption & iLevel) == 0)
  858. return;
  859. DWORD tid = GetCurrentThreadId();
  860. DWORD cbBufLen;
  861. IDebugOut * pDbgOut = *apDbgOut[iIndex];
  862. wsprintf(szOutBuffer, "%08x> ", tid);
  863. cbBufLen = strlen(szOutBuffer);
  864. va_list args;
  865. va_start(args, pscFormat);
  866. vsprintf(szOutBuffer + cbBufLen, pscFormat, args);
  867. va_end(args);
  868. UrlSpySendEntry(pDbgOut, szOutBuffer, tid, iOption & DEB_LEVEL_MASK, 0);
  869. }
  870. void PerfDbgLogFn(int tag, void * pvObj, const char * pchFmt, ...)
  871. {
  872. CLock lck(mxs);
  873. static char szOutBuffer[2048];
  874. static DWORD * apiLevel[] = { &UrlMkInfoLevel, &TransInfoLevel, &PProtInfoLevel, &NotfInfoLevel, &EProtInfoLevel, &TNotfInfoLevel };
  875. static IDebugOut ** apDbgOut[] = { &v_pUrlMkDbgOut, &v_pTransDbgOut, &v_pPProtDbgOut, &v_pEProtDbgOut };
  876. int iIndex = min(tag >> DEB_LEVEL_SHIFT, 2);
  877. int iLevel = *apiLevel[iIndex];
  878. if ((tag & iLevel) == 0)
  879. return;
  880. DWORD tid = GetCurrentThreadId();
  881. DWORD cbBufLen;
  882. IDebugOut * pDbgOut = *apDbgOut[iIndex];
  883. sprintf(szOutBuffer, "%08x> %p %s", tid, pvObj,
  884. *pchFmt == '+' ? "_IN " : (*pchFmt == '-' ? "OUT " : ""));
  885. cbBufLen = strlen(szOutBuffer);
  886. if (*pchFmt == '+' || *pchFmt == '-')
  887. pchFmt += 1;
  888. va_list args;
  889. va_start(args, pchFmt);
  890. vsprintf(szOutBuffer + cbBufLen, pchFmt, args);
  891. lstrcat(szOutBuffer, "\n");
  892. va_end(args);
  893. UrlSpySendEntry(pDbgOut, szOutBuffer, tid, tag & DEB_LEVEL_MASK, 0);
  894. }
  895. void UrlSpySendEntry(IDebugOut *pDbgOut, LPSTR szOutBuffer, DWORD ThreadId, DWORD dwFlags, DWORD dwReserved)
  896. {
  897. if (pDbgOut)
  898. {
  899. pDbgOut->SendEntry(ThreadId, dwFlags, szOutBuffer, dwReserved);
  900. }
  901. else
  902. {
  903. OutputDebugString(szOutBuffer);
  904. }
  905. }
  906. HRESULT RegisterDebugOut(LPCWSTR pwzName, DWORD dwOptions, IDebugOut *pDbgOut, DWORD dwReserved)
  907. {
  908. if (pwzName)
  909. {
  910. if (!wcsicmp(pwzName, L"UrlMk"))
  911. {
  912. UrlMkInfoLevel = dwOptions;
  913. if (v_pUrlMkDbgOut)
  914. {
  915. v_pUrlMkDbgOut->Release();
  916. v_pUrlMkDbgOut = NULL;
  917. }
  918. if (pDbgOut)
  919. {
  920. v_pUrlMkDbgOut = pDbgOut;
  921. pDbgOut->AddRef();
  922. }
  923. }
  924. if (!wcsicmp(pwzName, L"Trans"))
  925. {
  926. TransInfoLevel = dwOptions;
  927. if (v_pTransDbgOut)
  928. {
  929. v_pTransDbgOut->Release();
  930. v_pTransDbgOut = NULL;
  931. }
  932. if (pDbgOut)
  933. {
  934. v_pTransDbgOut = pDbgOut;
  935. pDbgOut->AddRef();
  936. }
  937. }
  938. if (!wcsicmp(pwzName, L"PProt"))
  939. {
  940. PProtInfoLevel = dwOptions;
  941. if (v_pPProtDbgOut)
  942. {
  943. v_pPProtDbgOut->Release();
  944. v_pPProtDbgOut = NULL;
  945. }
  946. if (pDbgOut)
  947. {
  948. v_pPProtDbgOut = pDbgOut;
  949. pDbgOut->AddRef();
  950. }
  951. }
  952. if (!wcsicmp(pwzName, L"Notf"))
  953. {
  954. NotfInfoLevel = dwOptions;
  955. if (v_pNotfDbgOut)
  956. {
  957. v_pNotfDbgOut->Release();
  958. v_pNotfDbgOut = NULL;
  959. }
  960. if (pDbgOut)
  961. {
  962. v_pNotfDbgOut = pDbgOut;
  963. pDbgOut->AddRef();
  964. }
  965. }
  966. if (!wcsicmp(pwzName, L"EProt"))
  967. {
  968. EProtInfoLevel = dwOptions;
  969. if (v_pEProtDbgOut)
  970. {
  971. v_pEProtDbgOut->Release();
  972. v_pEProtDbgOut = NULL;
  973. }
  974. if (pDbgOut)
  975. {
  976. v_pEProtDbgOut = pDbgOut;
  977. pDbgOut->AddRef();
  978. }
  979. }
  980. if (!wcsicmp(pwzName, L"TNotf"))
  981. {
  982. TNotfInfoLevel = dwOptions;
  983. if (v_pTNotfDbgOut)
  984. {
  985. v_pTNotfDbgOut->Release();
  986. v_pTNotfDbgOut = NULL;
  987. }
  988. if (pDbgOut)
  989. {
  990. v_pTNotfDbgOut = pDbgOut;
  991. pDbgOut->AddRef();
  992. }
  993. }
  994. }
  995. return NOERROR;
  996. }
  997. #endif //DBG==1
  998. /*
  999. const REGENTRY rgClassesRes[] =
  1000. {
  1001. //***** PROTOCOL_RES ENTRIES *****
  1002. STD_ENTRY(PROTOCOL_RES_CLSID_REGKEY, PROTOCOL_RES_DESCRIP),
  1003. STD_ENTRY(PROTOCOL_RES_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  1004. { KEYTYPE_STRING, PROTOCOL_RES_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  1005. };
  1006. */
  1007. /*
  1008. const REGENTRY rgClasses[] =
  1009. {
  1010. //***** URLMONIKER ENTRIES *****
  1011. STD_ENTRY(URLMONIKER_CLSID_REGKEY, URLMONIKER_DESCRIP),
  1012. STD_ENTRY(URLMONIKER_CLSID_REGKEY"\\InprocServer32", "%s"URLMON_NAME),
  1013. { KEYTYPE_STRING, URLMONIKER_CLSID_REGKEY"\\InprocServer32", "ThreadingModel", REG_SZ, (BYTE*)"Apartment" },
  1014. };
  1015. */