Source code of Windows XP (NT5)
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.

356 lines
10 KiB

  1. #ifndef _WSBGEN_H
  2. #define _WSBGEN_H
  3. /*++
  4. Copyright (c) 1996 Microsoft Corporation
  5. 1998 Seagate Software, Inc. All rights reserved.
  6. Module Name:
  7. wsbgen.h
  8. Abstract:
  9. This module defines very basic WSB functions and defines that are general to WSB
  10. Author:
  11. Michael Lotz [lotz] 12-Apr-1997
  12. Revision History:
  13. --*/
  14. // These macros define the module assignments for the error facilities.
  15. // See also Facility Names, below.
  16. #define WSB_FACILITY_PLATFORM 0x100
  17. #define WSB_FACILITY_RMS 0x101
  18. #define WSB_FACILITY_HSMENG 0x103
  19. #define WSB_FACILITY_JOB 0x104
  20. #define WSB_FACILITY_HSMTSKMGR 0x105
  21. #define WSB_FACILITY_FSA 0x106
  22. #define WSB_FACILITY_GUI 0x10a
  23. #define WSB_FACILITY_MOVER 0x10b
  24. #define WSB_FACILITY_LAUNCH 0x10c
  25. #define WSB_FACILITY_TEST 0x10d
  26. #define WSB_FACILITY_USERLINK 0x10e
  27. #define WSB_FACILITY_CLI 0x10f
  28. // Facility Names
  29. #define WSB_FACILITY_PLATFORM_NAME OLESTR("RsCommon.dll")
  30. #define WSB_FACILITY_RMS_NAME OLESTR("RsSub.dll")
  31. #define WSB_FACILITY_HSMENG_NAME OLESTR("RsEng.dll")
  32. #define WSB_FACILITY_JOB_NAME OLESTR("RsJob.dll")
  33. #define WSB_FACILITY_HSMTSKMGR_NAME OLESTR("RsTask.dll")
  34. #define WSB_FACILITY_FSA_NAME OLESTR("RsFsa.dll")
  35. #define WSB_FACILITY_GUI_NAME OLESTR("RsAdmin.dll")
  36. #define WSB_FACILITY_MOVER_NAME OLESTR("RsMover.dll")
  37. #define WSB_FACILITY_LAUNCH_NAME OLESTR("RsLaunch.exe")
  38. #define WSB_FACILITY_TEST_NAME OLESTR("RsTools.dll")
  39. #define WSB_FACILITY_USERLINK_NAME OLESTR("RsLnk.exe")
  40. #define WSB_FACILITY_CLI_NAME OLESTR("RsCli.dll")
  41. #define WSB_FACILITY_NTDLL_NAME OLESTR("ntdll.dll")
  42. // COM Interface & Library Defintions
  43. #define WSB_COLLECTION_MIN_INDEX 0
  44. #define WSB_COLLECTION_MAX_INDEX 0xfffffffe
  45. #define WSB_MAX_SERVICE_NAME 255
  46. // Guids used to store User and Password for scheduled tasks
  47. // Username {DC2D7CF0-6298-11d1-9F17-00A02488FCDE}
  48. static const GUID GUID_Username =
  49. { 0xdc2d7cf0, 0x6298, 0x11d1, { 0x9f, 0x17, 0x0, 0xa0, 0x24, 0x88, 0xfc, 0xde } };
  50. // Password {DC2D7CF1-6298-11d1-9F17-00A02488FCDE}
  51. static const GUID GUID_Password =
  52. { 0xdc2d7cf1, 0x6298, 0x11d1, { 0x9f, 0x17, 0x0, 0xa0, 0x24, 0x88, 0xfc, 0xde } };
  53. // Strings used to register event log categories
  54. #define WSB_SVC_BASE OLESTR("SYSTEM\\CurrentControlSet\\Services")
  55. #define WSB_LOG_BASE OLESTR("SYSTEM\\CurrentControlSet\\Services\\EventLog")
  56. #define WSB_LOG_APP OLESTR("Application")
  57. #define WSB_LOG_SYS OLESTR("System")
  58. #define WSB_LOG_CAT_COUNT OLESTR("CategoryCount")
  59. #define WSB_LOG_CAT_FILE OLESTR("CategoryMessageFile")
  60. #define WSB_LOG_MESSAGE_FILE OLESTR("EventMessageFile")
  61. #define WSB_LOG_TYPES OLESTR("TypesSupported")
  62. #define WSB_LOG_SOURCE_NAME OLESTR("Remote Storage")
  63. #define WSB_LOG_FILTER_NAME OLESTR("RsFilter")
  64. #define WSB_LOG_SVC_CATCOUNT 11
  65. #define WSB_LOG_SVC_CATFILE OLESTR("%SystemRoot%\\System32\\RsCommon.Dll")
  66. #define WSB_LOG_SVC_MSGFILES OLESTR("%SystemRoot%\\System32\\RsCommon.Dll")
  67. //
  68. // Common Functions
  69. // File/Directory
  70. extern WSB_EXPORT HRESULT WsbCreateAllDirectories(OLECHAR* path);
  71. extern WSB_EXPORT HRESULT WsbCreateAllDirectoriesForFile(OLECHAR* path);
  72. extern WSB_EXPORT HRESULT WsbGetWin32PathAsBstr(OLECHAR* path, BSTR* pWin32Path);
  73. extern WSB_EXPORT HRESULT WsbGetPathFromWin32AsBstr(OLECHAR* win32Path, BSTR* pPath);
  74. inline char WsbSign( INT Val ) {
  75. return( Val > 0 ? (char)1 : ( ( Val < 0 ) ? (char)-1 : (char)0 ) );
  76. }
  77. // String & Buffer Copy
  78. extern "C" {
  79. extern WSB_EXPORT HRESULT WsbAllocAndCopyComString(OLECHAR** dest, OLECHAR* src, ULONG bufferSize);
  80. extern WSB_EXPORT HRESULT WsbAllocAndCopyComString2(OLECHAR** dest, OLECHAR* src, ULONG bufferSize, BOOL inOrder);
  81. extern WSB_EXPORT HRESULT WsbGetComBuffer(OLECHAR** dest, ULONG requestedSize, ULONG neededSize, BOOL* pWasAllocated);
  82. extern WSB_EXPORT HRESULT WsbLoadComString(HINSTANCE hInstance, UINT uId, LPOLESTR* pszDest, ULONG ulBufferSize);
  83. extern WSB_EXPORT HRESULT WsbMatchComString(OLECHAR* end, UINT uId, USHORT checks, UINT* idMatch);
  84. }
  85. // Filetime Manipulations
  86. // NOTE: TICKS_PER_MONTH and TICKS_PER_YEAR are just approximations.
  87. #define WSB_FT_TYPES_MAX 7
  88. #define WSB_FT_TICKS_PER_SECOND ((LONGLONG) 10000000)
  89. #define WSB_FT_TICKS_PER_MINUTE ((LONGLONG) ((LONGLONG) 60 * WSB_FT_TICKS_PER_SECOND))
  90. #define WSB_FT_TICKS_PER_HOUR ((LONGLONG) ((LONGLONG) 60 * WSB_FT_TICKS_PER_MINUTE))
  91. #define WSB_FT_TICKS_PER_DAY ((LONGLONG) ((LONGLONG) 24 * WSB_FT_TICKS_PER_HOUR))
  92. #define WSB_FT_TICKS_PER_WEEK ((LONGLONG) ((LONGLONG) 7 * WSB_FT_TICKS_PER_DAY))
  93. #define WSB_FT_TICKS_PER_MONTH ((LONGLONG) ((LONGLONG) 31 * WSB_FT_TICKS_PER_DAY))
  94. #define WSB_FT_TICKS_PER_YEAR ((LONGLONG) ((LONGLONG) 365 * WSB_FT_TICKS_PER_DAY))
  95. extern "C" {
  96. extern WSB_EXPORT FILETIME WsbFtSubFt(FILETIME ft1, FILETIME ft2);
  97. extern WSB_EXPORT SHORT WsbCompareFileTimes(FILETIME ft1, FILETIME ft2, BOOL isRelative, BOOL isNewer);
  98. }
  99. // File name manipulations
  100. extern WSB_EXPORT HRESULT SquashFilepath(WCHAR* pPath, UCHAR* pKey, ULONG keySize);
  101. // Guid Manipulations
  102. // Constant that can be used to determine necessary buffer size in doing
  103. // GUID string operations. This includes the terminating L'\0'.
  104. #define WSB_GUID_STRING_SIZE \
  105. (sizeof(L"{00000000-0000-0000-0000-000000000000}")/sizeof(wchar_t))
  106. extern "C" {
  107. extern WSB_EXPORT int WsbCompareGuid(REFGUID guid1, REFGUID guid2);
  108. extern WSB_EXPORT HRESULT WsbStringFromGuid(REFGUID rguid, OLECHAR* sz);
  109. extern WSB_EXPORT HRESULT WsbGuidFromString(const OLECHAR*, GUID * pguid);
  110. }
  111. // Type Conversion
  112. #define WSB_FT_TO_WCS_ABS_STRLEN 20
  113. #define WSB_VDATE_TO_WCS_ABS_STRLEN 20
  114. extern "C" {
  115. extern WSB_EXPORT HRESULT WsbWCStoFT(OLECHAR* wcs, BOOL* pIsRelative, FILETIME* pTime);
  116. extern WSB_EXPORT HRESULT WsbWCStoLL(OLECHAR* wcs, LONGLONG* pvalue);
  117. extern WSB_EXPORT LONGLONG WsbFTtoLL(FILETIME time);
  118. extern WSB_EXPORT FILETIME WsbLLtoFT(LONGLONG value);
  119. extern WSB_EXPORT HRESULT WsbFTtoWCS(BOOL isRelative, FILETIME time, OLECHAR** wcs, ULONG bufferSize);
  120. extern WSB_EXPORT HRESULT WsbLLtoWCS(LONGLONG value, OLECHAR** wcs, ULONG ulBufferSize);
  121. extern WSB_EXPORT LONGLONG WsbHLtoLL(LONG high, LONG low);
  122. extern WSB_EXPORT void WsbLLtoHL(LONGLONG ll, LONG* pHigh, LONG* pLow);
  123. extern WSB_EXPORT HRESULT WsbDatetoFT(DATE date, LONG ticks, FILETIME* pFt);
  124. extern WSB_EXPORT HRESULT WsbFTtoDate(FILETIME ft, DATE* pDate, LONG* pTicks);
  125. extern WSB_EXPORT HRESULT WsbLocalDateTicktoUTCFT(DATE date, LONG ticks, FILETIME* pFT);
  126. extern WSB_EXPORT HRESULT WsbUTCFTtoLocalDateTick(FILETIME ft, DATE* pDate, LONG* pTicks);
  127. extern WSB_EXPORT HRESULT WsbDateToString(DATE date, OLECHAR** string);
  128. extern WSB_EXPORT HRESULT WsbStringToDate(OLECHAR* string, DATE* date);
  129. }
  130. // Account Helper functions
  131. extern "C" {
  132. extern WSB_EXPORT
  133. HRESULT
  134. WsbGetAccountDomainName(
  135. OLECHAR * szDomainName,
  136. DWORD cSize
  137. );
  138. extern WSB_EXPORT
  139. HRESULT
  140. WsbGetServiceInfo(
  141. IN GUID guidApp,
  142. OUT OLECHAR ** pszServiceName, OPTIONAL
  143. OUT OLECHAR ** pszAccountName OPTIONAL
  144. );
  145. extern WSB_EXPORT
  146. HRESULT
  147. WsbGetServiceTraceDefaults(
  148. IN OLECHAR* serviceName,
  149. IN OLECHAR* traceName,
  150. IN IUnknown* pUnk
  151. );
  152. extern WSB_EXPORT
  153. HRESULT
  154. WsbGetMetaDataPath(
  155. OUT CWsbStringPtr & Path
  156. );
  157. extern WSB_EXPORT
  158. HRESULT
  159. WsbGetComputerName(
  160. OUT CWsbStringPtr & String
  161. );
  162. extern WSB_EXPORT
  163. HRESULT
  164. WsbGetLocalSystemName(
  165. OUT CWsbStringPtr & String
  166. );
  167. }
  168. // WsbSvc.h
  169. extern WSB_EXPORT
  170. HRESULT
  171. WsbCheckService(
  172. IN const OLECHAR * computer,
  173. IN GUID guidApp
  174. );
  175. extern WSB_EXPORT
  176. HRESULT
  177. WsbGetServiceName(
  178. IN const OLECHAR *computer,
  179. IN GUID guidApp,
  180. IN DWORD cSize,
  181. OUT OLECHAR *serviceName
  182. );
  183. extern WSB_EXPORT
  184. HRESULT
  185. WsbGetServiceStatus(
  186. IN const OLECHAR *computer,
  187. IN GUID guidApp,
  188. OUT DWORD *serviceStatus
  189. );
  190. extern WSB_EXPORT HRESULT
  191. WsbRegisterEventLogSource(
  192. IN const WCHAR * LogName,
  193. IN const WCHAR * SourceName,
  194. IN DWORD CategoryCount,
  195. IN const WCHAR * CategoryMsgFile OPTIONAL,
  196. IN const WCHAR * MsgFiles
  197. );
  198. extern WSB_EXPORT HRESULT
  199. WsbUnregisterEventLogSource(
  200. IN const WCHAR * LogName,
  201. IN const WCHAR * SourceName
  202. );
  203. extern WSB_EXPORT HRESULT
  204. WsbUnregisterRsFilter (
  205. BOOL bDisplay
  206. );
  207. extern WSB_EXPORT HRESULT
  208. WsbRegisterRsFilter (
  209. BOOL bDisplay
  210. );
  211. extern WSB_EXPORT
  212. HRESULT
  213. WsbGetServiceId(
  214. OLECHAR* serviceName,
  215. GUID* pGuid
  216. );
  217. extern WSB_EXPORT
  218. HRESULT
  219. WsbCreateServiceId(
  220. OLECHAR* serviceName,
  221. GUID* pGuid
  222. );
  223. extern WSB_EXPORT
  224. HRESULT
  225. WsbConfirmServiceId(
  226. OLECHAR* serviceName,
  227. GUID guidConfirm
  228. );
  229. extern WSB_EXPORT
  230. HRESULT
  231. WsbSetServiceId(
  232. OLECHAR* serviceName,
  233. GUID guid
  234. );
  235. extern WSB_EXPORT
  236. HRESULT
  237. WsbCheckAccess(
  238. WSB_ACCESS_TYPE AccessType
  239. );
  240. extern WSB_EXPORT
  241. HRESULT
  242. WsbCheckUsnJournalForChanges(
  243. OLECHAR* volName,
  244. LONGLONG FileId,
  245. LONGLONG StartUsn,
  246. LONGLONG StopUsn,
  247. BOOL* pChanged
  248. );
  249. extern WSB_EXPORT
  250. HRESULT
  251. WsbMarkUsnSource(
  252. HANDLE changeHandle,
  253. OLECHAR* volName
  254. );
  255. extern WSB_EXPORT
  256. HRESULT
  257. WsbGetUsnFromFileHandle(
  258. HANDLE hFile,
  259. BOOL ForceClose,
  260. LONGLONG* pFileUsn
  261. );
  262. extern WSB_EXPORT
  263. HRESULT
  264. WsbCreateUsnJournal(
  265. OLECHAR* volName,
  266. ULONGLONG usnSize
  267. );
  268. extern WSB_EXPORT
  269. HRESULT
  270. WsbGetResourceString(
  271. ULONG id,
  272. WCHAR **ppString
  273. );
  274. extern WSB_EXPORT
  275. HRESULT
  276. WsbGetUsnJournalId(
  277. OLECHAR* volName,
  278. ULONGLONG* usnId
  279. );
  280. class WSB_EXPORT CWsbSecurityDescriptor : public CSecurityDescriptor
  281. {
  282. public:
  283. HRESULT AllowRid( DWORD Rid, DWORD dwAccessMask );
  284. };
  285. #endif // _WSBGEN_H