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.

107 lines
2.9 KiB

  1. // mswmdm.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f mswmdmps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "resource.h"
  7. #include "initguid.h"
  8. #include "mswmdm.h"
  9. #include "mswmdm_i.c"
  10. #include "MediaDevMgr.h"
  11. #include "Device.h"
  12. #include "Storage.h"
  13. #include "StorageGlobal.h"
  14. #include "WMDMDeviceEnum.h"
  15. CComModule _Module;
  16. BEGIN_OBJECT_MAP(ObjectMap)
  17. OBJECT_ENTRY(CLSID_MediaDevMgr, CMediaDevMgr)
  18. // OBJECT_ENTRY(CLSID_WMDMDevice, CWMDMDevice)
  19. // OBJECT_ENTRY(CLSID_WMDMStorage, CWMDMStorage)
  20. // OBJECT_ENTRY(CLSID_WMDMStorageGlobal, CWMDMStorageGlobal)
  21. //BJECT_ENTRY(CLSID_WMDMDeviceEnum, CWMDMDeviceEnum)
  22. END_OBJECT_MAP()
  23. /////////////////////////////////////////////////////////////////////////////
  24. // DLL Entry Point
  25. extern "C"
  26. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  27. {
  28. if (dwReason == DLL_PROCESS_ATTACH)
  29. {
  30. _Module.Init(ObjectMap, hInstance);
  31. DisableThreadLibraryCalls(hInstance);
  32. }
  33. else if (dwReason == DLL_PROCESS_DETACH)
  34. _Module.Term();
  35. return TRUE; // ok
  36. }
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Used to determine whether the DLL can be unloaded by OLE
  39. STDAPI DllCanUnloadNow(void)
  40. {
  41. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. // Returns a class factory to create an object of the requested type
  45. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  46. {
  47. HRESULT hr = S_OK;
  48. //
  49. // Purpose : THis is used so that the Shell team can use WMDM in the "Both"
  50. // threading model while WMP uses us via the Free threading model. This
  51. // class factory implementation simply delagates and uses the old class factory
  52. // of MediaDevMgr ONLY IF the new CLSID was used to CoCreate WMDM.
  53. //
  54. if( IsEqualGUID( rclsid, __uuidof(MediaDevMgrClassFactory) ) )
  55. {
  56. CComMediaDevMgrClassFactory *pNewClassFactory = NULL;
  57. hr = CComMediaDevMgrClassFactory::CreateInstance( &pNewClassFactory );
  58. CComPtr<IClassFactory> spClassFactory = pNewClassFactory;
  59. if( SUCCEEDED( hr ) )
  60. {
  61. hr = spClassFactory->QueryInterface( riid, ppv );
  62. }
  63. }
  64. else
  65. {
  66. hr = _Module.GetClassObject(rclsid, riid, ppv);
  67. }
  68. return( hr );
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // DllRegisterServer - Adds entries to the system registry
  72. STDAPI DllRegisterServer(void)
  73. {
  74. // registers object, typelib and all interfaces in typelib
  75. return _Module.RegisterServer(TRUE);
  76. }
  77. /////////////////////////////////////////////////////////////////////////////
  78. // DllUnregisterServer - Removes entries from the system registry
  79. STDAPI DllUnregisterServer(void)
  80. {
  81. _Module.UnregisterServer();
  82. return S_OK;
  83. }