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.

214 lines
5.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: proto.hxx
  7. //
  8. // Contents: Shared function prototypes.
  9. //
  10. // Classes: None.
  11. //
  12. // Functions: RequestService
  13. //
  14. // History: 25-Oct-95 MarkBl Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #ifndef __PROTO_HXX__
  18. #define __PROTO_HXX__
  19. #include "..\inc\defines.hxx"
  20. VOID
  21. GetExeNameFromCmdLine(
  22. LPCWSTR,
  23. DWORD,
  24. TCHAR *);
  25. typedef struct _JOB_CREDENTIALS {
  26. DWORD ccAccount;
  27. WCHAR wszAccount[MAX_USERNAME + 1];
  28. DWORD ccDomain;
  29. WCHAR wszDomain[MAX_DOMAINNAME + 1];
  30. DWORD ccPassword;
  31. WCHAR wszPassword[MAX_PASSWORD + 1];
  32. BOOL fIsPasswordNull;
  33. } JOB_CREDENTIALS, * PJOB_CREDENTIALS;
  34. HRESULT
  35. GetAccountInformation(
  36. LPCWSTR pwszJobName,
  37. PJOB_CREDENTIALS pjc);
  38. HRESULT
  39. GetNSAccountInformation(
  40. PJOB_CREDENTIALS pjc);
  41. HRESULT
  42. GetFileInformation(
  43. LPCWSTR pwszFileName,
  44. DWORD * pcbOwnerSid,
  45. PSID * ppOwnerSid,
  46. PSECURITY_DESCRIPTOR * ppOwnerSecDescr,
  47. UUID * pJobID,
  48. DWORD ccOwnerName,
  49. DWORD ccOwnerDomain,
  50. DWORD ccApplication,
  51. WCHAR wszOwnerName[],
  52. WCHAR wszOwnerDomain[],
  53. WCHAR wszApplication[],
  54. FILETIME * pftCreationTime,
  55. DWORD * pdwVolumeSerialNo);
  56. HRESULT
  57. InitSS(VOID);
  58. VOID
  59. UninitSS(VOID);
  60. BOOL
  61. InitializeSAWindow(VOID);
  62. VOID
  63. UninitializeSAWindow(VOID);
  64. HANDLE
  65. ImpersonateLoggedInUser(VOID);
  66. HANDLE
  67. ImpersonateUser(
  68. HANDLE hUserToken,
  69. HANDLE ThreadHandle);
  70. BOOL StopImpersonating(
  71. HANDLE ThreadHandle,
  72. BOOL fCloseHandle);
  73. BOOL
  74. IsAdminFileOwner(
  75. LPCWSTR pwszFile);
  76. HRESULT
  77. OpenLogFile(
  78. VOID);
  79. VOID
  80. CloseLogFile(
  81. VOID);
  82. //+---------------------------------------------------------------------------
  83. //
  84. // Function: LogTaskStatus
  85. //
  86. // Purpose: Log successful task operations.
  87. //
  88. // Arguments: [ptszTaskName] - the task name.
  89. // [ptszTaskTarget] - the application/document name.
  90. // [uMsgID] - this would typically be either:
  91. // IDS_LOG_JOB_STATUS_STARTED or
  92. // IDS_LOG_JOB_STATUS_FINISHED
  93. // [dwExitCode] - if uMsgID is IDS_LOG_JOB_STATUS_FINISHED,
  94. // it is the task exit code; ignored otherwise.
  95. //
  96. //----------------------------------------------------------------------------
  97. extern "C"
  98. VOID
  99. LogTaskStatus(
  100. LPCTSTR ptszTaskName,
  101. LPTSTR ptszTaskTarget,
  102. UINT uMsgID,
  103. DWORD dwExitCode = 0);
  104. //+---------------------------------------------------------------------------
  105. //
  106. // Function: LogTaskError
  107. //
  108. // Purpose: Log task warnings and errors.
  109. //
  110. // Arguments: [ptszTaskName] - the task name.
  111. // [ptszTaskTarget] - the application/document name.
  112. // [uSeverityMsgID] - this would typically be either:
  113. // IDS_LOG_JOB_NAME_WARNING or
  114. // IDS_LOG_JOB_NAME_ERROR
  115. // [uErrorClassMsgID] - this indicates the class of error, such
  116. // as "Unable to start task" or "Forced to
  117. // close"
  118. // [pst] - the time when the error occured; if NULL,
  119. // enters the current time.
  120. // [dwErrorCode] - if non-zero, then an error from the OS
  121. // that would be expanded by FormatMessage.
  122. // [uHelpHintMsgID] - if an error, then a suggestion as to a
  123. // possible remedy.
  124. //
  125. //----------------------------------------------------------------------------
  126. VOID
  127. LogTaskError(
  128. LPCTSTR ptszTaskName,
  129. LPCTSTR ptszTaskTarget,
  130. UINT uSeverityMsgID,
  131. UINT uErrorClassMsgID,
  132. LPSYSTEMTIME pst,
  133. DWORD dwErrCode = 0,
  134. UINT uHelpHintMsgID = 0);
  135. //+---------------------------------------------------------------------------
  136. //
  137. // Function: LogServiceEvent
  138. //
  139. // Purpose: Note the starting, stoping, pausing, and continuing of the
  140. // service.
  141. //
  142. // Arguments: [uStrId] - a string identifying the event.
  143. //
  144. //----------------------------------------------------------------------------
  145. VOID
  146. LogServiceEvent(
  147. UINT uStrId);
  148. //+---------------------------------------------------------------------------
  149. //
  150. // Function: LogServiceError
  151. //
  152. // Purpose: Log service failures.
  153. //
  154. // Arguments: [uErrorClassMsgID] - as above.
  155. // [dwErrCode] - as above.
  156. // [uHelpHintMsgID] - as above.
  157. //
  158. //----------------------------------------------------------------------------
  159. VOID
  160. LogServiceError(
  161. UINT uErrorClassMsgID,
  162. DWORD dwErrCode,
  163. UINT uHelpHintMsgID = 0);
  164. //+---------------------------------------------------------------------------
  165. //
  166. // Function: LogMissedRuns
  167. //
  168. // Synopsis: Write details about missed runs to the log file.
  169. //
  170. // Arguments: [pstLastRun], [pstNow] - times between which runs were missed.
  171. //
  172. //----------------------------------------------------------------------------
  173. VOID
  174. LogMissedRuns(
  175. const SYSTEMTIME * pstLastRun,
  176. const SYSTEMTIME * pstNow);
  177. HRESULT
  178. RequestService(
  179. CTask * pTask);
  180. VOID
  181. StopRpcServer(
  182. VOID);
  183. DWORD GetCurrentServiceState(VOID);
  184. inline BOOL IsServiceStopping(VOID) {
  185. return(GetCurrentServiceState() == SERVICE_STOP_PENDING ||
  186. GetCurrentServiceState() == SERVICE_STOPPED);
  187. }
  188. #endif // __PROTO_HXX__