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.

514 lines
12 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. common.h
  5. Abstract:
  6. This module defines the data structures and function prototypes
  7. shared by both SCE client and SCE server
  8. Author:
  9. Jin Huang (jinhuang) 23-Jan-1998
  10. Revision History:
  11. jinhuang (splitted from scep.h)
  12. --*/
  13. #ifndef _scecommon_
  14. #define _scecommon_
  15. typedef enum _SECURITY_DB_TYPE {
  16. SecurityDbSam = 1,
  17. SecurityDbLsa
  18. } SECURITY_DB_TYPE, *PSECURITY_DB_TYPE;
  19. #define SCE_TEMPLATE_MAX_SUPPORTED_VERSION 1
  20. #define szLegalNoticeTextKeyName L"MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System\\LegalNoticeText"
  21. //
  22. // type of system access lookup table
  23. //
  24. #define SCESETUP_UPDATE_DB_ONLY 0x1000L
  25. #define SCE_SYSTEM_DB 0x0100L
  26. #define SCE_CREATE_BUILTIN_ACCOUNTS 0x0200L
  27. #define SCE_POLBIND_NO_AUTH 0x0400L
  28. #define SCE_NO_ANALYZE 0x0800L
  29. #define SCE_NO_DOMAIN_POLICY 0x2000L
  30. #define SCE_NOCOPY_DOMAIN_POLICY 0x4000L
  31. #define SCE_COPY_LOCAL_POLICY 0x8000L
  32. #define SCE_POLICY_TEMPLATE 0x00010000L
  33. #define SCE_POLICY_FIRST 0x00020000L
  34. #define SCE_POLICY_LAST 0x00040000L
  35. #define SCE_SYSTEM_SETTINGS 0x00080000L
  36. #define SCE_DCPROMO_WAIT 0x00100000L
  37. #define SCE_SETUP_SERVICE_NOSTARTTYPE 0x00200000L
  38. #define SCE_NO_CONFIG_FILEKEY 0x00400000L
  39. #define SCE_DC_DEMOTE 0x00800000L
  40. #define SCE_RE_ANALYZE 0x01000000L
  41. #define SCE_RSOP_CALLBACK 0x02000000L
  42. #define SCE_GENERATE_ROLLBACK 0x04000000L
  43. #define SCE_FLAG_WINDOWS_DIR 1
  44. #define SCE_FLAG_SYSTEM_DIR 2
  45. #define SCE_FLAG_DSDIT_DIR 3
  46. #define SCE_FLAG_DSLOG_DIR 4
  47. #define SCE_FLAG_SYSVOL_DIR 5
  48. #define SCE_FLAG_BOOT_DRIVE 6
  49. #define SCE_GROUP_STATUS_DONE_IN_DS 0x80000000L
  50. #define SCEP_ADL_HTABLE_SIZE 256
  51. //
  52. // Macros to extract the SID from a object ACE
  53. //
  54. #define ScepObjectAceObjectTypePresent( Ace ) \
  55. ((((SCEP_PKNOWN_OBJECT_ACE)(Ace))->Flags & ACE_OBJECT_TYPE_PRESENT) != 0 )
  56. #define ScepObjectAceInheritedObjectTypePresent( Ace ) \
  57. ((((SCEP_PKNOWN_OBJECT_ACE)(Ace))->Flags & ACE_INHERITED_OBJECT_TYPE_PRESENT) != 0 )
  58. #define ScepObjectAceSid( Ace ) \
  59. ((PSID)(((PUCHAR)&(((SCEP_PKNOWN_OBJECT_ACE)(Ace))->SidStart)) + \
  60. (ScepObjectAceObjectTypePresent(Ace) ? sizeof(GUID) : 0 ) + \
  61. (ScepObjectAceInheritedObjectTypePresent(Ace) ? sizeof(GUID) : 0 )))
  62. #define ScepObjectAceObjectType( Ace ) \
  63. ((GUID *)(ScepObjectAceObjectTypePresent(Ace) ? \
  64. &((SCEP_PKNOWN_OBJECT_ACE)(Ace))->SidStart : \
  65. NULL ))
  66. #define ScepObjectAceInheritedObjectType( Ace ) \
  67. ((GUID *)(ScepObjectAceInheritedObjectTypePresent(Ace) ? \
  68. ( ScepObjectAceObjectTypePresent(Ace) ? \
  69. (PULONG)(((PUCHAR)(&((SCEP_PKNOWN_OBJECT_ACE)(Ace))->SidStart)) + sizeof(GUID)) : \
  70. &((SCEP_PKNOWN_OBJECT_ACE)(Ace))->SidStart ) : \
  71. NULL ))
  72. static GENERIC_MAPPING FileGenericMapping = {
  73. FILE_GENERIC_READ,
  74. FILE_GENERIC_WRITE,
  75. FILE_GENERIC_EXECUTE,
  76. FILE_ALL_ACCESS
  77. };
  78. static GENERIC_MAPPING KeyGenericMapping = {
  79. KEY_READ,
  80. KEY_WRITE,
  81. KEY_EXECUTE,
  82. KEY_ALL_ACCESS
  83. };
  84. #define SERVICE_GENERIC_READ (STANDARD_RIGHTS_READ |\
  85. SERVICE_QUERY_CONFIG |\
  86. SERVICE_QUERY_STATUS |\
  87. SERVICE_ENUMERATE_DEPENDENTS |\
  88. SERVICE_INTERROGATE |\
  89. SERVICE_USER_DEFINED_CONTROL)
  90. #define SERVICE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE |\
  91. SERVICE_START |\
  92. SERVICE_STOP |\
  93. SERVICE_PAUSE_CONTINUE |\
  94. SERVICE_INTERROGATE |\
  95. SERVICE_USER_DEFINED_CONTROL)
  96. #define SERVICE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE |\
  97. SERVICE_CHANGE_CONFIG )
  98. static GENERIC_MAPPING SvcGenMap = {
  99. SERVICE_GENERIC_READ,
  100. SERVICE_GENERIC_WRITE,
  101. SERVICE_GENERIC_EXECUTE,
  102. SERVICE_ALL_ACCESS
  103. };
  104. typedef struct _SCE_KEY_LOOKUP {
  105. PWSTR KeyString;
  106. UINT Offset;
  107. CHAR BufferType;
  108. }SCE_KEY_LOOKUP;
  109. typedef struct _SCE_TATTOO_KEYS_ {
  110. PWSTR KeyName;
  111. DWORD KeyLen;
  112. CHAR DataType;
  113. DWORD SaveValue;
  114. PWSTR Value;
  115. }SCE_TATTOO_KEYS;
  116. typedef struct _SCEP_HANDLE_ {
  117. PVOID hProfile;
  118. PCWSTR ServiceName;
  119. } SCEP_HANDLE, *PSCEP_HANDLE;
  120. //
  121. // ACE template on which extraction macros are based on
  122. //
  123. typedef struct _SCEP_KNOWN_OBJECT_ACE {
  124. ACE_HEADER Header;
  125. ACCESS_MASK Mask;
  126. ULONG Flags;
  127. // GUID ObjectType; // Optionally present
  128. // GUID InheritedObjectType; // Optionally present
  129. ULONG SidStart;
  130. } SCEP_KNOWN_OBJECT_ACE, *SCEP_PKNOWN_OBJECT_ACE;
  131. typedef struct _SCEP_ADL_NODE_ {
  132. PISID pSid;
  133. GUID *pGuidObjectType;
  134. GUID *pGuidInheritedObjectType;
  135. UCHAR AceType;
  136. DWORD dwEffectiveMask;
  137. DWORD dw_CI_IO_Mask;
  138. DWORD dw_OI_IO_Mask;
  139. DWORD dw_NP_CI_IO_Mask;
  140. struct _SCEP_ADL_NODE_ *Next;
  141. } SCEP_ADL_NODE, *PSCEP_ADL_NODE;
  142. #define TICKS_PRIVILEGE 15
  143. #define TICKS_GROUPS 15
  144. #define TICKS_SYSTEM_ACCESS 3
  145. #define TICKS_SYSTEM_AUDITING 3
  146. #define TICKS_KERBEROS 3
  147. #define TICKS_REGISTRY_VALUES 4
  148. #define TICKS_GENERAL_SERVICES 10
  149. #define TICKS_SPECIFIC_SERVICES 5
  150. #define TICKS_SPECIFIC_POLICIES 5
  151. #define TICKS_SECURITY_POLICY_DS ( TICKS_SYSTEM_ACCESS + \
  152. TICKS_SYSTEM_AUDITING + \
  153. TICKS_REGISTRY_VALUES + \
  154. TICKS_KERBEROS )
  155. #define TICKS_MIGRATION_SECTION 100
  156. #define TICKS_MIGRATION_V11 50
  157. #define SCE_OPEN_OPTION_REQUIRE_ANALYSIS 1
  158. #define SCE_OPEN_OPTION_TATTOO 2
  159. #define SCE_RESET_POLICY_KEEP_LOCAL 0x1
  160. #define SCE_RESET_POLICY_ENFORCE_ATREBOOT 0x2
  161. #define SCE_RESET_POLICY_SYSPREP 0x4
  162. #define SCE_RESET_POLICY_TATTOO 0x8
  163. //
  164. // strsd.c
  165. //
  166. DWORD
  167. WINAPI
  168. ConvertTextSecurityDescriptor (
  169. IN PWSTR pwszTextSD,
  170. OUT PSECURITY_DESCRIPTOR *ppSD,
  171. OUT PULONG pcSDSize,
  172. OUT PSECURITY_INFORMATION pSeInfo
  173. );
  174. DWORD
  175. WINAPI
  176. ConvertSecurityDescriptorToText (
  177. IN PSECURITY_DESCRIPTOR pSD,
  178. IN SECURITY_INFORMATION SecurityInfo,
  179. OUT PWSTR *ppwszTextSD,
  180. OUT PULONG pcTextSize
  181. );
  182. //
  183. // defined in common.cpp
  184. //
  185. SCESTATUS
  186. ScepDosErrorToSceStatus(
  187. DWORD rc
  188. );
  189. SCESTATUS
  190. WINAPI
  191. SceSvcpGetInformationTemplate(
  192. IN HINF hInf,
  193. IN PCWSTR ServiceName,
  194. IN PCWSTR Key OPTIONAL,
  195. OUT PSCESVC_CONFIGURATION_INFO *ServiceInfo
  196. );
  197. SCESTATUS
  198. ScepBuildErrorLogInfo(
  199. IN DWORD rc,
  200. OUT PSCE_ERROR_LOG_INFO *Errlog,
  201. IN UINT nId,
  202. // IN PCWSTR fmt,
  203. ...
  204. );
  205. DWORD
  206. ScepAddToNameList(
  207. OUT PSCE_NAME_LIST *pNameList,
  208. IN PWSTR Name,
  209. IN ULONG Len
  210. );
  211. DWORD
  212. ScepRegQueryIntValue(
  213. IN HKEY hKeyRoot,
  214. IN PWSTR SubKey,
  215. IN PWSTR ValueName,
  216. OUT DWORD *Value
  217. );
  218. DWORD
  219. ScepRegQueryBinaryValue(
  220. IN HKEY hKeyRoot,
  221. IN PWSTR SubKey,
  222. IN PWSTR ValueName,
  223. OUT PBYTE *ppValue
  224. );
  225. DWORD
  226. ScepRegSetIntValue(
  227. IN HKEY hKeyRoot,
  228. IN PWSTR SubKey,
  229. IN PWSTR ValueName,
  230. IN DWORD Value
  231. );
  232. DWORD
  233. ScepRegQueryValue(
  234. IN HKEY hKeyRoot,
  235. IN PWSTR SubKey,
  236. IN PCWSTR ValueName,
  237. OUT PVOID *Value,
  238. OUT LPDWORD pRegType
  239. );
  240. DWORD
  241. ScepRegSetValue(
  242. IN HKEY hKeyRoot,
  243. IN PWSTR SubKey,
  244. IN PWSTR ValueName,
  245. IN DWORD RegType,
  246. IN BYTE *Value,
  247. IN DWORD ValueLen
  248. );
  249. DWORD
  250. ScepRegDeleteValue(
  251. IN HKEY hKeyRoot,
  252. IN PWSTR SubKey,
  253. IN PWSTR ValueName
  254. );
  255. SCESTATUS
  256. ScepCreateDirectory(
  257. IN PCWSTR ProfileLocation,
  258. IN BOOL FileOrDir,
  259. PSECURITY_DESCRIPTOR pSecurityDescriptor
  260. );
  261. DWORD
  262. ScepSceStatusToDosError(
  263. IN SCESTATUS SceStatus
  264. );
  265. SCESTATUS
  266. ScepChangeAclRevision(
  267. IN PSECURITY_DESCRIPTOR pSD,
  268. IN BYTE NewRevision
  269. );
  270. BOOL
  271. ScepEqualGuid(
  272. IN GUID *Guid1,
  273. IN GUID *Guid2
  274. );
  275. SCESTATUS
  276. ScepAddToGroupMembership(
  277. OUT PSCE_GROUP_MEMBERSHIP *pGroupMembership,
  278. IN PWSTR Keyname,
  279. IN DWORD KeyLen,
  280. IN PSCE_NAME_LIST pMembers,
  281. IN DWORD ValueType,
  282. IN BOOL bCheckDup,
  283. IN BOOL bReplaceList
  284. );
  285. DWORD
  286. ScepAddOneServiceToList(
  287. IN LPWSTR lpServiceName,
  288. IN LPWSTR lpDisplayName,
  289. IN DWORD ServiceStatus,
  290. IN PVOID pGeneral OPTIONAL,
  291. IN SECURITY_INFORMATION SeInfo,
  292. IN BOOL bSecurity,
  293. OUT PSCE_SERVICES *pServiceList
  294. );
  295. DWORD
  296. ScepIsAdminLoggedOn(
  297. OUT PBOOL bpAdminLogon
  298. );
  299. DWORD
  300. ScepGetProfileSetting(
  301. IN PCWSTR ValueName,
  302. IN BOOL bAdminLogon,
  303. OUT PWSTR *Setting
  304. );
  305. DWORD
  306. ScepCompareObjectSecurity(
  307. IN SE_OBJECT_TYPE ObjectType,
  308. IN BOOL IsContainer,
  309. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  310. IN PSECURITY_DESCRIPTOR ProfileSD,
  311. IN SECURITY_INFORMATION ProfileSeInfo,
  312. OUT PBYTE IsDifferent
  313. );
  314. SCESTATUS
  315. ScepAddToNameStatusList(
  316. OUT PSCE_NAME_STATUS_LIST *pNameList,
  317. IN PWSTR Name,
  318. IN ULONG Len,
  319. IN DWORD Status
  320. );
  321. DWORD
  322. ScepAddToObjectList(
  323. OUT PSCE_OBJECT_LIST *pNameList,
  324. IN PWSTR Name,
  325. IN ULONG Len,
  326. IN BOOL IsContainer,
  327. IN BYTE Status,
  328. IN DWORD Count,
  329. IN BYTE byFlags
  330. );
  331. DWORD
  332. ScepGetNTDirectory(
  333. IN PWSTR *ppDirectory,
  334. IN PDWORD pDirSize,
  335. IN DWORD Flag
  336. );
  337. DWORD
  338. SceAdjustPrivilege(
  339. IN ULONG Priv,
  340. IN BOOL Enable,
  341. IN HANDLE TokenToAdjust
  342. );
  343. DWORD
  344. ScepGetEnvStringSize(
  345. IN LPVOID peb
  346. );
  347. //!!!!!!!!!!!!!!!!!!!!!!!!!!!
  348. // routines to handle events
  349. //!!!!!!!!!!!!!!!!!!!!!!!!!!!
  350. BOOL
  351. InitializeEvents (
  352. IN LPTSTR EventSourceName
  353. );
  354. int
  355. LogEvent (
  356. IN HINSTANCE hInstance,
  357. IN DWORD LogLevel,
  358. IN DWORD dwEventID,
  359. IN UINT idMsg,
  360. ...
  361. );
  362. int
  363. LogEventAndReport(
  364. IN HINSTANCE hInstance,
  365. IN LPTSTR LogFileName,
  366. IN DWORD LogLevel,
  367. IN DWORD dwEventID,
  368. IN UINT idMsg,
  369. ...
  370. );
  371. BOOL ShutdownEvents (void);
  372. SCESTATUS
  373. ScepConvertToSDDLFormat(
  374. IN LPTSTR pszValue,
  375. IN DWORD Len
  376. );
  377. DWORD
  378. ScepWriteVariableUnicodeLog(
  379. IN HANDLE hFile,
  380. IN BOOL bAddCRLF,
  381. IN LPTSTR szFormat,
  382. ...
  383. );
  384. DWORD
  385. ScepWriteSingleUnicodeLog(
  386. IN HANDLE hFile,
  387. IN BOOL bAddCRLF,
  388. IN LPWSTR szMsg
  389. );
  390. WCHAR *
  391. ScepWcstrr(
  392. IN PWSTR pString,
  393. IN const WCHAR *pSubstring
  394. );
  395. DWORD
  396. ScepExpandEnvironmentVariable(
  397. IN PWSTR oldFileName,
  398. IN PCWSTR szEnv,
  399. IN DWORD nFlag,
  400. OUT PWSTR *newFileName
  401. );
  402. DWORD
  403. ScepEnforcePolicyPropagation();
  404. DWORD
  405. ScepGetTimeStampString(
  406. IN OUT PWSTR pvBuffer
  407. );
  408. DWORD
  409. ScepAppendCreateMultiSzRegValue(
  410. IN HKEY hKeyRoot,
  411. IN PWSTR pszSubKey,
  412. IN PWSTR pszValueName,
  413. IN PWSTR pszValueValue
  414. );
  415. DWORD
  416. ScepEscapeString(
  417. IN const PWSTR pszSource,
  418. IN const DWORD dwSourceChars,
  419. IN const WCHAR wcEscapee,
  420. IN const WCHAR wcEscaper,
  421. IN OUT PWSTR pszTarget
  422. );
  423. #endif