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.

90 lines
2.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Hardware Event Detector
  3. ///////////////////////////////////////////////////////////////////////////////
  4. #ifndef _SHHWDTCT_H
  5. #define _SHHWDTCT_H
  6. #include "unk.h"
  7. #include "service.h"
  8. #include "namellst.h"
  9. #include <dbt.h>
  10. #define HINT_NONE 0
  11. #define HINT_NEW 1
  12. extern const CLSID CLSID_HWEventDetector;
  13. class CHWEventDetectorImpl : public CCOMBase, public IService
  14. {
  15. public:
  16. // Interface IService
  17. STDMETHODIMP InitMinimum(DWORD cArg, LPWSTR* ppszArgs,
  18. LPCWSTR pszEventRelinquishControl, DWORD* pdwCtrlAccept,
  19. BOOL* pfWantsDeviceEvents);
  20. STDMETHODIMP InitDeviceEventHandler(SERVICE_STATUS_HANDLE ssh);
  21. STDMETHODIMP InitFinal();
  22. STDMETHODIMP Run();
  23. // return S_FALSE and a non-zero dwWaitHint if pending
  24. STDMETHODIMP HandleServiceControl(DWORD dwControlCode, DWORD* pdwWaitHint);
  25. STDMETHODIMP HandlePowerEvent(DWORD dwEventType, LPVOID pEventData);
  26. STDMETHODIMP HandleDeviceEvent(DWORD dwEventType, LPVOID pEventData);
  27. STDMETHODIMP HandleHWProfileEvent(DWORD dwEventType, LPVOID pEventData);
  28. STDMETHODIMP HandleSessionChange(DWORD dwEventType, LPVOID pvEventData);
  29. public:
  30. CHWEventDetectorImpl();
  31. ~CHWEventDetectorImpl();
  32. static HRESULT HandleVolumeMediaEvent(LPCWSTR pszDeviceIDVolume,
  33. class CHWDeviceInst* phwdevinst, LPCWSTR pszEventType,
  34. BOOL* pfHasHandler);
  35. private:
  36. HRESULT _HandleInterfaceEvent(DEV_BROADCAST_DEVICEINTERFACE* pdbdi,
  37. DWORD dwEventType);
  38. HRESULT _HandleBroadcastHandleEvent(DEV_BROADCAST_HANDLE* pdbh,
  39. DWORD dwEventType);
  40. HRESULT _RegisterForNotif();
  41. HRESULT _UnregisterForNotif();
  42. // COM Server stuff
  43. HRESULT _RegisterFactories();
  44. HRESULT _UnregisterFactories();
  45. HRESULT _SuspendFactories();
  46. HRESULT _ResumeFactories();
  47. private:
  48. HANDLE _hEventRelinquishControl;
  49. HDEVNOTIFY _hdevnotifyAllInterfaces;
  50. HANDLE _hEventInitCompleted;
  51. #ifdef DEBUG
  52. void _DbgAssertValidState();
  53. #endif
  54. };
  55. typedef CUnkTmpl<CHWEventDetectorImpl> CHWEventDetector;
  56. // for now
  57. HRESULT _ExecuteHandler(LPCWSTR pszDeviceID, LPCWSTR pszEventType,
  58. LPCWSTR pszHandler);
  59. HRESULT _FinalDispatch(LPCWSTR pszDeviceIntfID, LPCWSTR pszEventType,
  60. LPCWSTR pszEventHandler);
  61. HRESULT _DispatchToHandler(LPCWSTR pszDeviceIntfID,
  62. class CHWDeviceInst* phwdevinst, LPCWSTR pszEventType,
  63. BOOL* pfHasHandler);
  64. HRESULT _ProcessInterfaceSpecialCased(GUID* pguidInterface,
  65. LPCWSTR pszDeviceID, DWORD dwEventType);
  66. HRESULT _IsInterfaceSpecialCased(GUID* pguidClass, BOOL* pfSpecialCased);
  67. HRESULT _TryAutoplay(LPCWSTR pszDeviceIntfID, CHWDeviceInst* phwdevinst,
  68. DWORD dwEventType);
  69. #endif // _SHHWDTCT_H