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.

113 lines
3.3 KiB

  1. // SAFSessionResolver.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To merge the proxy/stub code into the object DLL, add the file
  4. // dlldatax.c to the project. Make sure precompiled headers
  5. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  6. // defines for the project.
  7. //
  8. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  9. // need to remove the following define from dlldatax.c
  10. // #define _WIN32_WINNT 0x0400
  11. //
  12. // Further, if you are running MIDL without /Oicf switch, you also
  13. // need to remove the following define from dlldatax.c.
  14. // #define USE_STUBLESS_PROXY
  15. //
  16. // Modify the custom build rule for SAFSessionResolver.idl by adding the following
  17. // files to the Outputs.
  18. // SAFSessionResolver_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f SAFSessionResolverps.mk in the project directory.
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include <initguid.h>
  25. #include "SAFSessionResolver.h"
  26. #include "SAFSessionResolver_i.c"
  27. #include "SessionResolver.h"
  28. #ifdef _MERGE_PROXYSTUB
  29. extern "C" HINSTANCE hProxyDll;
  30. #endif
  31. CComModule _Module;
  32. BEGIN_OBJECT_MAP(ObjectMap)
  33. OBJECT_ENTRY(CLSID_SessionResolver, CSessionResolver)
  34. END_OBJECT_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // DLL Entry Point
  37. extern "C"
  38. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  39. {
  40. lpReserved;
  41. #ifdef _MERGE_PROXYSTUB
  42. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  43. return FALSE;
  44. #endif
  45. if (dwReason == DLL_PROCESS_ATTACH)
  46. {
  47. _Module.Init(ObjectMap, hInstance, &LIBID_SAFSESSIONRESOLVERLib);
  48. DisableThreadLibraryCalls(hInstance);
  49. }
  50. else if (dwReason == DLL_PROCESS_DETACH)
  51. _Module.Term();
  52. return TRUE; // ok
  53. }
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Used to determine whether the DLL can be unloaded by OLE
  56. STDAPI DllCanUnloadNow(void)
  57. {
  58. #ifdef _MERGE_PROXYSTUB
  59. if (PrxDllCanUnloadNow() != S_OK)
  60. return S_FALSE;
  61. #endif
  62. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // Returns a class factory to create an object of the requested type
  66. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  67. {
  68. #ifdef _MERGE_PROXYSTUB
  69. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  70. return S_OK;
  71. #endif
  72. return _Module.GetClassObject(rclsid, riid, ppv);
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // DllRegisterServer - Adds entries to the system registry
  76. STDAPI DllRegisterServer(void)
  77. {
  78. #ifdef _MERGE_PROXYSTUB
  79. HRESULT hRes = PrxDllRegisterServer();
  80. if (FAILED(hRes))
  81. return hRes;
  82. #endif
  83. // registers object, typelib and all interfaces in typelib
  84. return _Module.RegisterServer(TRUE);
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. // DllUnregisterServer - Removes entries from the system registry
  88. STDAPI DllUnregisterServer(void)
  89. {
  90. #ifdef _MERGE_PROXYSTUB
  91. PrxDllUnregisterServer();
  92. #endif
  93. return _Module.UnregisterServer(TRUE);
  94. }