1 /* $Id: rtl.h,v 1.1 2002/09/07 15:12:21 chorns Exp $
10 InitializeUnicodeString (
11 PUNICODE_STRING DestinationString,
17 Initialize an UNICODE_STRING from its fields. Use when you know the values of
18 all the fields in advance
22 #define InitializeUnicodeString(__PDEST_STRING__,__LENGTH__,__MAXLENGTH__,__BUFFER__) \
24 (__PDEST_STRING__)->Length = (__LENGTH__); \
25 (__PDEST_STRING__)->MaximumLength = (__MAXLENGTH__); \
26 (__PDEST_STRING__)->Buffer = (__BUFFER__); \
31 RtlInitUnicodeStringFromLiteral (
32 PUNICODE_STRING DestinationString,
36 Initialize an UNICODE_STRING from a wide string literal. WARNING: use only with
37 string literals and statically initialized arrays, it will calculate the wrong
42 #define RtlInitUnicodeStringFromLiteral(__PDEST_STRING__,__SOURCE_STRING__) \
43 InitializeUnicodeString( \
45 sizeof(__SOURCE_STRING__) - sizeof(WCHAR), \
46 sizeof(__SOURCE_STRING__), \
51 Static initializer for UNICODE_STRING variables. Usage:
53 UNICODE_STRING wstr = UNICODE_STRING_INITIALIZER(L"string");
57 #define UNICODE_STRING_INITIALIZER(__SOURCE_STRING__) \
59 sizeof((__SOURCE_STRING__)) - sizeof(WCHAR), \
60 sizeof((__SOURCE_STRING__)), \
65 Initializer for empty UNICODE_STRING variables. Usage:
67 UNICODE_STRING wstr = EMPTY_UNICODE_STRING;
70 #define EMPTY_UNICODE_STRING {0, 0, NULL}
72 typedef struct _INITIAL_TEB
79 } INITIAL_TEB
, *PINITIAL_TEB
;
81 typedef struct _RTL_HEAP_DEFINITION
85 } RTL_HEAP_DEFINITION
, *PRTL_HEAP_DEFINITION
;
87 typedef struct _RTL_ATOM_TABLE
91 PVOID Lock
; /* fast mutex (kernel mode)/ critical section (user mode) */
94 } RTL_ATOM_TABLE
, *PRTL_ATOM_TABLE
;
96 typedef struct _LB_RANGE
102 typedef struct _RTL_NLS_DATA
105 USHORT MaxCharacterSize
; // SBCS = 1, DBCS = 2
106 WCHAR DefaultCharacter
;
111 LB_RANGE LeadByteRange
[6];
113 PWCHAR MultiByteToUnicode
;
114 PCHAR UnicodeToMultiByte
;
115 PWCHAR DosMultiByteToUnicode
;
117 } RTL_NLS_DATA
, *PRTL_NLS_DATA
;
119 typedef struct _RTL_NLS_TABLE
121 RTL_NLS_DATA OemInfo
;
122 RTL_NLS_DATA AnsiInfo
;
124 PWCHAR DowncaseTable
;
125 } RTL_NLS_TABLE
, *PRTL_NLS_TABLE
;
128 typedef struct _RTL_GENERIC_TABLE
136 PVOID CompareRoutine
;
137 PVOID AllocateRoutine
;
140 } RTL_GENERIC_TABLE
, *PRTL_GENERIC_TABLE
;
143 typedef struct _RTL_MESSAGE_RESOURCE_ENTRY
148 } RTL_MESSAGE_RESOURCE_ENTRY
, *PRTL_MESSAGE_RESOURCE_ENTRY
;
150 typedef struct _RTL_MESSAGE_RESOURCE_BLOCK
154 ULONG OffsetToEntries
;
155 } RTL_MESSAGE_RESOURCE_BLOCK
, *PRTL_MESSAGE_RESOURCE_BLOCK
;
157 typedef struct _RTL_MESSAGE_RESOURCE_DATA
159 ULONG NumberOfBlocks
;
160 RTL_MESSAGE_RESOURCE_BLOCK Blocks
[1];
161 } RTL_MESSAGE_RESOURCE_DATA
, *PRTL_MESSAGE_RESOURCE_DATA
;
164 * PURPOSE: Used with RtlCheckRegistryKey, RtlCreateRegistryKey,
165 * RtlDeleteRegistryKey
167 #define RTL_REGISTRY_ABSOLUTE 0
168 #define RTL_REGISTRY_SERVICES 1
169 #define RTL_REGISTRY_CONTROL 2
170 #define RTL_REGISTRY_WINDOWS_NT 3
171 #define RTL_REGISTRY_DEVICEMAP 4
172 #define RTL_REGISTRY_USER 5
173 #define RTL_REGISTRY_ENUM 6 // ReactOS specific: Used internally in kernel only
174 #define RTL_REGISTRY_MAXIMUM 7
176 #define RTL_REGISTRY_HANDLE 0x40000000
177 #define RTL_REGISTRY_OPTIONAL 0x80000000
180 #define SHORT_SIZE (sizeof(USHORT))
181 #define SHORT_MASK (SHORT_SIZE-1)
182 #define LONG_SIZE (sizeof(ULONG))
183 #define LONG_MASK (LONG_SIZE-1)
184 #define LOWBYTE_MASK 0x00FF
186 #define FIRSTBYTE(Value) ((Value) & LOWBYTE_MASK)
187 #define SECONDBYTE(Value) (((Value) >> 8) & LOWBYTE_MASK)
188 #define THIRDBYTE(Value) (((Value) >> 16) & LOWBYTE_MASK)
189 #define FOURTHBYTE(Value) (((Value) >> 24) & LOWBYTE_MASK)
191 /* FIXME: reverse byte-order on big-endian machines (e.g. MIPS) */
192 #define SHORT_LEAST_SIGNIFICANT_BIT 0
193 #define SHORT_MOST_SIGNIFICANT_BIT 1
195 #define LONG_LEAST_SIGNIFICANT_BIT 0
196 #define LONG_3RD_MOST_SIGNIFICANT_BIT 1
197 #define LONG_2RD_MOST_SIGNIFICANT_BIT 2
198 #define LONG_MOST_SIGNIFICANT_BIT 3
202 #if defined(_NTOSKRNL_) || defined(__NTDLL__)
203 #define NLS_MB_CODE_PAGE_TAG NlsMbCodePageTag
204 #define NLS_MB_OEM_CODE_PAGE_TAG NlsMbOemCodePageTag
206 #define NLS_MB_CODE_PAGE_TAG (*NlsMbCodePageTag)
207 #define NLS_MB_OEM_CODE_PAGE_TAG (*NlsMbOemCodePageTag)
208 #endif /* _NTOSKRNL_ || __NTDLL__ */
210 extern BOOLEAN NLS_MB_CODE_PAGE_TAG
;
211 extern BOOLEAN NLS_MB_OEM_CODE_PAGE_TAG
;
215 * NOTE: ReactOS extensions
217 #define RtlMin(X,Y) (((X) < (Y))? (X) : (Y))
218 #define RtlMax(X,Y) (((X) > (Y))? (X) : (Y))
219 #define RtlMin3(X,Y,Z) (((X) < (Y)) ? RtlMin(X,Z) : RtlMin(Y,Z))
220 #define RtlMax3(X,Y,Z) (((X) > (Y)) ? RtlMax(X,Z) : RtlMax(Y,Z))
225 * InitializeObjectAttributes (
226 * POBJECT_ATTRIBUTES InitializedAttributes,
227 * PUNICODE_STRING ObjectName,
229 * HANDLE RootDirectory,
230 * PSECURITY_DESCRIPTOR SecurityDescriptor
233 * FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
234 * subsequent call to ZwCreateXXX or ZwOpenXXX
236 * InitializedAttributes (OUT) = Caller supplied storage for the
238 * ObjectName = Full path name for object
239 * Attributes = Attributes for the object
240 * RootDirectory = Where the object should be placed or NULL
241 * SecurityDescriptor = Ignored
243 #define InitializeObjectAttributes(p,n,a,r,s) \
245 (p)->Length = sizeof(OBJECT_ATTRIBUTES); \
246 (p)->ObjectName = n; \
247 (p)->Attributes = a; \
248 (p)->RootDirectory = r; \
249 (p)->SecurityDescriptor = s; \
250 (p)->SecurityQualityOfService = NULL; \
255 * An ReactOS extension
261 PSLIST_HEADER ListHead
264 PSINGLE_LIST_ENTRY ListEntry
;
266 ListEntry
= ListHead
->Next
.Next
;
269 ListHead
->Next
.Next
= ListEntry
->Next
;
271 ListHead
->Sequence
++;
278 * An ReactOS extension
284 PSLIST_HEADER ListHead
,
285 PSINGLE_LIST_ENTRY Entry
288 Entry
->Next
= ListHead
->Next
.Next
;
289 ListHead
->Next
.Next
= Entry
;
291 ListHead
->Sequence
++;
296 RtlAddAtomToAtomTable (
297 IN PRTL_ATOM_TABLE AtomTable
,
311 RtlAnsiCharToUnicodeChar (
317 RtlAnsiStringToUnicodeSize (
318 PANSI_STRING AnsiString
323 RtlAnsiStringToUnicodeString (
324 PUNICODE_STRING DestinationString
,
325 PANSI_STRING SourceString
,
326 BOOLEAN AllocateDestinationString
331 RtlAppendAsciizToString(
338 RtlAppendStringToString (
345 RtlAppendUnicodeStringToString (
346 PUNICODE_STRING Destination
,
347 PUNICODE_STRING Source
353 PRTL_BITMAP BitMapHeader
,
361 PRTL_BITMAP BitMapHeader
,
369 PVOID FailedAssertion
,
385 RtlCheckRegistryKey (
393 IN PRTL_BITMAP BitMapHeader
399 IN PRTL_BITMAP BitMapHeader
,
400 IN ULONG StartingIndex
,
401 IN ULONG NumberToClear
416 BOOLEAN CaseInsensitive
421 RtlCompareUnicodeString (
422 PUNICODE_STRING String1
,
423 PUNICODE_STRING String2
,
424 BOOLEAN BaseInsensitive
429 RtlConvertLongToLargeInteger (
430 IN LONG SignedInteger
435 RtlConvertSidToUnicodeString (
436 IN OUT PUNICODE_STRING String
,
438 IN BOOLEAN AllocateString
443 RtlConvertUlongToLargeInteger (
444 IN ULONG UnsignedInteger
458 #define RtlCopyMemory(Destination,Source,Length) \
459 memcpy((Destination),(Source),(Length))
461 #define RtlCopyBytes RtlCopyMemory
464 RtlCopyLuid(IN PLUID LuidDest
,
470 PSTRING DestinationString
,
476 RtlCopyUnicodeString (
477 PUNICODE_STRING DestinationString
,
478 PUNICODE_STRING SourceString
485 IN OUT PRTL_ATOM_TABLE
*AtomTable
496 PRTL_HEAP_DEFINITION Definition
501 RtlCreateRegistryKey (
508 RtlCreateSecurityDescriptor (
509 PSECURITY_DESCRIPTOR SecurityDescriptor
,
515 RtlCreateUnicodeString (
516 OUT PUNICODE_STRING Destination
,
522 RtlCreateUnicodeStringFromAsciiz (
523 OUT PUNICODE_STRING Destination
,
529 RtlCustomCPToUnicodeN (
530 PRTL_NLS_DATA NlsData
,
531 PWCHAR UnicodeString
,
540 RtlDeleteAtomFromAtomTable (
541 IN PRTL_ATOM_TABLE AtomTable
,
547 RtlDestroyAtomTable (
548 IN PRTL_ATOM_TABLE AtomTable
559 RtlDowncaseUnicodeString (
560 IN OUT PUNICODE_STRING DestinationString
,
561 IN PUNICODE_STRING SourceString
,
562 IN BOOLEAN AllocateDestinationString
568 IN PRTL_ATOM_TABLE AtomTable
,
569 IN BOOLEAN DeletePinned
574 RtlEnlargedIntegerMultiply (
581 RtlEnlargedUnsignedDivide (
582 ULARGE_INTEGER Dividend
,
589 RtlEnlargedUnsignedMultiply (
595 RtlEqualLuid(IN PLUID Luid1
,
604 BOOLEAN CaseInSensitive
609 RtlExtendedIntegerMultiply (
610 LARGE_INTEGER Multiplicand
,
616 RtlExtendedLargeIntegerDivide (
617 LARGE_INTEGER Dividend
,
624 RtlExtendedMagicDivide (
625 LARGE_INTEGER Dividend
,
626 LARGE_INTEGER MagicDivisor
,
651 PRTL_BITMAP BitMapHeader
,
658 RtlFindClearBitsAndSet (
659 PRTL_BITMAP BitMapHeader
,
666 RtlFindFirstRunClear (
667 PRTL_BITMAP BitMapHeader
,
674 PRTL_BITMAP BitMapHeader
,
680 RtlFindLongestRunClear (
681 PRTL_BITMAP BitMapHeader
,
687 RtlFindLongestRunSet (
688 PRTL_BITMAP BitMapHeader
,
695 IN PVOID BaseAddress
,
699 OUT PRTL_MESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
705 PRTL_BITMAP BitMapHeader
,
712 RtlFindSetBitsAndClear (
713 PRTL_BITMAP BitMapHeader
,
720 RtlFormatCurrentUserKeyPath (
721 IN OUT PUNICODE_STRING KeyPath
727 PANSI_STRING AnsiString
741 POEM_STRING OemString
746 RtlFreeUnicodeString (
747 PUNICODE_STRING UnicodeString
751 RtlGenerate8dot3Name(IN PUNICODE_STRING Name
,
752 IN BOOLEAN AllowExtendedCharacters
,
753 IN OUT PGENERATE_NAME_CONTEXT Context
,
754 OUT PUNICODE_STRING Name8dot3
);
758 RtlGetDefaultCodePage (
759 PUSHORT AnsiCodePage
,
766 * RtlGetProcessHeap (
770 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
775 RtlImageDirectoryEntryToData (
788 PIMAGE_SECTION_HEADER
790 RtlImageRvaToSection (
791 PIMAGE_NT_HEADERS NtHeader
,
799 PIMAGE_NT_HEADERS NtHeader
,
802 PIMAGE_SECTION_HEADER
*SectionHeader
808 PANSI_STRING DestinationString
,
815 PSTRING DestinationString
,
821 RtlInitUnicodeString (
822 PUNICODE_STRING DestinationString
,
828 RtlInitializeBitMap (
829 IN OUT PRTL_BITMAP BitMapHeader
,
830 IN PULONG BitMapBuffer
,
831 IN ULONG SizeOfBitMap
836 RtlInitializeContext (
837 IN HANDLE ProcessHandle
,
840 IN PTHREAD_START_ROUTINE StartAddress
,
841 IN OUT PINITIAL_TEB InitialTeb
846 RtlInitializeGenericTable (
847 IN OUT PRTL_GENERIC_TABLE Table
,
848 IN PVOID CompareRoutine
,
849 IN PVOID AllocateRoutine
,
850 IN PVOID FreeRoutine
,
851 IN ULONG UserParameter
856 RtlInsertElementGenericTable (
857 IN OUT PRTL_GENERIC_TABLE Table
,
859 IN ULONG ElementSize
,
874 RtlIntegerToUnicodeString (
877 IN OUT PUNICODE_STRING String
882 RtlIsGenericTableEmpty (
883 IN PRTL_GENERIC_TABLE Table
887 RtlIsNameLegalDOS8Dot3(IN PUNICODE_STRING UnicodeName
,
888 IN PANSI_STRING AnsiName
,
889 OUT PBOOLEAN SpacesFound
);
894 LARGE_INTEGER Addend1
,
895 LARGE_INTEGER Addend2
900 * RtlLargeIntegerAnd (
901 * PLARGE_INTEGER Result,
902 * LARGE_INTEGER Source,
906 #define RtlLargeIntegerAnd(Result, Source, Mask) \
908 Result.HighPart = Source.HighPart & Mask.HighPart; \
909 Result.LowPart = Source.LowPart & Mask.LowPart; \
914 RtlLargeIntegerArithmeticShift (
915 LARGE_INTEGER LargeInteger
,
921 RtlLargeIntegerDivide (
922 LARGE_INTEGER Dividend
,
923 LARGE_INTEGER Divisor
,
924 PLARGE_INTEGER Remainder
929 * RtlLargeIntegerEqualTo (
930 * LARGE_INTEGER Operand1,
931 * LARGE_INTEGER Operand2
934 #define RtlLargeIntegerEqualTo(X,Y) \
935 (!(((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
939 * RtlLargeIntegerEqualToZero (
940 * LARGE_INTEGER Operand
943 #define RtlLargeIntegerEqualToZero(X) \
944 (!((X).LowPart | (X).HighPart))
948 * RtlLargeIntegerGreaterThan (
949 * LARGE_INTEGER Operand1,
950 * LARGE_INTEGER Operand2
953 #define RtlLargeIntegerGreaterThan(X,Y) \
954 ((((X).HighPart == (Y).HighPart) && ((X).LowPart > (Y).LowPart)) || \
955 ((X).HighPart > (Y).HighPart))
959 * RtlLargeIntegerGreaterThanOrEqualTo (
960 * LARGE_INTEGER Operand1,
961 * LARGE_INTEGER Operand2
964 #define RtlLargeIntegerGreaterThanOrEqualTo(X,Y) \
965 ((((X).HighPart == (Y).HighPart) && ((X).LowPart >= (Y).LowPart)) || \
966 ((X).HighPart > (Y).HighPart))
970 * RtlLargeIntegerGreaterThanOrEqualToZero (
971 * LARGE_INTEGER Operand1
974 #define RtlLargeIntegerGreaterOrEqualToZero(X) \
979 * RtlLargeIntegerGreaterThanZero (
980 * LARGE_INTEGER Operand1
983 #define RtlLargeIntegerGreaterThanZero(X) \
984 ((((X).HighPart == 0) && ((X).LowPart > 0)) || \
989 * RtlLargeIntegerLessThan (
990 * LARGE_INTEGER Operand1,
991 * LARGE_INTEGER Operand2
994 #define RtlLargeIntegerLessThan(X,Y) \
995 ((((X).HighPart == (Y).HighPart) && ((X).LowPart < (Y).LowPart)) || \
996 ((X).HighPart < (Y).HighPart))
1000 * RtlLargeIntegerLessThanOrEqualTo (
1001 * LARGE_INTEGER Operand1,
1002 * LARGE_INTEGER Operand2
1005 #define RtlLargeIntegerLessThanOrEqualTo(X,Y) \
1006 ((((X).HighPart == (Y).HighPart) && ((X).LowPart <= (Y).LowPart)) || \
1007 ((X).HighPart < (Y).HighPart))
1011 * RtlLargeIntegerLessThanOrEqualToZero (
1012 * LARGE_INTEGER Operand
1015 #define RtlLargeIntegerLessOrEqualToZero(X) \
1016 (((X).HighPart < 0) || !((X).LowPart | (X).HighPart))
1020 * RtlLargeIntegerLessThanZero (
1021 * LARGE_INTEGER Operand
1024 #define RtlLargeIntegerLessThanZero(X) \
1025 (((X).HighPart < 0))
1029 RtlLargeIntegerNegate (
1030 LARGE_INTEGER Subtrahend
1035 * RtlLargeIntegerNotEqualTo (
1036 * LARGE_INTEGER Operand1,
1037 * LARGE_INTEGER Operand2
1040 #define RtlLargeIntegerNotEqualTo(X,Y) \
1041 ((((X).LowPart ^ (Y).LowPart) | ((X).HighPart ^ (Y).HighPart)))
1045 * RtlLargeIntegerNotEqualToZero (
1046 * LARGE_INTEGER Operand
1049 #define RtlLargeIntegerNotEqualToZero(X) \
1050 (((X).LowPart | (X).HighPart))
1054 RtlLargeIntegerShiftLeft (
1055 LARGE_INTEGER LargeInteger
,
1061 RtlLargeIntegerShiftRight (
1062 LARGE_INTEGER LargeInteger
,
1068 RtlLargeIntegerSubtract (
1069 LARGE_INTEGER Minuend
,
1070 LARGE_INTEGER Subtrahend
1075 RtlLengthSecurityDescriptor (
1076 PSECURITY_DESCRIPTOR SecurityDescriptor
1087 RtlLookupAtomInAtomTable (
1088 IN PRTL_ATOM_TABLE AtomTable
,
1093 #undef RtlMoveMemory
1096 RtlMoveMemory (PVOID Destination
, CONST VOID
* Source
, ULONG Length
);
1100 RtlMultiByteToUnicodeN (
1101 PWCHAR UnicodeString
,
1110 RtlMultiByteToUnicodeSize (
1118 RtlNtStatusToDosError (
1124 RtlNtStatusToDosErrorNoTeb (
1130 RtlNtStatusToPsxErrno (
1136 RtlNumberGenericTableElements (
1137 IN PRTL_GENERIC_TABLE Table
1142 RtlNumberOfClearBits (
1143 PRTL_BITMAP BitMapHeader
1148 RtlNumberOfSetBits (
1149 PRTL_BITMAP BitMapHeader
1154 RtlOemStringToUnicodeSize (
1155 POEM_STRING AnsiString
1160 RtlOemStringToUnicodeString (
1161 PUNICODE_STRING DestinationString
,
1162 POEM_STRING SourceString
,
1163 BOOLEAN AllocateDestinationString
1169 PWCHAR UnicodeString
,
1178 RtlOpenCurrentUser (
1179 IN ACCESS_MASK DesiredAccess
,
1180 OUT PHANDLE KeyHandle
1184 RtlPinAtomInAtomTable (
1185 IN PRTL_ATOM_TABLE AtomTable
,
1192 PANSI_STRING String1
,
1193 PANSI_STRING String2
,
1194 BOOLEAN CaseInsensitive
1199 RtlPrefixUnicodeString (
1200 PUNICODE_STRING String1
,
1201 PUNICODE_STRING String2
,
1202 BOOLEAN CaseInsensitive
1207 RtlQueryAtomInAtomTable (
1208 IN PRTL_ATOM_TABLE AtomTable
,
1210 IN OUT PULONG RefCount OPTIONAL
,
1211 IN OUT PULONG PinCount OPTIONAL
,
1212 IN OUT PWSTR AtomName OPTIONAL
,
1213 IN OUT PULONG NameLength OPTIONAL
1218 RtlQueryTimeZoneInformation (
1219 IN OUT PTIME_ZONE_INFORMATION TimeZoneInformation
1225 IN PEXCEPTION_RECORD ExceptionRecord
1239 * RtlRetrieveUlong (
1240 * PULONG DestinationAddress,
1241 * PULONG SourceAddress
1244 #define RtlRetrieveUlong(DestAddress,SrcAddress) \
1245 if ((ULONG)(SrcAddress) & LONG_MASK) \
1247 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
1248 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
1249 ((PUCHAR)(DestAddress))[2]=((PUCHAR)(SrcAddress))[2]; \
1250 ((PUCHAR)(DestAddress))[3]=((PUCHAR)(SrcAddress))[3]; \
1254 *((PULONG)(DestAddress))=*((PULONG)(SrcAddress)); \
1259 * RtlRetrieveUshort (
1260 * PUSHORT DestinationAddress,
1261 * PUSHORT SourceAddress
1264 #define RtlRetrieveUshort(DestAddress,SrcAddress) \
1265 if ((ULONG)(SrcAddress) & SHORT_MASK) \
1267 ((PUCHAR)(DestAddress))[0]=((PUCHAR)(SrcAddress))[0]; \
1268 ((PUCHAR)(DestAddress))[1]=((PUCHAR)(SrcAddress))[1]; \
1272 *((PUSHORT)(DestAddress))=*((PUSHORT)(SrcAddress)); \
1277 RtlSecondsSince1970ToTime (
1278 ULONG SecondsSince1970
,
1284 RtlSecondsSince1980ToTime (
1285 ULONG SecondsSince1980
,
1292 IN PRTL_BITMAP BitMapHeader
1298 PRTL_BITMAP BitMapHeader
,
1299 ULONG StartingIndex
,
1305 RtlSetDaclSecurityDescriptor (
1306 PSECURITY_DESCRIPTOR SecurityDescriptor
,
1307 BOOLEAN DaclPresent
,
1309 BOOLEAN DaclDefaulted
1314 RtlSetTimeZoneInformation (
1315 IN OUT PTIME_ZONE_INFORMATION TimeZoneInformation
1333 #define RtlStoreUlong(Address,Value) \
1334 if ((ULONG)(Address) & LONG_MASK) \
1336 ((PUCHAR)(Address))[LONG_LEAST_SIGNIFICANT_BIT]=(UCHAR)(FIRSTBYTE(Value)); \
1337 ((PUCHAR)(Address))[LONG_3RD_MOST_SIGNIFICANT_BIT]=(UCHAR)(FIRSTBYTE(Value)); \
1338 ((PUCHAR)(Address))[LONG_2ND_MOST_SIGNIFICANT_BIT]=(UCHAR)(THIRDBYTE(Value)); \
1339 ((PUCHAR)(Address))[LONG_MOST_SIGNIFICANT_BIT]=(UCHAR)(FOURTHBYTE(Value)); \
1343 *((PULONG)(Address))=(ULONG)(Value); \
1353 #define RtlStoreUshort(Address,Value) \
1354 if ((ULONG)(Address) & SHORT_MASK) \
1356 ((PUCHAR)(Address))[SHORT_LEAST_SIGNIFICANT_BIT]=(UCHAR)(FIRSTBYTE(Value)); \
1357 ((PUCHAR)(Address))[SHORT_MOST_SIGNIFICANT_BIT]=(UCHAR)(SECONDBYTE(Value)); \
1361 *((PUSHORT)(Address))=(USHORT)(Value); \
1366 RtlTimeFieldsToTime (
1367 PTIME_FIELDS TimeFields
,
1373 RtlTimeToSecondsSince1970 (
1374 PLARGE_INTEGER Time
,
1375 PULONG SecondsSince1970
1380 RtlTimeToSecondsSince1980 (
1381 PLARGE_INTEGER Time
,
1382 PULONG SecondsSince1980
1387 RtlTimeToTimeFields (
1388 PLARGE_INTEGER Time
,
1389 PTIME_FIELDS TimeFields
1394 RtlUnicodeStringToAnsiSize (
1395 IN PUNICODE_STRING UnicodeString
1400 RtlUnicodeStringToAnsiString (
1401 IN OUT PANSI_STRING DestinationString
,
1402 IN PUNICODE_STRING SourceString
,
1403 IN BOOLEAN AllocateDestinationString
1408 RtlUnicodeStringToInteger (
1409 IN PUNICODE_STRING String
,
1416 RtlUnicodeStringToOemSize (
1417 IN PUNICODE_STRING UnicodeString
1422 RtlUnicodeStringToCountedOemString (
1423 IN OUT POEM_STRING DestinationString
,
1424 IN PUNICODE_STRING SourceString
,
1425 IN BOOLEAN AllocateDestinationString
1430 RtlUnicodeStringToOemString (
1431 IN OUT POEM_STRING DestinationString
,
1432 IN PUNICODE_STRING SourceString
,
1433 IN BOOLEAN AllocateDestinationString
1438 RtlUnicodeToCustomCPN (
1439 PRTL_NLS_DATA NlsData
,
1443 PWCHAR UnicodeString
,
1449 RtlUnicodeToMultiByteN (
1453 PWCHAR UnicodeString
,
1459 RtlUnicodeToMultiByteSize (
1461 PWCHAR UnicodeString
,
1471 PWCHAR UnicodeString
,
1484 PEXCEPTION_REGISTRATION RegistrationFrame
,
1485 PVOID ReturnAddress
,
1486 PEXCEPTION_RECORD ExceptionRecord
,
1492 RtlUpcaseUnicodeChar (
1498 RtlUpcaseUnicodeString (
1499 IN OUT PUNICODE_STRING DestinationString
,
1500 IN PUNICODE_STRING SourceString
,
1501 IN BOOLEAN AllocateDestinationString
1506 RtlUpcaseUnicodeStringToAnsiString (
1507 IN OUT PANSI_STRING DestinationString
,
1508 IN PUNICODE_STRING SourceString
,
1509 IN BOOLEAN AllocateDestinationString
1514 RtlUpcaseUnicodeStringToCountedOemString (
1515 IN OUT POEM_STRING DestinationString
,
1516 IN PUNICODE_STRING SourceString
,
1517 IN BOOLEAN AllocateDestinationString
1522 RtlUpcaseUnicodeStringToOemString (
1523 IN OUT POEM_STRING DestinationString
,
1524 IN PUNICODE_STRING SourceString
,
1525 IN BOOLEAN AllocateDestinationString
1530 RtlUpcaseUnicodeToCustomCPN (
1531 PRTL_NLS_DATA NlsData
,
1535 PWCHAR UnicodeString
,
1541 RtlUpcaseUnicodeToMultiByteN (
1545 PWCHAR UnicodeString
,
1551 RtlUpcaseUnicodeToOemN (
1555 PWCHAR UnicodeString
,
1568 PSTRING DestinationString
,
1569 PSTRING SourceString
1582 RtlValidSecurityDescriptor (
1583 PSECURITY_DESCRIPTOR SecurityDescriptor
1587 RtlValidSid(IN PSID Sid
);
1589 #undef RtlZeroMemory
1592 RtlZeroMemory (PVOID Destination
, ULONG Length
);
1596 RtlxAnsiStringToUnicodeSize (
1597 IN PANSI_STRING AnsiString
1602 RtlxOemStringToUnicodeSize (
1603 IN POEM_STRING OemString
1608 RtlxUnicodeStringToAnsiSize (
1609 IN PUNICODE_STRING UnicodeString
1614 RtlxUnicodeStringToOemSize (
1615 IN PUNICODE_STRING UnicodeString
1619 /* Register io functions */
1623 READ_REGISTER_UCHAR (
1629 READ_REGISTER_USHORT (
1635 READ_REGISTER_ULONG (
1641 READ_REGISTER_BUFFER_UCHAR (
1649 READ_REGISTER_BUFFER_USHORT (
1657 READ_REGISTER_BUFFER_ULONG (
1665 WRITE_REGISTER_UCHAR (
1672 WRITE_REGISTER_USHORT (
1679 WRITE_REGISTER_ULONG (
1686 WRITE_REGISTER_BUFFER_UCHAR (
1694 WRITE_REGISTER_BUFFER_USHORT (
1702 WRITE_REGISTER_BUFFER_ULONG (
1709 NTSTATUS STDCALL
RtlCreateAcl(PACL Acl
, ULONG AclSize
, ULONG AclRevision
);
1710 NTSTATUS STDCALL
RtlQueryInformationAcl (PACL Acl
, PVOID Information
, ULONG InformationLength
, ACL_INFORMATION_CLASS InformationClass
);
1711 NTSTATUS STDCALL
RtlSetInformationAcl (PACL Acl
, PVOID Information
, ULONG InformationLength
, ACL_INFORMATION_CLASS InformationClass
);
1712 BOOLEAN STDCALL
RtlValidAcl (PACL Acl
);
1714 NTSTATUS STDCALL
RtlAddAccessAllowedAce(PACL Acl
, ULONG Revision
, ACCESS_MASK AccessMask
, PSID Sid
);
1715 NTSTATUS STDCALL
RtlAddAccessDeniedAce(PACL Acl
, ULONG Revision
, ACCESS_MASK AccessMask
, PSID Sid
);
1716 NTSTATUS STDCALL
RtlAddAce(PACL Acl
, ULONG Revision
, ULONG StartingIndex
, PACE AceList
, ULONG AceListLength
);
1717 NTSTATUS STDCALL
RtlAddAuditAccessAce (PACL Acl
, ULONG Revision
, ACCESS_MASK AccessMask
, PSID Sid
, BOOLEAN Success
, BOOLEAN Failure
);
1718 NTSTATUS STDCALL
RtlDeleteAce(PACL Acl
, ULONG AceIndex
);
1719 BOOLEAN STDCALL
RtlFirstFreeAce(PACL Acl
, PACE
* Ace
);
1720 NTSTATUS STDCALL
RtlGetAce(PACL Acl
, ULONG AceIndex
, PACE
*Ace
);
1722 NTSTATUS STDCALL
RtlAbsoluteToSelfRelativeSD (PSECURITY_DESCRIPTOR AbsSD
, PSECURITY_DESCRIPTOR RelSD
, PULONG BufferLength
);
1723 NTSTATUS STDCALL
RtlMakeSelfRelativeSD (PSECURITY_DESCRIPTOR AbsSD
, PSECURITY_DESCRIPTOR RelSD
, PULONG BufferLength
);
1724 NTSTATUS STDCALL
RtlCreateSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, ULONG Revision
);
1725 BOOLEAN STDCALL
RtlValidSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
);
1726 ULONG STDCALL
RtlLengthSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
);
1727 NTSTATUS STDCALL
RtlSetDaclSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, BOOLEAN DaclPresent
, PACL Dacl
, BOOLEAN DaclDefaulted
);
1728 NTSTATUS STDCALL
RtlGetDaclSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PBOOLEAN DaclPresent
, PACL
* Dacl
, PBOOLEAN DaclDefauted
);
1729 NTSTATUS STDCALL
RtlSetOwnerSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PSID Owner
, BOOLEAN OwnerDefaulted
);
1730 NTSTATUS STDCALL
RtlGetOwnerSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PSID
* Owner
, PBOOLEAN OwnerDefaulted
);
1731 NTSTATUS STDCALL
RtlSetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PSID Group
, BOOLEAN GroupDefaulted
);
1732 NTSTATUS STDCALL
RtlGetGroupSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PSID
* Group
, PBOOLEAN GroupDefaulted
);
1733 NTSTATUS STDCALL
RtlGetControlSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PSECURITY_DESCRIPTOR_CONTROL Control
, PULONG Revision
);
1734 NTSTATUS STDCALL
RtlSetSaclSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, BOOLEAN SaclPresent
, PACL Sacl
, BOOLEAN SaclDefaulted
);
1735 NTSTATUS STDCALL
RtlGetSaclSecurityDescriptor (PSECURITY_DESCRIPTOR SecurityDescriptor
, PBOOLEAN SaclPresent
, PACL
* Sacl
, PBOOLEAN SaclDefauted
);
1736 NTSTATUS STDCALL
RtlSelfRelativeToAbsoluteSD (PSECURITY_DESCRIPTOR RelSD
,
1737 PSECURITY_DESCRIPTOR AbsSD
,
1748 NTSTATUS STDCALL
RtlAllocateAndInitializeSid (PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
1749 UCHAR SubAuthorityCount
,
1750 ULONG SubAuthority0
,
1751 ULONG SubAuthority1
,
1752 ULONG SubAuthority2
,
1753 ULONG SubAuthority3
,
1754 ULONG SubAuthority4
,
1755 ULONG SubAuthority5
,
1756 ULONG SubAuthority6
,
1757 ULONG SubAuthority7
,
1759 ULONG STDCALL
RtlLengthRequiredSid (UCHAR SubAuthorityCount
);
1760 PSID_IDENTIFIER_AUTHORITY STDCALL
RtlIdentifierAuthoritySid (PSID Sid
);
1761 NTSTATUS STDCALL
RtlInitializeSid (PSID Sid
, PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
, UCHAR SubAuthorityCount
);
1762 PULONG STDCALL
RtlSubAuthoritySid (PSID Sid
, ULONG SubAuthority
);
1763 NTSTATUS STDCALL
RtlCopySid (ULONG BufferLength
, PSID Dest
, PSID Src
);
1764 BOOLEAN STDCALL
RtlEqualPrefixSid (PSID Sid1
, PSID Sid2
);
1765 BOOLEAN STDCALL
RtlEqualSid(PSID Sid1
, PSID Sid2
);
1766 PSID STDCALL
RtlFreeSid (PSID Sid
);
1767 ULONG STDCALL
RtlLengthSid (PSID Sid
);
1768 PULONG STDCALL
RtlSubAuthoritySid (PSID Sid
, ULONG SubAuthority
);
1769 PUCHAR STDCALL
RtlSubAuthorityCountSid (PSID Sid
);
1770 BOOLEAN STDCALL
RtlValidSid (PSID Sid
);
1771 NTSTATUS STDCALL
RtlConvertSidToUnicodeString (PUNICODE_STRING String
, PSID Sid
, BOOLEAN AllocateBuffer
);
1773 BOOLEAN STDCALL
RtlAreAllAccessesGranted (ACCESS_MASK GrantedAccess
, ACCESS_MASK DesiredAccess
);
1774 BOOLEAN STDCALL
RtlAreAnyAccessesGranted (ACCESS_MASK GrantedAccess
, ACCESS_MASK DesiredAccess
);
1775 VOID STDCALL
RtlMapGenericMask (PACCESS_MASK AccessMask
, PGENERIC_MAPPING GenericMapping
);
1778 /* functions exported from NTOSKRNL.EXE which are considered RTL */
1780 #if defined(__NTOSKRNL__) || defined(__NTDRIVER__) || defined(__NTHAL__) || defined(__NTDLL__) || defined(__NTAPP__)
1782 char *_itoa (int value
, char *string
, int radix
);
1783 int _snprintf(char * buf
, size_t cnt
, const char *fmt
, ...);
1784 int _snwprintf(wchar_t *buf
, size_t cnt
, const wchar_t *fmt
, ...);
1785 int _stricmp(const char *s1
, const char *s2
);
1786 char * _strlwr(char *x
);
1787 int _strnicmp(const char *s1
, const char *s2
, size_t n
);
1788 char * _strnset(char* szToFill
, int szFill
, size_t sizeMaxFill
);
1789 char * _strrev(char *s
);
1790 char * _strset(char* szToFill
, int szFill
);
1791 char * _strupr(char *x
);
1792 int _vsnprintf(char *buf
, size_t cnt
, const char *fmt
, va_list args
);
1793 int _wcsicmp (const wchar_t* cs
, const wchar_t* ct
);
1794 wchar_t * _wcslwr (wchar_t *x
);
1795 int _wcsnicmp (const wchar_t * cs
,const wchar_t * ct
,size_t count
);
1796 wchar_t* _wcsnset (wchar_t* wsToFill
, wchar_t wcFill
, size_t sizeMaxFill
);
1797 wchar_t * _wcsrev(wchar_t *s
);
1798 wchar_t *_wcsupr(wchar_t *x
);
1800 int atoi(const char *str
);
1801 long atol(const char *str
);
1807 int isxdigit(int c
);
1808 size_t mbstowcs (wchar_t *wcstr
, const char *mbstr
, size_t count
);
1809 int mbtowc (wchar_t *wchar
, const char *mbchar
, size_t count
);
1810 void * memchr(const void *s
, int c
, size_t n
);
1811 void * memcpy(void *to
, const void *from
, size_t count
);
1812 void * memmove(void *dest
,const void *src
, size_t count
);
1813 void * memset(void *src
, int val
, size_t count
);
1820 int sprintf(char * buf
, const char *fmt
, ...);
1821 void srand(unsigned seed
);
1822 char * strcat(char *s
, const char *append
);
1823 char * strchr(const char *s
, int c
);
1824 int strcmp(const char *s1
, const char *s2
);
1825 char * strcpy(char *to
, const char *from
);
1826 size_t strlen(const char *str
);
1827 char * strncat(char *dst
, const char *src
, size_t n
);
1828 int strncmp(const char *s1
, const char *s2
, size_t n
);
1829 char *strncpy(char *dst
, const char *src
, size_t n
);
1830 char *strrchr(const char *s
, int c
);
1831 size_t strspn(const char *s1
, const char *s2
);
1832 char *strstr(const char *s
, const char *find
);
1833 int swprintf(wchar_t *buf
, const wchar_t *fmt
, ...);
1836 wchar_t towlower(wchar_t c
);
1837 wchar_t towupper(wchar_t c
);
1838 int vsprintf(char *buf
, const char *fmt
, va_list args
);
1839 wchar_t * wcscat(wchar_t *dest
, const wchar_t *src
);
1840 wchar_t * wcschr(const wchar_t *str
, wchar_t ch
);
1841 int wcscmp(const wchar_t *cs
, const wchar_t *ct
);
1842 wchar_t* wcscpy(wchar_t* str1
, const wchar_t* str2
);
1843 size_t wcscspn(const wchar_t *str
,const wchar_t *reject
);
1844 size_t wcslen(const wchar_t *s
);
1845 wchar_t * wcsncat(wchar_t *dest
, const wchar_t *src
, size_t count
);
1846 int wcsncmp(const wchar_t *cs
, const wchar_t *ct
, size_t count
);
1847 wchar_t * wcsncpy(wchar_t *dest
, const wchar_t *src
, size_t count
);
1848 wchar_t * wcsrchr(const wchar_t *str
, wchar_t ch
);
1849 size_t wcsspn(const wchar_t *str
,const wchar_t *accept
);
1850 wchar_t *wcsstr(const wchar_t *s
,const wchar_t *b
);
1851 size_t wcstombs (char *mbstr
, const wchar_t *wcstr
, size_t count
);
1852 int wctomb (char *mbchar
, wchar_t wchar
);
1854 #endif /* __NTOSKRNL__ || __NTDRIVER__ || __NTHAL__ || __NTDLL__ || __NTAPP__ */
1856 #endif /* __DDK_RTL_H */