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.

72 lines
2.8 KiB

  1. #pragma once
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <TCHAR.h>
  5. // import the type library.
  6. // compiler generates .tlh and .tli files from this.
  7. // renaming of EOF is required since EOF is already in standard header files
  8. // and it is also in .thl files. This redifinition causes a compilation error.
  9. // Using no_namespace means you don't have to reference the namespace (ADODB) when
  10. // initializing or defining variables whose types are defined by what #import generates.
  11. // #import "F:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename ( "EOF", "EndOfFile" )
  12. // instead of importing, include the type library header file.
  13. // This is required for a few things in cdosys.tlh like FieldsPtr etc.
  14. #include "msado15.tlh"
  15. // testing HRESULT
  16. inline void TESTHR(HRESULT x) { if FAILED(x) _com_issue_error(x); };
  17. // event logging functions
  18. LONG SetupEventLog(BOOL bSetKey);
  19. void LogEvent(_TCHAR pFormat[MAX_PATH * 4], ...);
  20. void LogFatalEvent(_TCHAR pFormat[MAX_PATH * 4], ...);
  21. // kdMon method
  22. void kdMon();
  23. // This method loads the INI file for kdMon
  24. BOOL LoadINI();
  25. // This method tells kdMon() whether it is been signaled to stop
  26. // dwMilliSeconds is time to wait
  27. BOOL IsSignaledToStop(const HANDLE hStopEvent, DWORD dwMilliSeconds);
  28. // load values in the puiCounts and pulTimeStamps arrays from registry
  29. BOOL ReadRegValues(_TCHAR **ppszNames, DWORD dwTotalNames, ULONG *puiCounts, ULONG *pulTimeStamps);
  30. // write values in the puiCounts to registry. Timestamp is current one
  31. BOOL WriteRegValues(_TCHAR **ppszNames, DWORD dwTotalNames, ULONG *puiCounts);
  32. // scan the log file and get the count of number of lines
  33. ULONG ScanLogFile(_TCHAR *szKDFailureLogFile);
  34. // get the current TimeStamp value
  35. ULONG GetCurrentTimeStamp();
  36. // to add a specific time to a timestamp
  37. ULONG AddTime(ULONG ulTimeStamp, ULONG ulMinutes);
  38. // event ids and their messages.
  39. // these are needed while reporting an event to SCM
  40. #include "kdMonSvcMessages.h"
  41. // This is key under HKEY_LOCAL_MACHINE
  42. // Each service should have an entry as event source under this key
  43. // Otherwise, the service can not do a ReportEvent
  44. #define cszEventLogKey "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application"
  45. // The stop event name
  46. // used by kdMonSvc.cpp to create and signal a stop event
  47. // used by kdMon.cpp to open and wait for stop event
  48. #define cszStopEvent "kdMon_Stop_Event"
  49. #define cszkdMonINIFile "kdMon.ini"
  50. // log file used for debugging purpose
  51. #define cszLogFile "C:\\kdMonservice.log"
  52. // functions used for logging things
  53. void AddServiceLog(_TCHAR pFormat[MAX_PATH * 4], ...);
  54. void AppendToFile(_TCHAR szFileName[], _TCHAR szbuff[]);
  55. void GetError(_TCHAR szError[]);
  56. // constants used to recognize the file opening error
  57. #define E_FILE_NOT_FOUND -10
  58. #define E_PATH_NOT_FOUND -11
  59. #define E_OTHER_FILE_ERROR -12