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.

529 lines
9.2 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. ntrtl.h
  5. Abstract:
  6. Include file for NT runtime routines that are callable by both
  7. kernel mode code in the executive and user mode code in various
  8. NT subsystems.
  9. Author:
  10. Steve Wood (stevewo) 31-Mar-1989
  11. Environment:
  12. These routines are statically linked in the caller's executable and
  13. are callable in either kernel mode or user mode.
  14. Revision History:
  15. --*/
  16. #ifndef _NTRTL_
  17. #define _NTRTL_
  18. //#include <win16nt.h>
  19. //*************************************************************************
  20. //
  21. // Types from ntseapi.h
  22. #ifdef remove
  23. #include <ntseapi.h>
  24. #endif //remove
  25. typedef PVOID PSECURITY_DESCRIPTOR; // winnt
  26. typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
  27. typedef USHORT SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
  28. typedef struct _SID_IDENTIFIER_AUTHORITY {
  29. UCHAR Value[6];
  30. } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY;
  31. typedef struct _SID_AND_ATTRIBUTES {
  32. PSID Sid;
  33. ULONG Attributes;
  34. } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES;
  35. typedef struct _LUID_AND_ATTRIBUTES {
  36. LUID Luid;
  37. ULONG Attributes;
  38. } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES;
  39. typedef ULONG ACCESS_MASK; // winnt
  40. typedef ACCESS_MASK *PACCESS_MASK;
  41. typedef struct _GENERIC_MAPPING {
  42. ACCESS_MASK GenericRead;
  43. ACCESS_MASK GenericWrite;
  44. ACCESS_MASK GenericExecute;
  45. ACCESS_MASK GenericAll;
  46. } GENERIC_MAPPING;
  47. typedef GENERIC_MAPPING *PGENERIC_MAPPING;
  48. typedef struct _ACL {
  49. UCHAR AclRevision;
  50. UCHAR Sbz1;
  51. USHORT AclSize;
  52. USHORT AceCount;
  53. USHORT Sbz2;
  54. } ACL;
  55. typedef ACL *PACL;
  56. typedef enum _ACL_INFORMATION_CLASS {
  57. AclRevisionInformation = 1,
  58. AclSizeInformation
  59. } ACL_INFORMATION_CLASS;
  60. typedef struct _PRIVILEGE_SET {
  61. ULONG PrivilegeCount;
  62. ULONG Control;
  63. LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
  64. } PRIVILEGE_SET, * PPRIVILEGE_SET;
  65. //
  66. //
  67. //*************************************************************************
  68. //
  69. // Fast primitives to compare, move, and zero memory
  70. //
  71. #ifdef remove
  72. ULONG
  73. RtlCompareMemory (
  74. IN PVOID Source1,
  75. IN PVOID Source2,
  76. IN ULONG Length
  77. );
  78. VOID
  79. RtlMoveMemory (
  80. IN PVOID Destination,
  81. IN PVOID Source,
  82. IN ULONG Length
  83. );
  84. VOID
  85. RtlFillMemory (
  86. IN PVOID Destination,
  87. IN ULONG Length,
  88. IN UCHAR Fill
  89. );
  90. VOID
  91. RtlFillMemoryUlong (
  92. IN PVOID Destination,
  93. IN ULONG Length,
  94. IN ULONG Pattern
  95. );
  96. VOID
  97. RtlZeroMemory (
  98. IN PVOID Destination,
  99. IN ULONG Length
  100. );
  101. #endif //remove
  102. //
  103. // Security ID RTL routine definitions
  104. //
  105. BOOLEAN
  106. RtlValidSid (
  107. IN PSID Sid
  108. );
  109. BOOLEAN
  110. RtlEqualSid (
  111. IN PSID Sid1,
  112. IN PSID Sid2
  113. );
  114. BOOLEAN
  115. RtlEqualPrefixSid (
  116. IN PSID Sid1,
  117. IN PSID Sid2
  118. );
  119. ULONG
  120. RtlLengthRequiredSid (
  121. IN ULONG SubAuthorityCount
  122. );
  123. VOID
  124. RtlInitializeSid (
  125. IN PSID Sid,
  126. IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
  127. IN ULONG SubAuthorityCount
  128. );
  129. PSID_IDENTIFIER_AUTHORITY
  130. RtlIdentifierAuthoritySid (
  131. IN PSID Sid
  132. );
  133. PULONG
  134. RtlSubAuthoritySid (
  135. IN PSID Sid,
  136. IN ULONG SubAuthority
  137. );
  138. PUCHAR
  139. RtlSubAuthorityCountSid (
  140. IN PSID Sid
  141. );
  142. ULONG
  143. RtlLengthSid (
  144. IN PSID Sid
  145. );
  146. NTSTATUS
  147. RtlCopySid (
  148. IN ULONG DestinationSidLength,
  149. OUT PSID DestinationSid,
  150. IN PSID SourceSid
  151. );
  152. NTSTATUS
  153. RtlCopySidAndAttributesArray (
  154. IN ULONG ArrayLength,
  155. IN PSID_AND_ATTRIBUTES Source,
  156. IN ULONG TargetSidBufferSize,
  157. OUT PSID_AND_ATTRIBUTES TargetArrayElement,
  158. OUT PSID TargetSid,
  159. OUT PSID *NextTargetSid,
  160. OUT PULONG RemainingTargetSidSize
  161. );
  162. //
  163. // LUID RTL routine definitions
  164. //
  165. VOID
  166. RtlCopyLuidAndAttributesArray (
  167. IN ULONG ArrayLength,
  168. IN PLUID_AND_ATTRIBUTES Source,
  169. OUT PLUID_AND_ATTRIBUTES Target
  170. );
  171. //
  172. // ACCESS_MASK RTL routine definitions
  173. //
  174. BOOLEAN
  175. RtlAreAllAccessesGranted(
  176. IN ACCESS_MASK GrantedAccess,
  177. IN ACCESS_MASK DesiredAccess
  178. );
  179. BOOLEAN
  180. RtlAreAnyAccessesGranted(
  181. IN ACCESS_MASK GrantedAccess,
  182. IN ACCESS_MASK DesiredAccess
  183. );
  184. VOID
  185. RtlMapGenericMask(
  186. IN OUT PACCESS_MASK AccessMask,
  187. IN PGENERIC_MAPPING GenericMapping
  188. );
  189. //
  190. // ACL RTL routine definitions
  191. //
  192. BOOLEAN
  193. RtlValidAcl (
  194. IN PACL Acl
  195. );
  196. NTSTATUS
  197. RtlCreateAcl (
  198. IN PACL Acl,
  199. IN ULONG AclLength,
  200. IN ULONG AclRevision
  201. );
  202. NTSTATUS
  203. RtlQueryInformationAcl (
  204. IN PACL Acl,
  205. OUT PVOID AclInformation,
  206. IN ULONG AclInformationLength,
  207. IN ACL_INFORMATION_CLASS AclInformationClass
  208. );
  209. NTSTATUS
  210. RtlSetInformationAcl (
  211. IN PACL Acl,
  212. IN PVOID AclInformation,
  213. IN ULONG AclInformationLength,
  214. IN ACL_INFORMATION_CLASS AclInformationClass
  215. );
  216. NTSTATUS
  217. RtlAddAce (
  218. IN OUT PACL Acl,
  219. IN ULONG AceRevision,
  220. IN ULONG StartingAceIndex,
  221. IN PVOID AceList,
  222. IN ULONG AceListLength
  223. );
  224. NTSTATUS
  225. RtlDeleteAce (
  226. IN OUT PACL Acl,
  227. IN ULONG AceIndex
  228. );
  229. NTSTATUS
  230. RtlGetAce (
  231. IN PACL Acl,
  232. IN ULONG AceIndex,
  233. OUT PVOID *Ace
  234. );
  235. NTSTATUS
  236. RtlAddAccessAllowedAce (
  237. IN OUT PACL Acl,
  238. IN ULONG AceRevision,
  239. IN ACCESS_MASK AccessMask,
  240. IN PSID Sid
  241. );
  242. NTSTATUS
  243. RtlAddAccessDeniedAce (
  244. IN OUT PACL Acl,
  245. IN ULONG AceRevision,
  246. IN ACCESS_MASK AccessMask,
  247. IN PSID Sid
  248. );
  249. NTSTATUS
  250. RtlAddAuditAccessAce (
  251. IN OUT PACL Acl,
  252. IN ULONG AceRevision,
  253. IN ACCESS_MASK AccessMask,
  254. IN PSID Sid,
  255. IN BOOLEAN AuditSuccess,
  256. IN BOOLEAN AuditFailure
  257. );
  258. BOOLEAN
  259. RtlFirstFreeAce (
  260. IN PACL Acl,
  261. OUT PVOID *FirstFree
  262. );
  263. //
  264. // SecurityDescriptor RTL routine definitions
  265. //
  266. NTSTATUS
  267. RtlCreateSecurityDescriptor (
  268. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  269. IN ULONG Revision
  270. );
  271. BOOLEAN
  272. RtlValidSecurityDescriptor (
  273. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  274. );
  275. ULONG
  276. RtlLengthSecurityDescriptor (
  277. IN PSECURITY_DESCRIPTOR SecurityDescriptor
  278. );
  279. NTSTATUS
  280. RtlGetControlSecurityDescriptor (
  281. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  282. OUT PSECURITY_DESCRIPTOR_CONTROL Control,
  283. OUT PULONG Revision
  284. );
  285. NTSTATUS
  286. RtlSetDaclSecurityDescriptor (
  287. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  288. IN BOOLEAN DaclPresent,
  289. IN PACL Dacl OPTIONAL,
  290. IN BOOLEAN DaclDefaulted OPTIONAL
  291. );
  292. NTSTATUS
  293. RtlGetDaclSecurityDescriptor (
  294. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  295. OUT PBOOLEAN DaclPresent,
  296. OUT PACL *Dacl,
  297. OUT PBOOLEAN DaclDefaulted
  298. );
  299. NTSTATUS
  300. RtlSetSaclSecurityDescriptor (
  301. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  302. IN BOOLEAN SaclPresent,
  303. IN PACL Sacl OPTIONAL,
  304. IN BOOLEAN SaclDefaulted OPTIONAL
  305. );
  306. NTSTATUS
  307. RtlGetSaclSecurityDescriptor (
  308. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  309. OUT PBOOLEAN SaclPresent,
  310. OUT PACL *Sacl,
  311. OUT PBOOLEAN SaclDefaulted
  312. );
  313. NTSTATUS
  314. RtlSetOwnerSecurityDescriptor (
  315. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  316. IN PSID Owner OPTIONAL,
  317. IN BOOLEAN OwnerDefaulted OPTIONAL
  318. );
  319. NTSTATUS
  320. RtlGetOwnerSecurityDescriptor (
  321. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  322. OUT PSID *Owner,
  323. OUT PBOOLEAN OwnerDefaulted
  324. );
  325. NTSTATUS
  326. RtlSetGroupSecurityDescriptor (
  327. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  328. IN PSID Group OPTIONAL,
  329. IN BOOLEAN GroupDefaulted OPTIONAL
  330. );
  331. NTSTATUS
  332. RtlGetGroupSecurityDescriptor (
  333. IN PSECURITY_DESCRIPTOR SecurityDescriptor,
  334. OUT PSID *Group,
  335. OUT PBOOLEAN GroupDefaulted
  336. );
  337. NTSTATUS
  338. RtlMakeSelfRelativeSD(
  339. IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
  340. IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
  341. IN OUT PULONG BufferLength
  342. );
  343. NTSTATUS
  344. RtlAbsoluteToSelfRelativeSD(
  345. IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
  346. IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
  347. IN OUT PULONG BufferLength
  348. );
  349. NTSTATUS
  350. RtlSelfRelativeToAbsoluteSD(
  351. IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
  352. OUT PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
  353. IN OUT PULONG AbsoluteSecurityDescriptorSize,
  354. IN OUT PACL Dacl,
  355. IN OUT PULONG DaclSize,
  356. IN OUT PACL Sacl,
  357. IN OUT PULONG SaclSize,
  358. IN OUT PSID Owner,
  359. IN OUT PULONG OwnerSize,
  360. IN OUT PSID PrimaryGroup,
  361. IN OUT PULONG PrimaryGroupSize
  362. );
  363. NTSTATUS
  364. RtlNewSecurityGrantedAccess(
  365. IN ACCESS_MASK DesiredAccess,
  366. OUT PPRIVILEGE_SET Privileges,
  367. IN OUT PULONG Length,
  368. IN HANDLE Token OPTIONAL,
  369. IN PGENERIC_MAPPING GenericMapping,
  370. OUT PACCESS_MASK RemainingDesiredAccess
  371. );
  372. #ifdef remove
  373. typedef struct _MESSAGE_RESOURCE_ENTRY {
  374. USHORT Length;
  375. USHORT Reserved;
  376. UCHAR Text[ 1 ];
  377. } MESSAGE_RESOURCE_ENTRY, *PMESSAGE_RESOURCE_ENTRY;
  378. typedef struct _MESSAGE_RESOURCE_BLOCK {
  379. ULONG LowId;
  380. ULONG HighId;
  381. ULONG OffsetToEntries;
  382. } MESSAGE_RESOURCE_BLOCK, *PMESSAGE_RESOURCE_BLOCK;
  383. typedef struct _MESSAGE_RESOURCE_DATA {
  384. ULONG NumberOfBlocks;
  385. MESSAGE_RESOURCE_BLOCK Blocks[ 1 ];
  386. } MESSAGE_RESOURCE_DATA, *PMESSAGE_RESOURCE_DATA;
  387. NTSTATUS
  388. RtlFindMessage(
  389. IN PVOID DllHandle,
  390. IN ULONG MessageTableId,
  391. IN ULONG MessageLanguageId,
  392. IN ULONG MessageId,
  393. OUT PMESSAGE_RESOURCE_ENTRY *MessageEntry
  394. );
  395. #endif //remove
  396. //
  397. // Routine for converting NT status codes to DOS/OS|2 equivalents.
  398. //
  399. ULONG
  400. *RtlNtStatusToDosError (
  401. IN NTSTATUS Status
  402. );
  403. #endif // _NTRTL_