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.

187 lines
4.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 2000
  5. //
  6. // File: D L L M A I N . C P P
  7. //
  8. // Contents: DLL entry points for hnetcfg.dll
  9. //
  10. // Notes:
  11. //
  12. // Author: jonburs 22 May 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "dlldatax.h"
  18. #ifdef _MERGE_PROXYSTUB
  19. extern "C" HINSTANCE hProxyDll;
  20. #endif
  21. // extern
  22. extern void SetSAUIhInstance (HINSTANCE hInstance); // in saui.cpp
  23. // Global
  24. CComModule _Module;
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(CLSID_UPnPNAT, CUPnPNAT)
  27. OBJECT_ENTRY(CLSID_HNetCfgMgr, CHNetCfgMgr)
  28. OBJECT_ENTRY(CLSID_NetSharingManager, CNetSharingManager)
  29. OBJECT_ENTRY(CLSID_AlgSetup, CAlgSetup)
  30. END_OBJECT_MAP()
  31. HRESULT
  32. CompileMof(
  33. );
  34. //+---------------------------------------------------------------------------
  35. // DLL Entry Point
  36. //
  37. EXTERN_C
  38. BOOL
  39. WINAPI
  40. DllMain(
  41. HINSTANCE hInstance,
  42. DWORD dwReason,
  43. LPVOID pvReserved
  44. )
  45. {
  46. if ( !PrxDllMain(hInstance, dwReason, pvReserved) )
  47. {
  48. return FALSE;
  49. }
  50. if (dwReason == DLL_PROCESS_ATTACH)
  51. {
  52. ::DisableThreadLibraryCalls(hInstance);
  53. _Module.Init(ObjectMap, hInstance, &LIBID_NETCONLib);
  54. InitializeOemApi( hInstance );
  55. SetSAUIhInstance (hInstance);
  56. EnableOEMExceptionHandling();
  57. EnableNATExceptionHandling();
  58. }
  59. else if (dwReason == DLL_PROCESS_DETACH)
  60. {
  61. _Module.Term();
  62. ReleaseOemApi();
  63. DisableOEMExceptionHandling();
  64. DisableNATExceptionHandling();
  65. } else if (dwReason == DLL_THREAD_ATTACH) {
  66. EnableOEMExceptionHandling();
  67. EnableNATExceptionHandling();
  68. } else if (dwReason == DLL_THREAD_DETACH) {
  69. DisableOEMExceptionHandling();
  70. DisableNATExceptionHandling();
  71. }
  72. return TRUE;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // Used to determine whether the DLL can be unloaded by OLE
  76. STDAPI DllCanUnloadNow(VOID)
  77. {
  78. if ( PrxDllCanUnloadNow() != S_OK )
  79. {
  80. return S_FALSE;
  81. }
  82. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  83. }
  84. /////////////////////////////////////////////////////////////////////////////
  85. // Returns a class factory to create an object of the requested type
  86. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  87. {
  88. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  89. {
  90. return S_OK;
  91. }
  92. return _Module.GetClassObject(rclsid, riid, ppv);
  93. }
  94. static BOOL IsAllowedOS (void)
  95. { // (mostly cut-n-pasted from ...\net\config\common\ncbase\ncperms.cpp)
  96. #ifndef _WIN64 // On IA64, all homenet technologies are unavailable.
  97. // Look for the enterprise SKUs
  98. OSVERSIONINFOEXW verInfo = {0};
  99. ULONGLONG ConditionMask = 0;
  100. verInfo.dwOSVersionInfoSize = sizeof(verInfo);
  101. verInfo.wSuiteMask = VER_SUITE_DATACENTER |
  102. VER_SUITE_BACKOFFICE |
  103. VER_SUITE_SMALLBUSINESS_RESTRICTED |
  104. VER_SUITE_SMALLBUSINESS |
  105. VER_SUITE_BLADE;
  106. VER_SET_CONDITION(ConditionMask, VER_SUITENAME, VER_OR);
  107. if(VerifyVersionInfo(&verInfo, VER_SUITENAME, ConditionMask))
  108. return FALSE;
  109. return TRUE;
  110. #else
  111. return FALSE;
  112. #endif
  113. }
  114. //+---------------------------------------------------------------------------
  115. // DllRegisterServer - Adds entries to the system registry
  116. //
  117. STDAPI
  118. DllRegisterServer()
  119. {
  120. HRESULT hr = PrxDllRegisterServer();
  121. if ( FAILED(hr) )
  122. return hr;
  123. /* replaced with code below
  124. hr = _Module.RegisterServer(TRUE);
  125. */
  126. // don't register NetSharingManager on DTC, SBS, WebBlade SKUs.
  127. hr = _Module.RegisterServer(TRUE, &CLSID_UPnPNAT);
  128. if (SUCCEEDED(hr))
  129. hr = _Module.RegisterServer(TRUE, &CLSID_HNetCfgMgr);
  130. if (SUCCEEDED(hr))
  131. hr = _Module.RegisterServer(TRUE, &CLSID_AlgSetup);
  132. if (SUCCEEDED(hr))
  133. if (IsAllowedOS())
  134. hr = _Module.RegisterServer(TRUE, &CLSID_NetSharingManager);
  135. if (SUCCEEDED(hr)) // register second typelib
  136. hr = _Module.RegisterTypeLib (_T("\\2"));
  137. return hr;
  138. }
  139. //+---------------------------------------------------------------------------
  140. // DllUnregisterServer - Removes entries from the system registry
  141. //
  142. STDAPI
  143. DllUnregisterServer()
  144. {
  145. PrxDllUnregisterServer();
  146. _Module.UnregisterServer(TRUE);
  147. _Module.UnRegisterTypeLib (_T("\\2"));
  148. return S_OK;
  149. }