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.

295 lines
8.6 KiB

  1. // iextag.cpp : Implementation file for code common to all xtags..
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f ccapsps.mk in the project directory.
  5. #include <w95wraps.h>
  6. #include "headers.h"
  7. #pragma MARK_DATA(__FILE__)
  8. #pragma MARK_CODE(__FILE__)
  9. #pragma MARK_CONST(__FILE__)
  10. #include "resource.h"
  11. #include "initguid.h"
  12. #include "iextag.h"
  13. #include "peerfact.h"
  14. #include "ccaps.h"
  15. #include "homepg.h"
  16. #include "download.h"
  17. #ifndef __X_HTMLAREA_HXX_
  18. #define __X_HTMLAREA_HXX_
  19. #include "htmlarea.hxx"
  20. #endif
  21. #ifndef __X_SELECT_HXX_
  22. #define __X_SELECT_HXX_
  23. #include "select.hxx"
  24. #endif
  25. #ifndef __X_SELITEM_HXX_
  26. #define __X_SELITEM_HXX_
  27. #include "selitem.hxx"
  28. #endif
  29. #ifndef __X_COMBOBOX_HXX_
  30. #define __X_COMBOBOX_HXX_
  31. #include "combobox.hxx"
  32. #endif
  33. #ifndef __X_CHECKBOX_HXX_
  34. #define __X_CHECKBOX_HXX_
  35. #include "checkbox.hxx"
  36. #endif
  37. #ifndef __X_RADIO_HXX_
  38. #define __X_RADIO_HXX_
  39. #include "radio.hxx"
  40. #endif
  41. #ifndef __X_USERDATA_HXX_
  42. #define __X_USERDATA_HXX_
  43. #include "userdata.hxx"
  44. #endif
  45. #ifndef __X_RECTPEER_HXX_
  46. #define __X_RECTPEER_HXX_
  47. #include "rectpeer.hxx"
  48. #endif
  49. #ifndef __X_DEVICERECT_HXX_
  50. #define __X_DEVICERECT_HXX_
  51. #include "devicerect.hxx"
  52. #endif
  53. #ifndef __X_TMPPRINT_HXX_
  54. #define __X_TMPPRINT_HXX_
  55. #include "tmpprint.hxx"
  56. #endif
  57. #ifndef __X_HEADFOOT_HXX_
  58. #define __X_HEADFOOT_HXX_
  59. #include "headfoot.hxx"
  60. #endif
  61. #ifndef __X_SCROLLBAR_HXX_
  62. #define __X_SCROLLBAR_HXX_
  63. #include "scrllbar.hxx"
  64. #endif
  65. #ifndef __X_SPINBTTN_HXX_
  66. #define __X_SPINBTTN_HXX_
  67. #include "spinbttn.hxx"
  68. #endif
  69. #ifndef __X_SLIDEBAR_HXX_
  70. #define __X_SLIDEBAR_HXX_
  71. #include "slidebar.hxx"
  72. #endif
  73. #ifdef _ATL_STATIC_REGISTRY
  74. #include <statreg.h>
  75. #include <statreg.cpp>
  76. #endif
  77. #include <atlimpl.cpp>
  78. #if 1
  79. // this is according to IE5 bug 65301. (richards, alexz).
  80. #if _MSC_VER < 1200
  81. #pragma comment(linker, "/merge:.CRT=.data")
  82. #endif
  83. #endif
  84. #include "shfusion.h"
  85. CComModule _Module;
  86. BEGIN_OBJECT_MAP(ObjectMap)
  87. OBJECT_ENTRY(CLSID_PeerFactory, CPeerFactory)
  88. OBJECT_ENTRY(CLSID_ClientCaps, CClientCaps)
  89. OBJECT_ENTRY(CLSID_HomePage, CHomePage)
  90. OBJECT_ENTRY(CLSID_CDownloadBehavior, CDownloadBehavior)
  91. OBJECT_ENTRY(CLSID_CCombobox, CCombobox)
  92. OBJECT_ENTRY(CLSID_CIESelectElement, CIESelectElement)
  93. OBJECT_ENTRY(CLSID_CIEOptionElement, CIEOptionElement)
  94. OBJECT_ENTRY(CLSID_CHtmlArea, CHtmlArea)
  95. OBJECT_ENTRY(CLSID_CCheckBox, CCheckBox)
  96. OBJECT_ENTRY(CLSID_CRadioButton, CRadioButton)
  97. OBJECT_ENTRY(CLSID_CLayoutRect, CLayoutRect)
  98. OBJECT_ENTRY(CLSID_CDeviceRect, CDeviceRect)
  99. OBJECT_ENTRY(CLSID_CTemplatePrinter, CTemplatePrinter)
  100. OBJECT_ENTRY(CLSID_CHeaderFooter, CHeaderFooter)
  101. OBJECT_ENTRY(CLSID_CScrollBar, CScrollBar)
  102. OBJECT_ENTRY(CLSID_CSpinButton, CSpinButton)
  103. OBJECT_ENTRY(CLSID_CSliderBar, CSliderBar)
  104. END_OBJECT_MAP()
  105. HINSTANCE g_hInst = NULL;
  106. BOOL g_fUnicodePlatform;
  107. DWORD g_dwPlatformVersion; // (dwMajorVersion << 16) + (dwMinorVersion)
  108. DWORD g_dwPlatformID; // VER_PLATFORM_WIN32S/WIN32_WINDOWS/WIN32_WINNT
  109. DWORD g_dwPlatformBuild; // Build number
  110. BOOL g_fUseShell32InsteadOfSHFolder;
  111. // ISSUE: (alexz) find out why ATL leaks during registration and then remove usage of g_fDisableMemLeakReport
  112. #if DBG == 1
  113. BOOL g_fDisableMemLeakReport = FALSE;
  114. #endif
  115. /////////////////////////////////////////////////////////////////////////////
  116. // DLL Entry Point
  117. extern "C"
  118. BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  119. {
  120. switch (dwReason)
  121. {
  122. case DLL_PROCESS_ATTACH:
  123. {
  124. SHFusionInitializeFromModule((HMODULE)hInstance);
  125. OSVERSIONINFOA vi;
  126. #ifdef UNIX // Unix setup program doesn't invoke COM. Needs to do it here.
  127. CoInitialize(NULL);
  128. #endif // Unix
  129. vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
  130. GetVersionExA(&vi);
  131. g_dwPlatformVersion = (vi.dwMajorVersion << 16) + vi.dwMinorVersion;
  132. g_dwPlatformID = vi.dwPlatformId;
  133. g_dwPlatformBuild = vi.dwBuildNumber;
  134. g_fUnicodePlatform = ( g_dwPlatformID == VER_PLATFORM_WIN32_NT );
  135. // || vi.dwPlatformId == VER_PLATFORM_WIN32_UNIX);
  136. // NOTE: On Millennium or W2k we should use Shell32 for
  137. // SHGetFolderPath instead of SHFolder.
  138. g_fUseShell32InsteadOfSHFolder = (VER_PLATFORM_WIN32_WINDOWS == g_dwPlatformID
  139. && (g_dwPlatformVersion >= 0x0004005a))
  140. || (VER_PLATFORM_WIN32_NT == g_dwPlatformID
  141. && g_dwPlatformVersion >= 0x00050000);
  142. g_hInst = (HINSTANCE)hInstance;
  143. _Module.Init(ObjectMap, (HINSTANCE)hInstance);
  144. DisableThreadLibraryCalls((HINSTANCE)hInstance);
  145. CPersistUserData::GlobalInit();
  146. #ifdef UNIX
  147. CoUninitialize();
  148. #endif // Unix
  149. }
  150. break;
  151. case DLL_PROCESS_DETACH:
  152. CPersistUserData::GlobalUninit();
  153. _Module.Term();
  154. #if DBG == 1
  155. #ifndef UNIX // UNIX doesn't have _CrtDumpMemoryLeaks yet.
  156. if (!g_fDisableMemLeakReport && _CrtDumpMemoryLeaks())
  157. {
  158. if (IDYES == MessageBoxA (
  159. NULL,
  160. "MEMORY LEAKS DETECTED\r\n\r\n"
  161. "Break for instructions how to track the leaks?",
  162. "IEPEERS.DLL",
  163. MB_YESNO | MB_SETFOREGROUND))
  164. {
  165. DebugBreak();
  166. //
  167. // How to track the leaks:
  168. //
  169. // Step 1. Look for trace of memory leaks in debug output window, e.g.:
  170. //
  171. // Dumping objects ->
  172. // ...
  173. // {42} normal block at 0x01A00CC0, 226 bytes long.
  174. // Data: <m o n k e y w > 6D 00 6F 00 6E 00 6B 00 65 00 79 00 20 00 77 00
  175. // ...
  176. //
  177. // interesting info: block with serial number 42 leaked
  178. //
  179. // Step 2. Set breakpoint inside debug allocator on block number 42 using one of the
  180. // following methods:
  181. // - set break point in DLL_PROCESS_ATTACH case above, go to QuickWatch window,
  182. // and evaluate expression "_CrtSetBreakAlloc(42)"; or
  183. // - set break point in DLL_PROCESS_ATTACH case above, and set variable _crtBreakAlloc
  184. // global debug variable to 42; or
  185. // - place a call "_CrtSetBreakAlloc(42)" in DLL_PROCESS_ATTACH case above,
  186. // recompile and run.
  187. }
  188. }
  189. #endif // UNIX
  190. #endif
  191. SHFusionUninitialize();
  192. break;
  193. }
  194. return TRUE; // ok
  195. }
  196. /////////////////////////////////////////////////////////////////////////////
  197. // Used to determine whether the DLL can be unloaded by OLE
  198. STDAPI DllCanUnloadNow(void)
  199. {
  200. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  201. }
  202. /////////////////////////////////////////////////////////////////////////////
  203. // Returns a class factory to create an object of the requested type
  204. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  205. {
  206. return _Module.GetClassObject(rclsid, riid, ppv);
  207. }
  208. /////////////////////////////////////////////////////////////////////////////
  209. // DllRegisterServer - Adds entries to the system registry
  210. STDAPI DllRegisterServer(void)
  211. {
  212. #if DBG == 1
  213. g_fDisableMemLeakReport = TRUE;
  214. #endif
  215. // registers object, typelib and all interfaces in typelib
  216. HRESULT hr = _Module.RegisterServer(TRUE);
  217. return hr;
  218. }
  219. /////////////////////////////////////////////////////////////////////////////
  220. // DllUnregisterServer - Removes entries from the system registry
  221. STDAPI DllUnregisterServer(void)
  222. {
  223. #if DBG == 1
  224. g_fDisableMemLeakReport = TRUE;
  225. #endif
  226. _Module.UnregisterServer();
  227. return S_OK;
  228. }
  229. STDAPI DllEnumClassObjects(int i, CLSID *pclsid, IUnknown **ppUnk)
  230. {
  231. if (i >= (sizeof(ObjectMap)/sizeof(ObjectMap[0])) - 1)
  232. {
  233. return S_FALSE;
  234. }
  235. *pclsid = *(ObjectMap[i].pclsid);
  236. return _Module.GetClassObject(*pclsid, IID_IUnknown, (LPVOID*)ppUnk);
  237. }