3 Copyright (c) Alex Ionescu. All rights reserved.
11 Function definitions for the Run-Time Library
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
44 IN PLIST_ENTRY ListHead
47 ListHead
->Flink
= ListHead
->Blink
= ListHead
;
53 IN PLIST_ENTRY ListHead
,
58 OldFlink
= ListHead
->Flink
;
59 Entry
->Flink
= OldFlink
;
60 Entry
->Blink
= ListHead
;
61 OldFlink
->Blink
= Entry
;
62 ListHead
->Flink
= Entry
;
68 IN PLIST_ENTRY ListHead
,
73 OldBlink
= ListHead
->Blink
;
74 Entry
->Flink
= ListHead
;
75 Entry
->Blink
= OldBlink
;
76 OldBlink
->Flink
= Entry
;
77 ListHead
->Blink
= Entry
;
83 IN
const LIST_ENTRY
* ListHead
86 return (BOOLEAN
)(ListHead
->Flink
== ListHead
);
92 PSINGLE_LIST_ENTRY ListHead
95 PSINGLE_LIST_ENTRY FirstEntry
;
96 FirstEntry
= ListHead
->Next
;
97 if (FirstEntry
!= NULL
) {
98 ListHead
->Next
= FirstEntry
->Next
;
107 PSINGLE_LIST_ENTRY ListHead
,
108 PSINGLE_LIST_ENTRY Entry
111 Entry
->Next
= ListHead
->Next
;
112 ListHead
->Next
= Entry
;
118 IN PLIST_ENTRY Entry
)
120 PLIST_ENTRY OldFlink
;
121 PLIST_ENTRY OldBlink
;
123 OldFlink
= Entry
->Flink
;
124 OldBlink
= Entry
->Blink
;
125 OldFlink
->Blink
= OldBlink
;
126 OldBlink
->Flink
= OldFlink
;
127 return (BOOLEAN
)(OldFlink
== OldBlink
);
133 IN PLIST_ENTRY ListHead
)
138 Entry
= ListHead
->Flink
;
139 Flink
= Entry
->Flink
;
140 ListHead
->Flink
= Flink
;
141 Flink
->Blink
= ListHead
;
148 IN PLIST_ENTRY ListHead
)
153 Entry
= ListHead
->Blink
;
154 Blink
= Entry
->Blink
;
155 ListHead
->Blink
= Blink
;
156 Blink
->Flink
= ListHead
;
161 // Unicode string macros
165 RtlInitEmptyUnicodeString(OUT PUNICODE_STRING UnicodeString
,
167 IN USHORT BufferSize
)
169 UnicodeString
->Length
= 0;
170 UnicodeString
->MaximumLength
= BufferSize
;
171 UnicodeString
->Buffer
= Buffer
;
177 #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
178 ((L1)->LowPart == (L2)->LowPart))
182 RtlConvertUlongToLuid(ULONG Ulong
)
186 TempLuid
.LowPart
= Ulong
;
187 TempLuid
.HighPart
= 0;
197 #define ASSERT( exp ) \
199 (RtlAssert( #exp, __FILE__, __LINE__, NULL ),FALSE) : \
202 #define ASSERTMSG( msg, exp ) \
204 (RtlAssert( #exp, __FILE__, __LINE__, msg ),FALSE) : \
209 #define ASSERT( exp ) ((void) 0)
210 #define ASSERTMSG( msg, exp ) ((void) 0)
216 // This macro does nothing in kernel mode
218 #define RTL_PAGED_CODE NOP_FUNCTION
221 // RTL Splay Tree Functions
226 RtlSplay(PRTL_SPLAY_LINKS Links
);
231 RtlDelete(PRTL_SPLAY_LINKS Links
);
237 PRTL_SPLAY_LINKS Links
,
238 PRTL_SPLAY_LINKS
*Root
244 RtlSubtreeSuccessor(PRTL_SPLAY_LINKS Links
);
249 RtlSubtreePredecessor(PRTL_SPLAY_LINKS Links
);
254 RtlRealSuccessor(PRTL_SPLAY_LINKS Links
);
259 RtlRealPredecessor(PRTL_SPLAY_LINKS Links
);
261 #define RtlIsLeftChild(Links) \
262 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
264 #define RtlIsRightChild(Links) \
265 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
267 #define RtlRightChild(Links) \
268 ((PRTL_SPLAY_LINKS)(Links))->RightChild
270 #define RtlIsRoot(Links) \
271 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
273 #define RtlLeftChild(Links) \
274 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
276 #define RtlParent(Links) \
277 ((PRTL_SPLAY_LINKS)(Links))->Parent
279 #define RtlInitializeSplayLinks(Links) \
281 PRTL_SPLAY_LINKS _SplayLinks; \
282 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
283 _SplayLinks->Parent = _SplayLinks; \
284 _SplayLinks->LeftChild = NULL; \
285 _SplayLinks->RightChild = NULL; \
288 #define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
290 PRTL_SPLAY_LINKS _SplayParent; \
291 PRTL_SPLAY_LINKS _SplayChild; \
292 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
293 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
294 _SplayParent->LeftChild = _SplayChild; \
295 _SplayChild->Parent = _SplayParent; \
298 #define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
300 PRTL_SPLAY_LINKS _SplayParent; \
301 PRTL_SPLAY_LINKS _SplayChild; \
302 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
303 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
304 _SplayParent->RightChild = _SplayChild; \
305 _SplayChild->Parent = _SplayParent; \
309 #ifdef NTOS_KERNEL_RUNTIME
312 // Executing RTL functions at DISPATCH_LEVEL or higher will result in a
315 #define RTL_PAGED_CODE PAGED_CODE
320 // Error and Exception Functions
325 RtlAddVectoredExceptionHandler(
326 IN ULONG FirstHandler
,
327 IN PVECTORED_EXCEPTION_HANDLER VectoredHandler
334 IN PVOID FailedAssertion
,
343 RtlSetUnhandledExceptionFilter(
344 IN PVOID TopLevelExceptionFilter
351 OUT PCONTEXT ContextRecord
371 RtlEncodeSystemPointer(
378 RtlDecodeSystemPointer(
385 RtlDispatchException(
386 IN PEXCEPTION_RECORD ExceptionRecord
,
393 RtlNtStatusToDosError(
400 RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
408 IN PEXCEPTION_RECORD ExceptionRecord
421 RtlUnhandledExceptionFilter(
422 IN
struct _EXCEPTION_POINTERS
* ExceptionInfo
429 IN PVOID TargetFrame OPTIONAL
,
430 IN PVOID TargetIp OPTIONAL
,
431 IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL
,
441 RtlLogStackBackTrace(
452 IN HANDLE HeapHandle
,
462 IN PVOID BaseAddress OPTIONAL
,
463 IN SIZE_T SizeToReserve OPTIONAL
,
464 IN SIZE_T SizeToCommit OPTIONAL
,
465 IN PVOID Lock OPTIONAL
,
466 IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL
473 IN HANDLE HeapHandle
,
491 IN PVOID BaseAddress OPTIONAL
,
492 IN SIZE_T SizeToReserve OPTIONAL
,
493 IN SIZE_T SizeToCommit OPTIONAL
,
494 IN PVOID Lock OPTIONAL
,
495 IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL
519 IN HANDLE HeapHandle
,
543 IN PVOID BaseAddress
,
544 OUT PVOID
*UserValue
,
555 IN BOOLEAN ResetCounters
,
556 OUT PRTL_HEAP_TAG_INFO HeapTagInfo
582 OUT PRTL_HEAP_USAGE Usage
597 IN PVOID BaseAddress
,
607 IN PVOID MemoryPointer
619 #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
622 // Security Functions
627 RtlAbsoluteToSelfRelativeSD(
628 IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor
,
629 IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor
,
630 IN PULONG BufferLength
636 RtlAddAccessAllowedAce(
639 ACCESS_MASK AccessMask
,
646 RtlAddAccessAllowedAceEx(
648 IN ULONG dwAceRevision
,
657 RtlAddAccessAllowedObjectAce(
659 IN ULONG dwAceRevision
,
662 IN GUID
*ObjectTypeGuid OPTIONAL
,
663 IN GUID
*InheritedObjectTypeGuid OPTIONAL
,
670 RtlAddAccessDeniedAce(
673 ACCESS_MASK AccessMask
,
680 RtlAddAccessDeniedAceEx(
684 IN ACCESS_MASK AccessMask
,
691 RtlAddAccessDeniedObjectAce(
693 IN ULONG dwAceRevision
,
696 IN GUID
*ObjectTypeGuid OPTIONAL
,
697 IN GUID
*InheritedObjectTypeGuid OPTIONAL
,
707 ULONG StartingAceIndex
,
715 RtlAddAuditAccessAce(
718 ACCESS_MASK AccessMask
,
731 OUT PVOID
*ReturnedState
737 RtlAddAuditAccessAceEx(
741 IN ACCESS_MASK AccessMask
,
750 RtlAddAuditAccessObjectAce(
754 IN ACCESS_MASK AccessMask
,
755 IN GUID
*ObjectTypeGuid OPTIONAL
,
756 IN GUID
*InheritedObjectTypeGuid OPTIONAL
,
768 IN BOOLEAN ForThread
,
769 OUT PBOOLEAN OldValue
775 RtlAllocateAndInitializeSid(
776 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
777 IN UCHAR SubAuthorityCount
,
778 IN ULONG SubAuthority0
,
779 IN ULONG SubAuthority1
,
780 IN ULONG SubAuthority2
,
781 IN ULONG SubAuthority3
,
782 IN ULONG SubAuthority4
,
783 IN ULONG SubAuthority5
,
784 IN ULONG SubAuthority6
,
785 IN ULONG SubAuthority7
,
792 RtlAreAllAccessesGranted(
793 ACCESS_MASK GrantedAccess
,
794 ACCESS_MASK DesiredAccess
800 RtlAreAnyAccessesGranted(
801 ACCESS_MASK GrantedAccess
,
802 ACCESS_MASK DesiredAccess
816 RtlCopyLuidAndAttributesArray(
818 PLUID_AND_ATTRIBUTES Src
,
819 PLUID_AND_ATTRIBUTES Dest
825 RtlCopySidAndAttributesArray(
827 PSID_AND_ATTRIBUTES Src
,
829 PSID_AND_ATTRIBUTES Dest
,
831 PVOID
* RemainingSidArea
,
832 PULONG RemainingSidAreaSize
838 RtlConvertSidToUnicodeString(
839 OUT PUNICODE_STRING DestinationString
,
841 IN BOOLEAN AllocateDestinationString
865 RtlCreateSecurityDescriptor(
866 OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
873 RtlCreateSecurityDescriptorRelative(
874 OUT PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor
,
929 RtlGetControlSecurityDescriptor(
930 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
931 OUT PSECURITY_DESCRIPTOR_CONTROL Control
,
938 RtlGetDaclSecurityDescriptor(
939 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
940 OUT PBOOLEAN DaclPresent
,
942 OUT PBOOLEAN DaclDefaulted
948 RtlGetSaclSecurityDescriptor(
949 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
950 OUT PBOOLEAN SaclPresent
,
952 OUT PBOOLEAN SaclDefaulted
958 RtlGetGroupSecurityDescriptor(
959 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
961 OUT PBOOLEAN GroupDefaulted
967 RtlGetOwnerSecurityDescriptor(
968 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
970 OUT PBOOLEAN OwnerDefaulted
976 RtlGetSecurityDescriptorRMControl(
977 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
982 PSID_IDENTIFIER_AUTHORITY
984 RtlIdentifierAuthoritySid(PSID Sid
);
989 RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
);
996 IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority
,
997 IN UCHAR SubAuthorityCount
1003 RtlLengthRequiredSid(IN ULONG SubAuthorityCount
);
1008 RtlLengthSid(IN PSID Sid
);
1013 RtlMakeSelfRelativeSD(
1014 IN PSECURITY_DESCRIPTOR AbsoluteSD
,
1015 OUT PSECURITY_DESCRIPTOR SelfRelativeSD
,
1016 IN OUT PULONG BufferLength
);
1022 PACCESS_MASK AccessMask
,
1023 PGENERIC_MAPPING GenericMapping
1029 RtlQueryInformationAcl(
1032 ULONG InformationLength
,
1033 ACL_INFORMATION_CLASS InformationClass
1039 RtlReleasePrivilege(
1040 IN PVOID ReturnedState
1046 RtlSelfRelativeToAbsoluteSD(
1047 IN PSECURITY_DESCRIPTOR SelfRelativeSD
,
1048 OUT PSECURITY_DESCRIPTOR AbsoluteSD
,
1049 IN PULONG AbsoluteSDSize
,
1055 IN PULONG OwnerSize
,
1056 IN PSID PrimaryGroup
,
1057 IN PULONG PrimaryGroupSize
1063 RtlSelfRelativeToAbsoluteSD2(
1064 IN OUT PSECURITY_DESCRIPTOR SelfRelativeSD
,
1065 OUT PULONG BufferSize
1071 RtlSetAttributesSecurityDescriptor(
1072 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
1073 IN SECURITY_DESCRIPTOR_CONTROL Control
,
1080 RtlSetControlSecurityDescriptor(
1081 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
1082 IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest
,
1083 IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1089 RtlSetDaclSecurityDescriptor (
1090 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
1091 IN BOOLEAN DaclPresent
,
1093 IN BOOLEAN DaclDefaulted
1099 RtlSetGroupSecurityDescriptor(
1100 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
1102 IN BOOLEAN GroupDefaulted
1108 RtlSetInformationAcl(
1111 ULONG InformationLength
,
1112 ACL_INFORMATION_CLASS InformationClass
1118 RtlSetOwnerSecurityDescriptor(
1119 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
1121 IN BOOLEAN OwnerDefaulted
1127 RtlSetSaclSecurityDescriptor(
1128 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
1129 IN BOOLEAN SaclPresent
,
1131 IN BOOLEAN SaclDefaulted
1137 RtlSetSecurityDescriptorRMControl(
1138 IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor
,
1145 RtlSubAuthorityCountSid(
1154 IN ULONG SubAuthority
1160 RtlValidRelativeSecurityDescriptor(
1161 IN PSECURITY_DESCRIPTOR SecurityDescriptorInput
,
1162 IN ULONG SecurityDescriptorLength
,
1163 IN SECURITY_INFORMATION RequiredInformation
1169 RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor
);
1174 RtlValidSid(IN PSID Sid
);
1179 RtlValidAcl(PACL Acl
);
1184 RtlDeleteSecurityObject(
1185 IN PSECURITY_DESCRIPTOR
*ObjectDescriptor
1191 RtlNewSecurityObject(
1192 IN PSECURITY_DESCRIPTOR ParentDescriptor
,
1193 IN PSECURITY_DESCRIPTOR CreatorDescriptor
,
1194 OUT PSECURITY_DESCRIPTOR
*NewDescriptor
,
1195 IN BOOLEAN IsDirectoryObject
,
1197 IN PGENERIC_MAPPING GenericMapping
1203 RtlQuerySecurityObject(
1204 IN PSECURITY_DESCRIPTOR ObjectDescriptor
,
1205 IN SECURITY_INFORMATION SecurityInformation
,
1206 OUT PSECURITY_DESCRIPTOR ResultantDescriptor
,
1207 IN ULONG DescriptorLength
,
1208 OUT PULONG ReturnLength
1214 RtlSetSecurityObject(
1215 IN SECURITY_INFORMATION SecurityInformation
,
1216 IN PSECURITY_DESCRIPTOR ModificationDescriptor
,
1217 OUT PSECURITY_DESCRIPTOR
*ObjectsSecurityDescriptor
,
1218 IN PGENERIC_MAPPING GenericMapping
,
1223 // Single-Character Functions
1228 RtlLargeIntegerToChar(
1229 IN PLARGE_INTEGER Value
,
1238 RtlUpperChar(CHAR Source
);
1243 RtlUpcaseUnicodeChar(WCHAR Source
);
1248 RtlDowncaseUnicodeChar(IN WCHAR Source
);
1263 RtlIntegerToUnicode(
1265 IN ULONG Base OPTIONAL
,
1266 IN ULONG Length OPTIONAL
,
1267 IN OUT LPWSTR String
1273 RtlIntegerToUnicodeString(
1276 IN OUT PUNICODE_STRING String
1289 // Byte Swap Functions
1291 #if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || \
1292 ((defined(_M_AMD64) || \
1293 defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
1295 unsigned short __cdecl
_byteswap_ushort(unsigned short);
1296 unsigned long __cdecl
_byteswap_ulong (unsigned long);
1297 unsigned __int64 __cdecl
_byteswap_uint64(unsigned __int64
);
1298 #pragma intrinsic(_byteswap_ushort)
1299 #pragma intrinsic(_byteswap_ulong)
1300 #pragma intrinsic(_byteswap_uint64)
1301 #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1302 #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1303 #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1310 RtlUshortByteSwap(IN USHORT Source
);
1315 RtlUlongByteSwap(IN ULONG Source
);
1320 RtlUlonglongByteSwap(IN ULONGLONG Source
);
1325 // Unicode->Ansi String Functions
1330 RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString
);
1332 #ifdef NTOS_MODE_USER
1334 #define RtlUnicodeStringToAnsiSize(STRING) ( \
1335 NLS_MB_CODE_PAGE_TAG ? \
1336 RtlxUnicodeStringToAnsiSize(STRING) : \
1337 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1345 RtlUnicodeStringToAnsiString(
1346 PANSI_STRING DestinationString
,
1347 PCUNICODE_STRING SourceString
,
1348 BOOLEAN AllocateDestinationString
1352 // Unicode->OEM String Functions
1357 RtlUpcaseUnicodeStringToOemString(
1358 POEM_STRING DestinationString
,
1359 PCUNICODE_STRING SourceString
,
1360 BOOLEAN AllocateDestinationString
1366 RtlUpcaseUnicodeStringToCountedOemString(
1367 IN OUT POEM_STRING DestinationString
,
1368 IN PCUNICODE_STRING SourceString
,
1369 IN BOOLEAN AllocateDestinationString
1375 RtlUnicodeStringToOemString(
1376 POEM_STRING DestinationString
,
1377 PCUNICODE_STRING SourceString
,
1378 BOOLEAN AllocateDestinationString
1384 RtlUpcaseUnicodeToOemN(
1388 PWCHAR UnicodeString
,
1395 RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString
);
1397 #ifdef NTOS_MODE_USER
1399 #define RtlUnicodeStringToOemSize(STRING) ( \
1400 NLS_MB_OEM_CODE_PAGE_TAG ? \
1401 RtlxUnicodeStringToOemSize(STRING) : \
1402 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1405 #define RtlUnicodeStringToCountedOemSize(STRING) ( \
1406 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1418 PWCHAR UnicodeString
,
1423 // Unicode->MultiByte String Functions
1428 RtlUnicodeToMultiByteN(
1432 PWCHAR UnicodeString
,
1439 RtlUpcaseUnicodeToMultiByteN(
1443 PWCHAR UnicodeString
,
1450 RtlUnicodeToMultiByteSize(
1452 PWCHAR UnicodeString
,
1459 RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString
);
1462 // OEM to Unicode Functions
1467 RtlOemStringToUnicodeString(
1468 PUNICODE_STRING DestinationString
,
1469 PCOEM_STRING SourceString
,
1470 BOOLEAN AllocateDestinationString
1477 PWSTR UnicodeString
,
1478 ULONG MaxBytesInUnicodeString
,
1479 PULONG BytesInUnicodeString
,
1481 ULONG BytesInOemString
1484 #ifdef NTOS_MODE_USER
1486 #define RtlOemStringToUnicodeSize(STRING) ( \
1487 NLS_MB_OEM_CODE_PAGE_TAG ? \
1488 RtlxOemStringToUnicodeSize(STRING) : \
1489 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1492 #define RtlOemStringToCountedUnicodeSize(STRING) ( \
1493 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
1499 // Ansi->Unicode String Functions
1504 RtlxAnsiStringToUnicodeSize(
1505 PCANSI_STRING AnsiString
1511 RtlAnsiStringToUnicodeString(
1512 PUNICODE_STRING DestinationString
,
1513 PCANSI_STRING SourceString
,
1514 BOOLEAN AllocateDestinationString
1517 #ifdef NTOS_MODE_USER
1519 #define RtlAnsiStringToUnicodeSize(STRING) ( \
1520 NLS_MB_CODE_PAGE_TAG ? \
1521 RtlxAnsiStringToUnicodeSize(STRING) : \
1522 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
1530 RtlCreateUnicodeStringFromAsciiz(
1531 OUT PUNICODE_STRING Destination
,
1536 // Unicode String Functions
1541 RtlAppendUnicodeToString(
1542 PUNICODE_STRING Destination
,
1549 RtlAppendUnicodeStringToString(
1550 PUNICODE_STRING Destination
,
1551 PCUNICODE_STRING Source
1557 RtlCompareUnicodeString(
1558 PCUNICODE_STRING String1
,
1559 PCUNICODE_STRING String2
,
1560 BOOLEAN CaseInsensitive
1566 RtlCopyUnicodeString(
1567 PUNICODE_STRING DestinationString
,
1568 PCUNICODE_STRING SourceString
1574 RtlCreateUnicodeString(
1575 PUNICODE_STRING DestinationString
,
1579 #ifdef NTOS_MODE_USER
1584 RtlDowncaseUnicodeString(
1585 IN OUT PUNICODE_STRING UniDest
,
1586 IN PCUNICODE_STRING UniSource
,
1587 IN BOOLEAN AllocateDestinationString
1595 RtlDuplicateUnicodeString(
1597 IN PCUNICODE_STRING SourceString
,
1598 OUT PUNICODE_STRING DestinationString
1604 RtlEqualUnicodeString(
1605 PCUNICODE_STRING String1
,
1606 PCUNICODE_STRING String2
,
1607 BOOLEAN CaseInsensitive
1613 RtlFindCharInUnicodeString(
1615 IN PUNICODE_STRING SearchString
,
1616 IN PCUNICODE_STRING MatchString
,
1617 OUT PUSHORT Position
1623 RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString
);
1628 RtlHashUnicodeString(
1629 IN CONST UNICODE_STRING
*String
,
1630 IN BOOLEAN CaseInSensitive
,
1631 IN ULONG HashAlgorithm
,
1632 OUT PULONG HashValue
1638 RtlInitUnicodeString(
1639 IN OUT PUNICODE_STRING DestinationString
,
1640 IN PCWSTR SourceString
1646 RtlInitUnicodeStringEx(
1647 OUT PUNICODE_STRING DestinationString
,
1648 IN PCWSTR SourceString OPTIONAL
1664 PCANSI_STRING String1
,
1665 PCANSI_STRING String2
,
1666 BOOLEAN CaseInsensitive
1672 RtlPrefixUnicodeString(
1673 PCUNICODE_STRING String1
,
1674 PCUNICODE_STRING String2
,
1675 BOOLEAN CaseInsensitive
1681 RtlUpcaseUnicodeString(
1682 PUNICODE_STRING DestinationString
,
1683 PCUNICODE_STRING SourceString
,
1684 BOOLEAN AllocateDestinationString
1690 RtlUnicodeStringToInteger(
1691 PCUNICODE_STRING String
,
1699 RtlValidateUnicodeString(
1701 IN PCUNICODE_STRING String
1705 // Ansi String Functions
1710 RtlFreeAnsiString(IN PANSI_STRING AnsiString
);
1716 PANSI_STRING DestinationString
,
1721 // OEM String Functions
1726 RtlFreeOemString(IN POEM_STRING OemString
);
1729 // MultiByte->Unicode String Functions
1734 RtlMultiByteToUnicodeN(
1735 PWCHAR UnicodeString
,
1745 RtlMultiByteToUnicodeSize(
1757 RtlAddAtomToAtomTable(
1758 IN PRTL_ATOM_TABLE AtomTable
,
1768 IN OUT PRTL_ATOM_TABLE
*AtomTable
1774 RtlDeleteAtomFromAtomTable(
1775 IN PRTL_ATOM_TABLE AtomTable
,
1782 RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable
);
1787 RtlQueryAtomInAtomTable(
1788 IN PRTL_ATOM_TABLE AtomTable
,
1790 IN OUT PULONG RefCount OPTIONAL
,
1791 IN OUT PULONG PinCount OPTIONAL
,
1792 IN OUT PWSTR AtomName OPTIONAL
,
1793 IN OUT PULONG NameLength OPTIONAL
1799 RtlPinAtomInAtomTable(
1800 IN PRTL_ATOM_TABLE AtomTable
,
1807 RtlLookupAtomInAtomTable(
1808 IN PRTL_ATOM_TABLE AtomTable
,
1820 IN PVOID Destination
,
1826 // Process Management Functions
1831 RtlAcquirePebLock(VOID
);
1836 RtlCreateProcessParameters (
1837 OUT PRTL_USER_PROCESS_PARAMETERS
*ProcessParameters
,
1838 IN PUNICODE_STRING ImagePathName OPTIONAL
,
1839 IN PUNICODE_STRING DllPath OPTIONAL
,
1840 IN PUNICODE_STRING CurrentDirectory OPTIONAL
,
1841 IN PUNICODE_STRING CommandLine OPTIONAL
,
1842 IN PWSTR Environment OPTIONAL
,
1843 IN PUNICODE_STRING WindowTitle OPTIONAL
,
1844 IN PUNICODE_STRING DesktopInfo OPTIONAL
,
1845 IN PUNICODE_STRING ShellInfo OPTIONAL
,
1846 IN PUNICODE_STRING RuntimeInfo OPTIONAL
1852 RtlCreateUserProcess(
1853 IN PUNICODE_STRING ImageFileName
,
1854 IN ULONG Attributes
,
1855 IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters
,
1856 IN PSECURITY_DESCRIPTOR ProcessSecutityDescriptor OPTIONAL
,
1857 IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor OPTIONAL
,
1858 IN HANDLE ParentProcess OPTIONAL
,
1859 IN BOOLEAN CurrentDirectory
,
1860 IN HANDLE DebugPort OPTIONAL
,
1861 IN HANDLE ExceptionPort OPTIONAL
,
1862 OUT PRTL_USER_PROCESS_INFORMATION ProcessInfo
1868 RtlCreateUserThread(
1869 IN HANDLE ProcessHandle
,
1870 IN PSECURITY_DESCRIPTOR SecurityDescriptor
,
1871 IN BOOLEAN CreateSuspended
,
1872 IN LONG StackZeroBits
,
1873 IN ULONG StackReserve
,
1874 IN ULONG StackCommit
,
1875 IN PTHREAD_START_ROUTINE StartAddress
,
1877 IN OUT PHANDLE ThreadHandle
,
1878 IN OUT PCLIENT_ID ClientId
1882 PRTL_USER_PROCESS_PARAMETERS
1884 RtlDeNormalizeProcessParams(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
1889 RtlDestroyProcessParameters(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
1894 RtlExitUserThread(NTSTATUS Status
);
1899 RtlInitializeContext(
1900 IN HANDLE ProcessHandle
,
1901 OUT PCONTEXT ThreadContext
,
1902 IN PVOID ThreadStartParam OPTIONAL
,
1903 IN PTHREAD_START_ROUTINE ThreadStartAddress
,
1904 IN PINITIAL_TEB InitialTeb
1908 PRTL_USER_PROCESS_PARAMETERS
1910 RtlNormalizeProcessParams(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters
);
1915 RtlReleasePebLock(VOID
);
1920 RtlSetProcessIsCritical(
1921 IN BOOLEAN NewValue
,
1922 OUT PBOOLEAN OldValue OPTIONAL
,
1923 IN BOOLEAN IsWinlogon
1926 #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
1929 // Thread Pool Functions
1935 IN WORKERCALLBACKFUNC Function
,
1936 IN PVOID Context OPTIONAL
,
1941 // Environment/Path Functions
1946 RtlCreateEnvironment(
1954 RtlComputePrivatizedDllName_U(
1955 IN PUNICODE_STRING DllName
,
1956 OUT PUNICODE_STRING RealName
,
1957 OUT PUNICODE_STRING LocalName
1963 RtlDestroyEnvironment(
1964 IN PWSTR Environment
1970 RtlDoesFileExists_U(
1977 RtlDoesFileExists_UstrEx(
1978 IN PCUNICODE_STRING FileName
,
1979 IN BOOLEAN SucceedIfBusy
1985 RtlDetermineDosPathNameType_U(
1992 RtlDetermineDosPathNameType_Ustr(
1993 IN PCUNICODE_STRING Path
2002 IN PCWSTR Extension
,
2003 IN ULONG BufferSize
,
2011 RtlDosPathNameToNtPathName_U(
2012 IN PCWSTR DosPathName
,
2013 OUT PUNICODE_STRING NtPathName
,
2014 OUT PCWSTR
*NtFileNamePart
,
2015 OUT CURDIR
*DirectoryInfo
2021 RtlExpandEnvironmentStrings_U(
2023 PUNICODE_STRING Source
,
2024 PUNICODE_STRING Destination
,
2031 RtlGetCurrentDirectory_U(
2032 ULONG MaximumLength
,
2039 RtlGetFullPathName_U(
2043 OUT PWSTR
*ShortName
2049 RtlGetFullPathName_Ustr(
2050 IN PUNICODE_STRING FileName
,
2053 OUT PWSTR
*ShortName
,
2054 OUT PBOOLEAN InvalidName
,
2055 OUT RTL_PATH_TYPE
*PathType
2061 RtlIsDosDeviceName_U(
2068 RtlIsDosDeviceName_Ustr(
2069 IN PUNICODE_STRING Name
2076 RtlIsNameLegalDOS8Dot3(
2077 IN PCUNICODE_STRING Name
,
2078 IN OUT POEM_STRING OemName OPTIONAL
,
2079 IN OUT PBOOLEAN NameContainsSpaces OPTIONAL
2085 RtlQueryEnvironmentVariable_U(
2087 PUNICODE_STRING Name
,
2088 PUNICODE_STRING Value
2094 RtlSetCurrentDirectory_U(
2095 IN PUNICODE_STRING name
2101 RtlSetEnvironmentVariable(
2103 PUNICODE_STRING Name
,
2104 PUNICODE_STRING Value
2108 // Critical Section/Resource Functions
2113 RtlDeleteCriticalSection (
2114 IN PRTL_CRITICAL_SECTION CriticalSection
2120 RtlEnterCriticalSection(
2121 IN PRTL_CRITICAL_SECTION CriticalSection
2127 RtlInitializeCriticalSection(
2128 IN PRTL_CRITICAL_SECTION CriticalSection
2134 RtlInitializeCriticalSectionAndSpinCount(
2135 IN PRTL_CRITICAL_SECTION CriticalSection
,
2142 RtlLeaveCriticalSection(
2143 IN PRTL_CRITICAL_SECTION CriticalSection
2149 RtlTryEnterCriticalSection(
2150 IN PRTL_CRITICAL_SECTION CriticalSection
2156 RtlpUnWaitCriticalSection(
2157 IN PRTL_CRITICAL_SECTION CriticalSection
2163 RtlpWaitForCriticalSection(
2164 IN PRTL_CRITICAL_SECTION CriticalSection
2170 RtlAcquireResourceExclusive(
2171 IN PRTL_RESOURCE Resource
,
2178 RtlAcquireResourceShared(
2179 IN PRTL_RESOURCE Resource
,
2186 RtlConvertExclusiveToShared(
2187 IN PRTL_RESOURCE Resource
2193 RtlConvertSharedToExclusive(
2194 IN PRTL_RESOURCE Resource
2201 IN PRTL_RESOURCE Resource
2208 IN PRTL_RESOURCE Resource
2214 RtlInitializeResource(
2215 IN PRTL_RESOURCE Resource
2222 IN PRTL_RESOURCE Resource
2226 // Compression Functions
2232 IN USHORT CompressionFormatAndEngine
,
2233 IN PUCHAR UncompressedBuffer
,
2234 IN ULONG UncompressedBufferSize
,
2235 OUT PUCHAR CompressedBuffer
,
2236 IN ULONG CompressedBufferSize
,
2237 IN ULONG UncompressedChunkSize
,
2238 OUT PULONG FinalCompressedSize
,
2245 RtlDecompressBuffer(
2246 IN USHORT CompressionFormat
,
2247 OUT PUCHAR UncompressedBuffer
,
2248 IN ULONG UncompressedBufferSize
,
2249 IN PUCHAR CompressedBuffer
,
2250 IN ULONG CompressedBufferSize
,
2251 OUT PULONG FinalUncompressedSize
2257 RtlGetCompressionWorkSpaceSize(
2258 IN USHORT CompressionFormatAndEngine
,
2259 OUT PULONG CompressBufferWorkSpaceSize
,
2260 OUT PULONG CompressFragmentWorkSpaceSize
2264 // Debug Info Functions
2267 PRTL_DEBUG_INFORMATION
2269 RtlCreateQueryDebugBuffer(
2271 IN BOOLEAN EventPair
2277 RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer
);
2282 RtlQueryProcessDebugInformation(
2284 IN ULONG DebugInfoClassMask
,
2285 IN OUT PRTL_DEBUG_INFORMATION DebugBuffer
2295 IN PRTL_BITMAP BitMapHeader
,
2296 IN ULONG StartingIndex
,
2304 IN PRTL_BITMAP BitMapHeader
,
2305 IN ULONG StartingIndex
,
2313 IN PRTL_BITMAP BitMapHeader
,
2314 IN ULONG StartingIndex
,
2315 IN ULONG NumberToClear
2322 IN PRTL_BITMAP BitMapHeader
,
2323 IN ULONG NumberToFind
,
2330 RtlFindClearBitsAndSet(
2331 IN PRTL_BITMAP BitMapHeader
,
2332 IN ULONG NumberToFind
,
2339 RtlFindNextForwardRunClear(
2340 IN PRTL_BITMAP BitMapHeader
,
2342 IN PULONG StartingRunIndex
2348 RtlInitializeBitMap(
2349 IN PRTL_BITMAP BitMapHeader
,
2350 IN PULONG BitMapBuffer
,
2351 IN ULONG SizeOfBitMap
2358 IN PRTL_BITMAP BitMapHeader
2365 PRTL_BITMAP BitMapHeader
,
2373 IN PRTL_BITMAP BitMapHeader
,
2374 IN ULONG StartingIndex
,
2375 IN ULONG NumberToSet
2387 WAITORTIMERCALLBACKFUNC Callback
,
2397 RtlCreateTimerQueue(PHANDLE TimerQueue
);
2405 HANDLE CompletionEvent
2421 RtlDeleteTimerQueueEx(
2423 HANDLE CompletionEvent
2429 RtlDeleteTimerQueue(HANDLE TimerQueue
);
2436 InterlockedPushListSList(
2437 IN PSLIST_HEADER ListHead
,
2438 IN PSLIST_ENTRY List
,
2439 IN PSLIST_ENTRY ListEnd
,
2444 // Range List functions
2449 RtlFreeRangeList(IN PRTL_RANGE_LIST RangeList
);
2465 IN ULONG ComponentId
,
2474 IN PCH PromptString
,
2475 OUT PCH OutputString
,
2481 DbgBreakPoint(VOID
);
2484 // Handle Table Functions
2487 PRTL_HANDLE_TABLE_ENTRY
2490 IN PRTL_HANDLE_TABLE HandleTable
,
2497 RtlDestroyHandleTable(IN PRTL_HANDLE_TABLE HandleTable
);
2503 IN PRTL_HANDLE_TABLE HandleTable
,
2504 IN PRTL_HANDLE_TABLE_ENTRY Handle
2510 RtlInitializeHandleTable(
2512 IN ULONG HandleSize
,
2513 IN PRTL_HANDLE_TABLE HandleTable
2520 IN PRTL_HANDLE_TABLE HandleTable
,
2521 IN PRTL_HANDLE_TABLE_ENTRY Handle
2527 RtlIsValidIndexHandle(
2528 IN PRTL_HANDLE_TABLE HandleTable
,
2530 OUT PRTL_HANDLE_TABLE_ENTRY
*Handle
2540 IN PVOID BaseAddress
,
2544 OUT PRTL_MESSAGE_RESOURCE_ENTRY
*MessageResourceEntry
2550 RtlGetNtGlobalFlags(VOID
);
2555 RtlImageDirectoryEntryToData(
2557 BOOLEAN MappedAsImage
,
2566 PIMAGE_NT_HEADERS NtHeader
,
2569 PIMAGE_SECTION_HEADER
*SectionHeader
2575 RtlImageNtHeader(IN PVOID BaseAddress
);
2582 IN PVOID BaseAddress
,
2584 IN PIMAGE_NT_HEADERS
*NtHeader
2588 PIMAGE_SECTION_HEADER
2590 RtlImageRvaToSection(
2591 PIMAGE_NT_HEADERS NtHeader
,
2597 // Activation Context Functions
2599 #ifdef NTOS_MODE_USER
2603 RtlActivateActivationContextUnsafeFast(
2604 IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
,
2611 RtlAllocateActivationContextStack(
2618 RtlGetActiveActivationContext(
2625 RtlReleaseActivationContext(
2632 RtlDeactivateActivationContextUnsafeFast(
2633 IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
2639 RtlDosApplyFileIsolationRedirection_Ustr(
2641 IN PUNICODE_STRING OriginalName
,
2642 IN PUNICODE_STRING Extension
,
2643 IN OUT PUNICODE_STRING RedirectedName
,
2644 IN OUT PUNICODE_STRING RedirectedName2
,
2645 IN OUT PUNICODE_STRING
*OriginalName2
,
2654 RtlFindActivationContextSectionString(
2657 IN ULONG SectionType
,
2658 IN PUNICODE_STRING SectionName
,
2664 // Registry Functions
2669 RtlCheckRegistryKey(
2677 RtlFormatCurrentUserKeyPath(IN OUT PUNICODE_STRING KeyPath
);
2683 OUT HANDLE KeyHandle
,
2684 IN ACCESS_MASK DesiredAccess
,
2685 IN POBJECT_ATTRIBUTES ObjectAttributes
,
2693 IN ACCESS_MASK DesiredAccess
,
2694 OUT PHANDLE KeyHandle
2700 RtlQueryRegistryValues(
2701 IN ULONG RelativeTo
,
2703 IN PRTL_QUERY_REGISTRY_TABLE QueryTable
,
2705 IN PVOID Environment
2711 RtlWriteRegistryValue(
2727 IN PUSHORT AnsiTableBase
,
2728 IN PUSHORT OemTableBase
,
2729 IN PUSHORT CaseTableBase
,
2730 OUT PNLSTABLEINFO NlsTable
2736 RtlInitCodePageTable(
2737 IN PUSHORT TableBase
,
2738 OUT PCPTABLEINFO CodePageTable
2744 RtlResetRtlTranslations(IN PNLSTABLEINFO NlsTable
);
2746 #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
2749 // Misc conversion functions
2754 RtlConvertLongToLargeInteger(
2758 LARGE_INTEGER Result
;
2760 Result
.QuadPart
= SignedInteger
;
2767 RtlEnlargedIntegerMultiply(
2772 LARGE_INTEGER Product
;
2774 Product
.QuadPart
= (LONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2781 RtlEnlargedUnsignedDivide(
2782 IN ULARGE_INTEGER Dividend
,
2784 IN PULONG Remainder OPTIONAL
2789 Quotient
= (ULONG
)(Dividend
.QuadPart
/ Divisor
);
2791 *Remainder
= (ULONG
)(Dividend
.QuadPart
% Divisor
);
2800 RtlEnlargedUnsignedMultiply(
2805 LARGE_INTEGER Product
;
2807 Product
.QuadPart
= (ULONGLONG
)Multiplicand
* (ULONGLONG
)Multiplier
;
2823 IN USHORT PartialCrc
,
2829 // Network Functions
2834 RtlIpv4StringToAddressW(
2837 OUT PWCHAR Terminator
,
2838 OUT
struct in_addr
*Addr
2844 RtlIpv6StringToAddressA(
2846 OUT PCHAR
*Terminator
,
2847 OUT
struct in6_addr
*Addr
2853 RtlIpv6StringToAddressW(
2855 OUT PCHAR
*Terminator
,
2856 OUT
struct in6_addr
*Addr
2862 RtlIpv6StringToAddressExA(
2863 IN PCHAR AddressString
,
2864 IN
struct in6_addr
*Address
,
2872 RtlIpv6StringToAddressExW(
2873 IN PWCHAR AddressName
,
2874 IN
struct in6_addr
*Address
,
2886 RtlQueryTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
2891 RtlSecondsSince1970ToTime(
2892 IN ULONG SecondsSince1970
,
2893 OUT PLARGE_INTEGER Time
2899 RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation
);
2904 RtlTimeFieldsToTime(
2905 PTIME_FIELDS TimeFields
,
2912 RtlTimeToTimeFields(
2913 PLARGE_INTEGER Time
,
2914 PTIME_FIELDS TimeFields
2920 RtlSystemTimeToLocalTime(
2921 IN PLARGE_INTEGER SystemTime
,
2922 OUT PLARGE_INTEGER LocalTime
2926 // Version Functions
2931 RtlVerifyVersionInfo(
2932 IN PRTL_OSVERSIONINFOEXW VersionInfo
,
2934 IN ULONGLONG ConditionMask
2940 RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation
);
2945 RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType
);
2948 // Secure Memory Functions
2950 #ifdef NTOS_MODE_USER
2954 RtlRegisterSecureMemoryCacheCallback(
2955 IN PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback
);
2960 RtlFlushSecureMemoryCache(
2961 IN PVOID MemoryCache
,
2962 IN OPTIONAL SIZE_T MemoryLength