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.

51 lines
1.3 KiB

  1. // ntservice.h
  2. //
  3. // Definitions for CNTService
  4. //
  5. #pragma once
  6. #ifndef _NTSERVICE_H_
  7. #define _NTSERVICE_H_
  8. #include "ntservmsg.h" // Event message ids
  9. #define SERVICE_CONTROL_USER 128
  10. class CNTService
  11. {
  12. public:
  13. CNTService();
  14. virtual ~CNTService();
  15. static BOOL IsInstalled();
  16. static void LogEvent( WORD wType, DWORD dwID,
  17. const char* pszS1 = NULL,
  18. const char* pszS2 = NULL,
  19. const char* pszS3 = NULL);
  20. void SetStatus(DWORD dwState);
  21. BOOL Initialize();
  22. virtual void Run() = 0;
  23. virtual BOOL OnInit(DWORD& dwLastError) = 0;
  24. virtual void OnStop() = 0;
  25. virtual void OnInterrogate();
  26. virtual void OnPause();
  27. virtual void OnContinue();
  28. virtual void OnShutdown();
  29. virtual BOOL OnUserControl(DWORD dwOpcode) = 0;
  30. static void DebugMsg(const char* pszFormat, ...);
  31. // static member functions
  32. static void WINAPI Handler(DWORD dwOpcode);
  33. // data members
  34. SERVICE_STATUS_HANDLE m_hServiceStatus;
  35. SERVICE_STATUS m_Status;
  36. BOOL m_bIsRunning;
  37. };
  38. // WARNING: This limits the application to only one CNTService object.
  39. extern CNTService* g_pService; // nasty hack to get object ptr
  40. extern CRITICAL_SECTION g_csLock;
  41. #endif // _NTSERVICE_H_