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.

119 lines
3.3 KiB

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