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.

126 lines
5.1 KiB

  1. // stdafx.h : include file for standard system include files,
  2. // or project specific include files that are used frequently,
  3. // but are changed infrequently
  4. #if !defined(AFX_STDAFX_H__5EF76719_1222_4555_A843_943BECCA8BDA__INCLUDED_)
  5. #define AFX_STDAFX_H__5EF76719_1222_4555_A843_943BECCA8BDA__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #define STRICT
  10. #ifndef _WIN32_WINNT
  11. #define _WIN32_WINNT 0x0400
  12. #endif
  13. #define _ATL_APARTMENT_THREADED
  14. #include <atlbase.h>
  15. #include <objbase.h>
  16. #include <windows.h>
  17. #include <stdio.h>
  18. #define s_cszEventLogKey _T("System\\CurrentControlSet\\Services\\EventLog\\Application") // Event Log
  19. #include "resource.h"
  20. #include <initguid.h>
  21. #include <tchar.h>
  22. #include <mqoai.h>
  23. #include <mq.h>
  24. //You may derive a class from CComModule and use it if you want to override
  25. //something, but do not change the name of _Module
  26. typedef struct strParams
  27. {
  28. TCHAR DebuggerName[MAX_PATH]; // Path to debugger exe.
  29. TCHAR Symsrv[255]; // Symbol server connection string
  30. TCHAR PrimaryQueue[255]; // Primary queue connection string
  31. TCHAR SecondaryQueue[255]; // Secondary queue connection string
  32. DWORD dwDelay; // Minimum delay between dbg processes
  33. DWORD dwPrimaryWait; // Time to wait for a message to appear in the primary queue.
  34. DWORD dwSecondaryWait; // Time to wait for a message to appear in the secondary queue.
  35. DWORD dwMaxKdProcesses; // Maximum number of kd process to launch
  36. DWORD dwMaxDumpSize; // Dump size limt for ocakd to process
  37. TCHAR IniInstallLocation[MAX_PATH]; // Place to pick up new kd ini files
  38. DWORD IniCheckWaitTime; // Time to wait between checks for new INI files.
  39. TCHAR PrimaryResponseQueue[255]; // MSMQ connection string for kd to send responses
  40. TCHAR SecondaryResponseQueue[255]; // MSMQ connection string for kd to send responses if the primary
  41. // Queue is unreachable.
  42. QUEUEHANDLE hPrimaryQueue; // Handle to the primary MSMQ
  43. QUEUEHANDLE hSecondaryQueue; // Handle to the backup MSMQ
  44. }SVCPARAMS, *PSVCPARAMS;
  45. typedef struct _DBADDCRASH_PARAMS {
  46. PTCHAR Debugger; // Full path to debugger which adds dump to database
  47. PTCHAR DumpPath; // Full dump path which is being analyzed
  48. PTCHAR Guid; // Guid for dump identification in database
  49. PTCHAR SrNumber; // SR number to identify the PSS records for the dump
  50. PTCHAR ResponseMQ; // MSM Queue where debugger sends the response after analysing the dump
  51. PTCHAR SymPath; // Symbol / Image path for debugger
  52. ULONG Source; // Source where the dump came from
  53. DWORD dwMaxDumpSize; // Dump size limt for ocakd to process
  54. } DBADDCRASH_PARAMS, *PDBADDCRASH_PARAMS;
  55. class CServiceModule : public CComModule
  56. {
  57. public:
  58. //BOOL ConnectToMessageQueue(TCHAR *QueueConnectionString,IMSMQQueue **pqReceive );
  59. HRESULT RegisterServer(BOOL bRegTypeLib, BOOL bService);
  60. HRESULT UnregisterServer();
  61. void Init(_ATL_OBJMAP_ENTRY* p, HINSTANCE h, UINT nServiceNameID, const GUID* plibid = NULL);
  62. void Start();
  63. void ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
  64. void Handler(DWORD dwOpcode);
  65. void Run();
  66. BOOL IsInstalled();
  67. BOOL Install();
  68. BOOL Uninstall();
  69. LONG Unlock();
  70. void LogEvent(LPCTSTR pszFormat, ...);
  71. void SetServiceStatus(DWORD dwState);
  72. void SetupAsLocalServer();
  73. HRESULT SetupEventLog ( BOOL fSetup );
  74. VOID LogFatalEvent(LPCTSTR pFormat, ...);
  75. VOID NotifyDebuggerLaunch(PDBADDCRASH_PARAMS pDbParams);
  76. BOOL LaunchDebugger(PDBADDCRASH_PARAMS pDbParams, PPROCESS_INFORMATION pDbgProcess);
  77. ULONG64 GetFileSize(LPWSTR wszFile);
  78. BOOL PrepareForDebuggerLaunch();
  79. HRESULT ConnectToMSMQ(QUEUEHANDLE *hQueue, wchar_t *QueueConnectStr);
  80. BOOL ReceiveQueueMessage(PSVCPARAMS pParams,wchar_t *RecMessageBody, wchar_t *szMessageGuid, BOOL *UsePrimary, int* Type, wchar_t *szSR);
  81. // BOOL GetQueuedMessage(IMSMQQueue **pPrimaryQueue, TCHAR *Message, TCHAR *MessageLabel);
  82. BOOL GetServiceParams(SVCPARAMS *ServiceParams);
  83. DWORD CheckForIni(SVCPARAMS *ServiceParams);
  84. BOOL Initialize(PSVCPARAMS pParams);
  85. //Implementation
  86. private:
  87. static void WINAPI _ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv);
  88. static void WINAPI _Handler(DWORD dwOpcode);
  89. TCHAR m_szComputerName[sizeof (TCHAR) * (MAX_COMPUTERNAME_LENGTH + 1)];
  90. // data members
  91. public:
  92. TCHAR m_szServiceName[256];
  93. SERVICE_STATUS_HANDLE m_hServiceStatus;
  94. SERVICE_STATUS m_status;
  95. DWORD dwThreadID;
  96. BOOL m_bService;
  97. HANDLE m_hMonNotifyPipe;
  98. ULONG m_DebuggerCount;
  99. };
  100. #define s_cszStopEvent _T("DbgLauncherSvc_Event")
  101. extern CServiceModule _Module;
  102. #include <atlcom.h>
  103. //{{AFX_INSERT_LOCATION}}
  104. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  105. #endif // !defined(AFX_STDAFX_H__5EF76719_1222_4555_A843_943BECCA8BDA__INCLUDED)