ReactOS 0.4.15-dev-7889-g76290a6
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
213//
214// ASSERT Macros
215//
216#ifndef ASSERT
217#if DBG
218
219#define ASSERT( exp ) \
220 ((void)((!(exp)) ? \
221 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ),FALSE) : \
222 TRUE))
223
224#define ASSERTMSG( msg, exp ) \
225 ((void)((!(exp)) ? \
226 (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ),FALSE) : \
227 TRUE))
228
229#else
230
231#define ASSERT( exp ) ((void) 0)
232#define ASSERTMSG( msg, exp ) ((void) 0)
233
234#endif
235#endif
236
237#ifdef NTOS_KERNEL_RUNTIME
238
239//
240// Executing RTL functions at DISPATCH_LEVEL or higher will result in a
241// bugcheck.
242//
243#define RTL_PAGED_CODE PAGED_CODE
244
245#else
246
247//
248// This macro does nothing in user mode
249//
250#define RTL_PAGED_CODE()
251
252#endif
253
254//
255// RTL Splay Tree Functions
256//
257#ifndef RTL_USE_AVL_TABLES
258
260VOID
261NTAPI
268);
269
271PVOID
272NTAPI
277 _Out_opt_ PBOOLEAN NewElement
278);
279
281PVOID
282NTAPI
287 _Out_opt_ PBOOLEAN NewElement,
288 _In_ PVOID NodeOrParent,
289 _In_ TABLE_SEARCH_RESULT SearchResult
290);
291
294NTAPI
298);
299
302PVOID
303NTAPI
307);
308
310PVOID
311NTAPI
315 _Out_ PVOID *NodeOrParent,
316 _Out_ TABLE_SEARCH_RESULT *SearchResult
317);
318
321PVOID
322NTAPI
326);
327
330PVOID
331NTAPI
334 _Inout_ PVOID *RestartKey
335);
336
339PVOID
340NTAPI
343 _In_ ULONG I
344);
345
347ULONG
348NTAPI
351);
352
356NTAPI
359);
360
361#endif /* !RTL_USE_AVL_TABLES */
362
365NTAPI
368);
369
372NTAPI
375);
376
378VOID
379NTAPI
383);
384
388NTAPI
391);
392
396NTAPI
399);
400
404NTAPI
407);
408
412NTAPI
415);
416
417#define RtlIsLeftChild(Links) \
418 (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
419
420#define RtlIsRightChild(Links) \
421 (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
422
423#define RtlRightChild(Links) \
424 ((PRTL_SPLAY_LINKS)(Links))->RightChild
425
426#define RtlIsRoot(Links) \
427 (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
428
429#define RtlLeftChild(Links) \
430 ((PRTL_SPLAY_LINKS)(Links))->LeftChild
431
432#define RtlParent(Links) \
433 ((PRTL_SPLAY_LINKS)(Links))->Parent
434
435// FIXME: use inline function
436
437#define RtlInitializeSplayLinks(Links) \
438 { \
439 PRTL_SPLAY_LINKS _SplayLinks; \
440 _SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
441 _SplayLinks->Parent = _SplayLinks; \
442 _SplayLinks->LeftChild = NULL; \
443 _SplayLinks->RightChild = NULL; \
444 }
445
446#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
447 { \
448 PRTL_SPLAY_LINKS _SplayParent; \
449 PRTL_SPLAY_LINKS _SplayChild; \
450 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
451 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
452 _SplayParent->LeftChild = _SplayChild; \
453 _SplayChild->Parent = _SplayParent; \
454 }
455
456#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
457 { \
458 PRTL_SPLAY_LINKS _SplayParent; \
459 PRTL_SPLAY_LINKS _SplayChild; \
460 _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
461 _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
462 _SplayParent->RightChild = _SplayChild; \
463 _SplayChild->Parent = _SplayParent; \
464 }
465
466//
467// RTL AVL Tree Functions
468//
470VOID
471NTAPI
478);
479
481PVOID
482NTAPI
487 _Out_opt_ PBOOLEAN NewElement
488);
489
491PVOID
492NTAPI
497 _Out_opt_ PBOOLEAN NewElement,
498 _In_ PVOID NodeOrParent,
499 _In_ TABLE_SEARCH_RESULT SearchResult
500);
501
504NTAPI
508);
509
512PVOID
513NTAPI
517);
518
520PVOID
521NTAPI
525 _Out_ PVOID *NodeOrParent,
526 _Out_ TABLE_SEARCH_RESULT *SearchResult
527);
528
531PVOID
532NTAPI
536);
537
540PVOID
541NTAPI
544 _Inout_ PVOID *RestartKey
545);
546
549PVOID
550NTAPI
554 _Out_ PVOID *RestartKey
555);
556
559PVOID
560NTAPI
563 _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction,
565 _In_ ULONG NextFlag,
566 _Inout_ PVOID *RestartKey,
567 _Inout_ PULONG DeleteCount,
569);
570
573PVOID
574NTAPI
577 _In_ ULONG I
578);
579
581ULONG
582NTAPI
585);
586
590NTAPI
593);
594
595#ifdef RTL_USE_AVL_TABLES
596
597#define RtlInitializeGenericTable RtlInitializeGenericTableAvl
598#define RtlInsertElementGenericTable RtlInsertElementGenericTableAvl
599#define RtlInsertElementGenericTableFull RtlInsertElementGenericTableFullAvl
600#define RtlDeleteElementGenericTable RtlDeleteElementGenericTableAvl
601#define RtlLookupElementGenericTable RtlLookupElementGenericTableAvl
602#define RtlLookupElementGenericTableFull RtlLookupElementGenericTableFullAvl
603#define RtlEnumerateGenericTable RtlEnumerateGenericTableAvl
604#define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
605#define RtlGetElementGenericTable RtlGetElementGenericTableAvl
606#define RtlNumberGenericTableElements RtlNumberGenericTableElementsAvl
607#define RtlIsGenericTableEmpty RtlIsGenericTableEmptyAvl
608
609#endif /* RTL_USE_AVL_TABLES */
610
611//
612// Exception and Error Functions
613//
615PVOID
616NTAPI
618 _In_ ULONG FirstHandler,
619 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
620);
621
623ULONG
624NTAPI
626 _In_ PVOID VectoredHandlerHandle
627);
628
630PVOID
631NTAPI
633 _In_ ULONG FirstHandler,
634 _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
635);
636
638ULONG
639NTAPI
641 _In_ PVOID VectoredHandlerHandle
642);
643
645VOID
646NTAPI
648 _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter
649);
650
652LONG
653NTAPI
655 _In_ struct _EXCEPTION_POINTERS* ExceptionInfo
656);
657
660VOID
661NTAPI
663 _In_ PVOID FailedAssertion,
667);
668
670PVOID
671NTAPI
673 _In_ PVOID Pointer
674);
675
677PVOID
678NTAPI
680 _In_ PVOID Pointer
681);
682
684PVOID
685NTAPI
687 _In_ PVOID Pointer
688);
689
691PVOID
692NTAPI
694 _In_ PVOID Pointer
695);
696
699NTAPI
701 VOID
702);
703
705ULONG
706NTAPI
708 VOID
709);
710
712VOID
713NTAPI
715 _In_ ULONG LastError
716);
717
719VOID
720NTAPI
723);
724
727NTAPI
729 _In_ ULONG NewMode,
730 _Out_opt_ PULONG OldMode
731);
732
734ULONG
735NTAPI
737 VOID
738);
739
740#endif /* NTOS_MODE_USER */
741
743VOID
744NTAPI
747);
748
751NTAPI
753 _In_ PEXCEPTION_RECORD ExceptionRecord,
755);
756
759_When_(Status >= 0, _Out_range_(==, 0))
761ULONG
762NTAPI
765);
766
768_When_(Status >= 0, _Out_range_(==, 0))
770ULONG
771NTAPI
774);
775
778NTAPI
780 _In_ ULONG SecurityError
781);
782
784VOID
785NTAPI
787 _In_ PEXCEPTION_RECORD ExceptionRecord
788);
789
792VOID
793NTAPI
796);
797
799VOID
800NTAPI
802 _In_opt_ PVOID TargetFrame,
803 _In_opt_ PVOID TargetIp,
804 _In_opt_ PEXCEPTION_RECORD ExceptionRecord,
806);
807
808#define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
809
810#ifdef _M_AMD64
811
814NTAPI
816 _In_ DWORD64 ControlPc,
817 _Out_ PDWORD64 ImageBase,
818 _Inout_opt_ PUNWIND_HISTORY_TABLE HistoryTable
819);
820
823NTAPI
826 _In_ ULONG64 ImageBase,
827 _In_ ULONG64 ControlPc,
828 _In_ PRUNTIME_FUNCTION FunctionEntry,
830 _Outptr_ PVOID* HandlerData,
832 _Inout_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers
833);
834
835#endif // _M_AMD64
836
837//
838// Tracing Functions
839//
841ULONG
842NTAPI
847);
848
850USHORT
851NTAPI
853 VOID
854);
855
856#ifdef NTOS_MODE_USER
857//
858// Heap Functions
859//
864PVOID
865NTAPI
867 _In_ PVOID HeapHandle,
870);
871
874PVOID
875NTAPI
879 _In_opt_ SIZE_T SizeToReserve,
880 _In_opt_ SIZE_T SizeToCommit,
883);
884
886ULONG
887NTAPI
889 _In_ HANDLE HeapHandle,
891 _In_opt_ PWSTR TagName,
892 _In_ PWSTR TagSubName
893);
894
895ULONG
896NTAPI
898 _In_ HANDLE Heap,
900);
901
904PVOID
905NTAPI
909 _In_opt_ SIZE_T SizeToReserve,
910 _In_opt_ SIZE_T SizeToCommit,
913);
914
916HANDLE
917NTAPI
920);
921
923ULONG
924NTAPI
926 _In_ HANDLE Heap,
928 _In_ PVOID P,
930);
931
932_Success_(return != 0)
935NTAPI
937 _In_ HANDLE HeapHandle,
940);
941
942ULONG
943NTAPI
945 _In_ ULONG HeapCount,
946 _Out_cap_(HeapCount) HANDLE *HeapArray
947);
948
949_Success_(return != 0)
951NTAPI
953 _In_ PVOID HeapHandle,
956 _Inout_opt_ PVOID *UserValue,
957 _Out_opt_ PULONG UserFlags
958);
959
961PVOID
962NTAPI
964 _In_ PVOID HeapHandle,
966);
967
970NTAPI
972 _In_ PVOID HeapHandle,
973 _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
974 _Out_ PVOID HeapInformation,
975 _In_ SIZE_T HeapInformationLength,
978);
979
982PWSTR
983NTAPI
985 _In_ PVOID HeapHandle,
987 _In_ USHORT TagIndex,
988 _In_ BOOLEAN ResetCounters,
989 _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo
990);
991
996PVOID
997NTAPI
999 _In_ HANDLE Heap,
1003);
1004
1007NTAPI
1009 _In_ PVOID HeapHandle,
1010 _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
1011 _When_(HeapInformationClass==HeapCompatibilityInformation,_In_) PVOID HeapInformation,
1012 _In_ SIZE_T HeapInformationLength
1013);
1014
1016BOOLEAN
1017NTAPI
1019 _In_ HANDLE Heap
1020);
1021
1023ULONG
1024NTAPI
1026 _In_ HANDLE HeapHandle,
1031);
1032
1034ULONG
1035NTAPI
1037 _In_ HANDLE HeapHandle,
1040 _In_count_(Count) /* _Deref_ _Post_invalid_ */ PVOID * Array
1041);
1042
1045NTAPI
1047 _In_ HANDLE Heap,
1050);
1051
1053BOOLEAN
1054NTAPI
1056 _In_ HANDLE Heap
1057);
1058
1059BOOLEAN
1060NTAPI
1062 _In_ PVOID HeapHandle,
1065 _In_ PVOID UserValue
1066);
1067
1068BOOLEAN
1069NTAPI
1071 _In_ PVOID HeapHandle,
1074 _In_ ULONG UserFlagsReset,
1075 _In_ ULONG UserFlagsSet
1076);
1077
1079BOOLEAN
1080NTAPI
1082 _In_ HANDLE Heap,
1085);
1086
1089NTAPI
1091 _In_ HANDLE HeapHandle,
1092 _In_ PVOID HeapEntry
1093);
1094
1095#define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
1096
1097#endif // NTOS_MODE_USER
1098
1099#define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
1100
1102SIZE_T
1103NTAPI
1105 _In_ PVOID HeapHandle,
1107 _In_ PVOID MemoryPointer
1108);
1109
1110
1111//
1112// Security Functions
1113//
1117NTAPI
1122);
1123
1127NTAPI
1129 _Inout_ PACL Acl,
1133);
1134
1138NTAPI
1140 _Inout_ PACL pAcl,
1145);
1146
1149NTAPI
1151 _Inout_ PACL pAcl,
1155 _In_opt_ GUID *ObjectTypeGuid,
1156 _In_opt_ GUID *InheritedObjectTypeGuid,
1157 _In_ PSID pSid
1158);
1159
1162NTAPI
1164 _Inout_ PACL Acl,
1167 _In_ PSID Sid
1168);
1169
1172NTAPI
1174 _Inout_ PACL Acl,
1178 _In_ PSID Sid
1179);
1180
1183NTAPI
1185 _Inout_ PACL pAcl,
1189 _In_opt_ GUID *ObjectTypeGuid,
1190 _In_opt_ GUID *InheritedObjectTypeGuid,
1191 _In_ PSID pSid
1192);
1193
1196NTAPI
1198 _Inout_ PACL Acl,
1203);
1204
1207NTAPI
1209 _Inout_ PACL Acl,
1212 _In_ PSID Sid,
1214 _In_ BOOLEAN Failure
1215);
1216
1219NTAPI
1222 _In_ ULONG NumPriv,
1224 _Out_ PVOID *ReturnedState
1225);
1226
1229NTAPI
1231 _Inout_ PACL Acl,
1235 _In_ PSID Sid,
1237 _In_ BOOLEAN Failure
1238);
1239
1242NTAPI
1244 _Inout_ PACL Acl,
1248 _In_opt_ GUID *ObjectTypeGuid,
1249 _In_opt_ GUID *InheritedObjectTypeGuid,
1250 _In_ PSID Sid,
1252 _In_ BOOLEAN Failure
1253);
1254
1257NTAPI
1259 _Inout_ PACL Acl,
1262 _In_ ULONG MandatoryFlags,
1264 _In_ PSID LabelSid);
1265
1268NTAPI
1271 _In_ BOOLEAN NewValue,
1272 _In_ BOOLEAN ForThread,
1273 _Out_ PBOOLEAN OldValue
1274);
1275
1279NTAPI
1283 _In_ ULONG SubAuthority0,
1284 _In_ ULONG SubAuthority1,
1285 _In_ ULONG SubAuthority2,
1286 _In_ ULONG SubAuthority3,
1287 _In_ ULONG SubAuthority4,
1288 _In_ ULONG SubAuthority5,
1289 _In_ ULONG SubAuthority6,
1290 _In_ ULONG SubAuthority7,
1292);
1293
1295BOOLEAN
1296NTAPI
1300);
1301
1303BOOLEAN
1304NTAPI
1308);
1309
1312VOID
1313NTAPI
1315 _Out_ PLUID DestinationLuid,
1317 );
1318
1320VOID
1321NTAPI
1323 ULONG Count,
1326);
1327
1330NTAPI
1334 _In_ ULONG SidAreaSize,
1336 _In_ PSID SidArea,
1337 _Out_ PSID* RemainingSidArea,
1338 _Out_ PULONG RemainingSidAreaSize
1339);
1340
1344NTAPI
1347 _In_ PSID Sid,
1349);
1350
1354NTAPI
1356 _In_ ULONG DestinationSidLength,
1357 _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid,
1359);
1360
1363NTAPI
1365 PACL Acl,
1366 ULONG AclSize,
1368);
1369
1372NTAPI
1376);
1377
1380NTAPI
1384);
1385
1388NTAPI
1390 _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
1391 _Out_ PSECURITY_DESCRIPTOR *pDestinationSecurityDescriptor
1392);
1393
1396NTAPI
1398 PACL Acl,
1400);
1401
1403BOOLEAN
1404NTAPI
1406 PSID Sid1,
1407 PSID Sid2
1408);
1409
1411BOOLEAN
1412NTAPI
1414 _In_ PSID Sid1,
1415 _In_ PSID Sid2
1416);
1417
1419BOOLEAN
1420NTAPI
1422 PACL Acl,
1423 PACE* Ace
1424);
1425
1427PVOID
1428NTAPI
1431);
1432
1435NTAPI
1437 PACL Acl,
1439 PVOID *Ace
1440);
1441
1444NTAPI
1449);
1450
1453NTAPI
1457 _Out_ PACL *Dacl,
1459);
1460
1463NTAPI
1467 _Out_ PACL* Sacl,
1469);
1470
1473NTAPI
1476 _Out_ PSID *Group,
1478);
1479
1482NTAPI
1485 _Out_ PSID *Owner,
1487);
1488
1490BOOLEAN
1491NTAPI
1494 _Out_ PUCHAR RMControl
1495);
1496
1499NTAPI
1501
1504NTAPI
1506
1510NTAPI
1512 _Out_ PSID Sid,
1515);
1516
1518ULONG
1519NTAPI
1521
1524ULONG
1525NTAPI
1528
1530ULONG
1531NTAPI
1533
1536NTAPI
1538 _In_ PSECURITY_DESCRIPTOR AbsoluteSD,
1539 _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1541
1543VOID
1544NTAPI
1548);
1549
1550#ifdef NTOS_MODE_USER
1551
1554NTAPI
1556 PACL Acl,
1558 ULONG InformationLength,
1560);
1561
1562#endif
1563
1565VOID
1566NTAPI
1568 _In_ PVOID ReturnedState
1569);
1570
1571#if (NTDDI_VERSION >= NTDDI_VISTA)
1572
1575NTAPI
1578 _In_reads_opt_(PrivilegeCount) _When_(PrivilegeCount != 0, _Notnull_)
1579 PULONG PrivilegesToKeep,
1580 _In_ ULONG PrivilegeCount
1581);
1582
1583#endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1584
1588NTAPI
1601);
1602
1605NTAPI
1607 _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1609);
1610
1613NTAPI
1618);
1619
1622NTAPI
1625 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
1626 _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1627);
1628
1632NTAPI
1638);
1639
1643NTAPI
1648);
1649
1650#ifdef NTOS_MODE_USER
1651
1654NTAPI
1656 PACL Acl,
1658 ULONG InformationLength,
1660);
1661
1662#endif
1663
1667NTAPI
1672);
1673
1676NTAPI
1680 _In_ PACL Sacl,
1682);
1683
1685VOID
1686NTAPI
1689 _In_ PUCHAR RMControl
1690);
1691
1693PUCHAR
1694NTAPI
1696 _In_ PSID Sid
1697);
1698
1700PULONG
1701NTAPI
1703 _In_ PSID Sid,
1704 _In_ ULONG SubAuthority
1705);
1706
1710BOOLEAN
1711NTAPI
1716);
1717
1719BOOLEAN
1720NTAPI
1722
1724BOOLEAN
1725NTAPI
1727
1729BOOLEAN
1730NTAPI
1732
1735NTAPI
1737 _In_ PSECURITY_DESCRIPTOR *ObjectDescriptor
1738);
1739
1742NTAPI
1744 _In_ PSECURITY_DESCRIPTOR ParentDescriptor,
1745 _In_ PSECURITY_DESCRIPTOR CreatorDescriptor,
1750);
1751
1754NTAPI
1756 _In_ PSECURITY_DESCRIPTOR ObjectDescriptor,
1758 _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor,
1759 _In_ ULONG DescriptorLength,
1761);
1762
1765NTAPI
1768 _In_ PSECURITY_DESCRIPTOR ModificationDescriptor,
1769 _Out_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
1772);
1773
1774//
1775// Single-Character Functions
1776//
1779NTAPI
1782 _In_ ULONG Base,
1785);
1786
1788CHAR
1789NTAPI
1791
1793WCHAR
1794NTAPI
1796
1798WCHAR
1799NTAPI
1801
1804NTAPI
1807 _In_ ULONG Base,
1810);
1811
1814NTAPI
1820);
1821
1823_At_(String->MaximumLength, _Const_)
1826NTAPI
1831);
1832
1835NTAPI
1837 PCSZ String,
1838 ULONG Base,
1840);
1841
1842//
1843// Byte Swap Functions
1844//
1845#ifdef NTOS_MODE_USER
1846
1847unsigned short __cdecl _byteswap_ushort(unsigned short);
1848unsigned long __cdecl _byteswap_ulong (unsigned long);
1849unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1850#ifdef _MSC_VER
1851#pragma intrinsic(_byteswap_ushort)
1852#pragma intrinsic(_byteswap_ulong)
1853#pragma intrinsic(_byteswap_uint64)
1854#endif // _MSC_VER
1855#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1856#define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1857#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1858
1859#endif // NTOS_MODE_USER
1860
1861//
1862// Unicode->Ansi String Functions
1863//
1865ULONG
1866NTAPI
1868
1869#ifdef NTOS_MODE_USER
1870
1871#define RtlUnicodeStringToAnsiSize(STRING) ( \
1872 NLS_MB_CODE_PAGE_TAG ? \
1873 RtlxUnicodeStringToAnsiSize(STRING) : \
1874 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1875)
1876
1877#endif
1878
1881NTAPI
1886);
1887
1888//
1889// Unicode->OEM String Functions
1890//
1893NTAPI
1898);
1899
1902//_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1905NTAPI
1912);
1913
1916NTAPI
1921);
1922
1927NTAPI
1928RtlUnicodeStringToCountedOemString(
1934);
1935
1938NTAPI
1941 ULONG OemSize,
1942 PULONG ResultSize,
1944 ULONG UnicodeSize
1945);
1946
1948ULONG
1949NTAPI
1951
1952#ifdef NTOS_MODE_USER
1953
1954#define RtlUnicodeStringToOemSize(STRING) ( \
1955 NLS_MB_OEM_CODE_PAGE_TAG ? \
1956 RtlxUnicodeStringToOemSize(STRING) : \
1957 ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1958)
1959
1960#define RtlUnicodeStringToCountedOemSize(STRING) ( \
1961 (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
1962)
1963
1964#endif
1965
1968NTAPI
1971 ULONG OemSize,
1972 PULONG ResultSize,
1974 ULONG UnicodeSize
1975);
1976
1977//
1978// Unicode->MultiByte String Functions
1979//
1982NTAPI
1984 PCHAR MbString,
1985 ULONG MbSize,
1986 PULONG ResultSize,
1988 ULONG UnicodeSize
1989);
1990
1993NTAPI
1995 PCHAR MbString,
1996 ULONG MbSize,
1997 PULONG ResultSize,
1999 ULONG UnicodeSize
2000);
2001
2004NTAPI
2006 PULONG MbSize,
2008 ULONG UnicodeSize
2009);
2010
2012ULONG
2013NTAPI
2015
2016//
2017// OEM to Unicode Functions
2018//
2021NTAPI
2026);
2027
2031NTAPI
2038);
2039
2040#ifdef NTOS_MODE_USER
2041
2042#define RtlOemStringToUnicodeSize(STRING) ( \
2043 NLS_MB_OEM_CODE_PAGE_TAG ? \
2044 RtlxOemStringToUnicodeSize(STRING) : \
2045 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2046)
2047
2048#define RtlOemStringToCountedUnicodeSize(STRING) ( \
2049 (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
2050)
2051
2052#endif
2053
2054//
2055// Ansi->Unicode String Functions
2056//
2059WCHAR
2060NTAPI
2062 _Inout_ PUCHAR *SourceCharacter);
2063
2066NTAPI
2071);
2072
2074ULONG
2075NTAPI
2078);
2079
2080#ifdef NTOS_MODE_USER
2081
2082#define RtlAnsiStringToUnicodeSize(STRING) ( \
2083 NLS_MB_CODE_PAGE_TAG ? \
2084 RtlxAnsiStringToUnicodeSize(STRING) : \
2085 ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
2086)
2087
2088#endif
2089
2091BOOLEAN
2092NTAPI
2096);
2097
2098//
2099// Unicode String Functions
2100//
2103NTAPI
2107);
2108
2111NTAPI
2115);
2116
2118LONG
2119NTAPI
2121 PCUNICODE_STRING String1,
2124);
2125
2128LONG
2129NTAPI
2136);
2137
2139VOID
2140NTAPI
2144);
2145
2147BOOLEAN
2148NTAPI
2152);
2153
2154#ifdef NTOS_MODE_USER
2155
2158NTAPI
2160 _Inout_ PUNICODE_STRING UniDest,
2161 _In_ PCUNICODE_STRING UniSource,
2163);
2164
2167NTAPI
2172);
2173
2176NTAPI
2179 _In_ PCUNICODE_STRING SearchString,
2182);
2183
2184//
2185// Memory Functions
2186//
2187#if defined(_M_AMD64)
2188
2190VOID
2194 _In_ ULONG Pattern)
2195{
2197 if ((Length /= 4) != 0) {
2198 if (((ULONG64)Address & 4) != 0) {
2199 *Address = Pattern;
2200 if ((Length -= 1) == 0) {
2201 return;
2202 }
2203 Address += 1;
2204 }
2205 __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2);
2206 if ((Length & 1) != 0) Address[Length - 1] = Pattern;
2207 }
2208 return;
2209}
2210
2211#define RtlFillMemoryUlonglong(Destination, Length, Pattern) \
2212 __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2213
2214#else
2215
2217VOID
2218NTAPI
2222 _In_ ULONG Pattern
2223);
2224
2226VOID
2227NTAPI
2231 _In_ ULONGLONG Pattern
2232);
2233
2234#endif
2235
2238NTAPI
2243);
2244
2246SIZE_T
2247NTAPI
2251 _In_ ULONG Pattern
2252);
2253
2254#ifndef RtlEqualMemory
2255#define RtlEqualMemory(Destination, Source, Length) \
2256 (!memcmp(Destination, Source, Length))
2257#endif
2258
2259#define RtlCopyBytes RtlCopyMemory
2260#define RtlFillBytes RtlFillMemory
2261#define RtlZeroBytes RtlZeroMemory
2262
2263#endif
2264
2266BOOLEAN
2267NTAPI
2269 PCUNICODE_STRING String1,
2272);
2273
2276VOID
2277NTAPI
2281);
2282
2284VOID
2285NTAPI
2288);
2289
2292NTAPI
2298);
2299
2309VOID
2310NTAPI
2314);
2315
2325VOID
2326NTAPI
2330);
2331
2335NTAPI
2339);
2340
2342BOOLEAN
2343NTAPI
2346 _In_ INT Size,
2348);
2349
2353BOOLEAN
2354NTAPI
2356 _In_ const STRING *String1,
2359);
2360
2364BOOLEAN
2365NTAPI
2367 _In_ PCUNICODE_STRING String1,
2370);
2371
2374VOID
2375NTAPI
2379);
2380
2384LONG
2385NTAPI
2387 _In_ const STRING *String1,
2390);
2391
2393VOID
2394NTAPI
2398);
2399
2403BOOLEAN
2404NTAPI
2406 _In_ const STRING *String1,
2409);
2410
2414NTAPI
2418);
2419
2424NTAPI
2431);
2432
2436NTAPI
2441);
2442
2445NTAPI
2449);
2450
2451#define RTL_SKIP_BUFFER_COPY 0x00000001
2452
2455NTAPI
2460);
2461
2462#ifdef NTOS_MODE_USER
2463
2465VOID
2466RtlInitBuffer(
2470)
2471{
2472 Buffer->Buffer = Buffer->StaticBuffer = Data;
2473 Buffer->Size = Buffer->StaticSize = DataSize;
2474 Buffer->ReservedForAllocatedSize = 0;
2475 Buffer->ReservedForIMalloc = NULL;
2476}
2477
2480RtlEnsureBufferSize(
2484)
2485{
2486 if (Buffer && RequiredSize <= Buffer->Size)
2487 return STATUS_SUCCESS;
2489}
2490
2492VOID
2493RtlFreeBuffer(
2495)
2496{
2497 if (Buffer->Buffer != Buffer->StaticBuffer && Buffer->Buffer)
2498 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer->Buffer);
2499 Buffer->Buffer = Buffer->StaticBuffer;
2500 Buffer->Size = Buffer->StaticSize;
2501}
2502
2504VOID
2505NTAPI
2509);
2510
2512VOID
2513NTAPI
2515 _In_ UCHAR Hash,
2517);
2518
2519#endif /* NTOS_MODE_USER */
2520
2521//
2522// Ansi String Functions
2523//
2526VOID
2527NTAPI
2529 _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2531);
2532
2535VOID
2536NTAPI
2540);
2541
2545NTAPI
2549);
2550
2551//
2552// OEM String Functions
2553//
2556VOID
2557NTAPI
2559 _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2561);
2562
2563//
2564// MultiByte->Unicode String Functions
2565//
2569NTAPI
2576);
2577
2581NTAPI
2586);
2587
2588//
2589// Atom Functions
2590//
2593NTAPI
2595 _In_ PRTL_ATOM_TABLE AtomTable,
2596 _In_ PWSTR AtomName,
2598);
2599
2602NTAPI
2605 _Inout_ PRTL_ATOM_TABLE *AtomTable
2606);
2607
2610NTAPI
2612 _In_ PRTL_ATOM_TABLE AtomTable,
2614);
2615
2618NTAPI
2620
2623NTAPI
2625 _In_ PRTL_ATOM_TABLE AtomTable,
2627 _Out_opt_ PULONG RefCount,
2629 _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2630 _Inout_opt_ PULONG NameLength
2631);
2632
2635NTAPI
2637 _In_ PRTL_ATOM_TABLE AtomTable,
2639);
2640
2643NTAPI
2645 _In_ PRTL_ATOM_TABLE AtomTable,
2646 _In_ PWSTR AtomName,
2648);
2649
2650//
2651// Process Management Functions
2652//
2654PPEB
2655NTAPI
2657 VOID
2658);
2659
2661VOID
2662NTAPI
2664
2667NTAPI
2669 _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2670 _In_ PUNICODE_STRING ImagePathName,
2673 _In_opt_ PUNICODE_STRING CommandLine,
2675 _In_opt_ PUNICODE_STRING WindowTitle,
2676 _In_opt_ PUNICODE_STRING DesktopInfo,
2677 _In_opt_ PUNICODE_STRING ShellInfo,
2678 _In_opt_ PUNICODE_STRING RuntimeInfo
2679);
2680
2683NTAPI
2685 _In_ PUNICODE_STRING ImageFileName,
2687 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2688 _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2689 _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2690 _In_opt_ HANDLE ParentProcess,
2692 _In_opt_ HANDLE DebugPort,
2693 _In_opt_ HANDLE ExceptionPort,
2695);
2696
2697#if (NTDDI_VERSION >= NTDDI_WIN7)
2700NTAPI
2702 _In_ PVOID ThreadContext,
2703 _Out_ HANDLE *OutThreadHandle,
2709 _Reserved_ PVOID Reserved6,
2711 _Reserved_ PVOID Reserved8
2712);
2713#else
2716NTAPI
2720 _In_ BOOLEAN CreateSuspended,
2721 _In_ ULONG StackZeroBits,
2722 _In_ SIZE_T StackReserve,
2723 _In_ SIZE_T StackCommit,
2724 _In_ PTHREAD_START_ROUTINE StartAddress,
2726 _Out_opt_ PHANDLE ThreadHandle,
2728);
2729#endif
2730
2733NTAPI
2735 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2736
2739NTAPI
2741 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2742
2744VOID
2745NTAPI
2748
2750VOID
2751NTAPI
2754 _Out_ PCONTEXT ThreadContext,
2755 _In_opt_ PVOID ThreadStartParam,
2756 _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2757 _In_ PINITIAL_TEB InitialTeb
2758);
2759
2760#ifdef _M_AMD64
2761typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2762
2765NTAPI
2766RtlWow64GetThreadContext(
2767 _In_ HANDLE ThreadHandle,
2768 _Inout_ PWOW64_CONTEXT ThreadContext
2769);
2770
2771
2774NTAPI
2775RtlWow64SetThreadContext(
2776 _In_ HANDLE ThreadHandle,
2777 _In_ PWOW64_CONTEXT ThreadContext
2778);
2779#endif
2780
2782BOOLEAN
2783NTAPI
2785
2788NTAPI
2790 _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2791
2793VOID
2794NTAPI
2796
2799NTAPI
2803 _In_ PVOID CallSite,
2804 _In_ ULONG ArgumentCount,
2805 _In_ PULONG Arguments,
2806 _In_ BOOLEAN PassContext,
2807 _In_ BOOLEAN AlreadySuspended
2808);
2809
2812__cdecl
2814 _In_ BOOLEAN NewValue,
2815 _Out_opt_ PBOOLEAN OldValue,
2816 _In_ BOOLEAN NeedBreaks
2817);
2818
2821__cdecl
2823 _In_ BOOLEAN NewValue,
2824 _Out_opt_ PBOOLEAN OldValue,
2825 _In_ BOOLEAN NeedBreaks
2826);
2827
2829ULONG
2830NTAPI
2832 VOID
2833);
2834
2835
2836//
2837// Thread Pool Functions
2838//
2839//
2841NTAPI
2843 _In_ PRTL_START_POOL_THREAD StartPoolThread,
2844 _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2845);
2846
2849NTAPI
2851 _In_ HANDLE hWaitHandle,
2852 _In_opt_ HANDLE hCompletionEvent
2853);
2854
2857NTAPI
2859 _In_ HANDLE hWaitHandle
2860);
2861
2864NTAPI
2869);
2870
2873NTAPI
2878);
2879
2882NTAPI
2884 _In_ PHANDLE phNewWaitObject,
2885 _In_ HANDLE hObject,
2887 _In_ PVOID pvContext,
2888 _In_ ULONG ulMilliseconds,
2889 _In_ ULONG ulFlags
2890);
2891
2892//
2893// Environment/Path Functions
2894//
2897NTAPI
2899 _In_ BOOLEAN Inherit,
2901);
2902
2905NTAPI
2907 _In_ PUNICODE_STRING DllName,
2908 _Inout_ PUNICODE_STRING RealName,
2909 _Inout_ PUNICODE_STRING LocalName
2910);
2911
2913VOID
2914NTAPI
2917);
2918
2920BOOLEAN
2921NTAPI
2924);
2925
2928NTAPI
2931);
2932
2934ULONG
2935NTAPI
2942 _Out_ PWSTR *PartName
2943);
2944
2947NTAPI
2950 _In_ PUNICODE_STRING PathString,
2951 _In_ PUNICODE_STRING FileNameString,
2952 _In_ PUNICODE_STRING ExtensionString,
2953 _In_ PUNICODE_STRING CallerBuffer,
2955 _Out_opt_ PUNICODE_STRING* FullNameOut,
2956 _Out_opt_ PSIZE_T FilePartSize,
2958);
2959
2961BOOLEAN
2962NTAPI
2964 _In_opt_z_ PCWSTR DosPathName,
2965 _Out_ PUNICODE_STRING NtPathName,
2966 _Out_opt_ PCWSTR *NtFileNamePart,
2967 _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2968);
2969
2970
2971#define RTL_UNCHANGED_UNK_PATH 1
2972#define RTL_CONVERTED_UNC_PATH 2
2973#define RTL_CONVERTED_NT_PATH 3
2974#define RTL_UNCHANGED_DOS_PATH 4
2975
2978NTAPI
2984);
2985
2986
2988BOOLEAN
2989NTAPI
2992 _Out_ PUNICODE_STRING NtName,
2993 _Out_ PCWSTR *PartName,
2994 _Out_ PRTL_RELATIVE_NAME_U RelativeName
2995);
2996
3000NTAPI
3006);
3007
3009ULONG
3010NTAPI
3014);
3015
3017ULONG
3018NTAPI
3021 _In_ ULONG Size,
3024);
3025
3026#if (NTDDI_VERSION >= NTDDI_WIN7)
3029NTAPI
3034 _Out_opt_ PWSTR *FilePart,
3035 _Out_opt_ RTL_PATH_TYPE *InputPathType
3036 );
3037#endif
3038
3040NTAPI
3046 _Out_opt_ PSIZE_T FilePartSize,
3050);
3051
3054NTAPI
3057 _In_ PCUNICODE_STRING PathString,
3059);
3060
3062ULONG
3063NTAPI
3065 VOID
3066);
3067
3069ULONG
3070NTAPI
3073);
3074
3076ULONG
3077NTAPI
3080);
3081
3085BOOLEAN
3086NTAPI
3091);
3092
3095NTAPI
3100);
3101
3102VOID
3103NTAPI
3105 _In_ PRTL_RELATIVE_NAME_U RelativeName
3106);
3107
3110NTAPI
3113);
3114
3117NTAPI
3122);
3123
3124//
3125// Critical Section/Resource Functions
3126//
3129NTAPI
3132);
3133
3136NTAPI
3139);
3140
3143NTAPI
3146);
3147
3150NTAPI
3153 _In_ ULONG SpinCount
3154);
3155
3157ULONG
3158NTAPI
3161);
3162
3164ULONG
3165NTAPI
3168);
3169
3172NTAPI
3175);
3176
3178BOOLEAN
3179NTAPI
3182);
3183
3185VOID
3186NTAPI
3189);
3190
3193NTAPI
3196);
3197
3199BOOLEAN
3200NTAPI
3204);
3205
3207BOOLEAN
3208NTAPI
3212);
3213
3215VOID
3216NTAPI
3219);
3220
3222VOID
3223NTAPI
3226);
3227
3229VOID
3230NTAPI
3233);
3234
3236VOID
3237NTAPI
3240);
3241
3243VOID
3244NTAPI
3247);
3248
3250VOID
3251NTAPI
3254);
3255
3256//
3257// Compression Functions
3258//
3259NTSYSAPI //NT_RTL_COMPRESS_API
3261NTAPI
3263 _In_ USHORT CompressionFormatAndEngine,
3268 _In_ ULONG UncompressedChunkSize,
3269 _Out_ PULONG FinalCompressedSize,
3271);
3272
3274NTSYSAPI //NT_RTL_COMPRESS_API
3276NTAPI
3278 _In_ USHORT CompressionFormat,
3284);
3285
3288NTAPI
3290 _In_ USHORT CompressionFormatAndEngine,
3291 _Out_ PULONG CompressBufferWorkSpaceSize,
3292 _Out_ PULONG CompressFragmentWorkSpaceSize
3293);
3294
3295//
3296// Frame Functions
3297//
3299VOID
3300NTAPI
3303);
3304
3306VOID
3307NTAPI
3310);
3311
3314NTAPI
3316 VOID
3317);
3318
3319//
3320// Debug Info Functions
3321//
3324NTAPI
3326 _In_ ULONG Size,
3327 _In_ BOOLEAN EventPair
3328);
3329
3332NTAPI
3334
3337NTAPI
3340 _In_ ULONG DebugInfoClassMask,
3342);
3343
3344//
3345// Bitmap Functions
3346//
3347#ifdef NTOS_MODE_USER
3348
3350BOOLEAN
3351NTAPI
3353 _In_ PRTL_BITMAP BitMapHeader,
3356);
3357
3359BOOLEAN
3360NTAPI
3362 _In_ PRTL_BITMAP BitMapHeader,
3365);
3366
3368VOID
3369NTAPI
3371 _In_ PRTL_BITMAP BitMapHeader
3372);
3373
3375VOID
3376NTAPI
3378 _In_ PRTL_BITMAP BitMapHeader,
3379 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3380);
3381
3383VOID
3384NTAPI
3386 _In_ PRTL_BITMAP BitMapHeader,
3387 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3388 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3389);
3390
3392ULONG
3393NTAPI
3395 _In_ PRTL_BITMAP BitMapHeader,
3398);
3399
3401ULONG
3402NTAPI
3404 _In_ PRTL_BITMAP BitMapHeader,
3407);
3408
3410ULONG
3411NTAPI
3413 _In_ PRTL_BITMAP BitMapHeader,
3415);
3416
3418ULONG
3419NTAPI
3421 _In_ PRTL_BITMAP BitMapHeader,
3422 _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray,
3423 _In_range_(>, 0) ULONG SizeOfRunArray,
3424 _In_ BOOLEAN LocateLongestRuns
3425);
3426
3428ULONG
3429NTAPI
3431 _In_ PRTL_BITMAP BitMapHeader,
3432 _In_ ULONG FromIndex,
3433 _Out_ PULONG StartingRunIndex
3434);
3435
3437CCHAR
3438NTAPI
3441);
3442
3444ULONG
3445NTAPI
3447 _In_ PRTL_BITMAP BitMapHeader,
3449);
3450
3452CCHAR
3453NTAPI
3456);
3457
3459ULONG
3460NTAPI
3462 _In_ PRTL_BITMAP BitMapHeader,
3463 _In_ ULONG FromIndex,
3464 _Out_ PULONG StartingRunIndex
3465);
3466
3468ULONG
3469NTAPI
3471 _In_ PRTL_BITMAP BitMapHeader,
3472 _In_ ULONG FromIndex,
3473 _Out_ PULONG StartingRunIndex
3474);
3475
3477ULONG
3478NTAPI
3480 _In_ PRTL_BITMAP BitMapHeader,
3483);
3484
3486ULONG
3487NTAPI
3489 _In_ PRTL_BITMAP BitMapHeader,
3492);
3493
3494#ifdef __REACTOS__ // ReactOS improvement
3495_At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3496_At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3497#endif
3499VOID
3500NTAPI
3502 _Out_ PRTL_BITMAP BitMapHeader,
3503 _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3504 _In_opt_ ULONG SizeOfBitMap
3505);
3506
3508ULONG
3509NTAPI
3511 _In_ PRTL_BITMAP BitMapHeader
3512);
3513
3515ULONG
3516NTAPI
3518 _In_ PRTL_BITMAP BitMapHeader
3519);
3520
3522VOID
3523NTAPI
3524RtlSetBit(
3525 _In_ PRTL_BITMAP BitMapHeader,
3526 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3527);
3528
3530VOID
3531NTAPI
3533 _In_ PRTL_BITMAP BitMapHeader,
3534 _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3535 _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3536);
3537
3539VOID
3540NTAPI
3542 _In_ PRTL_BITMAP BitMapHeader
3543);
3544
3547BOOLEAN
3548NTAPI
3550 _In_ PRTL_BITMAP BitMapHeader,
3551 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3552);
3553
3554#if defined(_M_AMD64)
3557BOOLEAN
3559 _In_ PRTL_BITMAP BitMapHeader,
3560 _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition)
3561{
3562 return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
3563}
3564#else
3565#define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3566#endif /* defined(_M_AMD64) */
3567
3568#endif // NTOS_MODE_USER
3569
3570
3571//
3572// Timer Functions
3573//
3576NTAPI
3578 _In_ HANDLE TimerQueue,
3579 _In_ PHANDLE phNewTimer,
3585);
3586
3589NTAPI
3590RtlCreateTimerQueue(PHANDLE TimerQueue);
3591
3594NTAPI
3596 _In_ HANDLE TimerQueue,
3598 _In_ HANDLE CompletionEvent
3599);
3600
3603NTAPI
3605 _In_ HANDLE TimerQueue,
3609);
3610
3613NTAPI
3615 _In_ HANDLE TimerQueue,
3616 _In_opt_ HANDLE CompletionEvent
3617);
3618
3621NTAPI
3622RtlDeleteTimerQueue(HANDLE TimerQueue);
3623
3624//
3625// SList functions
3626//
3630 _Inout_ PSLIST_HEADER ListHead,
3634);
3635
3636//
3637// Range List functions
3638//
3640VOID
3641NTAPI
3643 _Out_ PRTL_RANGE_LIST RangeList
3644);
3645
3647VOID
3648NTAPI
3650 _In_ PRTL_RANGE_LIST RangeList
3651);
3652
3655NTAPI
3657 _Out_ PRTL_RANGE_LIST CopyRangeList,
3658 _In_ PRTL_RANGE_LIST RangeList
3659);
3660
3663NTAPI
3665 _Out_ PRTL_RANGE_LIST MergedRangeList,
3666 _In_ PRTL_RANGE_LIST RangeList1,
3667 _In_ PRTL_RANGE_LIST RangeList2,
3669);
3670
3673NTAPI
3675 _Out_ PRTL_RANGE_LIST InvertedRangeList,
3676 _In_ PRTL_RANGE_LIST RangeList
3677);
3678
3681NTAPI
3683 _Inout_ PRTL_RANGE_LIST RangeList,
3685 _In_ ULONGLONG End,
3690);
3691
3694NTAPI
3696 _Inout_ PRTL_RANGE_LIST RangeList,
3698 _In_ ULONGLONG End,
3700);
3701
3704NTAPI
3706 _Inout_ PRTL_RANGE_LIST RangeList,
3708);
3709
3712NTAPI
3714 _In_ PRTL_RANGE_LIST RangeList,
3715 _In_ ULONGLONG Minimum,
3716 _In_ ULONGLONG Maximum,
3720 _In_ UCHAR AttributeAvailableMask,
3724);
3725
3728NTAPI
3730 _In_ PRTL_RANGE_LIST RangeList,
3732 _In_ ULONGLONG End,
3734 _In_ UCHAR AttributeAvailableMask,
3737 _Out_ PBOOLEAN Available
3738);
3739
3742NTAPI
3744 _In_ PRTL_RANGE_LIST RangeList,
3747);
3748
3751NTAPI
3755 _In_ BOOLEAN MoveForwards
3756);
3757
3758//
3759// Debug Functions
3760//
3761ULONG
3762__cdecl
3765 ...
3766);
3767
3769ULONG
3770__cdecl
3775 ...
3776);
3777
3779ULONG
3780NTAPI
3782 _In_z_ PCCH Prompt,
3785);
3786
3787#undef DbgBreakPoint
3788VOID
3789NTAPI
3791 VOID
3792);
3793
3794VOID
3795NTAPI
3798 _In_ PVOID Base,
3800);
3801
3802VOID
3803NTAPI
3806 _In_ PVOID Base,
3808);
3809
3810VOID
3811NTAPI
3813 _In_ PCCH Name,
3815);
3816
3817//
3818// Generic Table Functions
3819//
3820#if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3822PVOID
3823NTAPI
3828 _Out_opt_ PBOOLEAN NewElement
3829);
3830
3832PVOID
3833NTAPI
3838 _Out_opt_ PBOOLEAN NewElement,
3839 _In_ PVOID NodeOrParent,
3840 _In_ TABLE_SEARCH_RESULT SearchResult
3841);
3842
3844BOOLEAN
3845NTAPI
3848);
3849
3851PVOID
3852NTAPI
3856 _Out_ PVOID *NodeOrParent,
3857 _Out_ TABLE_SEARCH_RESULT *SearchResult
3858);
3859#endif
3860
3861//
3862// Handle Table Functions
3863//
3866NTAPI
3870);
3871
3873VOID
3874NTAPI
3877
3879BOOLEAN
3880NTAPI
3884);
3885
3887VOID
3888NTAPI
3891 _In_ ULONG HandleSize,
3893);
3894
3896BOOLEAN
3897NTAPI
3901);
3902
3903_Success_(return!=FALSE)
3905BOOLEAN
3906NTAPI
3911);
3912
3913//
3914// PE Functions
3915//
3918NTAPI
3921 _In_ ULONG Type,
3922 _In_ ULONG Language,
3923 _In_ ULONG MessageId,
3924 _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3925);
3926
3928ULONG
3929NTAPI
3931
3932_Success_(return!=NULL)
3934PVOID
3935NTAPI
3941);
3942
3944PVOID
3945NTAPI
3947 _In_ PIMAGE_NT_HEADERS NtHeader,
3949 _In_ ULONG Rva,
3950 _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3951);
3952
3955NTAPI
3958
3961NTAPI
3966 _Out_ PIMAGE_NT_HEADERS *NtHeader
3967);
3968
3971NTAPI
3973 _In_ PIMAGE_NT_HEADERS NtHeader,
3975 _In_ ULONG Rva
3976);
3977
3978ULONG
3979NTAPI
3982 _In_ LONGLONG AdditionalBias,
3983 _In_opt_ PCSTR LoaderName,
3985 _In_ ULONG Conflict,
3987);
3988
3989//
3990// Activation Context Functions
3991//
3992#ifdef NTOS_MODE_USER
3995NTAPI
3998 _In_ PTEB Teb,
4001);
4002
4005NTAPI
4010);
4011
4013VOID
4014NTAPI
4017);
4018
4023 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
4025);
4026
4029NTAPI
4032);
4033
4036NTAPI
4039 _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
4040 _In_ ULONG ExtraBytes,
4041 _In_ PVOID NotificationRoutine,
4044);
4045
4048NTAPI
4051);
4052
4054VOID
4055NTAPI
4058);
4059
4062NTAPI
4065 _In_ ULONG_PTR ulCookie
4066);
4067
4069VOID
4070NTAPI
4073);
4074
4076VOID
4077NTAPI
4079
4084 _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
4085);
4086
4089NTAPI
4092 _In_ PUNICODE_STRING OriginalName,
4097 _In_ PULONG NewFlags,
4098 _In_ PSIZE_T FileNameSize,
4100);
4101
4104NTAPI
4107 _In_ const GUID *ExtensionGuid,
4108 _In_ ULONG SectionType,
4109 _In_ const UNICODE_STRING *SectionName,
4110 _Inout_ PVOID ReturnedData
4111);
4112
4115NTAPI
4119 _In_opt_ PVOID pvSubInstance,
4120 _In_ ULONG ulInfoClass,
4121 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
4122 _In_opt_ SIZE_T cbBuffer,
4123 _Out_opt_ SIZE_T *pcbWrittenOrRequired
4124);
4125
4128NTAPI
4130 _In_ ULONG ulInfoClass,
4131 _Out_bytecap_(cbBuffer) PVOID pvBuffer,
4132 _In_opt_ SIZE_T cbBuffer,
4133 _Out_opt_ SIZE_T *pcbWrittenOrRequired
4134);
4135
4138NTAPI
4141);
4142
4143//
4144// WOW64 Functions
4145//
4148NTAPI
4150 _In_ BOOLEAN Wow64FsEnableRedirection
4151);
4152
4155NTAPI
4157 _In_ PVOID Wow64FsEnableRedirection,
4158 _Out_ PVOID *OldFsRedirectionLevel
4159);
4160
4161#endif
4162
4163//
4164// Registry Functions
4165//
4170NTAPI
4172 _In_ ULONG RelativeTo,
4174);
4175
4178NTAPI
4180 _In_ ULONG RelativeTo,
4182);
4183
4186NTAPI
4188 _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
4189 PUNICODE_STRING KeyPath
4190);
4191
4194NTAPI
4198);
4199
4203NTAPI
4205 _In_ ULONG RelativeTo,
4207 _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
4211);
4212
4216NTAPI
4218 _In_ ULONG RelativeTo,
4224);
4225
4226#ifdef NTOS_MODE_USER
4229NTAPI
4237);
4238
4241NTAPI
4247);
4248
4251NTAPI
4254);
4255
4258NTAPI
4264);
4265
4268NTAPI
4275);
4276
4279NTAPI
4282 _In_ ULONG Type,
4283 _In_ PVOID Data,
4285);
4286#endif
4287
4288//
4289// NLS Functions
4290//
4292VOID
4293NTAPI
4297);
4298
4300VOID
4301NTAPI
4303 _In_ PUSHORT AnsiTableBase,
4304 _In_ PUSHORT OemTableBase,
4305 _In_ PUSHORT CaseTableBase,
4306 _Out_ PNLSTABLEINFO NlsTable
4307);
4308
4311VOID
4312NTAPI
4314 _In_ PUSHORT TableBase,
4316);
4317
4319VOID
4320NTAPI
4322 _In_ PNLSTABLEINFO NlsTable);
4323
4324#if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
4325
4326//
4327// Misc conversion functions
4328//
4329static __inline
4333 _In_ LONG SignedInteger
4334)
4335{
4337
4338 Result.QuadPart = SignedInteger;
4339 return Result;
4340}
4341
4342static __inline
4346 _In_ LONG Multiplicand,
4347 _In_ LONG Multiplier
4348)
4349{
4350 LARGE_INTEGER Product;
4351
4352 Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
4353 return Product;
4354}
4355
4356static __inline
4357ULONG
4360 _In_ ULARGE_INTEGER Dividend,
4363)
4364{
4365 ULONG Quotient;
4366
4367 Quotient = (ULONG)(Dividend.QuadPart / Divisor);
4368 if (Remainder) {
4369 *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
4370 }
4371
4372 return Quotient;
4373}
4374
4375static __inline
4379 _In_ ULONG Multiplicand,
4380 _In_ ULONG Multiplier
4381)