Source code of Windows XP (NT5)
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.

130 lines
3.6 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. AttachDebuggerIfAsked(hInstance);
  59. }
  60. else if (dwReason == DLL_PROCESS_DETACH)
  61. _Module.Term();
  62. return TRUE; // ok
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // Used to determine whether the DLL can be unloaded by OLE
  66. STDAPI DllCanUnloadNow(void)
  67. {
  68. #ifdef _MERGE_PROXYSTUB
  69. if (PrxDllCanUnloadNow() != S_OK)
  70. return S_FALSE;
  71. #endif
  72. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // Returns a class factory to create an object of the requested type
  76. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  77. {
  78. #ifdef _MERGE_PROXYSTUB
  79. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  80. return S_OK;
  81. #endif
  82. return _Module.GetClassObject(rclsid, riid, ppv);
  83. }
  84. /////////////////////////////////////////////////////////////////////////////
  85. // DllRegisterServer - Adds entries to the system registry
  86. STDAPI DllRegisterServer(void)
  87. {
  88. #ifdef _MERGE_PROXYSTUB
  89. HRESULT hRes = PrxDllRegisterServer();
  90. if (FAILED(hRes))
  91. return hRes;
  92. #endif
  93. // registers object, typelib and all interfaces in typelib
  94. return _Module.RegisterServer(TRUE);
  95. }
  96. /////////////////////////////////////////////////////////////////////////////
  97. // DllUnregisterServer - Removes entries from the system registry
  98. STDAPI DllUnregisterServer(void)
  99. {
  100. #ifdef _MERGE_PROXYSTUB
  101. PrxDllUnregisterServer();
  102. #endif
  103. return _Module.UnregisterServer(TRUE);
  104. }
  105. #include "RemoteDesktopClient.h"
  106. #include "TSRDPRemoteDesktopClient.h"