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.

129 lines
3.7 KiB

  1. // RDCHost.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 RDCHost.idl by adding the following
  17. // files to the Outputs.
  18. // RDCHost_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f RDCHostps.mk in the project directory.
  22. #include "stdafx.h"
  23. #ifdef TRC_FILE
  24. #undef TRC_FILE
  25. #endif
  26. #define TRC_FILE "_rdchst"
  27. #include "resource.h"
  28. #include <initguid.h>
  29. #include "RDCHost.h"
  30. #include "dlldatax.h"
  31. #include "RDCHost_i.c"
  32. #include "RemoteDesktopClientHost.h"
  33. #include "RemoteDesktopClient.h"
  34. #include "TSRDPRemoteDesktopClient.h"
  35. #ifdef _MERGE_PROXYSTUB
  36. extern "C" HINSTANCE hProxyDll;
  37. #endif
  38. CComModule _Module;
  39. BEGIN_OBJECT_MAP(ObjectMap)
  40. OBJECT_ENTRY(CLSID_SAFRemoteDesktopClientHost, CRemoteDesktopClientHost)
  41. OBJECT_ENTRY(CLSID_SAFRemoteDesktopClient, CRemoteDesktopClient)
  42. OBJECT_ENTRY(CLSID_TSRDPRemoteDesktopClient, CTSRDPRemoteDesktopClient)
  43. END_OBJECT_MAP()
  44. /////////////////////////////////////////////////////////////////////////////
  45. // DLL Entry Point
  46. extern "C"
  47. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  48. {
  49. lpReserved;
  50. #ifdef _MERGE_PROXYSTUB
  51. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  52. return FALSE;
  53. #endif
  54. if (dwReason == DLL_PROCESS_ATTACH)
  55. {
  56. _Module.Init(ObjectMap, hInstance, &LIBID_RDCCLIENTHOSTLib);
  57. DisableThreadLibraryCalls(hInstance);
  58. }
  59. else if (dwReason == DLL_PROCESS_DETACH)
  60. _Module.Term();
  61. return TRUE; // ok
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Used to determine whether the DLL can be unloaded by OLE
  65. STDAPI DllCanUnloadNow(void)
  66. {
  67. #ifdef _MERGE_PROXYSTUB
  68. if (PrxDllCanUnloadNow() != S_OK)
  69. return S_FALSE;
  70. #endif
  71. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  72. }
  73. /////////////////////////////////////////////////////////////////////////////
  74. // Returns a class factory to create an object of the requested type
  75. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  76. {
  77. #ifdef _MERGE_PROXYSTUB
  78. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  79. return S_OK;
  80. #endif
  81. return _Module.GetClassObject(rclsid, riid, ppv);
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. // DllRegisterServer - Adds entries to the system registry
  85. STDAPI DllRegisterServer(void)
  86. {
  87. #ifdef _MERGE_PROXYSTUB
  88. HRESULT hRes = PrxDllRegisterServer();
  89. if (FAILED(hRes))
  90. return hRes;
  91. #endif
  92. // registers object, typelib and all interfaces in typelib
  93. return _Module.RegisterServer(TRUE);
  94. }
  95. /////////////////////////////////////////////////////////////////////////////
  96. // DllUnregisterServer - Removes entries from the system registry
  97. STDAPI DllUnregisterServer(void)
  98. {
  99. #ifdef _MERGE_PROXYSTUB
  100. PrxDllUnregisterServer();
  101. #endif
  102. return _Module.UnregisterServer(TRUE);
  103. }
  104. #include "RemoteDesktopClient.h"
  105. #include "TSRDPRemoteDesktopClient.h"