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.

99 lines
2.5 KiB

  1. // Dglogs.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f Dglogsps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "dglogsres.h"
  7. #include <initguid.h>
  8. #include "Dglogs.h"
  9. #include "Dglogs_i.c"
  10. #include "DglogsCom.h"
  11. #include "Diagnostics.h"
  12. #include <netsh.h>
  13. DWORD WINAPI
  14. InitHelperDllEx(
  15. IN DWORD dwNetshVersion,
  16. OUT PVOID pReserved
  17. );
  18. DWORD WINAPI
  19. InitHelperDll(
  20. IN DWORD dwNetshVersion,
  21. OUT PVOID pReserved
  22. )
  23. {
  24. return InitHelperDllEx(dwNetshVersion,pReserved);
  25. }
  26. //extern GUID CLSID_Dgnet;
  27. CComModule _Module;
  28. BEGIN_OBJECT_MAP(ObjectMap)
  29. OBJECT_ENTRY(CLSID_DglogsCom, CDglogsCom)
  30. //OBJECT_ENTRY(CLSID_Dgnet, CGotNet)
  31. END_OBJECT_MAP()
  32. HMODULE g_hModule;
  33. CDiagnostics g_Diagnostics;
  34. //STDAPI RegisterhNetshHelper();
  35. //STDAPI UnRegisterNetShHelper();
  36. /////////////////////////////////////////////////////////////////////////////
  37. // DLL Entry Point
  38. extern "C"
  39. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  40. {
  41. if (dwReason == DLL_PROCESS_ATTACH)
  42. {
  43. _Module.Init(ObjectMap, hInstance, &LIBID_DGLOGSLib);
  44. DisableThreadLibraryCalls(hInstance);
  45. g_hModule = (HMODULE) hInstance;
  46. }
  47. else if (dwReason == DLL_PROCESS_DETACH)
  48. _Module.Term();
  49. return TRUE; // ok
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Used to determine whether the DLL can be unloaded by OLE
  53. STDAPI DllCanUnloadNow(void)
  54. {
  55. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Returns a class factory to create an object of the requested type
  59. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  60. {
  61. return _Module.GetClassObject(rclsid, riid, ppv);
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // DllRegisterServer - Adds entries to the system registry
  65. STDAPI DllRegisterServer(void)
  66. {
  67. // Register with Netsh
  68. // registers object, typelib and all interfaces in typelib
  69. return _Module.RegisterServer(TRUE);
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. // DllUnregisterServer - Removes entries from the system registry
  73. STDAPI DllUnregisterServer(void)
  74. {
  75. return _Module.UnregisterServer(TRUE);
  76. }