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.

146 lines
4.5 KiB

  1. /******************************************************************************
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. * evthandler.h
  7. *
  8. * Abstract:
  9. * CEventHandler class definition
  10. *
  11. * Revision History:
  12. * Brijesh Krishnaswami (brijeshk) 03/17/2000
  13. * created
  14. *
  15. *****************************************************************************/
  16. #ifndef _EVTHANDLER_H_
  17. #define _EVTHANDLER_H_
  18. #include "srrestoreptapi.h"
  19. #include "counter.h"
  20. typedef DWORD (WINAPI* WORKITEMFUNC)(PVOID);
  21. // shell notifications
  22. DWORD WINAPI OnDiskFree_200(PVOID pszDrive);
  23. DWORD WINAPI OnDiskFree_80(PVOID pszDrive);
  24. DWORD WINAPI OnDiskFree_50(PVOID pszDrive);
  25. DWORD WINAPI PostFilterIo(PVOID pNum);
  26. extern "C" void CALLBACK TimerCallback(PVOID, BOOLEAN);
  27. extern "C" void CALLBACK IoCompletionCallback(DWORD dwErrorCode,
  28. DWORD dwBytesTrns,
  29. LPOVERLAPPED pOverlapped);
  30. extern "C" void CALLBACK IdleRequestCallback(PVOID pContext, BOOLEAN fTimerFired);
  31. extern "C" void CALLBACK IdleStartCallback(PVOID pContext, BOOLEAN fTimerFired);
  32. extern "C" void CALLBACK IdleStopCallback(PVOID pContext, BOOLEAN fTimerFired);
  33. #define MAX_IOCTLS 5
  34. typedef struct _SR_OVERLAPPED
  35. {
  36. OVERLAPPED m_overlapped;
  37. HANDLE m_hDriver;
  38. DWORD m_dwRecordLength;
  39. PSR_NOTIFICATION_RECORD m_pRecord;
  40. } SR_OVERLAPPED, *LPSR_OVERLAPPED;
  41. class CEventHandler {
  42. public:
  43. CEventHandler();
  44. ~CEventHandler();
  45. // rpc functions
  46. DWORD DisableSRS(LPWSTR szDrive);
  47. DWORD EnableSRS(LPWSTR szDrive);
  48. DWORD DisableFIFOS(DWORD);
  49. DWORD EnableFIFOS();
  50. DWORD SRUpdateMonitoredListS(LPWSTR);
  51. DWORD SRUpdateDSSizeS(LPWSTR pszDrive, UINT64 ullSizeLimit);
  52. DWORD SRSwitchLogS();
  53. BOOL SRSetRestorePointS(PRESTOREPOINTINFOW, PSTATEMGRSTATUS);
  54. DWORD SRRemoveRestorePointS(DWORD);
  55. DWORD SRPrintStateS();
  56. // actions on the datastore
  57. DWORD OnReset(LPWSTR pszDrive); // filter initiated or DisableSRS/EnableSRS initiated
  58. DWORD OnFreeze(LPWSTR pszDrive); // filter initiated or OnLowDisk initiated
  59. DWORD OnThaw(LPWSTR pszDrive); // OnTimer initiated
  60. DWORD OnCompress(LPWSTR pszDrive); // OnIdle initiated
  61. DWORD OnFifo(LPWSTR pszDrive, DWORD dwTargetRp, int nPercent, BOOL fIncludeCurrentRp, BOOL fFifoAtleastOneRp);
  62. // filter initiated or timer initiated
  63. DWORD OnBoot(); // initialize all activity
  64. DWORD OnFirstRun();
  65. DWORD OnTimer(LPVOID, BOOL); // timer callback
  66. DWORD OnIdle();
  67. void OnStop(); // stop all activity
  68. // filter notifications
  69. void OnAny_Notification(DWORD dwErrorCode,
  70. DWORD dwBytesTrns,
  71. LPOVERLAPPED pOverlapped);
  72. void OnFirstWrite_Notification(LPWSTR pszDrive);
  73. void OnVolumeError_Notification(LPWSTR pszDrive, ULONG ulError);
  74. void OnSize_Notification(LPWSTR pszDrive, ULONG ulSize);
  75. DWORD WaitForStop( );
  76. void SignalStop( );
  77. DWORD XmlToBlob(LPWSTR);
  78. DWORD QueueWorkItem(WORKITEMFUNC pFunc, PVOID pv);
  79. void RefreshCurrentRp(BOOL fScanAllDrives);
  80. CCounter* GetCounter() {
  81. return &m_Counter;
  82. }
  83. CLock* GetLock() {
  84. return &m_DSLock;
  85. }
  86. CRestorePoint m_CurRp;
  87. HANDLE m_hIdleStartHandle;
  88. HANDLE m_hIdleRequestHandle;
  89. HANDLE m_hIdleStopHandle;
  90. private:
  91. CLock m_DSLock;
  92. HANDLE m_hTimerQueue;
  93. HANDLE m_hTimer;
  94. HINSTANCE m_hIdle;
  95. CCounter m_Counter;
  96. BOOL m_fNoRpOnSystem;
  97. FILETIME m_ftFreeze;
  98. BOOL m_fIdleSrvStarted;
  99. int m_nNestedCallCount;
  100. HMODULE m_hCOMDll;
  101. BOOL m_fCreateRpASAP;
  102. DWORD InitIdleDetection();
  103. BOOL EndIdleDetection();
  104. DWORD InitTimer();
  105. BOOL EndTimer();
  106. BOOL IsMachineIdle();
  107. BOOL IsTimeForAutoRp();
  108. DWORD WriteRestorePointLog(LPWSTR pszFullPath,
  109. PRESTOREPOINTINFOW pRPInfo);
  110. };
  111. extern CEventHandler *g_pEventHandler;
  112. #endif