ReactOS 0.4.15-dev-8413-gc1c91f2
rtlfuncs.h
Go to the documentation of this file.
1/*++ NDK Version: 0098
2
3Copyright (c) Alex Ionescu. All rights reserved.
4
5Header Name:
6
7 rtlfuncs.h
8
9Abstract:
10
11 Function definitions for the Run-Time Library
12
13Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17--*/
18
19#ifndef _RTLFUNCS_H
20#define _RTLFUNCS_H
21
22//
23// Dependencies
24//
25#include <umtypes.h>
26#include <ntnls.h>
27#include <rtltypes.h>
28#include <pstypes.h>
29#include <extypes.h>
30#include "in6addr.h"
31#include "inaddr.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37#ifdef NTOS_MODE_USER
38
39//
40// List Functions
41//
43VOID
45 _Out_ PLIST_ENTRY ListHead
46)
47{
48 ListHead->Flink = ListHead->Blink = ListHead;
49}
50
52VOID
54 _Inout_ PLIST_ENTRY ListHead,
56)
57{
58 PLIST_ENTRY OldFlink;
59 OldFlink = ListHead->Flink;
60 Entry->Flink = OldFlink;
61 Entry->Blink = ListHead;
62 OldFlink->Blink = Entry;
63 ListHead->Flink = Entry;
64}
65
67VOID
69 _Inout_ PLIST_ENTRY ListHead,
71)
72{
73 PLIST_ENTRY OldBlink;
74 OldBlink = ListHead->Blink;
75 Entry->Flink = ListHead;
76 Entry->Blink = OldBlink;
77 OldBlink->Flink = Entry;
78 ListHead->Blink = Entry;
79}
80
85 _In_ const LIST_ENTRY * ListHead
86)
87{
88 return (BOOLEAN)(ListHead->Flink == ListHead);
89}
90
95)
96{
97 PSINGLE_LIST_ENTRY FirstEntry;
98 FirstEntry = ListHead->Next;
99 if (FirstEntry != NULL) {
100 ListHead->Next = FirstEntry->Next;
101 }
102
103 return FirstEntry;
104}
105
107VOID
111)
112{
113 Entry->Next = ListHead->Next;
114 ListHead->Next = Entry;
115}
116
121{
122 PLIST_ENTRY OldFlink;
123 PLIST_ENTRY OldBlink;
124
125 OldFlink = Entry->Flink;
126 OldBlink = Entry->Blink;
127 OldFlink->Blink = OldBlink;
128 OldBlink->Flink = OldFlink;
129 return (BOOLEAN)(OldFlink == OldBlink);
130}
131
135 _Inout_ PLIST_ENTRY ListHead)
136{
137 PLIST_ENTRY Flink;
139
140 Entry = ListHead->Flink;
141 Flink = Entry->Flink;
142 ListHead->Flink = Flink;
143 Flink->Blink = ListHead;
144 return Entry;
145}
146
150 _Inout_ PLIST_ENTRY ListHead)
151{
152 PLIST_ENTRY Blink;
154
155 Entry = ListHead->Blink;
156 Blink = Entry->Blink;
157 ListHead->Blink = Blink;
158 Blink->Flink = ListHead;
159 return Entry;
160}
161
162//
163// Unicode string macros
164//
169VOID
170RtlInitEmptyUnicodeString(
174{
175 UnicodeString->Length = 0;
176 UnicodeString->MaximumLength = BufferSize;
177 UnicodeString->Buffer = Buffer;
178}
179
184VOID
185RtlInitEmptyAnsiString(
189{
190 AnsiString->Length = 0;
191 AnsiString->MaximumLength = BufferSize;
192 AnsiString->Buffer = Buffer;
193}
194
195//
196// LUID Macros
197//
198#define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
199 ((L1)->LowPart == (L2)->LowPart))
201LUID
205{
206 LUID TempLuid;
207
208 TempLuid.LowPart = Ulong;
209 TempLuid.HighPart = 0;
210 return TempLuid;
211}
212
216NTAPI
222 _In_reads_bytes_(UTF8StringByteCount) PCCH UTF8StringSource,
224
225//
226// ASSERT Macros
227//
228#ifndef ASSERT
229#if DBG
230
231#define ASSERT( exp ) \
232 ((void)((!(exp)) ? \
233 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ),FALSE) : \
234 TRUE))
235
236#define ASSERTMSG( msg, exp ) \
237 ((void)((!(exp)) ? \
238 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ),FALSE) : \
239 TRUE))
240
241#else
242
243#define ASSERT( exp ) ((void) 0)
244#define ASSERTMSG( msg, exp ) ((void) 0)
245
246#endif
247#endif
248
249#ifdef NTOS_KERNEL_RUNTIME
250
251//
252// Executing RTL functions at DISPATCH_LEVEL or higher will result in a
253// bugcheck.
254//
255#define RTL_PAGED_CODE PAGED_CODE
256
257#else
258
259//
260// This macro does nothing in user mode
261//
262#define RTL_PAGED_CODE()
263
264#endif
265
266//
267// RTL Splay Tree Functions
268//
269#ifndef RTL_USE_AVL_TABLES
270
272VOID
273NTAPI
280);
281
283PVOID
284NTAPI
289 _Out_opt_ PBOOLEAN NewElement
290);
291
293PVOID
294NTAPI
299 _Out_opt_ PBOOLEAN NewElement,
300 _In_ PVOID NodeOrParent,
301 _In_ TABLE_SEARCH_RESULT SearchResult
302);
303
306NTAPI
310);
311
314PVOID
315NTAPI
319);
320
322PVOID
323NTAPI
327 _Out_ PVOID *NodeOrParent,
328 _Out_ TABLE_SEARCH_RESULT *SearchResult
329);
330
333PVOID
334NTAPI
338);
339
342PVOID
343NTAPI
346 _Inout_ PVOID *RestartKey
347);
348
351PVOID
352NTAPI
355 _In_ ULONG I
356);
357
359ULONG
360NTAPI
363);
364
368NTAPI
371);
372
373#endif /* !RTL_USE_AVL_TABLES */
374
377NTAPI
380);
381
384NTAPI
387);
388
390VOID
391NTAPI
395);
396
400NTAPI
403);
404
408NTAPI
411);
412
416NTAPI
419);
420
424NTAPI
427);
428
429#define RtlIsLeftChild(Links) \
430 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
431
432#define RtlIsRightChild(Links) \
433 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
434
435#define RtlRightChild(Links) \
436 ((PRTL_SPLAY_LINKS)(Links))->RightChild
437
438#define RtlIsRoot(Links) \
439 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
440
441#define RtlLeftChild(Links) \
442 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
443
444#define RtlParent(Links) \
445 ((PRTL_SPLAY_LINKS)(Links))->Parent
446
447// FIXME: use inline function
448
449#define RtlInitializeSplayLinks(Links) \
450 { \
451 PRTL_SPLAY_LINKS _SplayLinks; \
452 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
453 _SplayLinks->Parent = _SplayLinks; \
454 _SplayLinks->LeftChild = NULL; \
455 _SplayLinks->RightChild = NULL; \
456 }
457
458#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
459 { \
460 PRTL_SPLAY_LINKS _SplayParent; \
461 PRTL_SPLAY_LINKS _SplayChild; \
462 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
463 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
464 _SplayParent->LeftChild = _SplayChild; \
465 _SplayChild->Parent = _SplayParent; \
466 }
467
468#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
469 { \
470 PRTL_SPLAY_LINKS _SplayParent; \
471 PRTL_SPLAY_LINKS _SplayChild; \
472 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
473 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
474 _SplayParent->RightChild = _SplayChild; \
475 _SplayChild->Parent = _SplayParent; \
476 }
477
478//
479// RTL AVL Tree Functions
480//
482VOID
483NTAPI
490);
491
493PVOID
494NTAPI
499 _Out_opt_ PBOOLEAN NewElement
500);
501
503PVOID
504NTAPI
509 _Out_opt_ PBOOLEAN NewElement,
510 _In_ PVOID NodeOrParent,
511 _In_ TABLE_SEARCH_RESULT SearchResult
512);
513
516NTAPI
520);
521
524PVOID
525NTAPI
529);
530
532PVOID
533NTAPI
537 _Out_ PVOID *NodeOrParent,
538 _Out_ TABLE_SEARCH_RESULT *SearchResult
539);
540
543PVOID
544NTAPI
548);
549
552PVOID
553NTAPI
556 _Inout_ PVOID *RestartKey
557);
558
561PVOID
562NTAPI
566 _Out_ PVOID *RestartKey
567);
568
571PVOID
572NTAPI
575 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction,
577 _In_ ULONG NextFlag,
578 _Inout_ PVOID *RestartKey,
579 _Inout_ PULONG DeleteCount,
581);
582
585PVOID
586NTAPI
589 _In_ ULONG I
590);
591
593ULONG
594NTAPI
597);
598
602NTAPI
605);
606
607#ifdef RTL_USE_AVL_TABLES
608
609#define RtlInitializeGenericTable RtlInitializeGenericTableAvl
610#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
611#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
612#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
613#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
614#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
615#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
616#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
617#define RtlGetElementGenericTable RtlGetElementGenericTableAvl
618#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
619#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
620
621#endif /* RTL_USE_AVL_TABLES */
622
623//
624// Exception and Error Functions
625//
627PVOID
628NTAPI
630 _In_ ULONG FirstHandler,
631 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
632);
633
635ULONG
636NTAPI
638 _In_ PVOID VectoredHandlerHandle
639);
640
642PVOID
643NTAPI
645 _In_ ULONG FirstHandler,
646 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
647);
648
650ULONG
651NTAPI
653 _In_ PVOID VectoredHandlerHandle
654);
655
657VOID
658NTAPI
660 _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter
661);
662
664LONG
665NTAPI
667 _In_ struct _EXCEPTION_POINTERS* ExceptionInfo
668);
669
672VOID
673NTAPI
675 _In_ PVOID FailedAssertion,
679);
680
682PVOID
683NTAPI
685 _In_ PVOID Pointer
686);
687
689PVOID
690NTAPI
692 _In_ PVOID Pointer
693);
694
696PVOID
697NTAPI
699 _In_ PVOID Pointer
700);
701
703PVOID
704NTAPI
706 _In_ PVOID Pointer
707);
708
711NTAPI
713 VOID
714);
715
717ULONG
718NTAPI
720 VOID
721);
722
724VOID
725NTAPI
727 _In_ ULONG LastError
728);
729
731VOID
732NTAPI
735);
736
739NTAPI
741 _In_ ULONG NewMode,
742 _Out_opt_ PULONG OldMode
743);
744
746ULONG
747NTAPI
749 VOID
750);
751
752#endif /* NTOS_MODE_USER */
753
755VOID
756NTAPI
759);
760
763NTAPI
765 _In_ PEXCEPTION_RECORD ExceptionRecord,
767);
768
771_When_(Status >= 0, _Out_range_(==, 0))
773ULONG
774NTAPI
777);
778
780_When_(Status >= 0, _Out_range_(==, 0))
782ULONG
783NTAPI
786);
787
790NTAPI
792 _In_ ULONG SecurityError
793);
794
796VOID
797NTAPI
799 _In_ PEXCEPTION_RECORD ExceptionRecord
800);
801
804VOID
805NTAPI
808);
809
811VOID
812NTAPI
814 _In_opt_ PVOID TargetFrame,
815 _In_opt_ PVOID TargetIp,
816 _In_opt_ PEXCEPTION_RECORD ExceptionRecord,
818);
819
820#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
821
822#ifdef _M_AMD64
823
826NTAPI
828 _In_ DWORD64 ControlPc,
829 _Out_ PDWORD64 ImageBase,
830 _Inout_opt_ PUNWIND_HISTORY_TABLE HistoryTable
831);
832
835NTAPI
838 _In_ ULONG64 ImageBase,
839 _In_ ULONG64 ControlPc,
840 _In_ PRUNTIME_FUNCTION FunctionEntry,
842 _Outptr_ PVOID* HandlerData,
844 _Inout_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers
845);
846
847#endif // _M_AMD64
848
849//
850// Tracing Functions
851//
853ULONG
854NTAPI
859);
860
862USHORT
863NTAPI
865 VOID
866);
867
868#ifdef NTOS_MODE_USER
869//
870// Heap Functions
871//
876PVOID
877NTAPI
879 _In_ PVOID HeapHandle,
882);
883
886PVOID
887NTAPI
891 _In_opt_ SIZE_T SizeToReserve,
892 _In_opt_ SIZE_T SizeToCommit,
895);
896
898ULONG
899NTAPI
901 _In_ HANDLE HeapHandle,
903 _In_opt_ PWSTR TagName,
904 _In_ PWSTR TagSubName
905);
906
907ULONG
908NTAPI
910 _In_ HANDLE Heap,
912);
913
916PVOID
917NTAPI
921 _In_opt_ SIZE_T SizeToReserve,
922 _In_opt_ SIZE_T SizeToCommit,
925);
926
928HANDLE
929NTAPI
932);
933
935ULONG
936NTAPI
938 _In_ HANDLE Heap,
940 _In_ PVOID P,
942);
943
944_Success_(return != 0)
947NTAPI
949 _In_ HANDLE HeapHandle,
952);
953
954ULONG
955NTAPI
957 _In_ ULONG HeapCount,
958 _Out_cap_(HeapCount) HANDLE *HeapArray
959);
960
961_Success_(return != 0)
963NTAPI
965 _In_ PVOID HeapHandle,
968 _Inout_opt_ PVOID *UserValue,
969 _Out_opt_ PULONG UserFlags
970);
971
973PVOID
974NTAPI
976 _In_ PVOID HeapHandle,
978);
979
982NTAPI
984 _In_ PVOID HeapHandle,
985 _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
986 _Out_ PVOID HeapInformation,
987 _In_ SIZE_T HeapInformationLength,
990);
991
994PWSTR
995NTAPI
997 _In_ PVOID HeapHandle,
999 _In_ USHORT TagIndex,
1000 _In_ BOOLEAN ResetCounters,
1001 _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo
1002);
1003
1008PVOID
1009NTAPI
1011 _In_ HANDLE Heap,
1015);
1016
1019NTAPI
1021 _In_ PVOID HeapHandle,
1022 _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
1023 _When_(HeapInformationClass==HeapCompatibilityInformation,_In_) PVOID HeapInformation,
1024 _In_ SIZE_T HeapInformationLength
1025);
1026
1028BOOLEAN
1029NTAPI
1031 _In_ HANDLE Heap
1032);
1033
1035ULONG
1036NTAPI
1038 _In_ HANDLE HeapHandle,
1043);
1044
1046ULONG
1047NTAPI
1049 _In_ HANDLE HeapHandle,
1052 _In_count_(Count) /* _Deref_ _Post_invalid_ */ PVOID * Array
1053);
1054
1057NTAPI
1059 _In_ HANDLE Heap,
1062);
1063
1065BOOLEAN
1066NTAPI
1068 _In_ HANDLE Heap
1069);
1070
1071BOOLEAN
1072NTAPI
1074 _In_ PVOID HeapHandle,
1077 _In_ PVOID UserValue
1078);
1079
1080BOOLEAN
1081NTAPI
1083 _In_ PVOID HeapHandle,
1086 _In_ ULONG UserFlagsReset,
1087 _In_ ULONG UserFlagsSet
1088);
1089
1091BOOLEAN
1092NTAPI
1094 _In_ HANDLE Heap,
1097);
1098
1101NTAPI
1103 _In_ HANDLE HeapHandle,
1104 _In_ PVOID HeapEntry
1105);
1106
1107#define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
1108
1109#endif // NTOS_MODE_USER
1110
1111#define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
1112
1114SIZE_T
1115NTAPI
1117 _In_ PVOID HeapHandle,
1119 _In_ PVOID MemoryPointer
1120);
1121
1122
1123//
1124// Security Functions
1125//
1129NTAPI
1134);
1135
1139NTAPI
1141 _Inout_ PACL Acl,
1145);
1146
1150NTAPI
1152 _Inout_ PACL pAcl,
1157);
1158
1161NTAPI
1163 _Inout_ PACL pAcl,
1167 _In_opt_ GUID *ObjectTypeGuid,
1168 _In_opt_ GUID *InheritedObjectTypeGuid,
1169 _In_ PSID pSid
1170);
1171
1174NTAPI
1176 _Inout_ PACL Acl,
1179 _In_ PSID Sid
1180);
1181
1184NTAPI
1186 _Inout_ PACL Acl,
1190 _In_ PSID Sid
1191);
1192
1195NTAPI
1197 _Inout_ PACL pAcl,
1201 _In_opt_ GUID *ObjectTypeGuid,
1202 _In_opt_ GUID *InheritedObjectTypeGuid,
1203 _In_ PSID pSid
1204);
1205
1208NTAPI
1210 _Inout_ PACL Acl,
1215);
1216
1219NTAPI
1221 _Inout_ PACL Acl,
1224 _In_ PSID Sid,
1226 _In_ BOOLEAN Failure
1227);
1228
1231NTAPI
1234 _In_ ULONG NumPriv,
1236 _Out_ PVOID *ReturnedState
1237);
1238
1241NTAPI
1243 _Inout_ PACL Acl,
1247 _In_ PSID Sid,
1249 _In_ BOOLEAN Failure
1250);
1251
1254NTAPI
1256 _Inout_ PACL Acl,
1260 _In_opt_ GUID *ObjectTypeGuid,
1261 _In_opt_ GUID *InheritedObjectTypeGuid,
1262 _In_ PSID Sid,
1264 _In_ BOOLEAN Failure
1265);
1266
1269NTAPI
1271 _Inout_ PACL Acl,
1274 _In_ ULONG MandatoryFlags,
1276 _In_ PSID LabelSid);
1277
1280NTAPI
1283 _In_ BOOLEAN NewValue,
1284 _In_ BOOLEAN ForThread,
1285 _Out_ PBOOLEAN OldValue
1286);
1287
1291NTAPI
1295 _In_ ULONG SubAuthority0,
1296 _In_ ULONG SubAuthority1,
1297 _In_ ULONG SubAuthority2,
1298 _In_ ULONG SubAuthority3,
1299 _In_ ULONG SubAuthority4,
1300 _In_ ULONG SubAuthority5,
1301 _In_ ULONG SubAuthority6,
1302 _In_ ULONG SubAuthority7,
1304);
1305
1307BOOLEAN
1308NTAPI
1312);
1313
1315BOOLEAN
1316NTAPI
1320);
1321
1324VOID
1325NTAPI
1327 _Out_ PLUID DestinationLuid,
1329 );
1330
1332VOID
1333NTAPI
1335 ULONG Count,
1338);
1339
1342NTAPI
1346 _In_ ULONG SidAreaSize,
1348 _In_ PSID SidArea,
1349 _Out_ PSID* RemainingSidArea,
1350 _Out_ PULONG RemainingSidAreaSize
1351);
1352
1356NTAPI
1359 _In_ PSID Sid,
1361);
1362
1366NTAPI
1368 _In_ ULONG DestinationSidLength,
1369 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid,
1371);
1372
1375NTAPI
1377 PACL Acl,
1378 ULONG AclSize,
1380);
1381
1384NTAPI
1388);
1389
1392NTAPI
1396);
1397
1400NTAPI
1402 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
1403 _Out_ PSECURITY_DESCRIPTOR *pDestinationSecurityDescriptor
1404);
1405
1408NTAPI
1410 PACL Acl,
1412);
1413
1415BOOLEAN
1416NTAPI
1418 PSID Sid1,
1419 PSID Sid2
1420);
1421
1423BOOLEAN
1424NTAPI
1426 _In_ PSID Sid1,
1427 _In_ PSID Sid2
1428);
1429
1431BOOLEAN
1432NTAPI
1434 PACL Acl,
1435 PACE* Ace
1436);
1437
1439PVOID
1440NTAPI
1443);
1444
1447NTAPI
1449 PACL Acl,
1451 PVOID *Ace
1452);
1453
1456NTAPI
1461);
1462
1465NTAPI
1469 _Out_ PACL *Dacl,
1471);
1472
1475NTAPI
1479 _Out_ PACL* Sacl,
1481);
1482
1485NTAPI
1488 _Out_ PSID *Group,
1490);
1491
1494NTAPI
1497 _Out_ PSID *Owner,
1499);
1500
1502BOOLEAN
1503NTAPI
1506 _Out_ PUCHAR RMControl
1507);
1508
1511NTAPI
1513
1516NTAPI
1518
1522NTAPI
1524 _Out_ PSID Sid,
1527);
1528
1530ULONG
1531NTAPI
1533
1536ULONG
1537NTAPI
1540
1542ULONG
1543NTAPI
1545
1548NTAPI
1550 _In_ PSECURITY_DESCRIPTOR AbsoluteSD,
1551 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1553
1555VOID
1556NTAPI
1560);
1561
1562#ifdef NTOS_MODE_USER
1563
1566NTAPI
1568 PACL Acl,
1570 ULONG InformationLength,
1572);
1573
1574#endif
1575
1577VOID
1578NTAPI
1580 _In_ PVOID ReturnedState
1581);
1582
1583#if (NTDDI_VERSION >= NTDDI_VISTA)
1584
1587NTAPI
1590 _In_reads_opt_(PrivilegeCount) _When_(PrivilegeCount != 0, _Notnull_)
1591 PULONG PrivilegesToKeep,
1592 _In_ ULONG PrivilegeCount
1593);
1594
1595#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1596
1600NTAPI
1613);
1614
1617NTAPI
1619 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1621);
1622
1625NTAPI
1630);
1631
1634NTAPI
1637 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
1638 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1639);
1640
1644NTAPI
1650);
1651
1655NTAPI
1660);
1661
1662#ifdef NTOS_MODE_USER
1663
1666NTAPI
1668 PACL Acl,
1670 ULONG InformationLength,
1672);
1673
1674#endif
1675
1679NTAPI
1684);
1685
1688NTAPI
1692 _In_ PACL Sacl,
1694);
1695
1697VOID
1698NTAPI
1701 _In_ PUCHAR RMControl
1702);
1703
1705PUCHAR
1706NTAPI
1708 _In_ PSID Sid
1709);
1710
1712PULONG
1713NTAPI
1715 _In_ PSID Sid,
1716 _In_ ULONG SubAuthority
1717);
1718
1722BOOLEAN
1723NTAPI
1728);
1729
1731BOOLEAN
1732NTAPI
1734
1736BOOLEAN
1737NTAPI
1739
1741BOOLEAN
1742NTAPI
1744
1747NTAPI
1749 _In_ PSECURITY_DESCRIPTOR *ObjectDescriptor
1750);
1751
1754NTAPI
1756 _In_ PSECURITY_DESCRIPTOR ParentDescriptor,
1757 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor,
1762);
1763
1766NTAPI
1768 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor,
1770 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor,
1771 _In_ ULONG DescriptorLength,
1773);
1774
1777NTAPI
1780 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor,
1781 _Out_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
1784);
1785
1786//
1787// Single-Character Functions
1788//
1791NTAPI
1794 _In_ ULONG Base,
1797);
1798
1800CHAR
1801NTAPI
1803
1805WCHAR
1806NTAPI
1808
1810WCHAR
1811NTAPI
1813
1816NTAPI
1819 _In_ ULONG Base,
1822);
1823
1826NTAPI
1832);
1833
1835_At_(String->MaximumLength, _Const_)
1838NTAPI
1843);
1844
1847NTAPI
1849 PCSZ String,
1850 ULONG Base,
1852);
1853
1854//
1855// Byte Swap Functions
1856//
1857#ifdef NTOS_MODE_USER
1858
1859unsigned short __cdecl _byteswap_ushort(unsigned short);
1860unsigned long __cdecl _byteswap_ulong (unsigned long);
1861unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1862#ifdef _MSC_VER
1863#pragma intrinsic(_byteswap_ushort)
1864#pragma intrinsic(_byteswap_ulong)
1865#pragma intrinsic(_byteswap_uint64)
1866#endif // _MSC_VER
1867#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1868#define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1869#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1870
1871#endif // NTOS_MODE_USER
1872
1873//
1874// Unicode->Ansi String Functions
1875//
1877ULONG
1878NTAPI
1880
1881#ifdef NTOS_MODE_USER
1882
1883#define RtlUnicodeStringToAnsiSize(STRING) ( \
1884 NLS_MB_CODE_PAGE_TAG ? \
1885 RtlxUnicodeStringToAnsiSize(STRING) : \
1886 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1887)
1888
1889#endif
1890
1893NTAPI
1898);
1899
1900//
1901// Unicode->OEM String Functions
1902//
1905NTAPI
1910);
1911
1914//_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1917NTAPI
1924);
1925
1928NTAPI
1933);
1934
1939NTAPI
1940RtlUnicodeStringToCountedOemString(
1946);
1947
1950NTAPI
1953 ULONG OemSize,
1954 PULONG ResultSize,
1956 ULONG UnicodeSize
1957);
1958
1960ULONG
1961NTAPI
1963
1964#ifdef NTOS_MODE_USER
1965
1966#define RtlUnicodeStringToOemSize(STRING) ( \
1967 NLS_MB_OEM_CODE_PAGE_TAG ? \
1968 RtlxUnicodeStringToOemSize(STRING) : \
1969 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1970)
1971
1972#define RtlUnicodeStringToCountedOemSize(STRING) ( \
1973 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1974)
1975
1976#endif
1977
1980NTAPI
1983 ULONG OemSize,
1984 PULONG ResultSize,
1986 ULONG UnicodeSize
1987);
1988
1989//
1990// Unicode->MultiByte String Functions
1991//
1994NTAPI
1996 PCHAR MbString,
1997 ULONG MbSize,
1998 PULONG ResultSize,
2000 ULONG UnicodeSize
2001);
2002
2005NTAPI
2007 PCHAR MbString,
2008 ULONG MbSize,
2009 PULONG ResultSize,
2011 ULONG UnicodeSize
2012);
2013
2016NTAPI
2018 PULONG MbSize,
2020 ULONG UnicodeSize
2021);
2022
2024ULONG
2025NTAPI
2027
2028//
2029// OEM to Unicode Functions
2030//
2033NTAPI
2038);
2039
2043NTAPI
2050);
2051
2052#ifdef NTOS_MODE_USER
2053
2054#define RtlOemStringToUnicodeSize(STRING) ( \
2055 NLS_MB_OEM_CODE_PAGE_TAG ? \
2056 RtlxOemStringToUnicodeSize(STRING) : \
2057 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2058)
2059
2060#define RtlOemStringToCountedUnicodeSize(STRING) ( \
2061 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
2062)
2063
2064#endif
2065
2066//
2067// Ansi->Unicode String Functions
2068//
2071WCHAR
2072NTAPI
2074 _Inout_ PUCHAR *SourceCharacter);
2075
2078NTAPI
2083);
2084
2086ULONG
2087NTAPI
2090);
2091
2092#ifdef NTOS_MODE_USER
2093
2094#define RtlAnsiStringToUnicodeSize(STRING) ( \
2095 NLS_MB_CODE_PAGE_TAG ? \
2096 RtlxAnsiStringToUnicodeSize(STRING) : \
2097 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2098)
2099
2100#endif
2101
2103BOOLEAN
2104NTAPI
2108);
2109
2110//
2111// Unicode String Functions
2112//
2115NTAPI
2119);
2120
2123NTAPI
2127);
2128
2130LONG
2131NTAPI
2133 PCUNICODE_STRING String1,
2136);
2137
2140LONG
2141NTAPI
2148);
2149
2151VOID
2152NTAPI
2156);
2157
2159BOOLEAN
2160NTAPI
2164);
2165
2166#ifdef NTOS_MODE_USER
2167
2170NTAPI
2172 _Inout_ PUNICODE_STRING UniDest,
2173 _In_ PCUNICODE_STRING UniSource,
2175);
2176
2179NTAPI
2184);
2185
2188NTAPI
2191 _In_ PCUNICODE_STRING SearchString,
2194);
2195
2196//
2197// Memory Functions
2198//
2199#if defined(_M_AMD64)
2200
2202VOID
2206 _In_ ULONG Pattern)
2207{
2209 if ((Length /= 4) != 0) {
2210 if (((ULONG64)Address & 4) != 0) {
2211 *Address = Pattern;
2212 if ((Length -= 1) == 0) {
2213 return;
2214 }
2215 Address += 1;
2216 }
2217 __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2);
2218 if ((Length & 1) != 0) Address[Length - 1] = Pattern;
2219 }
2220 return;
2221}
2222
2223#define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2224 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2225
2226#else
2227
2229VOID
2230NTAPI
2234 _In_ ULONG Pattern
2235);
2236
2238VOID
2239NTAPI
2243 _In_ ULONGLONG Pattern
2244);
2245
2246#endif
2247
2250NTAPI
2255);
2256
2258SIZE_T
2259NTAPI
2263 _In_ ULONG Pattern
2264);
2265
2266#ifndef RtlEqualMemory
2267#define RtlEqualMemory(Destination, Source, Length) \
2268 (!memcmp(Destination, Source, Length))
2269#endif
2270
2271#define RtlCopyBytes RtlCopyMemory
2272#define RtlFillBytes RtlFillMemory
2273#define RtlZeroBytes RtlZeroMemory
2274
2275#endif
2276
2278BOOLEAN
2279NTAPI
2281 PCUNICODE_STRING String1,
2284);
2285
2288VOID
2289NTAPI
2293);
2294
2296VOID
2297NTAPI
2300);
2301
2304NTAPI
2310);
2311
2321VOID
2322NTAPI
2326);
2327
2337VOID
2338NTAPI
2342);
2343
2347NTAPI
2351);
2352
2354BOOLEAN
2355NTAPI
2358 _In_ INT Size,
2360);
2361
2365BOOLEAN
2366NTAPI
2368 _In_ const STRING *String1,
2371);
2372
2376BOOLEAN
2377NTAPI
2379 _In_ PCUNICODE_STRING String1,
2382);
2383
2386VOID
2387NTAPI
2391);
2392
2396LONG
2397NTAPI
2399 _In_ const STRING *String1,
2402);
2403
2405VOID
2406NTAPI
2410);
2411
2415BOOLEAN
2416NTAPI
2418 _In_ const STRING *String1,
2421);
2422
2426NTAPI
2430);
2431
2436NTAPI
2443);
2444
2448NTAPI
2453);
2454
2457NTAPI
2461);
2462
2463#define RTL_SKIP_BUFFER_COPY 0x00000001
2464
2467NTAPI
2472);
2473
2474#ifdef NTOS_MODE_USER
2475
2477VOID
2478RtlInitBuffer(
2482)
2483{
2484 Buffer->Buffer = Buffer->StaticBuffer = Data;
2485 Buffer->Size = Buffer->StaticSize = DataSize;
2486 Buffer->ReservedForAllocatedSize = 0;
2487 Buffer->ReservedForIMalloc = NULL;
2488}
2489
2492RtlEnsureBufferSize(
2496)
2497{
2498 if (Buffer && RequiredSize <= Buffer->Size)
2499 return STATUS_SUCCESS;
2501}
2502
2504VOID
2505RtlFreeBuffer(
2507)
2508{
2509 if (Buffer->Buffer != Buffer->StaticBuffer && Buffer->Buffer)
2510 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer->Buffer);
2511 Buffer->Buffer = Buffer->StaticBuffer;
2512 Buffer->Size = Buffer->StaticSize;
2513}
2514
2516VOID
2517NTAPI
2521);
2522
2524VOID
2525NTAPI
2527 _In_ UCHAR Hash,
2529);
2530
2531#endif /* NTOS_MODE_USER */
2532
2533//
2534// Ansi String Functions
2535//
2538VOID
2539NTAPI
2541 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2543);
2544
2547VOID
2548NTAPI
2552);
2553
2557NTAPI
2561);
2562
2563//
2564// OEM String Functions
2565//
2568VOID
2569NTAPI
2571 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2573);
2574
2575//
2576// MultiByte->Unicode String Functions
2577//
2581NTAPI
2588);
2589
2593NTAPI
2598);
2599
2600//
2601// Atom Functions
2602//
2605NTAPI
2607 _In_ PRTL_ATOM_TABLE AtomTable,
2608 _In_ PWSTR AtomName,
2610);
2611
2614NTAPI
2617 _Inout_ PRTL_ATOM_TABLE *AtomTable
2618);
2619
2622NTAPI
2624 _In_ PRTL_ATOM_TABLE AtomTable,
2626);
2627
2630NTAPI
2632
2635NTAPI
2637 _In_ PRTL_ATOM_TABLE AtomTable,
2639 _Out_opt_ PULONG RefCount,
2641 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2642 _Inout_opt_ PULONG NameLength
2643);
2644
2647NTAPI
2649 _In_ PRTL_ATOM_TABLE AtomTable,
2651);
2652
2655NTAPI
2657 _In_ PRTL_ATOM_TABLE AtomTable,
2658 _In_ PWSTR AtomName,
2660);
2661
2662//
2663// Process Management Functions
2664//
2666PPEB
2667NTAPI
2669 VOID
2670);
2671
2673VOID
2674NTAPI
2676
2679NTAPI
2681 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2682 _In_ PUNICODE_STRING ImagePathName,
2685 _In_opt_ PUNICODE_STRING CommandLine,
2687 _In_opt_ PUNICODE_STRING WindowTitle,
2688 _In_opt_ PUNICODE_STRING DesktopInfo,
2689 _In_opt_ PUNICODE_STRING ShellInfo,
2690 _In_opt_ PUNICODE_STRING RuntimeInfo
2691);
2692
2695NTAPI
2697 _In_ PUNICODE_STRING ImageFileName,
2699 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2700 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2701 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2702 _In_opt_ HANDLE ParentProcess,
2704 _In_opt_ HANDLE DebugPort,
2705 _In_opt_ HANDLE ExceptionPort,
2707);
2708
2709#if (NTDDI_VERSION >= NTDDI_WIN7)
2712NTAPI
2714 _In_ PVOID ThreadContext,
2715 _Out_ HANDLE *OutThreadHandle,
2721 _Reserved_ PVOID Reserved6,
2723 _Reserved_ PVOID Reserved8
2724);
2725#else
2728NTAPI
2732 _In_ BOOLEAN CreateSuspended,
2733 _In_ ULONG StackZeroBits,
2734 _In_ SIZE_T StackReserve,
2735 _In_ SIZE_T StackCommit,
2736 _In_ PTHREAD_START_ROUTINE StartAddress,
2738 _Out_opt_ PHANDLE ThreadHandle,
2740);
2741#endif
2742
2745NTAPI
2747 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2748
2751NTAPI
2753 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2754
2756VOID
2757NTAPI
2760
2762VOID
2763NTAPI
2766 _Out_ PCONTEXT ThreadContext,
2767 _In_opt_ PVOID ThreadStartParam,
2768 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2769 _In_ PINITIAL_TEB InitialTeb
2770);
2771
2772#ifdef _M_AMD64
2773typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2774
2777NTAPI
2778RtlWow64GetThreadContext(
2779 _In_ HANDLE ThreadHandle,
2780 _Inout_ PWOW64_CONTEXT ThreadContext
2781);
2782
2783
2786NTAPI
2787RtlWow64SetThreadContext(
2788 _In_ HANDLE ThreadHandle,
2789 _In_ PWOW64_CONTEXT ThreadContext
2790);
2791#endif
2792
2794BOOLEAN
2795NTAPI
2797
2800NTAPI
2802 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2803
2805VOID
2806NTAPI
2808
2811NTAPI
2815 _In_ PVOID CallSite,
2816 _In_ ULONG ArgumentCount,
2817 _In_ PULONG Arguments,
2818 _In_ BOOLEAN PassContext,
2819 _In_ BOOLEAN AlreadySuspended
2820);
2821
2824__cdecl
2826 _In_ BOOLEAN NewValue,
2827 _Out_opt_ PBOOLEAN OldValue,
2828 _In_ BOOLEAN NeedBreaks
2829);
2830
2833__cdecl
2835 _In_ BOOLEAN NewValue,
2836 _Out_opt_ PBOOLEAN OldValue,
2837 _In_ BOOLEAN NeedBreaks
2838);
2839
2841ULONG
2842NTAPI
2844 VOID
2845);
2846
2847
2848//
2849// Thread Pool Functions
2850//
2851//
2853NTAPI
2855 _In_ PRTL_START_POOL_THREAD StartPoolThread,
2856 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2857);
2858
2861NTAPI
2863 _In_ HANDLE hWaitHandle,
2864 _In_opt_ HANDLE hCompletionEvent
2865);
2866
2869NTAPI
2871 _In_ HANDLE hWaitHandle
2872);
2873
2876NTAPI
2881);
2882
2885NTAPI
2890);
2891
2894NTAPI
2896 _In_ PHANDLE phNewWaitObject,
2897 _In_ HANDLE hObject,
2899 _In_ PVOID pvContext,
2900 _In_ ULONG ulMilliseconds,
2901 _In_ ULONG ulFlags
2902);
2903
2904//
2905// Environment/Path Functions
2906//
2909NTAPI
2911 _In_ BOOLEAN Inherit,
2913);
2914
2917NTAPI
2919 _In_ PUNICODE_STRING DllName,
2920 _Inout_ PUNICODE_STRING RealName,
2921 _Inout_ PUNICODE_STRING LocalName
2922);
2923
2925VOID
2926NTAPI
2929);
2930
2932BOOLEAN
2933NTAPI
2936);
2937
2940NTAPI
2943);
2944
2946ULONG
2947NTAPI
2954 _Out_ PWSTR *PartName
2955);
2956
2959NTAPI
2962 _In_ PUNICODE_STRING PathString,
2963 _In_ PUNICODE_STRING FileNameString,
2964 _In_ PUNICODE_STRING ExtensionString,
2965 _In_ PUNICODE_STRING CallerBuffer,
2967 _Out_opt_ PUNICODE_STRING* FullNameOut,
2968 _Out_opt_ PSIZE_T FilePartSize,
2970);
2971
2973BOOLEAN
2974NTAPI
2976 _In_opt_z_ PCWSTR DosPathName,
2977 _Out_ PUNICODE_STRING NtPathName,
2978 _Out_opt_ PCWSTR *NtFileNamePart,
2979 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2980);
2981
2982
2983#define RTL_UNCHANGED_UNK_PATH 1
2984#define RTL_CONVERTED_UNC_PATH 2
2985#define RTL_CONVERTED_NT_PATH 3
2986#define RTL_UNCHANGED_DOS_PATH 4
2987
2990NTAPI
2996);
2997
2998
3000BOOLEAN
3001NTAPI
3004 _Out_ PUNICODE_STRING NtName,
3005 _Out_ PCWSTR *PartName,
3006 _Out_ PRTL_RELATIVE_NAME_U RelativeName
3007);
3008
3012NTAPI
3018);
3019
3021ULONG
3022NTAPI
3026);
3027
3029ULONG
3030NTAPI
3033 _In_ ULONG Size,
3036);
3037
3038#if (NTDDI_VERSION >= NTDDI_WIN7)
3041NTAPI
3046 _Out_opt_ PWSTR *FilePart,
3047 _Out_opt_ RTL_PATH_TYPE *InputPathType
3048 );
3049#endif
3050
3052NTAPI
3058 _Out_opt_ PSIZE_T FilePartSize,
3062);
3063
3066NTAPI
3069 _In_ PCUNICODE_STRING PathString,
3071);
3072
3074ULONG
3075NTAPI
3077 VOID
3078);
3079
3081ULONG
3082NTAPI
3085);
3086
3088ULONG
3089NTAPI
3092);
3093
3097BOOLEAN
3098NTAPI
3103);
3104
3107NTAPI
3112);
3113
3114VOID
3115NTAPI
3117 _In_ PRTL_RELATIVE_NAME_U RelativeName
3118);
3119
3122NTAPI
3125);
3126
3129NTAPI
3134);
3135
3136//
3137// Critical Section/Resource Functions
3138//
3141NTAPI
3144);
3145
3148NTAPI
3151);
3152
3155NTAPI
3158);
3159
3162NTAPI
3165 _In_ ULONG SpinCount
3166);
3167
3169ULONG
3170NTAPI
3173);
3174
3176ULONG
3177NTAPI
3180);
3181
3184NTAPI
3187);
3188
3190BOOLEAN
3191NTAPI
3194);
3195
3197VOID
3198NTAPI
3201);
3202
3205NTAPI
3208);
3209
3211BOOLEAN
3212NTAPI
3216);
3217
3219BOOLEAN
3220NTAPI
3224);
3225
3227VOID
3228NTAPI
3231);
3232
3234VOID
3235NTAPI
3238);
3239
3241VOID
3242NTAPI
3245);
3246
3248VOID
3249NTAPI
3252);
3253
3255VOID
3256NTAPI
3259);
3260
3262VOID
3263NTAPI
3266);
3267
3268//
3269// Compression Functions
3270//
3271NTSYSAPI //NT_RTL_COMPRESS_API
3273NTAPI
3275 _In_ USHORT CompressionFormatAndEngine,
3280 _In_ ULONG UncompressedChunkSize,
3281 _Out_ PULONG FinalCompressedSize,
3283);
3284
3286NTSYSAPI //NT_RTL_COMPRESS_API
3288NTAPI
3290 _In_ USHORT CompressionFormat,
3296);
3297
3300NTAPI
3302 _In_ USHORT CompressionFormatAndEngine,
3303 _Out_ PULONG CompressBufferWorkSpaceSize,
3304 _Out_ PULONG CompressFragmentWorkSpaceSize
3305);
3306
3307//
3308// Frame Functions
3309//
3311VOID
3312NTAPI
3315);
3316
3318VOID
3319NTAPI
3322);
3323
3326NTAPI
3328 VOID
3329);
3330
3331//
3332// Debug Info Functions
3333//
3336NTAPI
3338 _In_ ULONG Size,
3339 _In_ BOOLEAN EventPair
3340);
3341
3344NTAPI
3346
3349NTAPI
3352 _In_ ULONG DebugInfoClassMask,
3354);
3355
3356//
3357// Bitmap Functions
3358//
3359#ifdef NTOS_MODE_USER
3360
3362BOOLEAN
3363NTAPI
3365 _In_ PRTL_BITMAP BitMapHeader,
3368);
3369
3371BOOLEAN
3372NTAPI
3374 _In_ PRTL_BITMAP BitMapHeader,
3377);
3378
3380VOID
3381NTAPI
3383 _In_ PRTL_BITMAP BitMapHeader
3384);
3385
3387VOID
3388NTAPI
3390 _In_ PRTL_BITMAP BitMapHeader,
3391 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3392);
3393
3395VOID
3396NTAPI
3398 _In_ PRTL_BITMAP BitMapHeader,
3399 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3400 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3401);
3402
3404ULONG
3405NTAPI
3407 _In_ PRTL_BITMAP BitMapHeader,
3410);
3411
3413ULONG
3414NTAPI
3416 _In_ PRTL_BITMAP BitMapHeader,
3419);
3420
3422ULONG
3423NTAPI
3425 _In_ PRTL_BITMAP BitMapHeader,
3427);
3428
3430ULONG
3431NTAPI
3433 _In_ PRTL_BITMAP BitMapHeader,
3434 _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray,
3435 _In_range_(>, 0) ULONG SizeOfRunArray,
3436 _In_ BOOLEAN LocateLongestRuns
3437);
3438
3440ULONG
3441NTAPI
3443 _In_ PRTL_BITMAP BitMapHeader,
3444 _In_ ULONG FromIndex,
3445 _Out_ PULONG StartingRunIndex
3446);
3447
3449CCHAR
3450NTAPI
3453);
3454
3456ULONG
3457NTAPI
3459 _In_ PRTL_BITMAP BitMapHeader,
3461);
3462
3464CCHAR
3465NTAPI
3468);
3469
3471ULONG
3472NTAPI
3474 _In_ PRTL_BITMAP BitMapHeader,
3475 _In_ ULONG FromIndex,
3476 _Out_ PULONG StartingRunIndex
3477);
3478
3480ULONG
3481NTAPI
3483 _In_ PRTL_BITMAP BitMapHeader,
3484 _In_ ULONG FromIndex,
3485 _Out_ PULONG StartingRunIndex
3486);
3487
3489ULONG
3490NTAPI
3492 _In_ PRTL_BITMAP BitMapHeader,
3495);
3496
3498ULONG
3499NTAPI
3501 _In_ PRTL_BITMAP BitMapHeader,
3504);
3505
3506#ifdef __REACTOS__ // ReactOS improvement
3507_At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3508_At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3509#endif
3511VOID
3512NTAPI
3514 _Out_ PRTL_BITMAP BitMapHeader,
3515 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3516 _In_opt_ ULONG SizeOfBitMap
3517);
3518
3520ULONG
3521NTAPI
3523 _In_ PRTL_BITMAP BitMapHeader
3524);
3525
3527ULONG
3528NTAPI
3530 _In_ PRTL_BITMAP BitMapHeader
3531);
3532
3534VOID
3535NTAPI
3536RtlSetBit(
3537 _In_ PRTL_BITMAP BitMapHeader,
3538 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3539);
3540
3542VOID
3543NTAPI
3545 _In_ PRTL_BITMAP BitMapHeader,
3546 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3547 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3548);
3549
3551VOID
3552NTAPI
3554 _In_ PRTL_BITMAP BitMapHeader
3555);
3556
3559BOOLEAN
3560NTAPI
3562 _In_ PRTL_BITMAP BitMapHeader,
3563 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3564);
3565
3566#if defined(_M_AMD64)
3569BOOLEAN
3571 _In_ PRTL_BITMAP BitMapHeader,
3572 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition)
3573{
3574 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
3575}
3576#else
3577#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3578#endif /* defined(_M_AMD64) */
3579
3580#endif // NTOS_MODE_USER
3581
3582
3583//
3584// Timer Functions
3585//
3588NTAPI
3590 _In_ HANDLE TimerQueue,
3591 _In_ PHANDLE phNewTimer,
3597);
3598
3601NTAPI
3602RtlCreateTimerQueue(PHANDLE TimerQueue);
3603
3606NTAPI
3608 _In_ HANDLE TimerQueue,
3610 _In_ HANDLE CompletionEvent
3611);
3612
3615NTAPI
3617 _In_ HANDLE TimerQueue,
3621);
3622
3625NTAPI
3627 _In_ HANDLE TimerQueue,
3628 _In_opt_ HANDLE CompletionEvent
3629);
3630
3633NTAPI
3634RtlDeleteTimerQueue(HANDLE TimerQueue);
3635
3636//
3637// SList functions
3638//
3642 _Inout_ PSLIST_HEADER ListHead,
3646);
3647
3648//
3649// Range List functions
3650//
3652VOID
3653NTAPI
3655 _Out_ PRTL_RANGE_LIST RangeList
3656);
3657
3659VOID
3660NTAPI
3662 _In_ PRTL_RANGE_LIST RangeList
3663);
3664
3667NTAPI
3669 _Out_ PRTL_RANGE_LIST CopyRangeList,
3670 _In_ PRTL_RANGE_LIST RangeList
3671);
3672
3675NTAPI
3677 _Out_ PRTL_RANGE_LIST MergedRangeList,
3678 _In_ PRTL_RANGE_LIST RangeList1,
3679 _In_ PRTL_RANGE_LIST RangeList2,
3681);
3682
3685NTAPI
3687 _Out_ PRTL_RANGE_LIST InvertedRangeList,
3688 _In_ PRTL_RANGE_LIST RangeList
3689);
3690
3693NTAPI
3695 _Inout_ PRTL_RANGE_LIST RangeList,
3697 _In_ ULONGLONG End,
3702);
3703
3706NTAPI
3708 _Inout_ PRTL_RANGE_LIST RangeList,
3710 _In_ ULONGLONG End,
3712);
3713
3716NTAPI
3718 _Inout_ PRTL_RANGE_LIST RangeList,
3720);
3721
3724NTAPI
3726 _In_ PRTL_RANGE_LIST RangeList,
3727 _In_ ULONGLONG Minimum,
3728 _In_ ULONGLONG Maximum,
3732 _In_ UCHAR AttributeAvailableMask,
3736);
3737
3740NTAPI
3742 _In_ PRTL_RANGE_LIST RangeList,
3744 _In_ ULONGLONG End,
3746 _In_ UCHAR AttributeAvailableMask,
3749 _Out_ PBOOLEAN Available
3750);
3751
3754NTAPI
3756 _In_ PRTL_RANGE_LIST RangeList,
3759);
3760
3763NTAPI
3767 _In_ BOOLEAN MoveForwards
3768);
3769
3770//
3771// Debug Functions
3772//
3773ULONG
3774__cdecl
3777 ...
3778);
3779
3781ULONG
3782__cdecl
3787 ...
3788);
3789
3791ULONG
3792NTAPI
3794 _In_z_ PCCH Prompt,
3797);
3798
3799#undef DbgBreakPoint
3800VOID
3801NTAPI
3803 VOID
3804);
3805
3806VOID
3807NTAPI
3810 _In_ PVOID Base,
3812);
3813
3814VOID
3815NTAPI
3818 _In_ PVOID Base,
3820);
3821
3822VOID
3823NTAPI
3825 _In_ PCCH Name,
3827);
3828
3829//
3830// Generic Table Functions
3831//
3832#if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3834PVOID
3835NTAPI
3840 _Out_opt_ PBOOLEAN NewElement
3841);
3842
3844PVOID
3845NTAPI
3850 _Out_opt_ PBOOLEAN NewElement,
3851 _In_ PVOID NodeOrParent,
3852 _In_ TABLE_SEARCH_RESULT SearchResult
3853);
3854
3856BOOLEAN
3857NTAPI
3860);
3861
3863PVOID
3864NTAPI
3868 _Out_ PVOID *NodeOrParent,
3869 _Out_ TABLE_SEARCH_RESULT *SearchResult
3870);
3871#endif
3872
3873//
3874// Handle Table Functions
3875//
3878NTAPI
3882);
3883
3885VOID
3886NTAPI
3889
3891BOOLEAN
3892NTAPI
3896);
3897
3899VOID
3900NTAPI
3903 _In_ ULONG HandleSize,
3905);
3906
3908BOOLEAN
3909NTAPI
3913);
3914
3915_Success_(return!=FALSE)
3917BOOLEAN
3918NTAPI
3923);
3924
3925//
3926// PE Functions
3927//
3930NTAPI
3933 _In_ ULONG Type,
3934 _In_ ULONG Language,
3935 _In_ ULONG MessageId,
3936 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3937);
3938
3940ULONG
3941NTAPI
3943
3944_Success_(return!=NULL)
3946PVOID
3947NTAPI
3953);
3954
3956PVOID
3957NTAPI
3959 _In_ PIMAGE_NT_HEADERS NtHeader,
3961 _In_ ULONG Rva,
3962 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3963);
3964
3967NTAPI
3970
3973NTAPI
3978 _Out_ PIMAGE_NT_HEADERS *NtHeader
3979);
3980
3983NTAPI
3985 _In_ PIMAGE_NT_HEADERS NtHeader,
3987 _In_ ULONG Rva
3988);
3989
3990ULONG
3991NTAPI
3994 _In_ LONGLONG AdditionalBias,
3995 _In_opt_ PCSTR LoaderName,
3997 _In_ ULONG Conflict,
3999);
4000
4001//
4002// Activation Context Functions
4003//
4004#ifdef NTOS_MODE_USER
4007NTAPI
4010 _In_ PTEB Teb,
4013);
4014
4017NTAPI
4022);
4023
4025VOID
4026NTAPI
4029);
4030
4034RtlActivateActivationContextUnsafeFast(
4035 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
4037);
4038
4041NTAPI
4042RtlAllocateActivationContextStack(
4044);
4045
4048NTAPI
4051 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
4052 _In_ ULONG ExtraBytes,
4053 _In_ PVOID NotificationRoutine,
4056);
4057
4060NTAPI
4063);
4064
4066VOID
4067NTAPI
4070);
4071
4074NTAPI
4077 _In_ ULONG_PTR ulCookie
4078);
4079
4081VOID
4082NTAPI
4083RtlFreeActivationContextStack(
4085);
4086
4088VOID
4089NTAPI
4091
4095RtlDeactivateActivationContextUnsafeFast(
4096 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
4097);
4098
4101NTAPI
4104 _In_ PUNICODE_STRING OriginalName,
4109 _In_ PULONG NewFlags,
4110 _In_ PSIZE_T FileNameSize,
4112);
4113
4116NTAPI
4119 _In_ const GUID *ExtensionGuid,
4120 _In_ ULONG SectionType,
4121 _In_ const UNICODE_STRING *SectionName,
4122 _Inout_ PVOID ReturnedData
4123);
4124
4127NTAPI
4131 _In_opt_ PVOID pvSubInstance,
4132 _In_ ULONG ulInfoClass,
4133 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
4134 _In_opt_ SIZE_T cbBuffer,
4135 _Out_opt_ SIZE_T *pcbWrittenOrRequired
4136);
4137
4140NTAPI
4141RtlQueryInformationActiveActivationContext(
4142 _In_ ULONG ulInfoClass,
4143 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
4144 _In_opt_ SIZE_T cbBuffer,
4145 _Out_opt_ SIZE_T *pcbWrittenOrRequired
4146);
4147
4150NTAPI
4153);
4154
4155//
4156// WOW64 Functions
4157//
4160NTAPI
4162 _In_ BOOLEAN Wow64FsEnableRedirection
4163);
4164
4167NTAPI
4169 _In_ PVOID Wow64FsEnableRedirection,
4170 _Out_ PVOID *OldFsRedirectionLevel
4171);
4172
4173#endif
4174
4175//
4176// Registry Functions
4177//
4182NTAPI
4184 _In_ ULONG RelativeTo,
4186);
4187
4190NTAPI
4192 _In_ ULONG RelativeTo,
4194);
4195
4198NTAPI
4200 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
4201 PUNICODE_STRING KeyPath
4202);
4203
4206NTAPI
4210);
4211
4215NTAPI
4217 _In_ ULONG RelativeTo,
4219 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
4223);
4224
4228NTAPI
4230 _In_ ULONG RelativeTo,
4236);
4237
4238#ifdef NTOS_MODE_USER
4241NTAPI
4249);
4250
4253NTAPI
4259);
4260
4263NTAPI
4266);
4267
4270NTAPI
4276);
4277
4280NTAPI
4287);
4288
4291NTAPI
4294 _In_ ULONG Type,
4295 _In_ PVOID Data,
4297);
4298#endif
4299
4300//
4301// NLS Functions
4302//
4304VOID
4305NTAPI
4309);
4310
4312VOID
4313NTAPI
4315 _In_ PUSHORT AnsiTableBase,
4316 _In_ PUSHORT OemTableBase,
4317 _In_ PUSHORT CaseTableBase,
4318 _Out_ PNLSTABLEINFO NlsTable
4319);
4320
4323VOID
4324NTAPI
4326 _In_ PUSHORT TableBase,
4328);
4329
4331VOID
4332NTAPI
4334 _In_ PNLSTABLEINFO NlsTable);
4335
4336#if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
4337
4338//
4339// Misc conversion functions
4340//
4341static __inline
4345 _In_ LONG SignedInteger
4346)
4347{
4349
4350 Result.QuadPart = SignedInteger;
4351 return Result;
4352}
4353
4354static __inline
4358 _In_ LONG Multiplicand,
4359 _In_ LONG Multiplier
4360)
4361{
4362 LARGE_INTEGER Product;
4363
4364 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
4365 return Product;
4366}
4367
4368static __inline
4369ULONG
4372 _In_ ULARGE_INTEGER Dividend,
4375)
4376{
4377 ULONG Quotient;
4378
<