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.

114 lines
2.6 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. mdhcp.cpp
  5. Abstract:
  6. Implementation of DLL Exports.
  7. Author:
  8. */
  9. // Note: Proxy/Stub Information
  10. // To build a separate proxy/stub DLL,
  11. // run nmake -f mdhcpps.mk in the project directory.
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "initguid.h"
  15. #include "mdhcp.h"
  16. #include "CMDhcp.h"
  17. #include "scope.h"
  18. #include "lease.h"
  19. #ifdef DEBUG_HEAPS
  20. // ZoltanS: for heap debugging
  21. #include <crtdbg.h>
  22. #include <stdio.h>
  23. #endif // DEBUG_HEAPS
  24. CComModule _Module;
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(CLSID_McastAddressAllocation, CMDhcp)
  27. END_OBJECT_MAP()
  28. /////////////////////////////////////////////////////////////////////////////
  29. // DLL Entry Point
  30. extern "C"
  31. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  32. {
  33. if (dwReason == DLL_PROCESS_ATTACH)
  34. {
  35. #ifdef DEBUG_HEAPS
  36. // ZoltanS: turn on leak detection
  37. _CrtSetDbgFlag( _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF );
  38. // ZoltanS: force a memory leak
  39. char * leak = new char [ 1977 ];
  40. sprintf(leak, "mdhcp.dll NORMAL leak");
  41. leak = NULL;
  42. #endif // DEBUG_HEAPS
  43. _Module.Init(ObjectMap, hInstance);
  44. DisableThreadLibraryCalls(hInstance);
  45. #ifdef MSPLOG
  46. // Register for trace output.
  47. MSPLOGREGISTER(_T("mdhcp"));
  48. #endif // MSPLOG
  49. }
  50. else if (dwReason == DLL_PROCESS_DETACH)
  51. {
  52. #ifdef MSPLOG
  53. // Deregister for trace output.
  54. MSPLOGDEREGISTER();
  55. #endif // MSPLOG
  56. _Module.Term();
  57. }
  58. return TRUE; // ok
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Used to determine whether the DLL can be unloaded by OLE
  62. STDAPI DllCanUnloadNow(void)
  63. {
  64. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  65. }
  66. /////////////////////////////////////////////////////////////////////////////
  67. // Returns a class factory to create an object of the requested type
  68. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  69. {
  70. return _Module.GetClassObject(rclsid, riid, ppv);
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. // DllRegisterServer - Adds entries to the system registry
  74. STDAPI DllRegisterServer(void)
  75. {
  76. // registers object, typelib and all interfaces in typelib
  77. return _Module.RegisterServer(TRUE);
  78. }
  79. /////////////////////////////////////////////////////////////////////////////
  80. // DllUnregisterServer - Removes entries from the system registry
  81. STDAPI DllUnregisterServer(void)
  82. {
  83. _Module.UnregisterServer();
  84. return S_OK;
  85. }