xref: /reactos/sdk/include/ndk/rtlfuncs.h (revision 43dad82f)
1c2c66affSColin Finck /*++ NDK Version: 0098
2c2c66affSColin Finck 
3c2c66affSColin Finck Copyright (c) Alex Ionescu.  All rights reserved.
4c2c66affSColin Finck 
5c2c66affSColin Finck Header Name:
6c2c66affSColin Finck 
7c2c66affSColin Finck     rtlfuncs.h
8c2c66affSColin Finck 
9c2c66affSColin Finck Abstract:
10c2c66affSColin Finck 
11c2c66affSColin Finck     Function definitions for the Run-Time Library
12c2c66affSColin Finck 
13c2c66affSColin Finck Author:
14c2c66affSColin Finck 
15c2c66affSColin Finck     Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16c2c66affSColin Finck 
17c2c66affSColin Finck --*/
18c2c66affSColin Finck 
19c2c66affSColin Finck #ifndef _RTLFUNCS_H
20c2c66affSColin Finck #define _RTLFUNCS_H
21c2c66affSColin Finck 
22c2c66affSColin Finck //
23c2c66affSColin Finck // Dependencies
24c2c66affSColin Finck //
25c2c66affSColin Finck #include <umtypes.h>
26c2c66affSColin Finck #include <ntnls.h>
27c2c66affSColin Finck #include <rtltypes.h>
28c2c66affSColin Finck #include <pstypes.h>
29c2c66affSColin Finck #include <extypes.h>
30c2c66affSColin Finck #include "in6addr.h"
31c2c66affSColin Finck #include "inaddr.h"
32c2c66affSColin Finck 
33c2c66affSColin Finck #ifdef __cplusplus
34c2c66affSColin Finck extern "C" {
35c2c66affSColin Finck #endif
36c2c66affSColin Finck 
37c2c66affSColin Finck #ifdef NTOS_MODE_USER
38c2c66affSColin Finck 
39c2c66affSColin Finck //
40c2c66affSColin Finck // List Functions
41c2c66affSColin Finck //
42c2c66affSColin Finck FORCEINLINE
43c2c66affSColin Finck VOID
InitializeListHead(_Out_ PLIST_ENTRY ListHead)44c2c66affSColin Finck InitializeListHead(
45c2c66affSColin Finck     _Out_ PLIST_ENTRY ListHead
46c2c66affSColin Finck )
47c2c66affSColin Finck {
48c2c66affSColin Finck     ListHead->Flink = ListHead->Blink = ListHead;
49c2c66affSColin Finck }
50c2c66affSColin Finck 
51c2c66affSColin Finck FORCEINLINE
52c2c66affSColin Finck VOID
InsertHeadList(_Inout_ PLIST_ENTRY ListHead,_Inout_ PLIST_ENTRY Entry)53c2c66affSColin Finck InsertHeadList(
54c2c66affSColin Finck     _Inout_ PLIST_ENTRY ListHead,
55c2c66affSColin Finck     _Inout_ PLIST_ENTRY Entry
56c2c66affSColin Finck )
57c2c66affSColin Finck {
58c2c66affSColin Finck     PLIST_ENTRY OldFlink;
59c2c66affSColin Finck     OldFlink = ListHead->Flink;
60c2c66affSColin Finck     Entry->Flink = OldFlink;
61c2c66affSColin Finck     Entry->Blink = ListHead;
62c2c66affSColin Finck     OldFlink->Blink = Entry;
63c2c66affSColin Finck     ListHead->Flink = Entry;
64c2c66affSColin Finck }
65c2c66affSColin Finck 
66c2c66affSColin Finck FORCEINLINE
67c2c66affSColin Finck VOID
InsertTailList(_Inout_ PLIST_ENTRY ListHead,_Inout_ PLIST_ENTRY Entry)68c2c66affSColin Finck InsertTailList(
69c2c66affSColin Finck     _Inout_ PLIST_ENTRY ListHead,
70c2c66affSColin Finck     _Inout_ PLIST_ENTRY Entry
71c2c66affSColin Finck )
72c2c66affSColin Finck {
73c2c66affSColin Finck     PLIST_ENTRY OldBlink;
74c2c66affSColin Finck     OldBlink = ListHead->Blink;
75c2c66affSColin Finck     Entry->Flink = ListHead;
76c2c66affSColin Finck     Entry->Blink = OldBlink;
77c2c66affSColin Finck     OldBlink->Flink = Entry;
78c2c66affSColin Finck     ListHead->Blink = Entry;
79c2c66affSColin Finck }
80c2c66affSColin Finck 
81c2c66affSColin Finck _Must_inspect_result_
82c2c66affSColin Finck FORCEINLINE
83c2c66affSColin Finck BOOLEAN
IsListEmpty(_In_ const LIST_ENTRY * ListHead)84c2c66affSColin Finck IsListEmpty(
85c2c66affSColin Finck     _In_ const LIST_ENTRY * ListHead
86c2c66affSColin Finck )
87c2c66affSColin Finck {
88c2c66affSColin Finck     return (BOOLEAN)(ListHead->Flink == ListHead);
89c2c66affSColin Finck }
90c2c66affSColin Finck 
91c2c66affSColin Finck FORCEINLINE
92c2c66affSColin Finck PSINGLE_LIST_ENTRY
PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)93c2c66affSColin Finck PopEntryList(
94c2c66affSColin Finck     _Inout_ PSINGLE_LIST_ENTRY ListHead
95c2c66affSColin Finck )
96c2c66affSColin Finck {
97c2c66affSColin Finck     PSINGLE_LIST_ENTRY FirstEntry;
98c2c66affSColin Finck     FirstEntry = ListHead->Next;
99c2c66affSColin Finck     if (FirstEntry != NULL) {
100c2c66affSColin Finck         ListHead->Next = FirstEntry->Next;
101c2c66affSColin Finck     }
102c2c66affSColin Finck 
103c2c66affSColin Finck     return FirstEntry;
104c2c66affSColin Finck }
105c2c66affSColin Finck 
106c2c66affSColin Finck FORCEINLINE
107c2c66affSColin Finck VOID
PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead,_Inout_ PSINGLE_LIST_ENTRY Entry)108c2c66affSColin Finck PushEntryList(
109c2c66affSColin Finck     _Inout_ PSINGLE_LIST_ENTRY ListHead,
110c2c66affSColin Finck     _Inout_ PSINGLE_LIST_ENTRY Entry
111c2c66affSColin Finck )
112c2c66affSColin Finck {
113c2c66affSColin Finck     Entry->Next = ListHead->Next;
114c2c66affSColin Finck     ListHead->Next = Entry;
115c2c66affSColin Finck }
116c2c66affSColin Finck 
117c2c66affSColin Finck FORCEINLINE
118c2c66affSColin Finck BOOLEAN
RemoveEntryList(_In_ PLIST_ENTRY Entry)119c2c66affSColin Finck RemoveEntryList(
120c2c66affSColin Finck     _In_ PLIST_ENTRY Entry)
121c2c66affSColin Finck {
122c2c66affSColin Finck     PLIST_ENTRY OldFlink;
123c2c66affSColin Finck     PLIST_ENTRY OldBlink;
124c2c66affSColin Finck 
125c2c66affSColin Finck     OldFlink = Entry->Flink;
126c2c66affSColin Finck     OldBlink = Entry->Blink;
127c2c66affSColin Finck     OldFlink->Blink = OldBlink;
128c2c66affSColin Finck     OldBlink->Flink = OldFlink;
129c2c66affSColin Finck     return (BOOLEAN)(OldFlink == OldBlink);
130c2c66affSColin Finck }
131c2c66affSColin Finck 
132c2c66affSColin Finck FORCEINLINE
133c2c66affSColin Finck PLIST_ENTRY
RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)134c2c66affSColin Finck RemoveHeadList(
135c2c66affSColin Finck     _Inout_ PLIST_ENTRY ListHead)
136c2c66affSColin Finck {
137c2c66affSColin Finck     PLIST_ENTRY Flink;
138c2c66affSColin Finck     PLIST_ENTRY Entry;
139c2c66affSColin Finck 
140c2c66affSColin Finck     Entry = ListHead->Flink;
141c2c66affSColin Finck     Flink = Entry->Flink;
142c2c66affSColin Finck     ListHead->Flink = Flink;
143c2c66affSColin Finck     Flink->Blink = ListHead;
144c2c66affSColin Finck     return Entry;
145c2c66affSColin Finck }
146c2c66affSColin Finck 
147c2c66affSColin Finck FORCEINLINE
148c2c66affSColin Finck PLIST_ENTRY
RemoveTailList(_Inout_ PLIST_ENTRY ListHead)149c2c66affSColin Finck RemoveTailList(
150c2c66affSColin Finck     _Inout_ PLIST_ENTRY ListHead)
151c2c66affSColin Finck {
152c2c66affSColin Finck     PLIST_ENTRY Blink;
153c2c66affSColin Finck     PLIST_ENTRY Entry;
154c2c66affSColin Finck 
155c2c66affSColin Finck     Entry = ListHead->Blink;
156c2c66affSColin Finck     Blink = Entry->Blink;
157c2c66affSColin Finck     ListHead->Blink = Blink;
158c2c66affSColin Finck     Blink->Flink = ListHead;
159c2c66affSColin Finck     return Entry;
160c2c66affSColin Finck }
161c2c66affSColin Finck 
162c2c66affSColin Finck //
163c2c66affSColin Finck // Unicode string macros
164c2c66affSColin Finck //
165c2c66affSColin Finck _At_(UnicodeString->Buffer, _Post_equal_to_(Buffer))
166c2c66affSColin Finck _At_(UnicodeString->Length, _Post_equal_to_(0))
167c2c66affSColin Finck _At_(UnicodeString->MaximumLength, _Post_equal_to_(BufferSize))
168c2c66affSColin Finck FORCEINLINE
169c2c66affSColin Finck VOID
170c2c66affSColin Finck RtlInitEmptyUnicodeString(
171c2c66affSColin Finck     _Out_ PUNICODE_STRING UnicodeString,
172c2c66affSColin Finck     _When_(BufferSize != 0, _Notnull_) _Writable_bytes_(BufferSize) __drv_aliasesMem PWCHAR Buffer,
173c2c66affSColin Finck     _In_ USHORT BufferSize)
174c2c66affSColin Finck {
175c2c66affSColin Finck     UnicodeString->Length = 0;
176c2c66affSColin Finck     UnicodeString->MaximumLength = BufferSize;
177c2c66affSColin Finck     UnicodeString->Buffer = Buffer;
178c2c66affSColin Finck }
179c2c66affSColin Finck 
180c2c66affSColin Finck _At_(AnsiString->Buffer, _Post_equal_to_(Buffer))
181c2c66affSColin Finck _At_(AnsiString->Length, _Post_equal_to_(0))
182c2c66affSColin Finck _At_(AnsiString->MaximumLength, _Post_equal_to_(BufferSize))
183c2c66affSColin Finck FORCEINLINE
184c2c66affSColin Finck VOID
185c2c66affSColin Finck RtlInitEmptyAnsiString(
186c2c66affSColin Finck     _Out_ PANSI_STRING AnsiString,
187c2c66affSColin Finck     _When_(BufferSize != 0, _Notnull_) _Writable_bytes_(BufferSize) __drv_aliasesMem PCHAR Buffer,
188c2c66affSColin Finck     _In_ USHORT BufferSize)
189c2c66affSColin Finck {
190c2c66affSColin Finck     AnsiString->Length = 0;
191c2c66affSColin Finck     AnsiString->MaximumLength = BufferSize;
192c2c66affSColin Finck     AnsiString->Buffer = Buffer;
193c2c66affSColin Finck }
194c2c66affSColin Finck 
195c2c66affSColin Finck //
196c2c66affSColin Finck // LUID Macros
197c2c66affSColin Finck //
198c2c66affSColin Finck #define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
199c2c66affSColin Finck                               ((L1)->LowPart  == (L2)->LowPart))
200c2c66affSColin Finck FORCEINLINE
201c2c66affSColin Finck LUID
202c2c66affSColin Finck NTAPI_INLINE
RtlConvertUlongToLuid(_In_ ULONG Ulong)203c2c66affSColin Finck RtlConvertUlongToLuid(
204c2c66affSColin Finck     _In_ ULONG Ulong)
205c2c66affSColin Finck {
206c2c66affSColin Finck     LUID TempLuid;
207c2c66affSColin Finck 
208c2c66affSColin Finck     TempLuid.LowPart = Ulong;
209c2c66affSColin Finck     TempLuid.HighPart = 0;
210c2c66affSColin Finck     return TempLuid;
211c2c66affSColin Finck }
212c2c66affSColin Finck 
213*43dad82fSTimo Kreuzer _Must_inspect_result_
214*43dad82fSTimo Kreuzer NTSYSAPI
215*43dad82fSTimo Kreuzer NTSTATUS
216*43dad82fSTimo Kreuzer NTAPI
217*43dad82fSTimo Kreuzer RtlUTF8ToUnicodeN(
218*43dad82fSTimo Kreuzer     _Out_writes_bytes_to_(UnicodeStringMaxByteCount, *UnicodeStringActualByteCount)
219*43dad82fSTimo Kreuzer         PWSTR UnicodeStringDestination,
220*43dad82fSTimo Kreuzer     _In_ ULONG UnicodeStringMaxByteCount,
221*43dad82fSTimo Kreuzer     _Out_ PULONG UnicodeStringActualByteCount,
222*43dad82fSTimo Kreuzer     _In_reads_bytes_(UTF8StringByteCount) PCCH UTF8StringSource,
223*43dad82fSTimo Kreuzer     _In_ ULONG UTF8StringByteCount);
224*43dad82fSTimo Kreuzer 
225c2c66affSColin Finck //
226c2c66affSColin Finck // ASSERT Macros
227c2c66affSColin Finck //
228c2c66affSColin Finck #ifndef ASSERT
229c2c66affSColin Finck #if DBG
230c2c66affSColin Finck 
231c2c66affSColin Finck #define ASSERT( exp ) \
232c2c66affSColin Finck     ((void)((!(exp)) ? \
233c2c66affSColin Finck         (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ),FALSE) : \
234c2c66affSColin Finck         TRUE))
235c2c66affSColin Finck 
236c2c66affSColin Finck #define ASSERTMSG( msg, exp ) \
237c2c66affSColin Finck     ((void)((!(exp)) ? \
238c2c66affSColin Finck         (RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, (PCHAR)msg ),FALSE) : \
239c2c66affSColin Finck         TRUE))
240c2c66affSColin Finck 
241c2c66affSColin Finck #else
242c2c66affSColin Finck 
243c2c66affSColin Finck #define ASSERT( exp )         ((void) 0)
244c2c66affSColin Finck #define ASSERTMSG( msg, exp ) ((void) 0)
245c2c66affSColin Finck 
246c2c66affSColin Finck #endif
247c2c66affSColin Finck #endif
248c2c66affSColin Finck 
249c2c66affSColin Finck #ifdef NTOS_KERNEL_RUNTIME
250c2c66affSColin Finck 
251c2c66affSColin Finck //
252c2c66affSColin Finck // Executing RTL functions at DISPATCH_LEVEL or higher will result in a
253c2c66affSColin Finck // bugcheck.
254c2c66affSColin Finck //
255c2c66affSColin Finck #define RTL_PAGED_CODE PAGED_CODE
256c2c66affSColin Finck 
257c2c66affSColin Finck #else
258c2c66affSColin Finck 
259c2c66affSColin Finck //
260c2c66affSColin Finck // This macro does nothing in user mode
261c2c66affSColin Finck //
262ff045b2dSHervé Poussineau #define RTL_PAGED_CODE()
263c2c66affSColin Finck 
264c2c66affSColin Finck #endif
265c2c66affSColin Finck 
266c2c66affSColin Finck //
267c2c66affSColin Finck // RTL Splay Tree Functions
268c2c66affSColin Finck //
269c2c66affSColin Finck #ifndef RTL_USE_AVL_TABLES
270c2c66affSColin Finck 
271c2c66affSColin Finck NTSYSAPI
272c2c66affSColin Finck VOID
273c2c66affSColin Finck NTAPI
274c2c66affSColin Finck RtlInitializeGenericTable(
275c2c66affSColin Finck     _Out_ PRTL_GENERIC_TABLE Table,
276c2c66affSColin Finck     _In_ PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine,
277c2c66affSColin Finck     _In_opt_ PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine,
278c2c66affSColin Finck     _In_opt_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine,
279c2c66affSColin Finck     _In_opt_ PVOID TableContext
280c2c66affSColin Finck );
281c2c66affSColin Finck 
282c2c66affSColin Finck NTSYSAPI
283c2c66affSColin Finck PVOID
284c2c66affSColin Finck NTAPI
285c2c66affSColin Finck RtlInsertElementGenericTable(
286c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
287c2c66affSColin Finck     _In_reads_bytes_(BufferSize) PVOID Buffer,
288c2c66affSColin Finck     _In_ CLONG BufferSize,
289c2c66affSColin Finck     _Out_opt_ PBOOLEAN NewElement
290c2c66affSColin Finck );
291c2c66affSColin Finck 
292c2c66affSColin Finck NTSYSAPI
293c2c66affSColin Finck PVOID
294c2c66affSColin Finck NTAPI
295c2c66affSColin Finck RtlInsertElementGenericTableFull(
296c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
297c2c66affSColin Finck     _In_reads_bytes_(BufferSize) PVOID Buffer,
298c2c66affSColin Finck     _In_ CLONG BufferSize,
299c2c66affSColin Finck     _Out_opt_ PBOOLEAN NewElement,
300c2c66affSColin Finck     _In_ PVOID NodeOrParent,
301c2c66affSColin Finck     _In_ TABLE_SEARCH_RESULT SearchResult
302c2c66affSColin Finck );
303c2c66affSColin Finck 
304c2c66affSColin Finck NTSYSAPI
305c2c66affSColin Finck BOOLEAN
306c2c66affSColin Finck NTAPI
307c2c66affSColin Finck RtlDeleteElementGenericTable(
308c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
309c2c66affSColin Finck     _In_ PVOID Buffer
310c2c66affSColin Finck );
311c2c66affSColin Finck 
312c2c66affSColin Finck _Must_inspect_result_
313c2c66affSColin Finck NTSYSAPI
314c2c66affSColin Finck PVOID
315c2c66affSColin Finck NTAPI
316c2c66affSColin Finck RtlLookupElementGenericTable(
317c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
318c2c66affSColin Finck     _In_ PVOID Buffer
319c2c66affSColin Finck );
320c2c66affSColin Finck 
321c2c66affSColin Finck NTSYSAPI
322c2c66affSColin Finck PVOID
323c2c66affSColin Finck NTAPI
324c2c66affSColin Finck RtlLookupElementGenericTableFull(
325c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
326c2c66affSColin Finck     _In_ PVOID Buffer,
327c2c66affSColin Finck     _Out_ PVOID *NodeOrParent,
328c2c66affSColin Finck     _Out_ TABLE_SEARCH_RESULT *SearchResult
329c2c66affSColin Finck );
330c2c66affSColin Finck 
331c2c66affSColin Finck _Must_inspect_result_
332c2c66affSColin Finck NTSYSAPI
333c2c66affSColin Finck PVOID
334c2c66affSColin Finck NTAPI
335c2c66affSColin Finck RtlEnumerateGenericTable(
336c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
337c2c66affSColin Finck     _In_ BOOLEAN Restart
338c2c66affSColin Finck );
339c2c66affSColin Finck 
340c2c66affSColin Finck _Must_inspect_result_
341c2c66affSColin Finck NTSYSAPI
342c2c66affSColin Finck PVOID
343c2c66affSColin Finck NTAPI
344c2c66affSColin Finck RtlEnumerateGenericTableWithoutSplaying(
345c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
346c2c66affSColin Finck     _Inout_ PVOID *RestartKey
347c2c66affSColin Finck );
348c2c66affSColin Finck 
349c2c66affSColin Finck _Must_inspect_result_
350c2c66affSColin Finck NTSYSAPI
351c2c66affSColin Finck PVOID
352c2c66affSColin Finck NTAPI
353c2c66affSColin Finck RtlGetElementGenericTable(
354c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
355c2c66affSColin Finck     _In_ ULONG I
356c2c66affSColin Finck );
357c2c66affSColin Finck 
358c2c66affSColin Finck NTSYSAPI
359c2c66affSColin Finck ULONG
360c2c66affSColin Finck NTAPI
361c2c66affSColin Finck RtlNumberGenericTableElements(
362c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table
363c2c66affSColin Finck );
364c2c66affSColin Finck 
365c2c66affSColin Finck _Must_inspect_result_
366c2c66affSColin Finck NTSYSAPI
367c2c66affSColin Finck BOOLEAN
368c2c66affSColin Finck NTAPI
369c2c66affSColin Finck RtlIsGenericTableEmpty(
370c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table
371c2c66affSColin Finck );
372c2c66affSColin Finck 
373c2c66affSColin Finck #endif /* !RTL_USE_AVL_TABLES */
374c2c66affSColin Finck 
375c2c66affSColin Finck NTSYSAPI
376c2c66affSColin Finck PRTL_SPLAY_LINKS
377c2c66affSColin Finck NTAPI
378c2c66affSColin Finck RtlSplay(
379c2c66affSColin Finck     _Inout_ PRTL_SPLAY_LINKS Links
380c2c66affSColin Finck );
381c2c66affSColin Finck 
382c2c66affSColin Finck NTSYSAPI
383c2c66affSColin Finck PRTL_SPLAY_LINKS
384c2c66affSColin Finck NTAPI
385c2c66affSColin Finck RtlDelete(
386c2c66affSColin Finck     _In_ PRTL_SPLAY_LINKS Links
387c2c66affSColin Finck );
388c2c66affSColin Finck 
389c2c66affSColin Finck NTSYSAPI
390c2c66affSColin Finck VOID
391c2c66affSColin Finck NTAPI
392c2c66affSColin Finck RtlDeleteNoSplay(
393c2c66affSColin Finck     _In_ PRTL_SPLAY_LINKS Links,
394c2c66affSColin Finck     _Inout_ PRTL_SPLAY_LINKS *Root
395c2c66affSColin Finck );
396c2c66affSColin Finck 
397c2c66affSColin Finck _Must_inspect_result_
398c2c66affSColin Finck NTSYSAPI
399c2c66affSColin Finck PRTL_SPLAY_LINKS
400c2c66affSColin Finck NTAPI
401c2c66affSColin Finck RtlSubtreeSuccessor(
402c2c66affSColin Finck     _In_ PRTL_SPLAY_LINKS Links
403c2c66affSColin Finck );
404c2c66affSColin Finck 
405c2c66affSColin Finck _Must_inspect_result_
406c2c66affSColin Finck NTSYSAPI
407c2c66affSColin Finck PRTL_SPLAY_LINKS
408c2c66affSColin Finck NTAPI
409c2c66affSColin Finck RtlSubtreePredecessor(
410c2c66affSColin Finck     _In_ PRTL_SPLAY_LINKS Links
411c2c66affSColin Finck );
412c2c66affSColin Finck 
413c2c66affSColin Finck _Must_inspect_result_
414c2c66affSColin Finck NTSYSAPI
415c2c66affSColin Finck PRTL_SPLAY_LINKS
416c2c66affSColin Finck NTAPI
417c2c66affSColin Finck RtlRealSuccessor(
418c2c66affSColin Finck     _In_ PRTL_SPLAY_LINKS Links
419c2c66affSColin Finck );
420c2c66affSColin Finck 
421c2c66affSColin Finck _Must_inspect_result_
422c2c66affSColin Finck NTSYSAPI
423c2c66affSColin Finck PRTL_SPLAY_LINKS
424c2c66affSColin Finck NTAPI
425c2c66affSColin Finck RtlRealPredecessor(
426c2c66affSColin Finck     _In_ PRTL_SPLAY_LINKS Links
427c2c66affSColin Finck );
428c2c66affSColin Finck 
429c2c66affSColin Finck #define RtlIsLeftChild(Links) \
430c2c66affSColin Finck     (RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
431c2c66affSColin Finck 
432c2c66affSColin Finck #define RtlIsRightChild(Links) \
433c2c66affSColin Finck     (RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
434c2c66affSColin Finck 
435c2c66affSColin Finck #define RtlRightChild(Links) \
436c2c66affSColin Finck     ((PRTL_SPLAY_LINKS)(Links))->RightChild
437c2c66affSColin Finck 
438c2c66affSColin Finck #define RtlIsRoot(Links) \
439c2c66affSColin Finck     (RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
440c2c66affSColin Finck 
441c2c66affSColin Finck #define RtlLeftChild(Links) \
442c2c66affSColin Finck     ((PRTL_SPLAY_LINKS)(Links))->LeftChild
443c2c66affSColin Finck 
444c2c66affSColin Finck #define RtlParent(Links) \
445c2c66affSColin Finck     ((PRTL_SPLAY_LINKS)(Links))->Parent
446c2c66affSColin Finck 
447c2c66affSColin Finck // FIXME: use inline function
448c2c66affSColin Finck 
449c2c66affSColin Finck #define RtlInitializeSplayLinks(Links)                  \
450c2c66affSColin Finck     {                                                   \
451c2c66affSColin Finck         PRTL_SPLAY_LINKS _SplayLinks;                   \
452c2c66affSColin Finck         _SplayLinks = (PRTL_SPLAY_LINKS)(Links);        \
453c2c66affSColin Finck         _SplayLinks->Parent = _SplayLinks;              \
454c2c66affSColin Finck         _SplayLinks->LeftChild = NULL;                  \
455c2c66affSColin Finck         _SplayLinks->RightChild = NULL;                 \
456c2c66affSColin Finck     }
457c2c66affSColin Finck 
458c2c66affSColin Finck #define RtlInsertAsLeftChild(ParentLinks,ChildLinks)    \
459c2c66affSColin Finck     {                                                   \
460c2c66affSColin Finck         PRTL_SPLAY_LINKS _SplayParent;                  \
461c2c66affSColin Finck         PRTL_SPLAY_LINKS _SplayChild;                   \
462c2c66affSColin Finck         _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
463c2c66affSColin Finck         _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks);   \
464c2c66affSColin Finck         _SplayParent->LeftChild = _SplayChild;          \
465c2c66affSColin Finck         _SplayChild->Parent = _SplayParent;             \
466c2c66affSColin Finck     }
467c2c66affSColin Finck 
468c2c66affSColin Finck #define RtlInsertAsRightChild(ParentLinks,ChildLinks)   \
469c2c66affSColin Finck     {                                                   \
470c2c66affSColin Finck         PRTL_SPLAY_LINKS _SplayParent;                  \
471c2c66affSColin Finck         PRTL_SPLAY_LINKS _SplayChild;                   \
472c2c66affSColin Finck         _SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
473c2c66affSColin Finck         _SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks);   \
474c2c66affSColin Finck         _SplayParent->RightChild = _SplayChild;         \
475c2c66affSColin Finck         _SplayChild->Parent = _SplayParent;             \
476c2c66affSColin Finck     }
477c2c66affSColin Finck 
478c2c66affSColin Finck //
479c2c66affSColin Finck // RTL AVL Tree Functions
480c2c66affSColin Finck //
481c2c66affSColin Finck NTSYSAPI
482c2c66affSColin Finck VOID
483c2c66affSColin Finck NTAPI
484c2c66affSColin Finck RtlInitializeGenericTableAvl(
485c2c66affSColin Finck     _Out_ PRTL_AVL_TABLE Table,
486c2c66affSColin Finck     _In_ PRTL_AVL_COMPARE_ROUTINE CompareRoutine,
487c2c66affSColin Finck     _In_opt_ PRTL_AVL_ALLOCATE_ROUTINE AllocateRoutine,
488c2c66affSColin Finck     _In_opt_ PRTL_AVL_FREE_ROUTINE FreeRoutine,
489c2c66affSColin Finck     _In_opt_ PVOID TableContext
490c2c66affSColin Finck );
491c2c66affSColin Finck 
492c2c66affSColin Finck NTSYSAPI
493c2c66affSColin Finck PVOID
494c2c66affSColin Finck NTAPI
495c2c66affSColin Finck RtlInsertElementGenericTableAvl(
496c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
497c2c66affSColin Finck     _In_reads_bytes_(BufferSize) PVOID Buffer,
498c2c66affSColin Finck     _In_ CLONG BufferSize,
499c2c66affSColin Finck     _Out_opt_ PBOOLEAN NewElement
500c2c66affSColin Finck );
501c2c66affSColin Finck 
502c2c66affSColin Finck NTSYSAPI
503c2c66affSColin Finck PVOID
504c2c66affSColin Finck NTAPI
505c2c66affSColin Finck RtlInsertElementGenericTableFullAvl(
506c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
507c2c66affSColin Finck     _In_reads_bytes_(BufferSize) PVOID Buffer,
508c2c66affSColin Finck     _In_ CLONG BufferSize,
509c2c66affSColin Finck     _Out_opt_ PBOOLEAN NewElement,
510c2c66affSColin Finck     _In_ PVOID NodeOrParent,
511c2c66affSColin Finck     _In_ TABLE_SEARCH_RESULT SearchResult
512c2c66affSColin Finck );
513c2c66affSColin Finck 
514c2c66affSColin Finck NTSYSAPI
515c2c66affSColin Finck BOOLEAN
516c2c66affSColin Finck NTAPI
517c2c66affSColin Finck RtlDeleteElementGenericTableAvl(
518c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
519c2c66affSColin Finck     _In_ PVOID Buffer
520c2c66affSColin Finck );
521c2c66affSColin Finck 
522c2c66affSColin Finck _Must_inspect_result_
523c2c66affSColin Finck NTSYSAPI
524c2c66affSColin Finck PVOID
525c2c66affSColin Finck NTAPI
526c2c66affSColin Finck RtlLookupElementGenericTableAvl(
527c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
528c2c66affSColin Finck     _In_ PVOID Buffer
529c2c66affSColin Finck );
530c2c66affSColin Finck 
531c2c66affSColin Finck NTSYSAPI
532c2c66affSColin Finck PVOID
533c2c66affSColin Finck NTAPI
534c2c66affSColin Finck RtlLookupElementGenericTableFullAvl(
535c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
536c2c66affSColin Finck     _In_ PVOID Buffer,
537c2c66affSColin Finck     _Out_ PVOID *NodeOrParent,
538c2c66affSColin Finck     _Out_ TABLE_SEARCH_RESULT *SearchResult
539c2c66affSColin Finck );
540c2c66affSColin Finck 
541c2c66affSColin Finck _Must_inspect_result_
542c2c66affSColin Finck NTSYSAPI
543c2c66affSColin Finck PVOID
544c2c66affSColin Finck NTAPI
545c2c66affSColin Finck RtlEnumerateGenericTableAvl(
546c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
547c2c66affSColin Finck     _In_ BOOLEAN Restart
548c2c66affSColin Finck );
549c2c66affSColin Finck 
550c2c66affSColin Finck _Must_inspect_result_
551c2c66affSColin Finck NTSYSAPI
552c2c66affSColin Finck PVOID
553c2c66affSColin Finck NTAPI
554c2c66affSColin Finck RtlEnumerateGenericTableWithoutSplayingAvl(
555c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
556c2c66affSColin Finck     _Inout_ PVOID *RestartKey
557c2c66affSColin Finck );
558c2c66affSColin Finck 
559c2c66affSColin Finck _Must_inspect_result_
560c2c66affSColin Finck NTSYSAPI
561c2c66affSColin Finck PVOID
562c2c66affSColin Finck NTAPI
563c2c66affSColin Finck RtlLookupFirstMatchingElementGenericTableAvl(
564c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
565c2c66affSColin Finck     _In_ PVOID Buffer,
566c2c66affSColin Finck     _Out_ PVOID *RestartKey
567c2c66affSColin Finck );
568c2c66affSColin Finck 
569c2c66affSColin Finck _Must_inspect_result_
570c2c66affSColin Finck NTSYSAPI
571c2c66affSColin Finck PVOID
572c2c66affSColin Finck NTAPI
573c2c66affSColin Finck RtlEnumerateGenericTableLikeADirectory(
574c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
575c2c66affSColin Finck     _In_opt_ PRTL_AVL_MATCH_FUNCTION MatchFunction,
576c2c66affSColin Finck     _In_opt_ PVOID MatchData,
577c2c66affSColin Finck     _In_ ULONG NextFlag,
578c2c66affSColin Finck     _Inout_ PVOID *RestartKey,
579c2c66affSColin Finck     _Inout_ PULONG DeleteCount,
580c2c66affSColin Finck     _In_ PVOID Buffer
581c2c66affSColin Finck );
582c2c66affSColin Finck 
583c2c66affSColin Finck _Must_inspect_result_
584c2c66affSColin Finck NTSYSAPI
585c2c66affSColin Finck PVOID
586c2c66affSColin Finck NTAPI
587c2c66affSColin Finck RtlGetElementGenericTableAvl(
588c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table,
589c2c66affSColin Finck     _In_ ULONG I
590c2c66affSColin Finck );
591c2c66affSColin Finck 
592c2c66affSColin Finck NTSYSAPI
593c2c66affSColin Finck ULONG
594c2c66affSColin Finck NTAPI
595c2c66affSColin Finck RtlNumberGenericTableElementsAvl(
596c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table
597c2c66affSColin Finck );
598c2c66affSColin Finck 
599c2c66affSColin Finck _Must_inspect_result_
600c2c66affSColin Finck NTSYSAPI
601c2c66affSColin Finck BOOLEAN
602c2c66affSColin Finck NTAPI
603c2c66affSColin Finck RtlIsGenericTableEmptyAvl(
604c2c66affSColin Finck     _In_ PRTL_AVL_TABLE Table
605c2c66affSColin Finck );
606c2c66affSColin Finck 
607c2c66affSColin Finck #ifdef RTL_USE_AVL_TABLES
608c2c66affSColin Finck 
609c2c66affSColin Finck #define RtlInitializeGenericTable               RtlInitializeGenericTableAvl
610c2c66affSColin Finck #define RtlInsertElementGenericTable            RtlInsertElementGenericTableAvl
611c2c66affSColin Finck #define RtlInsertElementGenericTableFull        RtlInsertElementGenericTableFullAvl
612c2c66affSColin Finck #define RtlDeleteElementGenericTable            RtlDeleteElementGenericTableAvl
613c2c66affSColin Finck #define RtlLookupElementGenericTable            RtlLookupElementGenericTableAvl
614c2c66affSColin Finck #define RtlLookupElementGenericTableFull        RtlLookupElementGenericTableFullAvl
615c2c66affSColin Finck #define RtlEnumerateGenericTable                RtlEnumerateGenericTableAvl
616c2c66affSColin Finck #define RtlEnumerateGenericTableWithoutSplaying RtlEnumerateGenericTableWithoutSplayingAvl
617c2c66affSColin Finck #define RtlGetElementGenericTable               RtlGetElementGenericTableAvl
618c2c66affSColin Finck #define RtlNumberGenericTableElements           RtlNumberGenericTableElementsAvl
619c2c66affSColin Finck #define RtlIsGenericTableEmpty                  RtlIsGenericTableEmptyAvl
620c2c66affSColin Finck 
621c2c66affSColin Finck #endif /* RTL_USE_AVL_TABLES */
622c2c66affSColin Finck 
623c2c66affSColin Finck //
624c2c66affSColin Finck // Exception and Error Functions
625c2c66affSColin Finck //
626c2c66affSColin Finck NTSYSAPI
627c2c66affSColin Finck PVOID
628c2c66affSColin Finck NTAPI
629c2c66affSColin Finck RtlAddVectoredExceptionHandler(
630c2c66affSColin Finck     _In_ ULONG FirstHandler,
631c2c66affSColin Finck     _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
632c2c66affSColin Finck );
633c2c66affSColin Finck 
634c2c66affSColin Finck NTSYSAPI
635c2c66affSColin Finck ULONG
636c2c66affSColin Finck NTAPI
637c2c66affSColin Finck RtlRemoveVectoredExceptionHandler(
638c2c66affSColin Finck     _In_ PVOID VectoredHandlerHandle
639c2c66affSColin Finck );
640c2c66affSColin Finck 
641c2c66affSColin Finck NTSYSAPI
642c2c66affSColin Finck PVOID
643c2c66affSColin Finck NTAPI
644c2c66affSColin Finck RtlAddVectoredContinueHandler(
645c2c66affSColin Finck     _In_ ULONG FirstHandler,
646c2c66affSColin Finck     _In_ PVECTORED_EXCEPTION_HANDLER VectoredHandler
647c2c66affSColin Finck );
648c2c66affSColin Finck 
649c2c66affSColin Finck NTSYSAPI
650c2c66affSColin Finck ULONG
651c2c66affSColin Finck NTAPI
652c2c66affSColin Finck RtlRemoveVectoredContinueHandler(
653c2c66affSColin Finck     _In_ PVOID VectoredHandlerHandle
654c2c66affSColin Finck );
655c2c66affSColin Finck 
656c2c66affSColin Finck NTSYSAPI
657c2c66affSColin Finck VOID
658c2c66affSColin Finck NTAPI
659c2c66affSColin Finck RtlSetUnhandledExceptionFilter(
660c2c66affSColin Finck     _In_ PRTLP_UNHANDLED_EXCEPTION_FILTER TopLevelExceptionFilter
661c2c66affSColin Finck );
662c2c66affSColin Finck 
663c2c66affSColin Finck NTSYSAPI
664c2c66affSColin Finck LONG
665c2c66affSColin Finck NTAPI
666c2c66affSColin Finck RtlUnhandledExceptionFilter(
667c2c66affSColin Finck     _In_ struct _EXCEPTION_POINTERS* ExceptionInfo
668c2c66affSColin Finck );
669c2c66affSColin Finck 
670c2c66affSColin Finck __analysis_noreturn
671c2c66affSColin Finck NTSYSAPI
672c2c66affSColin Finck VOID
673c2c66affSColin Finck NTAPI
674c2c66affSColin Finck RtlAssert(
675c2c66affSColin Finck     _In_ PVOID FailedAssertion,
676c2c66affSColin Finck     _In_ PVOID FileName,
677c2c66affSColin Finck     _In_ ULONG LineNumber,
678c2c66affSColin Finck     _In_opt_z_ PCHAR Message
679c2c66affSColin Finck );
680c2c66affSColin Finck 
681c2c66affSColin Finck NTSYSAPI
682c2c66affSColin Finck PVOID
683c2c66affSColin Finck NTAPI
684c2c66affSColin Finck RtlEncodePointer(
685c2c66affSColin Finck     _In_ PVOID Pointer
686c2c66affSColin Finck );
687c2c66affSColin Finck 
688c2c66affSColin Finck NTSYSAPI
689c2c66affSColin Finck PVOID
690c2c66affSColin Finck NTAPI
691c2c66affSColin Finck RtlDecodePointer(
692c2c66affSColin Finck     _In_ PVOID Pointer
693c2c66affSColin Finck );
694c2c66affSColin Finck 
695c2c66affSColin Finck NTSYSAPI
696c2c66affSColin Finck PVOID
697c2c66affSColin Finck NTAPI
698c2c66affSColin Finck RtlEncodeSystemPointer(
699c2c66affSColin Finck     _In_ PVOID Pointer
700c2c66affSColin Finck );
701c2c66affSColin Finck 
702c2c66affSColin Finck NTSYSAPI
703c2c66affSColin Finck PVOID
704c2c66affSColin Finck NTAPI
705c2c66affSColin Finck RtlDecodeSystemPointer(
706c2c66affSColin Finck     _In_ PVOID Pointer
707c2c66affSColin Finck );
708c2c66affSColin Finck 
709c2c66affSColin Finck NTSYSAPI
710c2c66affSColin Finck NTSTATUS
711c2c66affSColin Finck NTAPI
712c2c66affSColin Finck RtlGetLastNtStatus(
713c2c66affSColin Finck     VOID
714c2c66affSColin Finck );
715c2c66affSColin Finck 
716c2c66affSColin Finck NTSYSAPI
717c2c66affSColin Finck ULONG
718c2c66affSColin Finck NTAPI
719c2c66affSColin Finck RtlGetLastWin32Error(
720c2c66affSColin Finck     VOID
721c2c66affSColin Finck );
722c2c66affSColin Finck 
723c2c66affSColin Finck NTSYSAPI
724c2c66affSColin Finck VOID
725c2c66affSColin Finck NTAPI
726c2c66affSColin Finck RtlSetLastWin32Error(
727c2c66affSColin Finck     _In_ ULONG LastError
728c2c66affSColin Finck );
729c2c66affSColin Finck 
730c2c66affSColin Finck NTSYSAPI
731c2c66affSColin Finck VOID
732c2c66affSColin Finck NTAPI
733c2c66affSColin Finck RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
734c2c66affSColin Finck     _In_ NTSTATUS Status
735c2c66affSColin Finck );
736c2c66affSColin Finck 
737c2c66affSColin Finck NTSYSAPI
738c2c66affSColin Finck NTSTATUS
739c2c66affSColin Finck NTAPI
740c2c66affSColin Finck RtlSetThreadErrorMode(
741c2c66affSColin Finck     _In_ ULONG NewMode,
742c2c66affSColin Finck     _Out_opt_ PULONG OldMode
743c2c66affSColin Finck );
744c2c66affSColin Finck 
745c2c66affSColin Finck NTSYSAPI
746c2c66affSColin Finck ULONG
747c2c66affSColin Finck NTAPI
748c2c66affSColin Finck RtlGetThreadErrorMode(
749c2c66affSColin Finck     VOID
750c2c66affSColin Finck );
751c2c66affSColin Finck 
752c2c66affSColin Finck #endif /* NTOS_MODE_USER */
753c2c66affSColin Finck 
754c2c66affSColin Finck NTSYSAPI
755c2c66affSColin Finck VOID
756c2c66affSColin Finck NTAPI
757c2c66affSColin Finck RtlCaptureContext(
758c2c66affSColin Finck     _Out_ PCONTEXT ContextRecord
759c2c66affSColin Finck );
760c2c66affSColin Finck 
761c2c66affSColin Finck NTSYSAPI
762c2c66affSColin Finck BOOLEAN
763c2c66affSColin Finck NTAPI
764c2c66affSColin Finck RtlDispatchException(
765c2c66affSColin Finck     _In_ PEXCEPTION_RECORD ExceptionRecord,
766c2c66affSColin Finck     _In_ PCONTEXT Context
767c2c66affSColin Finck );
768c2c66affSColin Finck 
769c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
770c2c66affSColin Finck _When_(Status < 0, _Out_range_(>, 0))
771c2c66affSColin Finck _When_(Status >= 0, _Out_range_(==, 0))
772c2c66affSColin Finck NTSYSAPI
773c2c66affSColin Finck ULONG
774c2c66affSColin Finck NTAPI
775c2c66affSColin Finck RtlNtStatusToDosError(
776c2c66affSColin Finck     _In_ NTSTATUS Status
777c2c66affSColin Finck );
778c2c66affSColin Finck 
779c2c66affSColin Finck _When_(Status < 0, _Out_range_(>, 0))
780c2c66affSColin Finck _When_(Status >= 0, _Out_range_(==, 0))
781c2c66affSColin Finck NTSYSAPI
782c2c66affSColin Finck ULONG
783c2c66affSColin Finck NTAPI
784c2c66affSColin Finck RtlNtStatusToDosErrorNoTeb(
785c2c66affSColin Finck     _In_ NTSTATUS Status
786c2c66affSColin Finck );
787c2c66affSColin Finck 
788c2c66affSColin Finck NTSYSAPI
789c2c66affSColin Finck NTSTATUS
790c2c66affSColin Finck NTAPI
791c2c66affSColin Finck RtlMapSecurityErrorToNtStatus(
792c2c66affSColin Finck     _In_ ULONG SecurityError
793c2c66affSColin Finck );
794c2c66affSColin Finck 
795c2c66affSColin Finck NTSYSAPI
796c2c66affSColin Finck VOID
797c2c66affSColin Finck NTAPI
798c2c66affSColin Finck RtlRaiseException(
799c2c66affSColin Finck     _In_ PEXCEPTION_RECORD ExceptionRecord
800c2c66affSColin Finck );
801c2c66affSColin Finck 
802c2c66affSColin Finck DECLSPEC_NORETURN
803c2c66affSColin Finck NTSYSAPI
804c2c66affSColin Finck VOID
805c2c66affSColin Finck NTAPI
806c2c66affSColin Finck RtlRaiseStatus(
807c2c66affSColin Finck     _In_ NTSTATUS Status
808c2c66affSColin Finck );
809c2c66affSColin Finck 
810c2c66affSColin Finck NTSYSAPI
811c2c66affSColin Finck VOID
812c2c66affSColin Finck NTAPI
813c2c66affSColin Finck RtlUnwind(
814c2c66affSColin Finck     _In_opt_ PVOID TargetFrame,
815c2c66affSColin Finck     _In_opt_ PVOID TargetIp,
816c2c66affSColin Finck     _In_opt_ PEXCEPTION_RECORD ExceptionRecord,
817c2c66affSColin Finck     _In_ PVOID ReturnValue
818c2c66affSColin Finck );
819c2c66affSColin Finck 
820c2c66affSColin Finck #define RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT 8
821c2c66affSColin Finck 
82204fe6665STimo Kreuzer #ifdef _M_AMD64
82304fe6665STimo Kreuzer 
82404fe6665STimo Kreuzer NTSYSAPI
82504fe6665STimo Kreuzer PRUNTIME_FUNCTION
82604fe6665STimo Kreuzer NTAPI
82704fe6665STimo Kreuzer RtlLookupFunctionEntry(
82804fe6665STimo Kreuzer     _In_ DWORD64 ControlPc,
82904fe6665STimo Kreuzer     _Out_ PDWORD64 ImageBase,
83004fe6665STimo Kreuzer     _Inout_opt_ PUNWIND_HISTORY_TABLE HistoryTable
83104fe6665STimo Kreuzer );
83204fe6665STimo Kreuzer 
83304fe6665STimo Kreuzer NTSYSAPI
83404fe6665STimo Kreuzer PEXCEPTION_ROUTINE
83504fe6665STimo Kreuzer NTAPI
83604fe6665STimo Kreuzer RtlVirtualUnwind(
83704fe6665STimo Kreuzer     _In_ ULONG HandlerType,
83804fe6665STimo Kreuzer     _In_ ULONG64 ImageBase,
83904fe6665STimo Kreuzer     _In_ ULONG64 ControlPc,
84004fe6665STimo Kreuzer     _In_ PRUNTIME_FUNCTION FunctionEntry,
84104fe6665STimo Kreuzer     _Inout_ PCONTEXT Context,
84204fe6665STimo Kreuzer     _Outptr_ PVOID* HandlerData,
84304fe6665STimo Kreuzer     _Out_ PULONG64 EstablisherFrame,
84404fe6665STimo Kreuzer     _Inout_opt_ PKNONVOLATILE_CONTEXT_POINTERS ContextPointers
84504fe6665STimo Kreuzer );
84604fe6665STimo Kreuzer 
84704fe6665STimo Kreuzer #endif // _M_AMD64
84804fe6665STimo Kreuzer 
849c2c66affSColin Finck //
850c2c66affSColin Finck // Tracing Functions
851c2c66affSColin Finck //
852c2c66affSColin Finck NTSYSAPI
853c2c66affSColin Finck ULONG
854c2c66affSColin Finck NTAPI
855c2c66affSColin Finck RtlWalkFrameChain(
856c2c66affSColin Finck     _Out_writes_(Count - (Flags >> RTL_STACK_WALKING_MODE_FRAMES_TO_SKIP_SHIFT)) PVOID *Callers,
857c2c66affSColin Finck     _In_ ULONG Count,
858c2c66affSColin Finck     _In_ ULONG Flags
859c2c66affSColin Finck );
860c2c66affSColin Finck 
861c2c66affSColin Finck NTSYSAPI
862c2c66affSColin Finck USHORT
863c2c66affSColin Finck NTAPI
864c2c66affSColin Finck RtlLogStackBackTrace(
865c2c66affSColin Finck     VOID
866c2c66affSColin Finck );
867c2c66affSColin Finck 
868c2c66affSColin Finck #ifdef NTOS_MODE_USER
869c2c66affSColin Finck //
870c2c66affSColin Finck // Heap Functions
871c2c66affSColin Finck //
872c2c66affSColin Finck _Must_inspect_result_
873c2c66affSColin Finck _Ret_maybenull_
874c2c66affSColin Finck _Post_writable_byte_size_(Size)
875c2c66affSColin Finck NTSYSAPI
876c2c66affSColin Finck PVOID
877c2c66affSColin Finck NTAPI
878c2c66affSColin Finck RtlAllocateHeap(
879c2c66affSColin Finck     _In_ PVOID HeapHandle,
880c2c66affSColin Finck     _In_opt_ ULONG Flags,
881c2c66affSColin Finck     _In_ SIZE_T Size
882c2c66affSColin Finck );
883c2c66affSColin Finck 
884c2c66affSColin Finck _Must_inspect_result_
885c2c66affSColin Finck NTSYSAPI
886c2c66affSColin Finck PVOID
887c2c66affSColin Finck NTAPI
888c2c66affSColin Finck RtlCreateHeap(
889c2c66affSColin Finck     _In_ ULONG Flags,
890c2c66affSColin Finck     _In_opt_ PVOID BaseAddress,
891c2c66affSColin Finck     _In_opt_ SIZE_T SizeToReserve,
892c2c66affSColin Finck     _In_opt_ SIZE_T SizeToCommit,
893c2c66affSColin Finck     _In_opt_ PVOID Lock,
894c2c66affSColin Finck     _In_opt_ PRTL_HEAP_PARAMETERS Parameters
895c2c66affSColin Finck );
896c2c66affSColin Finck 
897c2c66affSColin Finck NTSYSAPI
898c2c66affSColin Finck ULONG
899c2c66affSColin Finck NTAPI
900c2c66affSColin Finck RtlCreateTagHeap(
901c2c66affSColin Finck     _In_ HANDLE HeapHandle,
902c2c66affSColin Finck     _In_ ULONG Flags,
90325bff3a1SSerge Gautherie     _In_opt_ PWSTR TagName,
904c2c66affSColin Finck     _In_ PWSTR TagSubName
905c2c66affSColin Finck );
906c2c66affSColin Finck 
907c2c66affSColin Finck ULONG
908c2c66affSColin Finck NTAPI
909c2c66affSColin Finck RtlCompactHeap(
910c2c66affSColin Finck     _In_ HANDLE Heap,
911c2c66affSColin Finck     _In_ ULONG Flags
912c2c66affSColin Finck );
913c2c66affSColin Finck 
914c2c66affSColin Finck _Must_inspect_result_
915c2c66affSColin Finck NTSYSAPI
916c2c66affSColin Finck PVOID
917c2c66affSColin Finck NTAPI
918c2c66affSColin Finck RtlDebugCreateHeap(
919c2c66affSColin Finck     _In_ ULONG Flags,
920c2c66affSColin Finck     _In_opt_ PVOID BaseAddress,
921c2c66affSColin Finck     _In_opt_ SIZE_T SizeToReserve,
922c2c66affSColin Finck     _In_opt_ SIZE_T SizeToCommit,
923c2c66affSColin Finck     _In_opt_ PVOID Lock,
924c2c66affSColin Finck     _In_opt_ PRTL_HEAP_PARAMETERS Parameters
925c2c66affSColin Finck );
926c2c66affSColin Finck 
927c2c66affSColin Finck NTSYSAPI
928c2c66affSColin Finck HANDLE
929c2c66affSColin Finck NTAPI
930c2c66affSColin Finck RtlDestroyHeap(
931c2c66affSColin Finck     _In_ _Post_invalid_ HANDLE Heap
932c2c66affSColin Finck );
933c2c66affSColin Finck 
934c2c66affSColin Finck NTSYSAPI
935c2c66affSColin Finck ULONG
936c2c66affSColin Finck NTAPI
937c2c66affSColin Finck RtlExtendHeap(
938c2c66affSColin Finck     _In_ HANDLE Heap,
939c2c66affSColin Finck     _In_ ULONG Flags,
940c2c66affSColin Finck     _In_ PVOID P,
941c2c66affSColin Finck     _In_ SIZE_T Size
942c2c66affSColin Finck );
943c2c66affSColin Finck 
944c2c66affSColin Finck _Success_(return != 0)
945c2c66affSColin Finck NTSYSAPI
946c2c66affSColin Finck BOOLEAN
947c2c66affSColin Finck NTAPI
948c2c66affSColin Finck RtlFreeHeap(
949c2c66affSColin Finck     _In_ HANDLE HeapHandle,
950c2c66affSColin Finck     _In_opt_ ULONG Flags,
951c2c66affSColin Finck     _In_ _Post_invalid_ PVOID P
952c2c66affSColin Finck );
953c2c66affSColin Finck 
954c2c66affSColin Finck ULONG
955c2c66affSColin Finck NTAPI
956c2c66affSColin Finck RtlGetProcessHeaps(
957c2c66affSColin Finck     _In_ ULONG HeapCount,
958c2c66affSColin Finck     _Out_cap_(HeapCount) HANDLE *HeapArray
959c2c66affSColin Finck );
960c2c66affSColin Finck 
961c2c66affSColin Finck _Success_(return != 0)
962c2c66affSColin Finck BOOLEAN
963c2c66affSColin Finck NTAPI
964c2c66affSColin Finck RtlGetUserInfoHeap(
965c2c66affSColin Finck     _In_ PVOID HeapHandle,
966c2c66affSColin Finck     _In_ ULONG Flags,
967c2c66affSColin Finck     _In_ PVOID BaseAddress,
968c2c66affSColin Finck     _Inout_opt_ PVOID *UserValue,
969c2c66affSColin Finck     _Out_opt_ PULONG UserFlags
970c2c66affSColin Finck );
971c2c66affSColin Finck 
972c2c66affSColin Finck NTSYSAPI
973c2c66affSColin Finck PVOID
974c2c66affSColin Finck NTAPI
975c2c66affSColin Finck RtlProtectHeap(
976c2c66affSColin Finck     _In_ PVOID HeapHandle,
977c2c66affSColin Finck     _In_ BOOLEAN Protect
978c2c66affSColin Finck );
979c2c66affSColin Finck 
980c2c66affSColin Finck NTSYSAPI
981c2c66affSColin Finck NTSTATUS
982c2c66affSColin Finck NTAPI
983c2c66affSColin Finck RtlQueryHeapInformation(
984c2c66affSColin Finck     _In_ PVOID HeapHandle,
985c2c66affSColin Finck     _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
986c2c66affSColin Finck     _Out_ PVOID HeapInformation,
987c2c66affSColin Finck     _In_ SIZE_T HeapInformationLength,
988c2c66affSColin Finck     _When_(HeapInformationClass==HeapCompatibilityInformation, _On_failure_(_Out_opt_))
989c2c66affSColin Finck         _Out_opt_ PSIZE_T ReturnLength
990c2c66affSColin Finck );
991c2c66affSColin Finck 
992c2c66affSColin Finck _Ret_opt_z_
993c2c66affSColin Finck NTSYSAPI
994c2c66affSColin Finck PWSTR
995c2c66affSColin Finck NTAPI
996c2c66affSColin Finck RtlQueryTagHeap(
997c2c66affSColin Finck     _In_ PVOID HeapHandle,
998c2c66affSColin Finck     _In_ ULONG Flags,
999c2c66affSColin Finck     _In_ USHORT TagIndex,
1000c2c66affSColin Finck     _In_ BOOLEAN ResetCounters,
1001c2c66affSColin Finck     _Out_ PRTL_HEAP_TAG_INFO HeapTagInfo
1002c2c66affSColin Finck );
1003c2c66affSColin Finck 
1004c2c66affSColin Finck _Must_inspect_result_
1005c2c66affSColin Finck _Ret_maybenull_
1006c2c66affSColin Finck _Post_writable_byte_size_(Size)
1007c2c66affSColin Finck NTSYSAPI
1008c2c66affSColin Finck PVOID
1009c2c66affSColin Finck NTAPI
1010c2c66affSColin Finck RtlReAllocateHeap(
1011c2c66affSColin Finck     _In_ HANDLE Heap,
1012c2c66affSColin Finck     _In_opt_ ULONG Flags,
1013c2c66affSColin Finck     _In_ _Post_invalid_ PVOID Ptr,
1014c2c66affSColin Finck     _In_ SIZE_T Size
1015c2c66affSColin Finck );
1016c2c66affSColin Finck 
1017c2c66affSColin Finck NTSYSAPI
1018c2c66affSColin Finck NTSTATUS
1019c2c66affSColin Finck NTAPI
1020c2c66affSColin Finck RtlSetHeapInformation(
1021c2c66affSColin Finck     _In_ PVOID HeapHandle,
1022c2c66affSColin Finck     _In_ HEAP_INFORMATION_CLASS HeapInformationClass,
1023c2c66affSColin Finck     _When_(HeapInformationClass==HeapCompatibilityInformation,_In_) PVOID HeapInformation,
1024c2c66affSColin Finck     _In_ SIZE_T HeapInformationLength
1025c2c66affSColin Finck );
1026c2c66affSColin Finck 
1027c2c66affSColin Finck NTSYSAPI
1028c2c66affSColin Finck BOOLEAN
1029c2c66affSColin Finck NTAPI
1030c2c66affSColin Finck RtlLockHeap(
1031c2c66affSColin Finck     _In_ HANDLE Heap
1032c2c66affSColin Finck );
1033c2c66affSColin Finck 
1034c2c66affSColin Finck NTSYSAPI
1035774ef4e8SKatayama Hirofumi MZ ULONG
1036c2c66affSColin Finck NTAPI
1037c2c66affSColin Finck RtlMultipleAllocateHeap(
1038c2c66affSColin Finck     _In_ HANDLE HeapHandle,
1039c2c66affSColin Finck     _In_ ULONG Flags,
1040c2c66affSColin Finck     _In_ SIZE_T Size,
1041c2c66affSColin Finck     _In_ ULONG Count,
1042c2c66affSColin Finck     _Out_cap_(Count) _Deref_post_bytecap_(Size) PVOID * Array
1043c2c66affSColin Finck );
1044c2c66affSColin Finck 
1045c2c66affSColin Finck NTSYSAPI
1046774ef4e8SKatayama Hirofumi MZ ULONG
1047c2c66affSColin Finck NTAPI
1048c2c66affSColin Finck RtlMultipleFreeHeap(
1049c2c66affSColin Finck     _In_ HANDLE HeapHandle,
1050c2c66affSColin Finck     _In_ ULONG Flags,
1051c2c66affSColin Finck     _In_ ULONG Count,
1052c2c66affSColin Finck     _In_count_(Count) /* _Deref_ _Post_invalid_ */ PVOID * Array
1053c2c66affSColin Finck );
1054c2c66affSColin Finck 
1055c2c66affSColin Finck NTSYSAPI
1056c2c66affSColin Finck NTSTATUS
1057c2c66affSColin Finck NTAPI
1058c2c66affSColin Finck RtlUsageHeap(
1059c2c66affSColin Finck     _In_ HANDLE Heap,
1060c2c66affSColin Finck     _In_ ULONG Flags,
1061c2c66affSColin Finck     _Out_ PRTL_HEAP_USAGE Usage
1062c2c66affSColin Finck );
1063c2c66affSColin Finck 
1064c2c66affSColin Finck NTSYSAPI
1065c2c66affSColin Finck BOOLEAN
1066c2c66affSColin Finck NTAPI
1067c2c66affSColin Finck RtlUnlockHeap(
1068c2c66affSColin Finck     _In_ HANDLE Heap
1069c2c66affSColin Finck );
1070c2c66affSColin Finck 
1071c2c66affSColin Finck BOOLEAN
1072c2c66affSColin Finck NTAPI
1073c2c66affSColin Finck RtlSetUserValueHeap(
1074c2c66affSColin Finck     _In_ PVOID HeapHandle,
1075c2c66affSColin Finck     _In_ ULONG Flags,
1076c2c66affSColin Finck     _In_ PVOID BaseAddress,
1077c2c66affSColin Finck     _In_ PVOID UserValue
1078c2c66affSColin Finck );
1079c2c66affSColin Finck 
1080c2c66affSColin Finck BOOLEAN
1081c2c66affSColin Finck NTAPI
1082c2c66affSColin Finck RtlSetUserFlagsHeap(
1083c2c66affSColin Finck     _In_ PVOID HeapHandle,
1084c2c66affSColin Finck     _In_ ULONG Flags,
1085c2c66affSColin Finck     _In_ PVOID BaseAddress,
1086c2c66affSColin Finck     _In_ ULONG UserFlagsReset,
1087c2c66affSColin Finck     _In_ ULONG UserFlagsSet
1088c2c66affSColin Finck );
1089c2c66affSColin Finck 
1090c2c66affSColin Finck NTSYSAPI
1091c2c66affSColin Finck BOOLEAN
1092c2c66affSColin Finck NTAPI
1093c2c66affSColin Finck RtlValidateHeap(
1094c2c66affSColin Finck     _In_ HANDLE Heap,
1095c2c66affSColin Finck     _In_ ULONG Flags,
1096c2c66affSColin Finck     _In_opt_ PVOID P
1097c2c66affSColin Finck );
1098c2c66affSColin Finck 
1099c2c66affSColin Finck NTSYSAPI
1100c2c66affSColin Finck NTSTATUS
1101c2c66affSColin Finck NTAPI
1102c2c66affSColin Finck RtlWalkHeap(
1103c2c66affSColin Finck     _In_ HANDLE HeapHandle,
1104c2c66affSColin Finck     _In_ PVOID HeapEntry
1105c2c66affSColin Finck );
1106c2c66affSColin Finck 
1107c2c66affSColin Finck #define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
1108c2c66affSColin Finck 
1109c2c66affSColin Finck #endif // NTOS_MODE_USER
1110c2c66affSColin Finck 
1111c2c66affSColin Finck #define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
1112c2c66affSColin Finck 
1113c2c66affSColin Finck NTSYSAPI
1114c2c66affSColin Finck SIZE_T
1115c2c66affSColin Finck NTAPI
1116c2c66affSColin Finck RtlSizeHeap(
1117c2c66affSColin Finck     _In_ PVOID HeapHandle,
1118c2c66affSColin Finck     _In_ ULONG Flags,
1119c2c66affSColin Finck     _In_ PVOID MemoryPointer
1120c2c66affSColin Finck );
1121c2c66affSColin Finck 
1122c2c66affSColin Finck 
1123c2c66affSColin Finck //
1124c2c66affSColin Finck // Security Functions
1125c2c66affSColin Finck //
1126c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1127c2c66affSColin Finck NTSYSAPI
1128c2c66affSColin Finck NTSTATUS
1129c2c66affSColin Finck NTAPI
1130c2c66affSColin Finck RtlAbsoluteToSelfRelativeSD(
1131c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
1132c2c66affSColin Finck     _Out_writes_bytes_to_opt_(*BufferLength, *BufferLength) PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
1133c2c66affSColin Finck     _Inout_ PULONG BufferLength
1134c2c66affSColin Finck );
1135c2c66affSColin Finck 
1136c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1137c2c66affSColin Finck NTSYSAPI
1138c2c66affSColin Finck NTSTATUS
1139c2c66affSColin Finck NTAPI
1140c2c66affSColin Finck RtlAddAccessAllowedAce(
1141c2c66affSColin Finck     _Inout_ PACL Acl,
1142c2c66affSColin Finck     _In_ ULONG Revision,
1143c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1144c2c66affSColin Finck     _In_ PSID Sid
1145c2c66affSColin Finck );
1146c2c66affSColin Finck 
1147c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1148c2c66affSColin Finck NTSYSAPI
1149c2c66affSColin Finck NTSTATUS
1150c2c66affSColin Finck NTAPI
1151c2c66affSColin Finck RtlAddAccessAllowedAceEx(
1152c2c66affSColin Finck     _Inout_ PACL pAcl,
1153c2c66affSColin Finck     _In_ ULONG dwAceRevision,
1154c2c66affSColin Finck     _In_ ULONG AceFlags,
1155c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1156c2c66affSColin Finck     _In_ PSID pSid
1157c2c66affSColin Finck );
1158c2c66affSColin Finck 
1159c2c66affSColin Finck NTSYSAPI
1160c2c66affSColin Finck NTSTATUS
1161c2c66affSColin Finck NTAPI
1162c2c66affSColin Finck RtlAddAccessAllowedObjectAce(
1163c2c66affSColin Finck     _Inout_ PACL pAcl,
1164c2c66affSColin Finck     _In_ ULONG dwAceRevision,
1165c2c66affSColin Finck     _In_ ULONG AceFlags,
1166c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1167c2c66affSColin Finck     _In_opt_ GUID *ObjectTypeGuid,
1168c2c66affSColin Finck     _In_opt_ GUID *InheritedObjectTypeGuid,
1169c2c66affSColin Finck     _In_ PSID pSid
1170c2c66affSColin Finck );
1171c2c66affSColin Finck 
1172c2c66affSColin Finck NTSYSAPI
1173c2c66affSColin Finck NTSTATUS
1174c2c66affSColin Finck NTAPI
1175c2c66affSColin Finck RtlAddAccessDeniedAce(
1176c2c66affSColin Finck     _Inout_ PACL Acl,
1177c2c66affSColin Finck     _In_ ULONG Revision,
1178c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1179c2c66affSColin Finck     _In_ PSID Sid
1180c2c66affSColin Finck );
1181c2c66affSColin Finck 
1182c2c66affSColin Finck NTSYSAPI
1183c2c66affSColin Finck NTSTATUS
1184c2c66affSColin Finck NTAPI
1185c2c66affSColin Finck RtlAddAccessDeniedAceEx(
1186c2c66affSColin Finck     _Inout_ PACL Acl,
1187c2c66affSColin Finck     _In_ ULONG Revision,
1188c2c66affSColin Finck     _In_ ULONG Flags,
1189c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1190c2c66affSColin Finck     _In_ PSID Sid
1191c2c66affSColin Finck );
1192c2c66affSColin Finck 
1193c2c66affSColin Finck NTSYSAPI
1194c2c66affSColin Finck NTSTATUS
1195c2c66affSColin Finck NTAPI
1196c2c66affSColin Finck RtlAddAccessDeniedObjectAce(
1197c2c66affSColin Finck     _Inout_ PACL pAcl,
1198c2c66affSColin Finck     _In_ ULONG dwAceRevision,
1199c2c66affSColin Finck     _In_ ULONG AceFlags,
1200c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1201c2c66affSColin Finck     _In_opt_ GUID *ObjectTypeGuid,
1202c2c66affSColin Finck     _In_opt_ GUID *InheritedObjectTypeGuid,
1203c2c66affSColin Finck     _In_ PSID pSid
1204c2c66affSColin Finck );
1205c2c66affSColin Finck 
1206c2c66affSColin Finck NTSYSAPI
1207c2c66affSColin Finck NTSTATUS
1208c2c66affSColin Finck NTAPI
1209c2c66affSColin Finck RtlAddAce(
1210c2c66affSColin Finck     _Inout_ PACL Acl,
1211c2c66affSColin Finck     _In_ ULONG AceRevision,
1212c2c66affSColin Finck     _In_ ULONG StartingAceIndex,
1213c2c66affSColin Finck     _In_reads_bytes_(AceListLength) PVOID AceList,
1214c2c66affSColin Finck     _In_ ULONG AceListLength
1215c2c66affSColin Finck );
1216c2c66affSColin Finck 
1217c2c66affSColin Finck NTSYSAPI
1218c2c66affSColin Finck NTSTATUS
1219c2c66affSColin Finck NTAPI
1220c2c66affSColin Finck RtlAddAuditAccessAce(
1221c2c66affSColin Finck     _Inout_ PACL Acl,
1222c2c66affSColin Finck     _In_ ULONG Revision,
1223c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1224c2c66affSColin Finck     _In_ PSID Sid,
1225c2c66affSColin Finck     _In_ BOOLEAN Success,
1226c2c66affSColin Finck     _In_ BOOLEAN Failure
1227c2c66affSColin Finck );
1228c2c66affSColin Finck 
1229c2c66affSColin Finck NTSYSAPI
1230c2c66affSColin Finck NTSTATUS
1231c2c66affSColin Finck NTAPI
1232c2c66affSColin Finck RtlAcquirePrivilege(
1233c2c66affSColin Finck     _In_ PULONG Privilege,
1234c2c66affSColin Finck     _In_ ULONG NumPriv,
1235c2c66affSColin Finck     _In_ ULONG Flags,
1236c2c66affSColin Finck     _Out_ PVOID *ReturnedState
1237c2c66affSColin Finck );
1238c2c66affSColin Finck 
1239c2c66affSColin Finck NTSYSAPI
1240c2c66affSColin Finck NTSTATUS
1241c2c66affSColin Finck NTAPI
1242c2c66affSColin Finck RtlAddAuditAccessAceEx(
1243c2c66affSColin Finck     _Inout_ PACL Acl,
1244c2c66affSColin Finck     _In_ ULONG Revision,
1245c2c66affSColin Finck     _In_ ULONG Flags,
1246c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1247c2c66affSColin Finck     _In_ PSID Sid,
1248c2c66affSColin Finck     _In_ BOOLEAN Success,
1249c2c66affSColin Finck     _In_ BOOLEAN Failure
1250c2c66affSColin Finck );
1251c2c66affSColin Finck 
1252c2c66affSColin Finck NTSYSAPI
1253c2c66affSColin Finck NTSTATUS
1254c2c66affSColin Finck NTAPI
1255c2c66affSColin Finck RtlAddAuditAccessObjectAce(
1256c2c66affSColin Finck     _Inout_ PACL Acl,
1257c2c66affSColin Finck     _In_ ULONG Revision,
1258c2c66affSColin Finck     _In_ ULONG Flags,
1259c2c66affSColin Finck     _In_ ACCESS_MASK AccessMask,
1260c2c66affSColin Finck     _In_opt_ GUID *ObjectTypeGuid,
1261c2c66affSColin Finck     _In_opt_ GUID *InheritedObjectTypeGuid,
1262c2c66affSColin Finck     _In_ PSID Sid,
1263c2c66affSColin Finck     _In_ BOOLEAN Success,
1264c2c66affSColin Finck     _In_ BOOLEAN Failure
1265c2c66affSColin Finck );
1266c2c66affSColin Finck 
1267c2c66affSColin Finck NTSYSAPI
1268c2c66affSColin Finck NTSTATUS
1269c2c66affSColin Finck NTAPI
1270c2c66affSColin Finck RtlAddMandatoryAce(
1271c2c66affSColin Finck     _Inout_ PACL Acl,
1272c2c66affSColin Finck     _In_ ULONG Revision,
1273c2c66affSColin Finck     _In_ ULONG Flags,
1274c2c66affSColin Finck     _In_ ULONG MandatoryFlags,
1275c2c66affSColin Finck     _In_ UCHAR AceType,
1276c2c66affSColin Finck     _In_ PSID LabelSid);
1277c2c66affSColin Finck 
1278c2c66affSColin Finck NTSYSAPI
1279c2c66affSColin Finck NTSTATUS
1280c2c66affSColin Finck NTAPI
1281c2c66affSColin Finck RtlAdjustPrivilege(
1282c2c66affSColin Finck     _In_ ULONG Privilege,
1283c2c66affSColin Finck     _In_ BOOLEAN NewValue,
1284c2c66affSColin Finck     _In_ BOOLEAN ForThread,
1285c2c66affSColin Finck     _Out_ PBOOLEAN OldValue
1286c2c66affSColin Finck );
1287c2c66affSColin Finck 
1288c2c66affSColin Finck _Must_inspect_result_
1289c2c66affSColin Finck NTSYSAPI
1290c2c66affSColin Finck NTSTATUS
1291c2c66affSColin Finck NTAPI
1292c2c66affSColin Finck RtlAllocateAndInitializeSid(
1293c2c66affSColin Finck     _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1294c2c66affSColin Finck     _In_ UCHAR SubAuthorityCount,
1295c2c66affSColin Finck     _In_ ULONG SubAuthority0,
1296c2c66affSColin Finck     _In_ ULONG SubAuthority1,
1297c2c66affSColin Finck     _In_ ULONG SubAuthority2,
1298c2c66affSColin Finck     _In_ ULONG SubAuthority3,
1299c2c66affSColin Finck     _In_ ULONG SubAuthority4,
1300c2c66affSColin Finck     _In_ ULONG SubAuthority5,
1301c2c66affSColin Finck     _In_ ULONG SubAuthority6,
1302c2c66affSColin Finck     _In_ ULONG SubAuthority7,
1303c2c66affSColin Finck     _Outptr_ PSID *Sid
1304c2c66affSColin Finck );
1305c2c66affSColin Finck 
1306c2c66affSColin Finck NTSYSAPI
1307c2c66affSColin Finck BOOLEAN
1308c2c66affSColin Finck NTAPI
1309c2c66affSColin Finck RtlAreAllAccessesGranted(
1310c2c66affSColin Finck     ACCESS_MASK GrantedAccess,
1311c2c66affSColin Finck     ACCESS_MASK DesiredAccess
1312c2c66affSColin Finck );
1313c2c66affSColin Finck 
1314c2c66affSColin Finck NTSYSAPI
1315c2c66affSColin Finck BOOLEAN
1316c2c66affSColin Finck NTAPI
1317c2c66affSColin Finck RtlAreAnyAccessesGranted(
1318c2c66affSColin Finck     ACCESS_MASK GrantedAccess,
1319c2c66affSColin Finck     ACCESS_MASK DesiredAccess
1320c2c66affSColin Finck );
1321c2c66affSColin Finck 
1322c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1323c2c66affSColin Finck NTSYSAPI
1324c2c66affSColin Finck VOID
1325c2c66affSColin Finck NTAPI
1326c2c66affSColin Finck RtlCopyLuid (
1327c2c66affSColin Finck     _Out_ PLUID DestinationLuid,
1328c2c66affSColin Finck     _In_ PLUID SourceLuid
1329c2c66affSColin Finck     );
1330c2c66affSColin Finck 
1331c2c66affSColin Finck NTSYSAPI
1332c2c66affSColin Finck VOID
1333c2c66affSColin Finck NTAPI
1334c2c66affSColin Finck RtlCopyLuidAndAttributesArray(
1335c2c66affSColin Finck     ULONG Count,
1336c2c66affSColin Finck     PLUID_AND_ATTRIBUTES Src,
1337c2c66affSColin Finck     PLUID_AND_ATTRIBUTES Dest
1338c2c66affSColin Finck );
1339c2c66affSColin Finck 
1340c2c66affSColin Finck NTSYSAPI
1341c2c66affSColin Finck NTSTATUS
1342c2c66affSColin Finck NTAPI
1343c2c66affSColin Finck RtlCopySidAndAttributesArray(
1344c2c66affSColin Finck     _In_ ULONG Count,
1345c2c66affSColin Finck     _In_ PSID_AND_ATTRIBUTES Src,
1346c2c66affSColin Finck     _In_ ULONG SidAreaSize,
1347c2c66affSColin Finck     _In_ PSID_AND_ATTRIBUTES Dest,
1348c2c66affSColin Finck     _In_ PSID SidArea,
1349c2c66affSColin Finck     _Out_ PSID* RemainingSidArea,
1350c2c66affSColin Finck     _Out_ PULONG RemainingSidAreaSize
1351c2c66affSColin Finck );
1352c2c66affSColin Finck 
1353c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1354c2c66affSColin Finck NTSYSAPI
1355c2c66affSColin Finck NTSTATUS
1356c2c66affSColin Finck NTAPI
1357c2c66affSColin Finck RtlConvertSidToUnicodeString(
1358c2c66affSColin Finck     _Inout_ PUNICODE_STRING UnicodeString,
1359c2c66affSColin Finck     _In_ PSID Sid,
1360c2c66affSColin Finck     _In_ BOOLEAN AllocateDestinationString
1361c2c66affSColin Finck );
1362c2c66affSColin Finck 
1363c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1364c2c66affSColin Finck NTSYSAPI
1365c2c66affSColin Finck NTSTATUS
1366c2c66affSColin Finck NTAPI
1367c2c66affSColin Finck RtlCopySid(
1368c2c66affSColin Finck     _In_ ULONG DestinationSidLength,
1369c2c66affSColin Finck     _Out_writes_bytes_(DestinationSidLength) PSID DestinationSid,
1370c2c66affSColin Finck     _In_ PSID SourceSid
1371c2c66affSColin Finck );
1372c2c66affSColin Finck 
1373c2c66affSColin Finck NTSYSAPI
1374c2c66affSColin Finck NTSTATUS
1375c2c66affSColin Finck NTAPI
1376c2c66affSColin Finck RtlCreateAcl(
1377c2c66affSColin Finck     PACL Acl,
1378c2c66affSColin Finck     ULONG AclSize,
1379c2c66affSColin Finck     ULONG AclRevision
1380c2c66affSColin Finck );
1381c2c66affSColin Finck 
1382c2c66affSColin Finck NTSYSAPI
1383c2c66affSColin Finck NTSTATUS
1384c2c66affSColin Finck NTAPI
1385c2c66affSColin Finck RtlCreateSecurityDescriptor(
1386c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1387c2c66affSColin Finck     _In_ ULONG Revision
1388c2c66affSColin Finck );
1389c2c66affSColin Finck 
1390c2c66affSColin Finck NTSYSAPI
1391c2c66affSColin Finck NTSTATUS
1392c2c66affSColin Finck NTAPI
1393c2c66affSColin Finck RtlCreateSecurityDescriptorRelative(
1394c2c66affSColin Finck     _Out_ PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
1395c2c66affSColin Finck     _In_ ULONG Revision
1396c2c66affSColin Finck );
1397c2c66affSColin Finck 
1398c2c66affSColin Finck NTSYSAPI
1399c2c66affSColin Finck NTSTATUS
1400c2c66affSColin Finck NTAPI
1401c2c66affSColin Finck RtlCopySecurityDescriptor(
1402c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
1403c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR *pDestinationSecurityDescriptor
1404c2c66affSColin Finck );
1405c2c66affSColin Finck 
1406c2c66affSColin Finck NTSYSAPI
1407c2c66affSColin Finck NTSTATUS
1408c2c66affSColin Finck NTAPI
1409c2c66affSColin Finck RtlDeleteAce(
1410c2c66affSColin Finck     PACL Acl,
1411c2c66affSColin Finck     ULONG AceIndex
1412c2c66affSColin Finck );
1413c2c66affSColin Finck 
1414c2c66affSColin Finck NTSYSAPI
1415c2c66affSColin Finck BOOLEAN
1416c2c66affSColin Finck NTAPI
1417c2c66affSColin Finck RtlEqualPrefixSid(
1418c2c66affSColin Finck     PSID Sid1,
1419c2c66affSColin Finck     PSID Sid2
1420c2c66affSColin Finck );
1421c2c66affSColin Finck 
1422c2c66affSColin Finck NTSYSAPI
1423c2c66affSColin Finck BOOLEAN
1424c2c66affSColin Finck NTAPI
1425c2c66affSColin Finck RtlEqualSid (
1426c2c66affSColin Finck     _In_ PSID Sid1,
1427c2c66affSColin Finck     _In_ PSID Sid2
1428c2c66affSColin Finck );
1429c2c66affSColin Finck 
1430c2c66affSColin Finck NTSYSAPI
1431c2c66affSColin Finck BOOLEAN
1432c2c66affSColin Finck NTAPI
1433c2c66affSColin Finck RtlFirstFreeAce(
1434c2c66affSColin Finck     PACL Acl,
1435c2c66affSColin Finck     PACE* Ace
1436c2c66affSColin Finck );
1437c2c66affSColin Finck 
1438c2c66affSColin Finck NTSYSAPI
1439c2c66affSColin Finck PVOID
1440c2c66affSColin Finck NTAPI
1441c2c66affSColin Finck RtlFreeSid(
1442c2c66affSColin Finck     _In_ _Post_invalid_ PSID Sid
1443c2c66affSColin Finck );
1444c2c66affSColin Finck 
1445c2c66affSColin Finck NTSYSAPI
1446c2c66affSColin Finck NTSTATUS
1447c2c66affSColin Finck NTAPI
1448c2c66affSColin Finck RtlGetAce(
1449c2c66affSColin Finck     PACL Acl,
1450c2c66affSColin Finck     ULONG AceIndex,
1451c2c66affSColin Finck     PVOID *Ace
1452c2c66affSColin Finck );
1453c2c66affSColin Finck 
1454c2c66affSColin Finck NTSYSAPI
1455c2c66affSColin Finck NTSTATUS
1456c2c66affSColin Finck NTAPI
1457c2c66affSColin Finck RtlGetControlSecurityDescriptor(
1458c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1459c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR_CONTROL Control,
1460c2c66affSColin Finck     _Out_ PULONG Revision
1461c2c66affSColin Finck );
1462c2c66affSColin Finck 
1463c2c66affSColin Finck NTSYSAPI
1464c2c66affSColin Finck NTSTATUS
1465c2c66affSColin Finck NTAPI
1466c2c66affSColin Finck RtlGetDaclSecurityDescriptor(
1467c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1468c2c66affSColin Finck     _Out_ PBOOLEAN DaclPresent,
1469c2c66affSColin Finck     _Out_ PACL *Dacl,
1470c2c66affSColin Finck     _Out_ PBOOLEAN DaclDefaulted
1471c2c66affSColin Finck );
1472c2c66affSColin Finck 
1473c2c66affSColin Finck NTSYSAPI
1474c2c66affSColin Finck NTSTATUS
1475c2c66affSColin Finck NTAPI
1476c2c66affSColin Finck RtlGetSaclSecurityDescriptor(
1477c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1478c2c66affSColin Finck     _Out_ PBOOLEAN SaclPresent,
1479c2c66affSColin Finck     _Out_ PACL* Sacl,
1480c2c66affSColin Finck     _Out_ PBOOLEAN SaclDefaulted
1481c2c66affSColin Finck );
1482c2c66affSColin Finck 
1483c2c66affSColin Finck NTSYSAPI
1484c2c66affSColin Finck NTSTATUS
1485c2c66affSColin Finck NTAPI
1486c2c66affSColin Finck RtlGetGroupSecurityDescriptor(
1487c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1488c2c66affSColin Finck     _Out_ PSID *Group,
1489c2c66affSColin Finck     _Out_ PBOOLEAN GroupDefaulted
1490c2c66affSColin Finck );
1491c2c66affSColin Finck 
1492c2c66affSColin Finck NTSYSAPI
1493c2c66affSColin Finck NTSTATUS
1494c2c66affSColin Finck NTAPI
1495c2c66affSColin Finck RtlGetOwnerSecurityDescriptor(
1496c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1497c2c66affSColin Finck     _Out_ PSID *Owner,
1498c2c66affSColin Finck     _Out_ PBOOLEAN OwnerDefaulted
1499c2c66affSColin Finck );
1500c2c66affSColin Finck 
1501c2c66affSColin Finck NTSYSAPI
1502c2c66affSColin Finck BOOLEAN
1503c2c66affSColin Finck NTAPI
1504c2c66affSColin Finck RtlGetSecurityDescriptorRMControl(
1505c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1506c2c66affSColin Finck     _Out_ PUCHAR RMControl
1507c2c66affSColin Finck );
1508c2c66affSColin Finck 
1509c2c66affSColin Finck NTSYSAPI
1510c2c66affSColin Finck PSID_IDENTIFIER_AUTHORITY
1511c2c66affSColin Finck NTAPI
1512c2c66affSColin Finck RtlIdentifierAuthoritySid(PSID Sid);
1513c2c66affSColin Finck 
1514c2c66affSColin Finck NTSYSAPI
1515c2c66affSColin Finck NTSTATUS
1516c2c66affSColin Finck NTAPI
1517c2c66affSColin Finck RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
1518c2c66affSColin Finck 
1519c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1520c2c66affSColin Finck NTSYSAPI
1521c2c66affSColin Finck NTSTATUS
1522c2c66affSColin Finck NTAPI
1523c2c66affSColin Finck RtlInitializeSid(
1524c2c66affSColin Finck     _Out_ PSID Sid,
1525c2c66affSColin Finck     _In_ PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
1526c2c66affSColin Finck     _In_ UCHAR SubAuthorityCount
1527c2c66affSColin Finck );
1528c2c66affSColin Finck 
1529c2c66affSColin Finck NTSYSAPI
1530c2c66affSColin Finck ULONG
1531c2c66affSColin Finck NTAPI
1532c2c66affSColin Finck RtlLengthRequiredSid(IN ULONG SubAuthorityCount);
1533c2c66affSColin Finck 
1534c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1535c2c66affSColin Finck NTSYSAPI
1536c2c66affSColin Finck ULONG
1537c2c66affSColin Finck NTAPI
1538c2c66affSColin Finck RtlLengthSecurityDescriptor(
1539c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor);
1540c2c66affSColin Finck 
1541c2c66affSColin Finck NTSYSAPI
1542c2c66affSColin Finck ULONG
1543c2c66affSColin Finck NTAPI
1544c2c66affSColin Finck RtlLengthSid(IN PSID Sid);
1545c2c66affSColin Finck 
1546c2c66affSColin Finck NTSYSAPI
1547c2c66affSColin Finck NTSTATUS
1548c2c66affSColin Finck NTAPI
1549c2c66affSColin Finck RtlMakeSelfRelativeSD(
1550c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR AbsoluteSD,
1551c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1552c2c66affSColin Finck     _Inout_ PULONG BufferLength);
1553c2c66affSColin Finck 
1554c2c66affSColin Finck NTSYSAPI
1555c2c66affSColin Finck VOID
1556c2c66affSColin Finck NTAPI
1557c2c66affSColin Finck RtlMapGenericMask(
1558c2c66affSColin Finck     PACCESS_MASK AccessMask,
1559c2c66affSColin Finck     PGENERIC_MAPPING GenericMapping
1560c2c66affSColin Finck );
1561c2c66affSColin Finck 
1562c2c66affSColin Finck #ifdef NTOS_MODE_USER
1563c2c66affSColin Finck 
1564c2c66affSColin Finck NTSYSAPI
1565c2c66affSColin Finck NTSTATUS
1566c2c66affSColin Finck NTAPI
1567c2c66affSColin Finck RtlQueryInformationAcl(
1568c2c66affSColin Finck     PACL Acl,
1569c2c66affSColin Finck     PVOID Information,
1570c2c66affSColin Finck     ULONG InformationLength,
1571c2c66affSColin Finck     ACL_INFORMATION_CLASS InformationClass
1572c2c66affSColin Finck );
1573c2c66affSColin Finck 
1574c2c66affSColin Finck #endif
1575c2c66affSColin Finck 
1576c2c66affSColin Finck NTSYSAPI
1577c2c66affSColin Finck VOID
1578c2c66affSColin Finck NTAPI
1579c2c66affSColin Finck RtlReleasePrivilege(
1580c2c66affSColin Finck     _In_ PVOID ReturnedState
1581c2c66affSColin Finck );
1582c2c66affSColin Finck 
1583badd9704SRatin Gao #if (NTDDI_VERSION >= NTDDI_VISTA)
1584badd9704SRatin Gao 
1585badd9704SRatin Gao NTSYSAPI
1586badd9704SRatin Gao NTSTATUS
1587badd9704SRatin Gao NTAPI
1588badd9704SRatin Gao RtlRemovePrivileges(
1589badd9704SRatin Gao     _In_ HANDLE TokenHandle,
1590badd9704SRatin Gao     _In_reads_opt_(PrivilegeCount) _When_(PrivilegeCount != 0, _Notnull_)
1591badd9704SRatin Gao          PULONG PrivilegesToKeep,
1592badd9704SRatin Gao     _In_ ULONG PrivilegeCount
1593badd9704SRatin Gao );
1594badd9704SRatin Gao 
1595badd9704SRatin Gao #endif /* (NTDDI_VERSION >= NTDDI_VISTA) */
1596badd9704SRatin Gao 
1597c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1598c2c66affSColin Finck NTSYSAPI
1599c2c66affSColin Finck NTSTATUS
1600c2c66affSColin Finck NTAPI
1601c2c66affSColin Finck RtlSelfRelativeToAbsoluteSD(
1602c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
1603c2c66affSColin Finck     _Out_writes_bytes_to_opt_(*AbsoluteSecurityDescriptorSize, *AbsoluteSecurityDescriptorSize) PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
1604c2c66affSColin Finck     _Inout_ PULONG AbsoluteSecurityDescriptorSize,
1605c2c66affSColin Finck     _Out_writes_bytes_to_opt_(*DaclSize, *DaclSize) PACL Dacl,
1606c2c66affSColin Finck     _Inout_ PULONG DaclSize,
1607c2c66affSColin Finck     _Out_writes_bytes_to_opt_(*SaclSize, *SaclSize) PACL Sacl,
1608c2c66affSColin Finck     _Inout_ PULONG SaclSize,
1609c2c66affSColin Finck     _Out_writes_bytes_to_opt_(*OwnerSize, *OwnerSize) PSID Owner,
1610c2c66affSColin Finck     _Inout_ PULONG OwnerSize,
1611c2c66affSColin Finck     _Out_writes_bytes_to_opt_(*PrimaryGroupSize, *PrimaryGroupSize) PSID PrimaryGroup,
1612c2c66affSColin Finck     _Inout_ PULONG PrimaryGroupSize
1613c2c66affSColin Finck );
1614c2c66affSColin Finck 
1615c2c66affSColin Finck NTSYSAPI
1616c2c66affSColin Finck NTSTATUS
1617c2c66affSColin Finck NTAPI
1618c2c66affSColin Finck RtlSelfRelativeToAbsoluteSD2(
1619c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SelfRelativeSD,
1620c2c66affSColin Finck     _Out_ PULONG BufferSize
1621c2c66affSColin Finck );
1622c2c66affSColin Finck 
1623c2c66affSColin Finck NTSYSAPI
1624c2c66affSColin Finck NTSTATUS
1625c2c66affSColin Finck NTAPI
1626c2c66affSColin Finck RtlSetAttributesSecurityDescriptor(
1627c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1628c2c66affSColin Finck     _In_ SECURITY_DESCRIPTOR_CONTROL Control,
1629c2c66affSColin Finck     _Out_ PULONG Revision
1630c2c66affSColin Finck );
1631c2c66affSColin Finck 
1632c2c66affSColin Finck NTSYSAPI
1633c2c66affSColin Finck NTSTATUS
1634c2c66affSColin Finck NTAPI
1635c2c66affSColin Finck RtlSetControlSecurityDescriptor(
1636c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1637c2c66affSColin Finck     _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
1638c2c66affSColin Finck     _In_ SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
1639c2c66affSColin Finck );
1640c2c66affSColin Finck 
1641c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1642c2c66affSColin Finck NTSYSAPI
1643c2c66affSColin Finck NTSTATUS
1644c2c66affSColin Finck NTAPI
1645c2c66affSColin Finck RtlSetDaclSecurityDescriptor(
1646c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1647c2c66affSColin Finck     _In_ BOOLEAN DaclPresent,
1648c2c66affSColin Finck     _In_opt_ PACL Dacl,
1649c2c66affSColin Finck     _In_opt_ BOOLEAN DaclDefaulted
1650c2c66affSColin Finck );
1651c2c66affSColin Finck 
1652c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1653c2c66affSColin Finck NTSYSAPI
1654c2c66affSColin Finck NTSTATUS
1655c2c66affSColin Finck NTAPI
1656c2c66affSColin Finck RtlSetGroupSecurityDescriptor(
1657c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1658c2c66affSColin Finck     _In_opt_ PSID Group,
1659c2c66affSColin Finck     _In_opt_ BOOLEAN GroupDefaulted
1660c2c66affSColin Finck );
1661c2c66affSColin Finck 
1662c2c66affSColin Finck #ifdef NTOS_MODE_USER
1663c2c66affSColin Finck 
1664c2c66affSColin Finck NTSYSAPI
1665c2c66affSColin Finck NTSTATUS
1666c2c66affSColin Finck NTAPI
1667c2c66affSColin Finck RtlSetInformationAcl(
1668c2c66affSColin Finck     PACL Acl,
1669c2c66affSColin Finck     PVOID Information,
1670c2c66affSColin Finck     ULONG InformationLength,
1671c2c66affSColin Finck     ACL_INFORMATION_CLASS InformationClass
1672c2c66affSColin Finck );
1673c2c66affSColin Finck 
1674c2c66affSColin Finck #endif
1675c2c66affSColin Finck 
1676c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1677c2c66affSColin Finck NTSYSAPI
1678c2c66affSColin Finck NTSTATUS
1679c2c66affSColin Finck NTAPI
1680c2c66affSColin Finck RtlSetOwnerSecurityDescriptor(
1681c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1682c2c66affSColin Finck     _In_opt_ PSID Owner,
1683c2c66affSColin Finck     _In_opt_ BOOLEAN OwnerDefaulted
1684c2c66affSColin Finck );
1685c2c66affSColin Finck 
1686c2c66affSColin Finck NTSYSAPI
1687c2c66affSColin Finck NTSTATUS
1688c2c66affSColin Finck NTAPI
1689c2c66affSColin Finck RtlSetSaclSecurityDescriptor(
1690c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1691c2c66affSColin Finck     _In_ BOOLEAN SaclPresent,
1692c2c66affSColin Finck     _In_ PACL Sacl,
1693c2c66affSColin Finck     _In_ BOOLEAN SaclDefaulted
1694c2c66affSColin Finck );
1695c2c66affSColin Finck 
1696c2c66affSColin Finck NTSYSAPI
1697c2c66affSColin Finck VOID
1698c2c66affSColin Finck NTAPI
1699c2c66affSColin Finck RtlSetSecurityDescriptorRMControl(
1700c2c66affSColin Finck     _Inout_ PSECURITY_DESCRIPTOR SecurityDescriptor,
1701c2c66affSColin Finck     _In_ PUCHAR RMControl
1702c2c66affSColin Finck );
1703c2c66affSColin Finck 
1704c2c66affSColin Finck NTSYSAPI
1705c2c66affSColin Finck PUCHAR
1706c2c66affSColin Finck NTAPI
1707c2c66affSColin Finck RtlSubAuthorityCountSid(
1708c2c66affSColin Finck     _In_ PSID Sid
1709c2c66affSColin Finck );
1710c2c66affSColin Finck 
1711c2c66affSColin Finck NTSYSAPI
1712c2c66affSColin Finck PULONG
1713c2c66affSColin Finck NTAPI
1714c2c66affSColin Finck RtlSubAuthoritySid(
1715c2c66affSColin Finck     _In_ PSID Sid,
1716c2c66affSColin Finck     _In_ ULONG SubAuthority
1717c2c66affSColin Finck );
1718c2c66affSColin Finck 
1719c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
1720c2c66affSColin Finck _Must_inspect_result_
1721c2c66affSColin Finck NTSYSAPI
1722c2c66affSColin Finck BOOLEAN
1723c2c66affSColin Finck NTAPI
1724c2c66affSColin Finck RtlValidRelativeSecurityDescriptor(
1725c2c66affSColin Finck     _In_reads_bytes_(SecurityDescriptorLength) PSECURITY_DESCRIPTOR SecurityDescriptorInput,
1726c2c66affSColin Finck     _In_ ULONG SecurityDescriptorLength,
1727c2c66affSColin Finck     _In_ SECURITY_INFORMATION RequiredInformation
1728c2c66affSColin Finck );
1729c2c66affSColin Finck 
1730c2c66affSColin Finck NTSYSAPI
1731c2c66affSColin Finck BOOLEAN
1732c2c66affSColin Finck NTAPI
1733c2c66affSColin Finck RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
1734c2c66affSColin Finck 
1735c2c66affSColin Finck NTSYSAPI
1736c2c66affSColin Finck BOOLEAN
1737c2c66affSColin Finck NTAPI
1738c2c66affSColin Finck RtlValidSid(IN PSID Sid);
1739c2c66affSColin Finck 
1740c2c66affSColin Finck NTSYSAPI
1741c2c66affSColin Finck BOOLEAN
1742c2c66affSColin Finck NTAPI
1743c2c66affSColin Finck RtlValidAcl(PACL Acl);
1744c2c66affSColin Finck 
1745c2c66affSColin Finck NTSYSAPI
1746c2c66affSColin Finck NTSTATUS
1747c2c66affSColin Finck NTAPI
1748c2c66affSColin Finck RtlDeleteSecurityObject(
1749c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR *ObjectDescriptor
1750c2c66affSColin Finck );
1751c2c66affSColin Finck 
1752c2c66affSColin Finck NTSYSAPI
1753c2c66affSColin Finck NTSTATUS
1754c2c66affSColin Finck NTAPI
1755c2c66affSColin Finck RtlNewSecurityObject(
1756c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR ParentDescriptor,
1757c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR CreatorDescriptor,
1758c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR *NewDescriptor,
1759c2c66affSColin Finck     _In_ BOOLEAN IsDirectoryObject,
1760c2c66affSColin Finck     _In_ HANDLE Token,
1761c2c66affSColin Finck     _In_ PGENERIC_MAPPING GenericMapping
1762c2c66affSColin Finck );
1763c2c66affSColin Finck 
1764c2c66affSColin Finck NTSYSAPI
1765c2c66affSColin Finck NTSTATUS
1766c2c66affSColin Finck NTAPI
1767c2c66affSColin Finck RtlQuerySecurityObject(
1768c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR ObjectDescriptor,
1769c2c66affSColin Finck     _In_ SECURITY_INFORMATION SecurityInformation,
1770c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR ResultantDescriptor,
1771c2c66affSColin Finck     _In_ ULONG DescriptorLength,
1772c2c66affSColin Finck     _Out_ PULONG ReturnLength
1773c2c66affSColin Finck );
1774c2c66affSColin Finck 
1775c2c66affSColin Finck NTSYSAPI
1776c2c66affSColin Finck NTSTATUS
1777c2c66affSColin Finck NTAPI
1778c2c66affSColin Finck RtlSetSecurityObject(
1779c2c66affSColin Finck     _In_ SECURITY_INFORMATION SecurityInformation,
1780c2c66affSColin Finck     _In_ PSECURITY_DESCRIPTOR ModificationDescriptor,
1781c2c66affSColin Finck     _Out_ PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
1782c2c66affSColin Finck     _In_ PGENERIC_MAPPING GenericMapping,
1783c2c66affSColin Finck     _In_ HANDLE Token
1784c2c66affSColin Finck );
1785c2c66affSColin Finck 
1786c2c66affSColin Finck //
1787c2c66affSColin Finck // Single-Character Functions
1788c2c66affSColin Finck //
1789c2c66affSColin Finck NTSYSAPI
1790c2c66affSColin Finck NTSTATUS
1791c2c66affSColin Finck NTAPI
1792c2c66affSColin Finck RtlLargeIntegerToChar(
1793c2c66affSColin Finck     _In_ PLARGE_INTEGER Value,
1794c2c66affSColin Finck     _In_ ULONG Base,
1795c2c66affSColin Finck     _In_ ULONG Length,
1796c2c66affSColin Finck     _Out_ PCHAR String
1797c2c66affSColin Finck );
1798c2c66affSColin Finck 
1799c2c66affSColin Finck NTSYSAPI
1800c2c66affSColin Finck CHAR
1801c2c66affSColin Finck NTAPI
1802c2c66affSColin Finck RtlUpperChar(CHAR Source);
1803c2c66affSColin Finck 
1804c2c66affSColin Finck NTSYSAPI
1805c2c66affSColin Finck WCHAR
1806c2c66affSColin Finck NTAPI
1807c2c66affSColin Finck RtlUpcaseUnicodeChar(WCHAR Source);
1808c2c66affSColin Finck 
1809c2c66affSColin Finck NTSYSAPI
1810c2c66affSColin Finck WCHAR
1811c2c66affSColin Finck NTAPI
1812c2c66affSColin Finck RtlDowncaseUnicodeChar(IN WCHAR Source);
1813c2c66affSColin Finck 
1814c2c66affSColin Finck NTSYSAPI
1815c2c66affSColin Finck NTSTATUS
1816c2c66affSColin Finck NTAPI
1817c2c66affSColin Finck RtlIntegerToChar(
1818c2c66affSColin Finck     _In_ ULONG Value,
1819c2c66affSColin Finck     _In_ ULONG Base,
1820c2c66affSColin Finck     _In_ ULONG Length,
1821c2c66affSColin Finck     _Out_ PCHAR String
1822c2c66affSColin Finck );
1823c2c66affSColin Finck 
1824c2c66affSColin Finck NTSYSAPI
1825c2c66affSColin Finck NTSTATUS
1826c2c66affSColin Finck NTAPI
1827c2c66affSColin Finck RtlIntegerToUnicode(
1828c2c66affSColin Finck     _In_ ULONG Value,
1829c2c66affSColin Finck     _In_opt_ ULONG Base,
1830c2c66affSColin Finck     _In_opt_ ULONG Length,
1831c2c66affSColin Finck     _Inout_ LPWSTR String
1832c2c66affSColin Finck );
1833c2c66affSColin Finck 
1834c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
1835c2c66affSColin Finck _At_(String->MaximumLength, _Const_)
1836c2c66affSColin Finck NTSYSAPI
1837c2c66affSColin Finck NTSTATUS
1838c2c66affSColin Finck NTAPI
1839c2c66affSColin Finck RtlIntegerToUnicodeString(
1840c2c66affSColin Finck     _In_ ULONG Value,
1841c2c66affSColin Finck     _In_opt_ ULONG Base,
1842c2c66affSColin Finck     _Inout_ PUNICODE_STRING String
1843c2c66affSColin Finck );
1844c2c66affSColin Finck 
1845c2c66affSColin Finck NTSYSAPI
1846c2c66affSColin Finck NTSTATUS
1847c2c66affSColin Finck NTAPI
1848c2c66affSColin Finck RtlCharToInteger(
1849c2c66affSColin Finck     PCSZ String,
1850c2c66affSColin Finck     ULONG Base,
1851c2c66affSColin Finck     PULONG Value
1852c2c66affSColin Finck );
1853c2c66affSColin Finck 
1854c2c66affSColin Finck //
1855c2c66affSColin Finck // Byte Swap Functions
1856c2c66affSColin Finck //
1857c2c66affSColin Finck #ifdef NTOS_MODE_USER
1858c2c66affSColin Finck 
1859c2c66affSColin Finck unsigned short __cdecl _byteswap_ushort(unsigned short);
1860c2c66affSColin Finck unsigned long  __cdecl _byteswap_ulong (unsigned long);
1861c2c66affSColin Finck unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
1862c2c66affSColin Finck #ifdef _MSC_VER
1863c2c66affSColin Finck #pragma intrinsic(_byteswap_ushort)
1864c2c66affSColin Finck #pragma intrinsic(_byteswap_ulong)
1865c2c66affSColin Finck #pragma intrinsic(_byteswap_uint64)
1866c2c66affSColin Finck #endif // _MSC_VER
1867c2c66affSColin Finck #define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
1868c2c66affSColin Finck #define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
1869c2c66affSColin Finck #define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
1870c2c66affSColin Finck 
1871c2c66affSColin Finck #endif // NTOS_MODE_USER
1872c2c66affSColin Finck 
1873c2c66affSColin Finck //
1874c2c66affSColin Finck // Unicode->Ansi String Functions
1875c2c66affSColin Finck //
1876c2c66affSColin Finck NTSYSAPI
1877c2c66affSColin Finck ULONG
1878c2c66affSColin Finck NTAPI
1879c2c66affSColin Finck RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString);
1880c2c66affSColin Finck 
1881c2c66affSColin Finck #ifdef NTOS_MODE_USER
1882c2c66affSColin Finck 
1883c2c66affSColin Finck #define RtlUnicodeStringToAnsiSize(STRING) (                  \
1884c2c66affSColin Finck     NLS_MB_CODE_PAGE_TAG ?                                    \
1885c2c66affSColin Finck     RtlxUnicodeStringToAnsiSize(STRING) :                     \
1886c2c66affSColin Finck     ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
1887c2c66affSColin Finck )
1888c2c66affSColin Finck 
1889c2c66affSColin Finck #endif
1890c2c66affSColin Finck 
1891c2c66affSColin Finck NTSYSAPI
1892c2c66affSColin Finck NTSTATUS
1893c2c66affSColin Finck NTAPI
1894c2c66affSColin Finck RtlUnicodeStringToAnsiString(
1895c2c66affSColin Finck     PANSI_STRING DestinationString,
1896c2c66affSColin Finck     PCUNICODE_STRING SourceString,
1897c2c66affSColin Finck     BOOLEAN AllocateDestinationString
1898c2c66affSColin Finck );
1899c2c66affSColin Finck 
1900c2c66affSColin Finck //
1901c2c66affSColin Finck // Unicode->OEM String Functions
1902c2c66affSColin Finck //
1903c2c66affSColin Finck NTSYSAPI
1904c2c66affSColin Finck NTSTATUS
1905c2c66affSColin Finck NTAPI
1906c2c66affSColin Finck RtlUpcaseUnicodeStringToOemString(
1907c2c66affSColin Finck     POEM_STRING DestinationString,
1908c2c66affSColin Finck     PCUNICODE_STRING SourceString,
1909c2c66affSColin Finck     BOOLEAN AllocateDestinationString
1910c2c66affSColin Finck );
1911c2c66affSColin Finck 
1912c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
1913c2c66affSColin Finck _Must_inspect_result_
1914c2c66affSColin Finck //_At_(DestinationString->Buffer, _Post_bytecount_(DestinationString->Length))
1915c2c66affSColin Finck NTSYSAPI
1916c2c66affSColin Finck NTSTATUS
1917c2c66affSColin Finck NTAPI
1918c2c66affSColin Finck RtlUpcaseUnicodeStringToCountedOemString(
1919c2c66affSColin Finck     _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
1920c2c66affSColin Finck     _When_(!AllocateDestinationString, _Inout_)
1921c2c66affSColin Finck         POEM_STRING DestinationString,
1922c2c66affSColin Finck     _In_ PCUNICODE_STRING SourceString,
1923c2c66affSColin Finck     _In_ BOOLEAN AllocateDestinationString
1924c2c66affSColin Finck );
1925c2c66affSColin Finck 
1926c2c66affSColin Finck NTSYSAPI
1927c2c66affSColin Finck NTSTATUS
1928c2c66affSColin Finck NTAPI
1929c2c66affSColin Finck RtlUnicodeStringToOemString(
1930c2c66affSColin Finck     POEM_STRING DestinationString,
1931c2c66affSColin Finck     PCUNICODE_STRING SourceString,
1932c2c66affSColin Finck     BOOLEAN AllocateDestinationString
1933c2c66affSColin Finck );
1934c2c66affSColin Finck 
1935a3629ab0SJérôme Gardou _IRQL_requires_max_(PASSIVE_LEVEL)
1936a3629ab0SJérôme Gardou _Must_inspect_result_
1937c2c66affSColin Finck NTSYSAPI
1938c2c66affSColin Finck NTSTATUS
1939c2c66affSColin Finck NTAPI
194053a6c44fSJérôme Gardou RtlUnicodeStringToCountedOemString(
1941a3629ab0SJérôme Gardou     _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
1942a3629ab0SJérôme Gardou     _When_(!AllocateDestinationString, _Inout_)
1943a3629ab0SJérôme Gardou         POEM_STRING DestinationString,
1944a3629ab0SJérôme Gardou     _In_ PCUNICODE_STRING SourceString,
1945a3629ab0SJérôme Gardou     _In_ BOOLEAN AllocateDestinationString
1946a3629ab0SJérôme Gardou );
194753a6c44fSJérôme Gardou 
194853a6c44fSJérôme Gardou NTSYSAPI
194953a6c44fSJérôme Gardou NTSTATUS
195053a6c44fSJérôme Gardou NTAPI
1951c2c66affSColin Finck RtlUpcaseUnicodeToOemN(
1952c2c66affSColin Finck     PCHAR OemString,
1953c2c66affSColin Finck     ULONG OemSize,
1954c2c66affSColin Finck     PULONG ResultSize,
1955c2c66affSColin Finck     PCWCH UnicodeString,
1956c2c66affSColin Finck     ULONG UnicodeSize
1957c2c66affSColin Finck );
1958c2c66affSColin Finck 
1959c2c66affSColin Finck NTSYSAPI
1960c2c66affSColin Finck ULONG
1961c2c66affSColin Finck NTAPI
1962c2c66affSColin Finck RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString);
1963c2c66affSColin Finck 
1964c2c66affSColin Finck #ifdef NTOS_MODE_USER
1965c2c66affSColin Finck 
1966c2c66affSColin Finck #define RtlUnicodeStringToOemSize(STRING) (                             \
1967c2c66affSColin Finck     NLS_MB_OEM_CODE_PAGE_TAG ?                                          \
1968c2c66affSColin Finck     RtlxUnicodeStringToOemSize(STRING) :                                \
1969c2c66affSColin Finck     ((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR)           \
1970c2c66affSColin Finck )
1971c2c66affSColin Finck 
1972c2c66affSColin Finck #define RtlUnicodeStringToCountedOemSize(STRING) (                      \
1973c2c66affSColin Finck     (ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL))      \
1974c2c66affSColin Finck )
1975c2c66affSColin Finck 
1976c2c66affSColin Finck #endif
1977c2c66affSColin Finck 
1978c2c66affSColin Finck NTSYSAPI
1979c2c66affSColin Finck NTSTATUS
1980c2c66affSColin Finck NTAPI
1981c2c66affSColin Finck RtlUnicodeToOemN(
1982c2c66affSColin Finck     PCHAR OemString,
1983c2c66affSColin Finck     ULONG OemSize,
1984c2c66affSColin Finck     PULONG ResultSize,
1985c2c66affSColin Finck     PCWCH UnicodeString,
1986c2c66affSColin Finck     ULONG UnicodeSize
1987c2c66affSColin Finck );
1988c2c66affSColin Finck 
1989c2c66affSColin Finck //
1990c2c66affSColin Finck // Unicode->MultiByte String Functions
1991c2c66affSColin Finck //
1992c2c66affSColin Finck NTSYSAPI
1993c2c66affSColin Finck NTSTATUS
1994c2c66affSColin Finck NTAPI
1995c2c66affSColin Finck RtlUnicodeToMultiByteN(
1996c2c66affSColin Finck     PCHAR MbString,
1997c2c66affSColin Finck     ULONG MbSize,
1998c2c66affSColin Finck     PULONG ResultSize,
1999c2c66affSColin Finck     PCWCH UnicodeString,
2000c2c66affSColin Finck     ULONG UnicodeSize
2001c2c66affSColin Finck );
2002c2c66affSColin Finck 
2003c2c66affSColin Finck NTSYSAPI
2004c2c66affSColin Finck NTSTATUS
2005c2c66affSColin Finck NTAPI
2006c2c66affSColin Finck RtlUpcaseUnicodeToMultiByteN(
2007c2c66affSColin Finck     PCHAR MbString,
2008c2c66affSColin Finck     ULONG MbSize,
2009c2c66affSColin Finck     PULONG ResultSize,
2010c2c66affSColin Finck     PCWCH UnicodeString,
2011c2c66affSColin Finck     ULONG UnicodeSize
2012c2c66affSColin Finck );
2013c2c66affSColin Finck 
2014c2c66affSColin Finck NTSYSAPI
2015c2c66affSColin Finck NTSTATUS
2016c2c66affSColin Finck NTAPI
2017c2c66affSColin Finck RtlUnicodeToMultiByteSize(
2018c2c66affSColin Finck     PULONG MbSize,
2019c2c66affSColin Finck     PCWCH UnicodeString,
2020c2c66affSColin Finck     ULONG UnicodeSize
2021c2c66affSColin Finck );
2022c2c66affSColin Finck 
2023c2c66affSColin Finck NTSYSAPI
2024c2c66affSColin Finck ULONG
2025c2c66affSColin Finck NTAPI
2026c2c66affSColin Finck RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString);
2027c2c66affSColin Finck 
2028c2c66affSColin Finck //
2029c2c66affSColin Finck // OEM to Unicode Functions
2030c2c66affSColin Finck //
2031c2c66affSColin Finck NTSYSAPI
2032c2c66affSColin Finck NTSTATUS
2033c2c66affSColin Finck NTAPI
2034c2c66affSColin Finck RtlOemStringToUnicodeString(
2035c2c66affSColin Finck     PUNICODE_STRING DestinationString,
2036c2c66affSColin Finck     PCOEM_STRING SourceString,
2037c2c66affSColin Finck     BOOLEAN AllocateDestinationString
2038c2c66affSColin Finck );
2039c2c66affSColin Finck 
2040c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2041c2c66affSColin Finck NTSYSAPI
2042c2c66affSColin Finck NTSTATUS
2043c2c66affSColin Finck NTAPI
2044c2c66affSColin Finck RtlOemToUnicodeN(
2045c2c66affSColin Finck     _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
2046c2c66affSColin Finck     _In_ ULONG MaxBytesInUnicodeString,
2047c2c66affSColin Finck     _Out_opt_ PULONG BytesInUnicodeString,
2048c2c66affSColin Finck     _In_reads_bytes_(BytesInOemString) PCCH OemString,
2049c2c66affSColin Finck     _In_ ULONG BytesInOemString
2050c2c66affSColin Finck );
2051c2c66affSColin Finck 
2052c2c66affSColin Finck #ifdef NTOS_MODE_USER
2053c2c66affSColin Finck 
2054c2c66affSColin Finck #define RtlOemStringToUnicodeSize(STRING) (                             \
2055c2c66affSColin Finck     NLS_MB_OEM_CODE_PAGE_TAG ?                                          \
2056c2c66affSColin Finck     RtlxOemStringToUnicodeSize(STRING) :                                \
2057c2c66affSColin Finck     ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)              \
2058c2c66affSColin Finck )
2059c2c66affSColin Finck 
2060c2c66affSColin Finck #define RtlOemStringToCountedUnicodeSize(STRING) (                      \
2061c2c66affSColin Finck     (ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL))   \
2062c2c66affSColin Finck )
2063c2c66affSColin Finck 
2064c2c66affSColin Finck #endif
2065c2c66affSColin Finck 
2066c2c66affSColin Finck //
2067c2c66affSColin Finck // Ansi->Unicode String Functions
2068c2c66affSColin Finck //
2069c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
2070c2c66affSColin Finck NTSYSAPI
2071c2c66affSColin Finck WCHAR
2072c2c66affSColin Finck NTAPI
2073c2c66affSColin Finck RtlAnsiCharToUnicodeChar(
2074c2c66affSColin Finck   _Inout_ PUCHAR *SourceCharacter);
2075c2c66affSColin Finck 
2076c2c66affSColin Finck NTSYSAPI
2077c2c66affSColin Finck NTSTATUS
2078c2c66affSColin Finck NTAPI
2079c2c66affSColin Finck RtlAnsiStringToUnicodeString(
2080c2c66affSColin Finck     PUNICODE_STRING DestinationString,
2081c2c66affSColin Finck     PCANSI_STRING SourceString,
2082c2c66affSColin Finck     BOOLEAN AllocateDestinationString
2083c2c66affSColin Finck );
2084c2c66affSColin Finck 
2085c2c66affSColin Finck NTSYSAPI
2086c2c66affSColin Finck ULONG
2087c2c66affSColin Finck NTAPI
2088c2c66affSColin Finck RtlxAnsiStringToUnicodeSize(
2089c2c66affSColin Finck     PCANSI_STRING AnsiString
2090c2c66affSColin Finck );
2091c2c66affSColin Finck 
2092c2c66affSColin Finck #ifdef NTOS_MODE_USER
2093c2c66affSColin Finck 
2094c2c66affSColin Finck #define RtlAnsiStringToUnicodeSize(STRING) (                        \
2095c2c66affSColin Finck     NLS_MB_CODE_PAGE_TAG ?                                          \
2096c2c66affSColin Finck     RtlxAnsiStringToUnicodeSize(STRING) :                           \
2097c2c66affSColin Finck     ((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR)          \
2098c2c66affSColin Finck )
2099c2c66affSColin Finck 
2100c2c66affSColin Finck #endif
2101c2c66affSColin Finck 
2102c2c66affSColin Finck NTSYSAPI
2103c2c66affSColin Finck BOOLEAN
2104c2c66affSColin Finck NTAPI
2105c2c66affSColin Finck RtlCreateUnicodeStringFromAsciiz(
2106c2c66affSColin Finck     _Out_ PUNICODE_STRING Destination,
2107c2c66affSColin Finck     _In_ PCSZ Source
2108c2c66affSColin Finck );
2109c2c66affSColin Finck 
2110c2c66affSColin Finck //
2111c2c66affSColin Finck // Unicode String Functions
2112c2c66affSColin Finck //
2113c2c66affSColin Finck NTSYSAPI
2114c2c66affSColin Finck NTSTATUS
2115c2c66affSColin Finck NTAPI
2116c2c66affSColin Finck RtlAppendUnicodeToString(
2117c2c66affSColin Finck     PUNICODE_STRING Destination,
2118c2c66affSColin Finck     PCWSTR Source
2119c2c66affSColin Finck );
2120c2c66affSColin Finck 
2121c2c66affSColin Finck NTSYSAPI
2122c2c66affSColin Finck NTSTATUS
2123c2c66affSColin Finck NTAPI
2124c2c66affSColin Finck RtlAppendUnicodeStringToString(
2125c2c66affSColin Finck     PUNICODE_STRING Destination,
2126c2c66affSColin Finck     PCUNICODE_STRING Source
2127c2c66affSColin Finck );
2128c2c66affSColin Finck 
2129c2c66affSColin Finck NTSYSAPI
2130c2c66affSColin Finck LONG
2131c2c66affSColin Finck NTAPI
2132c2c66affSColin Finck RtlCompareUnicodeString(
2133c2c66affSColin Finck     PCUNICODE_STRING String1,
2134c2c66affSColin Finck     PCUNICODE_STRING String2,
2135c2c66affSColin Finck     BOOLEAN CaseInsensitive
2136c2c66affSColin Finck );
2137c2c66affSColin Finck 
21383a0b5338STimo Kreuzer _Must_inspect_result_
21393a0b5338STimo Kreuzer NTSYSAPI
21403a0b5338STimo Kreuzer LONG
21413a0b5338STimo Kreuzer NTAPI
21423a0b5338STimo Kreuzer RtlCompareUnicodeStrings(
21433a0b5338STimo Kreuzer     _In_reads_(String1Length) PCWCH String1,
21443a0b5338STimo Kreuzer     _In_ SIZE_T String1Length,
21453a0b5338STimo Kreuzer     _In_reads_(String2Length) PCWCH String2,
21463a0b5338STimo Kreuzer     _In_ SIZE_T String2Length,
21473a0b5338STimo Kreuzer     _In_ BOOLEAN CaseInSensitive
21483a0b5338STimo Kreuzer );
21493a0b5338STimo Kreuzer 
2150c2c66affSColin Finck NTSYSAPI
2151c2c66affSColin Finck VOID
2152c2c66affSColin Finck NTAPI
2153c2c66affSColin Finck RtlCopyUnicodeString(
2154c2c66affSColin Finck     PUNICODE_STRING DestinationString,
2155c2c66affSColin Finck     PCUNICODE_STRING SourceString
2156c2c66affSColin Finck );
2157c2c66affSColin Finck 
2158c2c66affSColin Finck NTSYSAPI
2159c2c66affSColin Finck BOOLEAN
2160c2c66affSColin Finck NTAPI
2161c2c66affSColin Finck RtlCreateUnicodeString(
2162c2c66affSColin Finck     PUNICODE_STRING DestinationString,
2163c2c66affSColin Finck     PCWSTR SourceString
2164c2c66affSColin Finck );
2165c2c66affSColin Finck 
2166c2c66affSColin Finck #ifdef NTOS_MODE_USER
2167c2c66affSColin Finck 
2168c2c66affSColin Finck NTSYSAPI
2169c2c66affSColin Finck NTSTATUS
2170c2c66affSColin Finck NTAPI
2171c2c66affSColin Finck RtlDowncaseUnicodeString(
2172c2c66affSColin Finck     _Inout_ PUNICODE_STRING UniDest,
2173c2c66affSColin Finck     _In_ PCUNICODE_STRING UniSource,
2174c2c66affSColin Finck     _In_ BOOLEAN AllocateDestinationString
2175c2c66affSColin Finck );
2176c2c66affSColin Finck 
2177c2c66affSColin Finck NTSYSAPI
2178c2c66affSColin Finck NTSTATUS
2179c2c66affSColin Finck NTAPI
2180c2c66affSColin Finck RtlDuplicateUnicodeString(
2181c2c66affSColin Finck     _In_ ULONG Flags,
2182c2c66affSColin Finck     _In_ PCUNICODE_STRING SourceString,
2183c2c66affSColin Finck     _Out_ PUNICODE_STRING DestinationString
2184c2c66affSColin Finck );
2185c2c66affSColin Finck 
218605351046SThomas Faber NTSYSAPI
218705351046SThomas Faber NTSTATUS
218805351046SThomas Faber NTAPI
218905351046SThomas Faber RtlFindCharInUnicodeString(
219005351046SThomas Faber     _In_ ULONG Flags,
219105351046SThomas Faber     _In_ PCUNICODE_STRING SearchString,
219205351046SThomas Faber     _In_ PCUNICODE_STRING MatchString,
219305351046SThomas Faber     _Out_ PUSHORT Position
219405351046SThomas Faber );
219505351046SThomas Faber 
2196c2c66affSColin Finck //
2197c2c66affSColin Finck // Memory Functions
2198c2c66affSColin Finck //
2199fb0ebac3STimo Kreuzer #if defined(_M_AMD64)
2200fb0ebac3STimo Kreuzer 
2201fb0ebac3STimo Kreuzer FORCEINLINE
2202fb0ebac3STimo Kreuzer VOID
RtlFillMemoryUlong(_Out_writes_bytes_all_ (Length)PVOID Destination,_In_ SIZE_T Length,_In_ ULONG Pattern)2203fb0ebac3STimo Kreuzer RtlFillMemoryUlong(
2204fb0ebac3STimo Kreuzer     _Out_writes_bytes_all_(Length) PVOID Destination,
2205fb0ebac3STimo Kreuzer     _In_ SIZE_T Length,
2206fb0ebac3STimo Kreuzer     _In_ ULONG Pattern)
2207fb0ebac3STimo Kreuzer {
2208fb0ebac3STimo Kreuzer     PULONG Address = (PULONG)Destination;
2209fb0ebac3STimo Kreuzer     if ((Length /= 4) != 0) {
2210fb0ebac3STimo Kreuzer         if (((ULONG64)Address & 4) != 0) {
2211fb0ebac3STimo Kreuzer             *Address = Pattern;
2212fb0ebac3STimo Kreuzer             if ((Length -= 1) == 0) {
2213fb0ebac3STimo Kreuzer                 return;
2214fb0ebac3STimo Kreuzer             }
2215fb0ebac3STimo Kreuzer             Address += 1;
2216fb0ebac3STimo Kreuzer         }
2217fb0ebac3STimo Kreuzer         __stosq((PULONG64)(Address), Pattern | ((ULONG64)Pattern << 32), Length / 2);
2218fb0ebac3STimo Kreuzer         if ((Length & 1) != 0) Address[Length - 1] = Pattern;
2219fb0ebac3STimo Kreuzer     }
2220fb0ebac3STimo Kreuzer     return;
2221fb0ebac3STimo Kreuzer }
2222fb0ebac3STimo Kreuzer 
2223fb0ebac3STimo Kreuzer #define RtlFillMemoryUlonglong(Destination, Length, Pattern)                \
2224fb0ebac3STimo Kreuzer     __stosq((PULONG64)(Destination), Pattern, (Length) / 8)
2225fb0ebac3STimo Kreuzer 
2226fb0ebac3STimo Kreuzer #else
2227fb0ebac3STimo Kreuzer 
2228c2c66affSColin Finck NTSYSAPI
2229c2c66affSColin Finck VOID
2230c2c66affSColin Finck NTAPI
2231c2c66affSColin Finck RtlFillMemoryUlong(
2232fb0ebac3STimo Kreuzer     _Out_writes_bytes_all_(Length) PVOID Destination,
2233c2c66affSColin Finck     _In_ SIZE_T Length,
2234fb0ebac3STimo Kreuzer     _In_ ULONG Pattern
2235c2c66affSColin Finck );
2236c2c66affSColin Finck 
2237c2c66affSColin Finck NTSYSAPI
2238c2c66affSColin Finck VOID
2239c2c66affSColin Finck NTAPI
2240c2c66affSColin Finck RtlFillMemoryUlonglong(
2241c2c66affSColin Finck     _Out_ PVOID Destination,
2242c2c66affSColin Finck     _In_ SIZE_T Length,
2243c2c66affSColin Finck     _In_ ULONGLONG Pattern
2244c2c66affSColin Finck );
2245c2c66affSColin Finck 
2246fb0ebac3STimo Kreuzer #endif
2247fb0ebac3STimo Kreuzer 
2248c2c66affSColin Finck NTSYSAPI
2249c2c66affSColin Finck NTSTATUS
2250c2c66affSColin Finck NTAPI
2251c2c66affSColin Finck RtlCopyMappedMemory(
2252c2c66affSColin Finck     _Out_writes_bytes_all_(Size) PVOID Destination,
2253c2c66affSColin Finck     _In_reads_bytes_(Size) const VOID *Source,
2254c2c66affSColin Finck     _In_ SIZE_T Size
2255c2c66affSColin Finck );
2256c2c66affSColin Finck 
2257c2c66affSColin Finck NTSYSAPI
2258c2c66affSColin Finck SIZE_T
2259c2c66affSColin Finck NTAPI
2260c2c66affSColin Finck RtlCompareMemoryUlong(
2261c2c66affSColin Finck     _In_ PVOID Source,
2262c2c66affSColin Finck     _In_ SIZE_T Length,
2263c2c66affSColin Finck     _In_ ULONG Pattern
2264c2c66affSColin Finck );
2265c2c66affSColin Finck 
2266c2c66affSColin Finck #ifndef RtlEqualMemory
2267c2c66affSColin Finck #define RtlEqualMemory(Destination, Source, Length) \
2268c2c66affSColin Finck     (!memcmp(Destination, Source, Length))
2269c2c66affSColin Finck #endif
2270c2c66affSColin Finck 
2271c2c66affSColin Finck #define RtlCopyBytes RtlCopyMemory
2272c2c66affSColin Finck #define RtlFillBytes RtlFillMemory
2273c2c66affSColin Finck #define RtlZeroBytes RtlZeroMemory
2274c2c66affSColin Finck 
2275c2c66affSColin Finck #endif
2276c2c66affSColin Finck 
2277c2c66affSColin Finck NTSYSAPI
2278c2c66affSColin Finck BOOLEAN
2279c2c66affSColin Finck NTAPI
2280c2c66affSColin Finck RtlEqualUnicodeString(
2281c2c66affSColin Finck     PCUNICODE_STRING String1,
2282c2c66affSColin Finck     PCUNICODE_STRING String2,
2283c2c66affSColin Finck     BOOLEAN CaseInsensitive
2284c2c66affSColin Finck );
2285c2c66affSColin Finck 
2286c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2287c2c66affSColin Finck NTSYSAPI
2288c2c66affSColin Finck VOID
2289c2c66affSColin Finck NTAPI
2290c2c66affSColin Finck RtlFreeUnicodeString(
2291c2c66affSColin Finck     _Inout_ _At_(UnicodeString->Buffer, __drv_freesMem(Mem))
2292c2c66affSColin Finck         PUNICODE_STRING UnicodeString
2293c2c66affSColin Finck );
2294c2c66affSColin Finck 
2295c2c66affSColin Finck NTSYSAPI
2296c2c66affSColin Finck VOID
2297c2c66affSColin Finck NTAPI
2298c2c66affSColin Finck RtlEraseUnicodeString(
2299c2c66affSColin Finck     _Inout_ PUNICODE_STRING String
2300c2c66affSColin Finck );
2301c2c66affSColin Finck 
2302c2c66affSColin Finck NTSYSAPI
2303c2c66affSColin Finck NTSTATUS
2304c2c66affSColin Finck NTAPI
2305c2c66affSColin Finck RtlHashUnicodeString(
2306c2c66affSColin Finck     _In_ CONST UNICODE_STRING *String,
2307c2c66affSColin Finck     _In_ BOOLEAN CaseInSensitive,
2308c2c66affSColin Finck     _In_ ULONG HashAlgorithm,
2309c2c66affSColin Finck     _Out_ PULONG HashValue
2310c2c66affSColin Finck );
2311c2c66affSColin Finck 
2312c2c66affSColin Finck _IRQL_requires_max_(DISPATCH_LEVEL)
2313c2c66affSColin Finck _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
2314c2c66affSColin Finck _When_(SourceString != NULL,
2315522821bbSPierre Schweitzer _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString)))
2316522821bbSPierre Schweitzer _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(CHAR))))
2317522821bbSPierre Schweitzer _When_(SourceString == NULL,
2318522821bbSPierre Schweitzer _At_(DestinationString->Length, _Post_equal_to_(0))
2319522821bbSPierre Schweitzer _At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
2320522821bbSPierre Schweitzer NTSYSAPI
2321522821bbSPierre Schweitzer VOID
2322522821bbSPierre Schweitzer NTAPI
2323522821bbSPierre Schweitzer RtlInitString(
2324522821bbSPierre Schweitzer     _Out_ PSTRING DestinationString,
2325522821bbSPierre Schweitzer     _In_opt_z_ __drv_aliasesMem PCSTR SourceString
2326522821bbSPierre Schweitzer );
2327522821bbSPierre Schweitzer 
2328522821bbSPierre Schweitzer _IRQL_requires_max_(DISPATCH_LEVEL)
2329522821bbSPierre Schweitzer _At_(DestinationString->Buffer, _Post_equal_to_(SourceString))
2330522821bbSPierre Schweitzer _When_(SourceString != NULL,
2331c2c66affSColin Finck _At_(DestinationString->Length, _Post_equal_to_(_String_length_(SourceString) * sizeof(WCHAR)))
2332c2c66affSColin Finck _At_(DestinationString->MaximumLength, _Post_equal_to_(DestinationString->Length + sizeof(WCHAR))))
2333c2c66affSColin Finck _When_(SourceString == NULL,
2334c2c66affSColin Finck _At_(DestinationString->Length, _Post_equal_to_(0))
2335c2c66affSColin Finck _At_(DestinationString->MaximumLength, _Post_equal_to_(0)))
2336c2c66affSColin Finck NTSYSAPI
2337c2c66affSColin Finck VOID
2338c2c66affSColin Finck NTAPI
2339c2c66affSColin Finck RtlInitUnicodeString(
2340c2c66affSColin Finck     _Out_ PUNICODE_STRING DestinationString,
2341c2c66affSColin Finck     _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2342c2c66affSColin Finck );
2343c2c66affSColin Finck 
2344c2c66affSColin Finck _IRQL_requires_max_(DISPATCH_LEVEL)
2345c2c66affSColin Finck NTSYSAPI
2346c2c66affSColin Finck NTSTATUS
2347c2c66affSColin Finck NTAPI
2348c2c66affSColin Finck RtlInitUnicodeStringEx(
2349c2c66affSColin Finck     _Out_ PUNICODE_STRING DestinationString,
2350c2c66affSColin Finck     _In_opt_z_ __drv_aliasesMem PCWSTR SourceString
2351c2c66affSColin Finck );
2352c2c66affSColin Finck 
2353c2c66affSColin Finck NTSYSAPI
2354c2c66affSColin Finck BOOLEAN
2355c2c66affSColin Finck NTAPI
2356c2c66affSColin Finck RtlIsTextUnicode(
2357c2c66affSColin Finck     _In_ CONST VOID* Buffer,
2358c2c66affSColin Finck     _In_ INT Size,
2359c2c66affSColin Finck     _Inout_opt_ INT* Flags
2360c2c66affSColin Finck );
2361c2c66affSColin Finck 
2362c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2363c2c66affSColin Finck _Must_inspect_result_
2364c2c66affSColin Finck NTSYSAPI
2365c2c66affSColin Finck BOOLEAN
2366c2c66affSColin Finck NTAPI
2367c2c66affSColin Finck RtlPrefixString(
2368c2c66affSColin Finck     _In_ const STRING *String1,
2369c2c66affSColin Finck     _In_ const STRING *String2,
2370c2c66affSColin Finck     _In_ BOOLEAN CaseInsensitive
2371c2c66affSColin Finck );
2372c2c66affSColin Finck 
2373c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2374c2c66affSColin Finck _Must_inspect_result_
2375c2c66affSColin Finck NTSYSAPI
2376c2c66affSColin Finck BOOLEAN
2377c2c66affSColin Finck NTAPI
2378c2c66affSColin Finck RtlPrefixUnicodeString(
2379c2c66affSColin Finck     _In_ PCUNICODE_STRING String1,
2380c2c66affSColin Finck     _In_ PCUNICODE_STRING String2,
2381c2c66affSColin Finck     _In_ BOOLEAN CaseInsensitive
2382c2c66affSColin Finck );
2383c2c66affSColin Finck 
2384c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2385c2c66affSColin Finck NTSYSAPI
2386c2c66affSColin Finck VOID
2387c2c66affSColin Finck NTAPI
2388c2c66affSColin Finck RtlUpperString(
2389c2c66affSColin Finck     _Inout_ PSTRING DestinationString,
2390c2c66affSColin Finck     _In_ const STRING *SourceString
2391c2c66affSColin Finck );
2392c2c66affSColin Finck 
2393c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2394c2c66affSColin Finck _Must_inspect_result_
2395c2c66affSColin Finck NTSYSAPI
2396c2c66affSColin Finck LONG
2397c2c66affSColin Finck NTAPI
2398c2c66affSColin Finck RtlCompareString(
2399c2c66affSColin Finck     _In_ const STRING *String1,
2400c2c66affSColin Finck     _In_ const STRING *String2,
2401c2c66affSColin Finck     _In_ BOOLEAN CaseInSensitive
2402c2c66affSColin Finck );
2403c2c66affSColin Finck 
2404c2c66affSColin Finck NTSYSAPI
2405c2c66affSColin Finck VOID
2406c2c66affSColin Finck NTAPI
2407c2c66affSColin Finck RtlCopyString(
2408c2c66affSColin Finck     _Out_ PSTRING DestinationString,
2409c2c66affSColin Finck     _In_opt_ const STRING *SourceString
2410c2c66affSColin Finck );
2411c2c66affSColin Finck 
2412c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2413c2c66affSColin Finck _Must_inspect_result_
2414c2c66affSColin Finck NTSYSAPI
2415c2c66affSColin Finck BOOLEAN
2416c2c66affSColin Finck NTAPI
2417c2c66affSColin Finck RtlEqualString(
2418c2c66affSColin Finck     _In_ const STRING *String1,
2419c2c66affSColin Finck     _In_ const STRING *String2,
2420c2c66affSColin Finck     _In_ BOOLEAN CaseInSensitive
2421c2c66affSColin Finck );
2422c2c66affSColin Finck 
2423c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
2424c2c66affSColin Finck NTSYSAPI
2425c2c66affSColin Finck NTSTATUS
2426c2c66affSColin Finck NTAPI
2427c2c66affSColin Finck RtlAppendStringToString(
2428c2c66affSColin Finck     _Inout_ PSTRING Destination,
2429c2c66affSColin Finck     _In_ const STRING *Source
2430c2c66affSColin Finck );
2431c2c66affSColin Finck 
2432c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2433c2c66affSColin Finck _When_(AllocateDestinationString, _Must_inspect_result_)
2434c2c66affSColin Finck NTSYSAPI
2435c2c66affSColin Finck NTSTATUS
2436c2c66affSColin Finck NTAPI
2437c2c66affSColin Finck RtlUpcaseUnicodeString(
2438c2c66affSColin Finck     _When_(AllocateDestinationString, _Out_ _At_(DestinationString->Buffer, __drv_allocatesMem(Mem)))
2439c2c66affSColin Finck     _When_(!AllocateDestinationString, _Inout_)
2440c2c66affSColin Finck         PUNICODE_STRING DestinationString,
2441c2c66affSColin Finck     _In_ PCUNICODE_STRING SourceString,
2442c2c66affSColin Finck     _In_ BOOLEAN AllocateDestinationString
2443c2c66affSColin Finck );
2444c2c66affSColin Finck 
2445c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2446c2c66affSColin Finck NTSYSAPI
2447c2c66affSColin Finck NTSTATUS
2448c2c66affSColin Finck NTAPI
2449c2c66affSColin Finck RtlUnicodeStringToInteger(
2450c2c66affSColin Finck     _In_ PCUNICODE_STRING String,
2451c2c66affSColin Finck     _In_opt_ ULONG Base,
2452c2c66affSColin Finck     _Out_ PULONG Value
2453c2c66affSColin Finck );
2454c2c66affSColin Finck 
2455c2c66affSColin Finck NTSYSAPI
2456c2c66affSColin Finck NTSTATUS
2457c2c66affSColin Finck NTAPI
2458c2c66affSColin Finck RtlValidateUnicodeString(
2459c2c66affSColin Finck     _In_ ULONG Flags,
2460c2c66affSColin Finck     _In_ PCUNICODE_STRING String
2461c2c66affSColin Finck );
2462c2c66affSColin Finck 
2463c2c66affSColin Finck #define RTL_SKIP_BUFFER_COPY    0x00000001
2464c2c66affSColin Finck 
2465c2c66affSColin Finck NTSYSAPI
2466c2c66affSColin Finck NTSTATUS
2467c2c66affSColin Finck NTAPI
2468c2c66affSColin Finck RtlpEnsureBufferSize(
2469c2c66affSColin Finck     _In_ ULONG Flags,
2470c2c66affSColin Finck     _Inout_ PRTL_BUFFER Buffer,
2471c2c66affSColin Finck     _In_ SIZE_T RequiredSize
2472c2c66affSColin Finck );
2473c2c66affSColin Finck 
2474c2c66affSColin Finck #ifdef NTOS_MODE_USER
2475c2c66affSColin Finck 
2476c2c66affSColin Finck FORCEINLINE
2477c2c66affSColin Finck VOID
RtlInitBuffer(_Inout_ PRTL_BUFFER Buffer,_In_ PUCHAR Data,_In_ ULONG DataSize)2478c2c66affSColin Finck RtlInitBuffer(
2479c2c66affSColin Finck     _Inout_ PRTL_BUFFER Buffer,
2480c2c66affSColin Finck     _In_ PUCHAR Data,
2481c2c66affSColin Finck     _In_ ULONG DataSize
2482c2c66affSColin Finck )
2483c2c66affSColin Finck {
2484c2c66affSColin Finck     Buffer->Buffer = Buffer->StaticBuffer = Data;
2485c2c66affSColin Finck     Buffer->Size = Buffer->StaticSize = DataSize;
2486c2c66affSColin Finck     Buffer->ReservedForAllocatedSize = 0;
2487c2c66affSColin Finck     Buffer->ReservedForIMalloc = NULL;
2488c2c66affSColin Finck }
2489c2c66affSColin Finck 
2490c2c66affSColin Finck FORCEINLINE
2491c2c66affSColin Finck NTSTATUS
RtlEnsureBufferSize(_In_ ULONG Flags,_Inout_ PRTL_BUFFER Buffer,_In_ ULONG RequiredSize)2492c2c66affSColin Finck RtlEnsureBufferSize(
2493c2c66affSColin Finck     _In_ ULONG Flags,
2494c2c66affSColin Finck     _Inout_ PRTL_BUFFER Buffer,
2495c2c66affSColin Finck     _In_ ULONG RequiredSize
2496c2c66affSColin Finck )
2497c2c66affSColin Finck {
2498c2c66affSColin Finck     if (Buffer && RequiredSize <= Buffer->Size)
2499c2c66affSColin Finck         return STATUS_SUCCESS;
2500c2c66affSColin Finck     return RtlpEnsureBufferSize(Flags, Buffer, RequiredSize);
2501c2c66affSColin Finck }
2502c2c66affSColin Finck 
2503c2c66affSColin Finck FORCEINLINE
2504c2c66affSColin Finck VOID
RtlFreeBuffer(_Inout_ PRTL_BUFFER Buffer)2505c2c66affSColin Finck RtlFreeBuffer(
2506c2c66affSColin Finck     _Inout_ PRTL_BUFFER Buffer
2507c2c66affSColin Finck )
2508c2c66affSColin Finck {
2509c2c66affSColin Finck     if (Buffer->Buffer != Buffer->StaticBuffer && Buffer->Buffer)
2510c2c66affSColin Finck         RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer->Buffer);
2511c2c66affSColin Finck     Buffer->Buffer = Buffer->StaticBuffer;
2512c2c66affSColin Finck     Buffer->Size = Buffer->StaticSize;
2513c2c66affSColin Finck }
2514c2c66affSColin Finck 
2515782ff232SAndreas Maier NTSYSAPI
2516782ff232SAndreas Maier VOID
2517782ff232SAndreas Maier NTAPI
2518782ff232SAndreas Maier RtlRunEncodeUnicodeString(
2519782ff232SAndreas Maier     _Inout_ PUCHAR Hash,
2520782ff232SAndreas Maier     _Inout_ PUNICODE_STRING String
2521782ff232SAndreas Maier );
2522782ff232SAndreas Maier 
2523782ff232SAndreas Maier NTSYSAPI
2524782ff232SAndreas Maier VOID
2525782ff232SAndreas Maier NTAPI
2526782ff232SAndreas Maier RtlRunDecodeUnicodeString(
2527782ff232SAndreas Maier     _In_ UCHAR Hash,
2528782ff232SAndreas Maier     _Inout_ PUNICODE_STRING String
2529782ff232SAndreas Maier );
2530782ff232SAndreas Maier 
2531c2c66affSColin Finck #endif /* NTOS_MODE_USER */
2532c2c66affSColin Finck 
2533c2c66affSColin Finck //
2534c2c66affSColin Finck // Ansi String Functions
2535c2c66affSColin Finck //
2536c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2537c2c66affSColin Finck NTSYSAPI
2538c2c66affSColin Finck VOID
2539c2c66affSColin Finck NTAPI
2540c2c66affSColin Finck RtlFreeAnsiString(
2541c2c66affSColin Finck     _Inout_ _At_(AnsiString->Buffer, __drv_freesMem(Mem))
2542c2c66affSColin Finck         PANSI_STRING AnsiString
2543c2c66affSColin Finck );
2544c2c66affSColin Finck 
2545c2c66affSColin Finck _IRQL_requires_max_(DISPATCH_LEVEL)
2546c2c66affSColin Finck NTSYSAPI
2547c2c66affSColin Finck VOID
2548c2c66affSColin Finck NTAPI
2549c2c66affSColin Finck RtlInitAnsiString(
2550c2c66affSColin Finck     _Out_ PANSI_STRING DestinationString,
2551c2c66affSColin Finck     _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2552c2c66affSColin Finck );
2553c2c66affSColin Finck 
2554c2c66affSColin Finck _IRQL_requires_max_(DISPATCH_LEVEL)
2555c2c66affSColin Finck NTSYSAPI
2556c2c66affSColin Finck NTSTATUS
2557c2c66affSColin Finck NTAPI
2558c2c66affSColin Finck RtlInitAnsiStringEx(
2559c2c66affSColin Finck     _Out_ PANSI_STRING DestinationString,
2560c2c66affSColin Finck     _In_opt_z_ __drv_aliasesMem PCSZ SourceString
2561c2c66affSColin Finck );
2562c2c66affSColin Finck 
2563c2c66affSColin Finck //
2564c2c66affSColin Finck // OEM String Functions
2565c2c66affSColin Finck //
2566c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2567c2c66affSColin Finck NTSYSAPI
2568c2c66affSColin Finck VOID
2569c2c66affSColin Finck NTAPI
2570c2c66affSColin Finck RtlFreeOemString(
2571c2c66affSColin Finck     _Inout_ _At_(OemString->Buffer, __drv_freesMem(Mem))
2572c2c66affSColin Finck         POEM_STRING OemString
2573c2c66affSColin Finck );
2574c2c66affSColin Finck 
2575c2c66affSColin Finck //
2576c2c66affSColin Finck // MultiByte->Unicode String Functions
2577c2c66affSColin Finck //
2578c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2579c2c66affSColin Finck NTSYSAPI
2580c2c66affSColin Finck NTSTATUS
2581c2c66affSColin Finck NTAPI
2582c2c66affSColin Finck RtlMultiByteToUnicodeN(
2583c2c66affSColin Finck     _Out_writes_bytes_to_(MaxBytesInUnicodeString, *BytesInUnicodeString) PWCH UnicodeString,
2584c2c66affSColin Finck     _In_ ULONG MaxBytesInUnicodeString,
2585c2c66affSColin Finck     _Out_opt_ PULONG BytesInUnicodeString,
2586c2c66affSColin Finck     _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2587c2c66affSColin Finck     _In_ ULONG BytesInMultiByteString
2588c2c66affSColin Finck );
2589c2c66affSColin Finck 
2590c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
2591c2c66affSColin Finck NTSYSAPI
2592c2c66affSColin Finck NTSTATUS
2593c2c66affSColin Finck NTAPI
2594c2c66affSColin Finck RtlMultiByteToUnicodeSize(
2595c2c66affSColin Finck     _Out_ PULONG BytesInUnicodeString,
2596c2c66affSColin Finck     _In_reads_bytes_(BytesInMultiByteString) const CHAR *MultiByteString,
2597c2c66affSColin Finck     _In_ ULONG BytesInMultiByteString
2598c2c66affSColin Finck );
2599c2c66affSColin Finck 
2600c2c66affSColin Finck //
2601c2c66affSColin Finck // Atom Functions
2602c2c66affSColin Finck //
2603c2c66affSColin Finck NTSYSAPI
2604c2c66affSColin Finck NTSTATUS
2605c2c66affSColin Finck NTAPI
2606c2c66affSColin Finck RtlAddAtomToAtomTable(
2607c2c66affSColin Finck     _In_ PRTL_ATOM_TABLE AtomTable,
2608c2c66affSColin Finck     _In_ PWSTR AtomName,
2609c2c66affSColin Finck     _Out_ PRTL_ATOM Atom
2610c2c66affSColin Finck );
2611c2c66affSColin Finck 
2612c2c66affSColin Finck NTSYSAPI
2613c2c66affSColin Finck NTSTATUS
2614c2c66affSColin Finck NTAPI
2615c2c66affSColin Finck RtlCreateAtomTable(
2616c2c66affSColin Finck     _In_ ULONG TableSize,
2617c2c66affSColin Finck     _Inout_ PRTL_ATOM_TABLE *AtomTable
2618c2c66affSColin Finck );
2619c2c66affSColin Finck 
2620c2c66affSColin Finck NTSYSAPI
2621c2c66affSColin Finck NTSTATUS
2622c2c66affSColin Finck NTAPI
2623c2c66affSColin Finck RtlDeleteAtomFromAtomTable(
2624c2c66affSColin Finck     _In_ PRTL_ATOM_TABLE AtomTable,
2625c2c66affSColin Finck     _In_ RTL_ATOM Atom
2626c2c66affSColin Finck );
2627c2c66affSColin Finck 
2628c2c66affSColin Finck NTSYSAPI
2629c2c66affSColin Finck NTSTATUS
2630c2c66affSColin Finck NTAPI
2631c2c66affSColin Finck RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
2632c2c66affSColin Finck 
2633c2c66affSColin Finck NTSYSAPI
2634c2c66affSColin Finck NTSTATUS
2635c2c66affSColin Finck NTAPI
2636c2c66affSColin Finck RtlQueryAtomInAtomTable(
2637c2c66affSColin Finck     _In_ PRTL_ATOM_TABLE AtomTable,
2638c2c66affSColin Finck     _In_ RTL_ATOM Atom,
2639c2c66affSColin Finck     _Out_opt_ PULONG RefCount,
2640c2c66affSColin Finck     _Out_opt_ PULONG PinCount,
2641c2c66affSColin Finck     _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName,
2642c2c66affSColin Finck     _Inout_opt_ PULONG NameLength
2643c2c66affSColin Finck );
2644c2c66affSColin Finck 
2645c2c66affSColin Finck NTSYSAPI
2646c2c66affSColin Finck NTSTATUS
2647c2c66affSColin Finck NTAPI
2648c2c66affSColin Finck RtlPinAtomInAtomTable(
2649c2c66affSColin Finck     _In_ PRTL_ATOM_TABLE AtomTable,
2650c2c66affSColin Finck     _In_ RTL_ATOM Atom
2651c2c66affSColin Finck );
2652c2c66affSColin Finck 
2653c2c66affSColin Finck NTSYSAPI
2654c2c66affSColin Finck NTSTATUS
2655c2c66affSColin Finck NTAPI
2656c2c66affSColin Finck RtlLookupAtomInAtomTable(
2657c2c66affSColin Finck     _In_ PRTL_ATOM_TABLE AtomTable,
2658c2c66affSColin Finck     _In_ PWSTR AtomName,
2659c2c66affSColin Finck     _Out_ PRTL_ATOM Atom
2660c2c66affSColin Finck );
2661c2c66affSColin Finck 
2662c2c66affSColin Finck //
2663c2c66affSColin Finck // Process Management Functions
2664c2c66affSColin Finck //
2665c2c66affSColin Finck NTSYSAPI
2666c2c66affSColin Finck PPEB
2667c2c66affSColin Finck NTAPI
2668c2c66affSColin Finck RtlGetCurrentPeb(
2669c2c66affSColin Finck     VOID
2670c2c66affSColin Finck );
2671c2c66affSColin Finck 
2672c2c66affSColin Finck NTSYSAPI
2673c2c66affSColin Finck VOID
2674c2c66affSColin Finck NTAPI
2675c2c66affSColin Finck RtlAcquirePebLock(VOID);
2676c2c66affSColin Finck 
2677c2c66affSColin Finck NTSYSAPI
2678c2c66affSColin Finck NTSTATUS
2679c2c66affSColin Finck NTAPI
2680c2c66affSColin Finck RtlCreateProcessParameters (
2681c2c66affSColin Finck     _Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
2682c2c66affSColin Finck     _In_ PUNICODE_STRING ImagePathName,
2683c2c66affSColin Finck     _In_opt_ PUNICODE_STRING DllPath,
2684c2c66affSColin Finck     _In_opt_ PUNICODE_STRING CurrentDirectory,
2685c2c66affSColin Finck     _In_opt_ PUNICODE_STRING CommandLine,
2686c2c66affSColin Finck     _In_opt_ PWSTR Environment,
2687c2c66affSColin Finck     _In_opt_ PUNICODE_STRING WindowTitle,
2688c2c66affSColin Finck     _In_opt_ PUNICODE_STRING DesktopInfo,
2689c2c66affSColin Finck     _In_opt_ PUNICODE_STRING ShellInfo,
2690c2c66affSColin Finck     _In_opt_ PUNICODE_STRING RuntimeInfo
2691c2c66affSColin Finck );
2692c2c66affSColin Finck 
2693c2c66affSColin Finck NTSYSAPI
2694c2c66affSColin Finck NTSTATUS
2695c2c66affSColin Finck NTAPI
2696c2c66affSColin Finck RtlCreateUserProcess(
2697c2c66affSColin Finck     _In_ PUNICODE_STRING ImageFileName,
2698c2c66affSColin Finck     _In_ ULONG Attributes,
2699c2c66affSColin Finck     _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
2700c2c66affSColin Finck     _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor,
2701c2c66affSColin Finck     _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor,
2702c2c66affSColin Finck     _In_opt_ HANDLE ParentProcess,
2703c2c66affSColin Finck     _In_ BOOLEAN CurrentDirectory,
2704c2c66affSColin Finck     _In_opt_ HANDLE DebugPort,
2705c2c66affSColin Finck     _In_opt_ HANDLE ExceptionPort,
2706c2c66affSColin Finck     _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo
2707c2c66affSColin Finck );
2708c2c66affSColin Finck 
2709c2c66affSColin Finck #if (NTDDI_VERSION >= NTDDI_WIN7)
2710c2c66affSColin Finck NTSYSAPI
2711c2c66affSColin Finck NTSTATUS
2712c2c66affSColin Finck NTAPI
2713c2c66affSColin Finck RtlCreateUserThread(
2714c2c66affSColin Finck     _In_ PVOID ThreadContext,
2715c2c66affSColin Finck     _Out_ HANDLE *OutThreadHandle,
2716c2c66affSColin Finck     _Reserved_ PVOID Reserved1,
2717c2c66affSColin Finck     _Reserved_ PVOID Reserved2,
2718c2c66affSColin Finck     _Reserved_ PVOID Reserved3,
2719c2c66affSColin Finck     _Reserved_ PVOID Reserved4,
2720c2c66affSColin Finck     _Reserved_ PVOID Reserved5,
2721c2c66affSColin Finck     _Reserved_ PVOID Reserved6,
2722c2c66affSColin Finck     _Reserved_ PVOID Reserved7,
2723c2c66affSColin Finck     _Reserved_ PVOID Reserved8
2724c2c66affSColin Finck );
2725c2c66affSColin Finck #else
2726c2c66affSColin Finck NTSYSAPI
2727c2c66affSColin Finck NTSTATUS
2728c2c66affSColin Finck NTAPI
2729c2c66affSColin Finck RtlCreateUserThread(
2730c2c66affSColin Finck     _In_ HANDLE ProcessHandle,
2731c2c66affSColin Finck     _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor,
2732c2c66affSColin Finck     _In_ BOOLEAN CreateSuspended,
2733c2c66affSColin Finck     _In_ ULONG StackZeroBits,
2734c2c66affSColin Finck     _In_ SIZE_T StackReserve,
2735c2c66affSColin Finck     _In_ SIZE_T StackCommit,
2736c2c66affSColin Finck     _In_ PTHREAD_START_ROUTINE StartAddress,
2737c2c66affSColin Finck     _In_ PVOID Parameter,
2738c2c66affSColin Finck     _Out_opt_ PHANDLE ThreadHandle,
2739c2c66affSColin Finck     _Out_opt_ PCLIENT_ID ClientId
2740c2c66affSColin Finck );
2741c2c66affSColin Finck #endif
2742c2c66affSColin Finck 
2743c2c66affSColin Finck NTSYSAPI
2744c2c66affSColin Finck PRTL_USER_PROCESS_PARAMETERS
2745c2c66affSColin Finck NTAPI
2746c2c66affSColin Finck RtlDeNormalizeProcessParams(
2747c2c66affSColin Finck     _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2748c2c66affSColin Finck 
2749c2c66affSColin Finck NTSYSAPI
2750c2c66affSColin Finck NTSTATUS
2751c2c66affSColin Finck NTAPI
2752c2c66affSColin Finck RtlDestroyProcessParameters(
2753c2c66affSColin Finck     _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2754c2c66affSColin Finck 
2755c2c66affSColin Finck NTSYSAPI
2756c2c66affSColin Finck VOID
2757c2c66affSColin Finck NTAPI
2758c2c66affSColin Finck RtlExitUserThread(
2759c2c66affSColin Finck     _In_ NTSTATUS Status);
2760c2c66affSColin Finck 
2761c2c66affSColin Finck NTSYSAPI
2762c2c66affSColin Finck VOID
2763c2c66affSColin Finck NTAPI
2764c2c66affSColin Finck RtlInitializeContext(
2765c2c66affSColin Finck     _In_ HANDLE ProcessHandle,
2766c2c66affSColin Finck     _Out_ PCONTEXT ThreadContext,
2767c2c66affSColin Finck     _In_opt_ PVOID ThreadStartParam,
2768c2c66affSColin Finck     _In_ PTHREAD_START_ROUTINE ThreadStartAddress,
2769c2c66affSColin Finck     _In_ PINITIAL_TEB InitialTeb
2770c2c66affSColin Finck );
2771c2c66affSColin Finck 
2772c2c66affSColin Finck #ifdef _M_AMD64
2773c2c66affSColin Finck typedef struct _WOW64_CONTEXT *PWOW64_CONTEXT;
2774c2c66affSColin Finck 
2775c2c66affSColin Finck NTSYSAPI
2776c2c66affSColin Finck NTSTATUS
2777c2c66affSColin Finck NTAPI
2778c2c66affSColin Finck RtlWow64GetThreadContext(
2779c2c66affSColin Finck     _In_ HANDLE ThreadHandle,
2780c2c66affSColin Finck     _Inout_ PWOW64_CONTEXT ThreadContext
2781c2c66affSColin Finck );
2782c2c66affSColin Finck 
2783c2c66affSColin Finck 
2784c2c66affSColin Finck NTSYSAPI
2785c2c66affSColin Finck NTSTATUS
2786c2c66affSColin Finck NTAPI
2787c2c66affSColin Finck RtlWow64SetThreadContext(
2788c2c66affSColin Finck     _In_ HANDLE ThreadHandle,
2789c2c66affSColin Finck     _In_ PWOW64_CONTEXT ThreadContext
2790c2c66affSColin Finck );
2791c2c66affSColin Finck #endif
2792c2c66affSColin Finck 
2793c2c66affSColin Finck NTSYSAPI
2794c2c66affSColin Finck BOOLEAN
2795c2c66affSColin Finck NTAPI
2796c2c66affSColin Finck RtlIsThreadWithinLoaderCallout(VOID);
2797c2c66affSColin Finck 
2798c2c66affSColin Finck NTSYSAPI
2799c2c66affSColin Finck PRTL_USER_PROCESS_PARAMETERS
2800c2c66affSColin Finck NTAPI
2801c2c66affSColin Finck RtlNormalizeProcessParams(
2802c2c66affSColin Finck     _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
2803c2c66affSColin Finck 
2804c2c66affSColin Finck NTSYSAPI
2805c2c66affSColin Finck VOID
2806c2c66affSColin Finck NTAPI
2807c2c66affSColin Finck RtlReleasePebLock(VOID);
2808c2c66affSColin Finck 
2809c2c66affSColin Finck NTSYSAPI
2810c2c66affSColin Finck NTSTATUS
2811c2c66affSColin Finck NTAPI
2812c2c66affSColin Finck RtlRemoteCall(
2813c2c66affSColin Finck     _In_ HANDLE Process,
2814c2c66affSColin Finck     _In_ HANDLE Thread,
2815c2c66affSColin Finck     _In_ PVOID CallSite,
2816c2c66affSColin Finck     _In_ ULONG ArgumentCount,
2817c2c66affSColin Finck     _In_ PULONG Arguments,
2818c2c66affSColin Finck     _In_ BOOLEAN PassContext,
2819c2c66affSColin Finck     _In_ BOOLEAN AlreadySuspended
2820c2c66affSColin Finck );
2821c2c66affSColin Finck 
2822c2c66affSColin Finck NTSYSAPI
2823c2c66affSColin Finck NTSTATUS
2824c2c66affSColin Finck __cdecl
2825c2c66affSColin Finck RtlSetProcessIsCritical(
2826c2c66affSColin Finck     _In_ BOOLEAN NewValue,
2827c2c66affSColin Finck     _Out_opt_ PBOOLEAN OldValue,
2828c2c66affSColin Finck     _In_ BOOLEAN NeedBreaks
2829c2c66affSColin Finck );
2830c2c66affSColin Finck 
2831c2c66affSColin Finck NTSYSAPI
2832c2c66affSColin Finck NTSTATUS
2833c2c66affSColin Finck __cdecl
2834c2c66affSColin Finck RtlSetThreadIsCritical(
2835c2c66affSColin Finck     _In_ BOOLEAN NewValue,
2836c2c66affSColin Finck     _Out_opt_ PBOOLEAN OldValue,
2837c2c66affSColin Finck     _In_ BOOLEAN NeedBreaks
2838c2c66affSColin Finck );
2839c2c66affSColin Finck 
2840c2c66affSColin Finck NTSYSAPI
2841c2c66affSColin Finck ULONG
2842c2c66affSColin Finck NTAPI
2843c2c66affSColin Finck RtlGetCurrentProcessorNumber(
2844c2c66affSColin Finck     VOID
2845c2c66affSColin Finck );
2846c2c66affSColin Finck 
2847c2c66affSColin Finck 
2848c2c66affSColin Finck //
2849c2c66affSColin Finck // Thread Pool Functions
2850c2c66affSColin Finck //
2851c2c66affSColin Finck //
2852c2c66affSColin Finck NTSTATUS
2853c2c66affSColin Finck NTAPI
2854c2c66affSColin Finck RtlSetThreadPoolStartFunc(
2855c2c66affSColin Finck     _In_ PRTL_START_POOL_THREAD StartPoolThread,
2856c2c66affSColin Finck     _In_ PRTL_EXIT_POOL_THREAD ExitPoolThread
2857c2c66affSColin Finck );
2858c2c66affSColin Finck 
2859c2c66affSColin Finck NTSYSAPI
2860c2c66affSColin Finck NTSTATUS
2861c2c66affSColin Finck NTAPI
2862c2c66affSColin Finck RtlDeregisterWaitEx(
2863c2c66affSColin Finck     _In_ HANDLE hWaitHandle,
2864c2c66affSColin Finck     _In_opt_ HANDLE hCompletionEvent
2865c2c66affSColin Finck );
2866c2c66affSColin Finck 
2867c2c66affSColin Finck NTSYSAPI
2868c2c66affSColin Finck NTSTATUS
2869c2c66affSColin Finck NTAPI
2870c2c66affSColin Finck RtlDeregisterWait(
2871c2c66affSColin Finck     _In_ HANDLE hWaitHandle
2872c2c66affSColin Finck );
2873c2c66affSColin Finck 
2874c2c66affSColin Finck NTSYSAPI
2875c2c66affSColin Finck NTSTATUS
2876c2c66affSColin Finck NTAPI
2877c2c66affSColin Finck RtlQueueWorkItem(
2878c2c66affSColin Finck     _In_ WORKERCALLBACKFUNC Function,
2879c2c66affSColin Finck     _In_opt_ PVOID Context,
2880c2c66affSColin Finck     _In_ ULONG Flags
2881c2c66affSColin Finck );
2882c2c66affSColin Finck 
2883c2c66affSColin Finck NTSYSAPI
2884c2c66affSColin Finck NTSTATUS
2885c2c66affSColin Finck NTAPI
2886c2c66affSColin Finck RtlSetIoCompletionCallback(
2887c2c66affSColin Finck     _In_ HANDLE FileHandle,
2888c2c66affSColin Finck     _In_ PIO_APC_ROUTINE Callback,
2889c2c66affSColin Finck     _In_ ULONG Flags
2890c2c66affSColin Finck );
2891c2c66affSColin Finck 
2892c2c66affSColin Finck NTSYSAPI
2893c2c66affSColin Finck NTSTATUS
2894c2c66affSColin Finck NTAPI
2895c2c66affSColin Finck RtlRegisterWait(
2896c2c66affSColin Finck     _In_ PHANDLE phNewWaitObject,
2897c2c66affSColin Finck     _In_ HANDLE hObject,
2898c2c66affSColin Finck     _In_ WAITORTIMERCALLBACKFUNC Callback,
2899c2c66affSColin Finck     _In_ PVOID pvContext,
2900c2c66affSColin Finck     _In_ ULONG ulMilliseconds,
2901c2c66affSColin Finck     _In_ ULONG ulFlags
2902c2c66affSColin Finck );
2903c2c66affSColin Finck 
2904c2c66affSColin Finck //
2905c2c66affSColin Finck // Environment/Path Functions
2906c2c66affSColin Finck //
2907c2c66affSColin Finck NTSYSAPI
2908c2c66affSColin Finck NTSTATUS
2909c2c66affSColin Finck NTAPI
2910c2c66affSColin Finck RtlCreateEnvironment(
2911c2c66affSColin Finck     _In_ BOOLEAN Inherit,
2912c2c66affSColin Finck     _Out_ PWSTR *Environment
2913c2c66affSColin Finck );
2914c2c66affSColin Finck 
2915c2c66affSColin Finck NTSYSAPI
2916c2c66affSColin Finck NTSTATUS
2917c2c66affSColin Finck NTAPI
2918c2c66affSColin Finck RtlComputePrivatizedDllName_U(
2919c2c66affSColin Finck     _In_ PUNICODE_STRING DllName,
2920e1aae1c6SMark Jansen     _Inout_ PUNICODE_STRING RealName,
2921e1aae1c6SMark Jansen     _Inout_ PUNICODE_STRING LocalName
2922c2c66affSColin Finck );
2923c2c66affSColin Finck 
2924c2c66affSColin Finck NTSYSAPI
2925c2c66affSColin Finck VOID
2926c2c66affSColin Finck NTAPI
2927c2c66affSColin Finck RtlDestroyEnvironment(
2928c2c66affSColin Finck     _In_ PWSTR Environment
2929c2c66affSColin Finck );
2930c2c66affSColin Finck 
2931c2c66affSColin Finck NTSYSAPI
2932c2c66affSColin Finck BOOLEAN
2933c2c66affSColin Finck NTAPI
2934c2c66affSColin Finck RtlDoesFileExists_U(
2935c2c66affSColin Finck     _In_ PCWSTR FileName
2936c2c66affSColin Finck );
2937c2c66affSColin Finck 
2938c2c66affSColin Finck NTSYSAPI
2939c2c66affSColin Finck RTL_PATH_TYPE
2940c2c66affSColin Finck NTAPI
2941c2c66affSColin Finck RtlDetermineDosPathNameType_U(
2942c2c66affSColin Finck     _In_ PCWSTR Path
2943c2c66affSColin Finck );
2944c2c66affSColin Finck 
2945c2c66affSColin Finck NTSYSAPI
2946c2c66affSColin Finck ULONG
2947c2c66affSColin Finck NTAPI
2948c2c66affSColin Finck RtlDosSearchPath_U(
2949c2c66affSColin Finck     _In_ PCWSTR Path,
2950c2c66affSColin Finck     _In_ PCWSTR FileName,
2951c2c66affSColin Finck     _In_ PCWSTR Extension,
2952c2c66affSColin Finck     _In_ ULONG BufferSize,
2953c2c66affSColin Finck     _Out_ PWSTR Buffer,
2954c2c66affSColin Finck     _Out_ PWSTR *PartName
2955c2c66affSColin Finck );
2956c2c66affSColin Finck 
2957c2c66affSColin Finck NTSYSAPI
2958c2c66affSColin Finck NTSTATUS
2959c2c66affSColin Finck NTAPI
2960c2c66affSColin Finck RtlDosSearchPath_Ustr(
2961c2c66affSColin Finck     _In_ ULONG Flags,
2962c2c66affSColin Finck     _In_ PUNICODE_STRING PathString,
2963c2c66affSColin Finck     _In_ PUNICODE_STRING FileNameString,
2964c2c66affSColin Finck     _In_ PUNICODE_STRING ExtensionString,
2965c2c66affSColin Finck     _In_ PUNICODE_STRING CallerBuffer,
2966c2c66affSColin Finck     _Inout_opt_ PUNICODE_STRING DynamicString,
2967c2c66affSColin Finck     _Out_opt_ PUNICODE_STRING* FullNameOut,
2968c2c66affSColin Finck     _Out_opt_ PSIZE_T FilePartSize,
2969c2c66affSColin Finck     _Out_opt_ PSIZE_T LengthNeeded
2970c2c66affSColin Finck );
2971c2c66affSColin Finck 
2972c2c66affSColin Finck NTSYSAPI
2973c2c66affSColin Finck BOOLEAN
2974c2c66affSColin Finck NTAPI
2975c2c66affSColin Finck RtlDosPathNameToNtPathName_U(
2976c2c66affSColin Finck     _In_opt_z_ PCWSTR DosPathName,
2977c2c66affSColin Finck     _Out_ PUNICODE_STRING NtPathName,
2978c2c66affSColin Finck     _Out_opt_ PCWSTR *NtFileNamePart,
2979c2c66affSColin Finck     _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo
2980c2c66affSColin Finck );
2981c2c66affSColin Finck 
2982c2c66affSColin Finck 
2983c2c66affSColin Finck #define RTL_UNCHANGED_UNK_PATH  1
2984c2c66affSColin Finck #define RTL_CONVERTED_UNC_PATH  2
2985c2c66affSColin Finck #define RTL_CONVERTED_NT_PATH   3
2986c2c66affSColin Finck #define RTL_UNCHANGED_DOS_PATH  4
2987c2c66affSColin Finck 
2988c2c66affSColin Finck NTSYSAPI
2989c2c66affSColin Finck NTSTATUS
2990c2c66affSColin Finck NTAPI
2991c2c66affSColin Finck RtlNtPathNameToDosPathName(
2992c2c66affSColin Finck     _In_ ULONG Flags,
2993c2c66affSColin Finck     _Inout_ PRTL_UNICODE_STRING_BUFFER Path,
2994c2c66affSColin Finck     _Out_opt_ PULONG PathType,
2995c2c66affSColin Finck     _Out_opt_ PULONG Unknown
2996c2c66affSColin Finck );
2997c2c66affSColin Finck 
2998c2c66affSColin Finck 
2999c2c66affSColin Finck NTSYSAPI
3000c2c66affSColin Finck BOOLEAN
3001c2c66affSColin Finck NTAPI
3002c2c66affSColin Finck RtlDosPathNameToRelativeNtPathName_U(
3003c2c66affSColin Finck     _In_ PCWSTR DosName,
3004c2c66affSColin Finck     _Out_ PUNICODE_STRING NtName,
3005c2c66affSColin Finck     _Out_ PCWSTR *PartName,
3006c2c66affSColin Finck     _Out_ PRTL_RELATIVE_NAME_U RelativeName
3007c2c66affSColin Finck );
3008c2c66affSColin Finck 
3009c2c66affSColin Finck _At_(Destination->Buffer, _Out_bytecap_(Destination->MaximumLength))
3010c2c66affSColin Finck NTSYSAPI
3011c2c66affSColin Finck NTSTATUS
3012c2c66affSColin Finck NTAPI
3013c2c66affSColin Finck RtlExpandEnvironmentStrings_U(
3014c2c66affSColin Finck     _In_z_ PWSTR Environment,
3015c2c66affSColin Finck     _In_ PUNICODE_STRING Source,
3016c2c66affSColin Finck     _Inout_ PUNICODE_STRING Destination,
3017c2c66affSColin Finck     _Out_ PULONG Length
3018c2c66affSColin Finck );
3019c2c66affSColin Finck 
3020c2c66affSColin Finck NTSYSAPI
3021c2c66affSColin Finck ULONG
3022c2c66affSColin Finck NTAPI
3023c2c66affSColin Finck RtlGetCurrentDirectory_U(
3024c2c66affSColin Finck     _In_ ULONG MaximumLength,
3025c2c66affSColin Finck     _Out_bytecap_(MaximumLength) PWSTR Buffer
3026c2c66affSColin Finck );
3027c2c66affSColin Finck 
3028c2c66affSColin Finck NTSYSAPI
3029c2c66affSColin Finck ULONG
3030c2c66affSColin Finck NTAPI
3031c2c66affSColin Finck RtlGetFullPathName_U(
3032c2c66affSColin Finck     _In_ PCWSTR FileName,
3033c2c66affSColin Finck     _In_ ULONG Size,
3034c2c66affSColin Finck     _Out_z_bytecap_(Size) PWSTR Buffer,
3035c2c66affSColin Finck     _Out_opt_ PWSTR *ShortName
3036c2c66affSColin Finck );
3037c2c66affSColin Finck 
3038c2c66affSColin Finck #if (NTDDI_VERSION >= NTDDI_WIN7)
3039c2c66affSColin Finck NTSYSAPI
3040c2c66affSColin Finck NTSTATUS
3041c2c66affSColin Finck NTAPI
3042c2c66affSColin Finck RtlGetFullPathName_UEx(
3043c2c66affSColin Finck     _In_ PWSTR FileName,
3044c2c66affSColin Finck     _In_ ULONG BufferLength,
3045c2c66affSColin Finck     _Out_ PWSTR Buffer,
3046c2c66affSColin Finck     _Out_opt_ PWSTR *FilePart,
3047c2c66affSColin Finck     _Out_opt_ RTL_PATH_TYPE *InputPathType
3048c2c66affSColin Finck     );
3049c2c66affSColin Finck #endif
3050c2c66affSColin Finck 
3051c2c66affSColin Finck NTSTATUS
3052c2c66affSColin Finck NTAPI
3053c2c66affSColin Finck RtlGetFullPathName_UstrEx(
3054c2c66affSColin Finck     _In_ PUNICODE_STRING FileName,
3055c2c66affSColin Finck     _In_opt_ PUNICODE_STRING StaticString,
3056c2c66affSColin Finck     _In_opt_ PUNICODE_STRING DynamicString,
3057c2c66affSColin Finck     _Out_opt_ PUNICODE_STRING *StringUsed,
3058c2c66affSColin Finck     _Out_opt_ PSIZE_T FilePartSize,
3059c2c66affSColin Finck     _Out_opt_ PBOOLEAN NameInvalid,
3060c2c66affSColin Finck     _Out_ RTL_PATH_TYPE* PathType,
3061c2c66affSColin Finck     _Out_opt_ PSIZE_T LengthNeeded
3062c2c66affSColin Finck );
3063c2c66affSColin Finck 
3064c2c66affSColin Finck NTSYSAPI
3065c2c66affSColin Finck NTSTATUS
3066c2c66affSColin Finck NTAPI
3067c2c66affSColin Finck RtlGetLengthWithoutTrailingPathSeperators(
3068c2c66affSColin Finck     _Reserved_ ULONG Flags,
3069c2c66affSColin Finck     _In_ PCUNICODE_STRING PathString,
3070c2c66affSColin Finck     _Out_ PULONG Length
3071c2c66affSColin Finck );
3072c2c66affSColin Finck 
3073c2c66affSColin Finck NTSYSAPI
3074c2c66affSColin Finck ULONG
3075c2c66affSColin Finck NTAPI
3076c2c66affSColin Finck RtlGetLongestNtPathLength(
3077c2c66affSColin Finck     VOID
3078c2c66affSColin Finck );
3079c2c66affSColin Finck 
3080c2c66affSColin Finck NTSYSAPI
3081c2c66affSColin Finck ULONG
3082c2c66affSColin Finck NTAPI
3083c2c66affSColin Finck RtlIsDosDeviceName_U(
3084c2c66affSColin Finck     _In_ PCWSTR Name
3085c2c66affSColin Finck );
3086c2c66affSColin Finck 
3087c2c66affSColin Finck NTSYSAPI
3088c2c66affSColin Finck ULONG
3089c2c66affSColin Finck NTAPI
3090c2c66affSColin Finck RtlIsDosDeviceName_Ustr(
3091c2c66affSColin Finck     _In_ PCUNICODE_STRING Name
3092c2c66affSColin Finck );
3093c2c66affSColin Finck 
3094c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
3095c2c66affSColin Finck _Must_inspect_result_
3096c2c66affSColin Finck NTSYSAPI
3097c2c66affSColin Finck BOOLEAN
3098c2c66affSColin Finck NTAPI
3099c2c66affSColin Finck RtlIsNameLegalDOS8Dot3(
3100c2c66affSColin Finck     _In_ PCUNICODE_STRING Name,
3101c2c66affSColin Finck     _Inout_opt_ POEM_STRING OemName,
3102c2c66affSColin Finck     _Out_opt_ PBOOLEAN NameContainsSpaces
3103c2c66affSColin Finck );
3104c2c66affSColin Finck 
3105c2c66affSColin Finck NTSYSAPI
3106c2c66affSColin Finck NTSTATUS
3107c2c66affSColin Finck NTAPI
3108c2c66affSColin Finck RtlQueryEnvironmentVariable_U(
3109c2c66affSColin Finck     _In_opt_ PWSTR Environment,
3110c2c66affSColin Finck     _In_ PCUNICODE_STRING Name,
3111c2c66affSColin Finck     _Out_ PUNICODE_STRING Value
3112c2c66affSColin Finck );
3113c2c66affSColin Finck 
3114c2c66affSColin Finck VOID
3115c2c66affSColin Finck NTAPI
3116c2c66affSColin Finck RtlReleaseRelativeName(
3117c2c66affSColin Finck     _In_ PRTL_RELATIVE_NAME_U RelativeName
3118c2c66affSColin Finck );
3119c2c66affSColin Finck 
3120c2c66affSColin Finck NTSYSAPI
3121c2c66affSColin Finck NTSTATUS
3122c2c66affSColin Finck NTAPI
3123c2c66affSColin Finck RtlSetCurrentDirectory_U(
3124c2c66affSColin Finck     _In_ PUNICODE_STRING name
3125c2c66affSColin Finck );
3126c2c66affSColin Finck 
3127c2c66affSColin Finck NTSYSAPI
3128c2c66affSColin Finck NTSTATUS
3129c2c66affSColin Finck NTAPI
3130c2c66affSColin Finck RtlSetEnvironmentVariable(
3131c2c66affSColin Finck     _In_z_ PWSTR *Environment,
3132c2c66affSColin Finck     _In_ PUNICODE_STRING Name,
3133c2c66affSColin Finck     _In_ PUNICODE_STRING Value
3134c2c66affSColin Finck );
3135c2c66affSColin Finck 
3136c2c66affSColin Finck //
3137c2c66affSColin Finck // Critical Section/Resource Functions
3138c2c66affSColin Finck //
3139c2c66affSColin Finck NTSYSAPI
3140c2c66affSColin Finck NTSTATUS
3141c2c66affSColin Finck NTAPI
3142c2c66affSColin Finck RtlDeleteCriticalSection (
3143c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3144c2c66affSColin Finck );
3145c2c66affSColin Finck 
3146c2c66affSColin Finck NTSYSAPI
3147c2c66affSColin Finck NTSTATUS
3148c2c66affSColin Finck NTAPI
3149c2c66affSColin Finck RtlEnterCriticalSection(
3150c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3151c2c66affSColin Finck );
3152c2c66affSColin Finck 
3153c2c66affSColin Finck NTSYSAPI
3154c2c66affSColin Finck NTSTATUS
3155c2c66affSColin Finck NTAPI
3156c2c66affSColin Finck RtlInitializeCriticalSection(
3157c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3158c2c66affSColin Finck );
3159c2c66affSColin Finck 
3160c2c66affSColin Finck NTSYSAPI
3161c2c66affSColin Finck NTSTATUS
3162c2c66affSColin Finck NTAPI
3163c2c66affSColin Finck RtlInitializeCriticalSectionAndSpinCount(
3164c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection,
3165c2c66affSColin Finck     _In_ ULONG SpinCount
3166c2c66affSColin Finck );
3167c2c66affSColin Finck 
3168c2c66affSColin Finck NTSYSAPI
3169c2c66affSColin Finck ULONG
3170c2c66affSColin Finck NTAPI
3171c2c66affSColin Finck RtlIsCriticalSectionLocked(
3172c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3173c2c66affSColin Finck );
3174c2c66affSColin Finck 
3175c2c66affSColin Finck NTSYSAPI
3176c2c66affSColin Finck ULONG
3177c2c66affSColin Finck NTAPI
3178c2c66affSColin Finck RtlIsCriticalSectionLockedByThread(
3179c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3180c2c66affSColin Finck );
3181c2c66affSColin Finck 
3182c2c66affSColin Finck NTSYSAPI
3183c2c66affSColin Finck NTSTATUS
3184c2c66affSColin Finck NTAPI
3185c2c66affSColin Finck RtlLeaveCriticalSection(
3186c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3187c2c66affSColin Finck );
3188c2c66affSColin Finck 
3189c2c66affSColin Finck NTSYSAPI
3190c2c66affSColin Finck BOOLEAN
3191c2c66affSColin Finck NTAPI
3192c2c66affSColin Finck RtlTryEnterCriticalSection(
3193c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3194c2c66affSColin Finck );
3195c2c66affSColin Finck 
3196c2c66affSColin Finck NTSYSAPI
3197c2c66affSColin Finck VOID
3198c2c66affSColin Finck NTAPI
3199c2c66affSColin Finck RtlpUnWaitCriticalSection(
3200c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3201c2c66affSColin Finck );
3202c2c66affSColin Finck 
3203c2c66affSColin Finck NTSYSAPI
3204c2c66affSColin Finck NTSTATUS
3205c2c66affSColin Finck NTAPI
3206c2c66affSColin Finck RtlpWaitForCriticalSection(
3207c2c66affSColin Finck     _In_ PRTL_CRITICAL_SECTION CriticalSection
3208c2c66affSColin Finck );
3209c2c66affSColin Finck 
3210c2c66affSColin Finck NTSYSAPI
3211c2c66affSColin Finck BOOLEAN
3212c2c66affSColin Finck NTAPI
3213c2c66affSColin Finck RtlAcquireResourceExclusive(
3214c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource,
3215c2c66affSColin Finck     _In_ BOOLEAN Wait
3216c2c66affSColin Finck );
3217c2c66affSColin Finck 
3218c2c66affSColin Finck NTSYSAPI
3219c2c66affSColin Finck BOOLEAN
3220c2c66affSColin Finck NTAPI
3221c2c66affSColin Finck RtlAcquireResourceShared(
3222c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource,
3223c2c66affSColin Finck     _In_ BOOLEAN Wait
3224c2c66affSColin Finck );
3225c2c66affSColin Finck 
3226c2c66affSColin Finck NTSYSAPI
3227c2c66affSColin Finck VOID
3228c2c66affSColin Finck NTAPI
3229c2c66affSColin Finck RtlConvertExclusiveToShared(
3230c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource
3231c2c66affSColin Finck );
3232c2c66affSColin Finck 
3233c2c66affSColin Finck NTSYSAPI
3234c2c66affSColin Finck VOID
3235c2c66affSColin Finck NTAPI
3236c2c66affSColin Finck RtlConvertSharedToExclusive(
3237c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource
3238c2c66affSColin Finck );
3239c2c66affSColin Finck 
3240c2c66affSColin Finck NTSYSAPI
3241c2c66affSColin Finck VOID
3242c2c66affSColin Finck NTAPI
3243c2c66affSColin Finck RtlDeleteResource(
3244c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource
3245c2c66affSColin Finck );
3246c2c66affSColin Finck 
3247c2c66affSColin Finck NTSYSAPI
3248c2c66affSColin Finck VOID
3249c2c66affSColin Finck NTAPI
3250c2c66affSColin Finck RtlDumpResource(
3251c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource
3252c2c66affSColin Finck );
3253c2c66affSColin Finck 
3254c2c66affSColin Finck NTSYSAPI
3255c2c66affSColin Finck VOID
3256c2c66affSColin Finck NTAPI
3257c2c66affSColin Finck RtlInitializeResource(
3258c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource
3259c2c66affSColin Finck );
3260c2c66affSColin Finck 
3261c2c66affSColin Finck NTSYSAPI
3262c2c66affSColin Finck VOID
3263c2c66affSColin Finck NTAPI
3264c2c66affSColin Finck RtlReleaseResource(
3265c2c66affSColin Finck     _In_ PRTL_RESOURCE Resource
3266c2c66affSColin Finck );
3267c2c66affSColin Finck 
3268c2c66affSColin Finck //
3269c2c66affSColin Finck // Compression Functions
3270c2c66affSColin Finck //
3271c2c66affSColin Finck NTSYSAPI //NT_RTL_COMPRESS_API
3272c2c66affSColin Finck NTSTATUS
3273c2c66affSColin Finck NTAPI
3274c2c66affSColin Finck RtlCompressBuffer(
3275c2c66affSColin Finck     _In_ USHORT CompressionFormatAndEngine,
3276c2c66affSColin Finck     _In_reads_bytes_(UncompressedBufferSize) PUCHAR UncompressedBuffer,
3277c2c66affSColin Finck     _In_ ULONG UncompressedBufferSize,
3278c2c66affSColin Finck     _Out_writes_bytes_to_(CompressedBufferSize, *FinalCompressedSize) PUCHAR CompressedBuffer,
3279c2c66affSColin Finck     _In_ ULONG CompressedBufferSize,
3280c2c66affSColin Finck     _In_ ULONG UncompressedChunkSize,
3281c2c66affSColin Finck     _Out_ PULONG FinalCompressedSize,
3282c2c66affSColin Finck     _In_ PVOID WorkSpace
3283c2c66affSColin Finck );
3284c2c66affSColin Finck 
3285c2c66affSColin Finck _IRQL_requires_max_(APC_LEVEL)
3286c2c66affSColin Finck NTSYSAPI //NT_RTL_COMPRESS_API
3287c2c66affSColin Finck NTSTATUS
3288c2c66affSColin Finck NTAPI
3289c2c66affSColin Finck RtlDecompressBuffer(
3290c2c66affSColin Finck     _In_ USHORT CompressionFormat,
3291c2c66affSColin Finck     _Out_writes_bytes_to_(UncompressedBufferSize, *FinalUncompressedSize) PUCHAR UncompressedBuffer,
3292c2c66affSColin Finck     _In_ ULONG UncompressedBufferSize,
3293c2c66affSColin Finck     _In_reads_bytes_(CompressedBufferSize) PUCHAR CompressedBuffer,
3294c2c66affSColin Finck     _In_ ULONG CompressedBufferSize,
3295c2c66affSColin Finck     _Out_ PULONG FinalUncompressedSize
3296c2c66affSColin Finck );
3297c2c66affSColin Finck 
3298c2c66affSColin Finck NTSYSAPI
3299c2c66affSColin Finck NTSTATUS
3300c2c66affSColin Finck NTAPI
3301c2c66affSColin Finck RtlGetCompressionWorkSpaceSize(
3302c2c66affSColin Finck     _In_ USHORT CompressionFormatAndEngine,
3303c2c66affSColin Finck     _Out_ PULONG CompressBufferWorkSpaceSize,
3304c2c66affSColin Finck     _Out_ PULONG CompressFragmentWorkSpaceSize
3305c2c66affSColin Finck );
3306c2c66affSColin Finck 
3307c2c66affSColin Finck //
3308c2c66affSColin Finck // Frame Functions
3309c2c66affSColin Finck //
3310c2c66affSColin Finck NTSYSAPI
3311c2c66affSColin Finck VOID
3312c2c66affSColin Finck NTAPI
3313c2c66affSColin Finck RtlPopFrame(
3314c2c66affSColin Finck     _In_ PTEB_ACTIVE_FRAME Frame
3315c2c66affSColin Finck );
3316c2c66affSColin Finck 
3317c2c66affSColin Finck NTSYSAPI
3318c2c66affSColin Finck VOID
3319c2c66affSColin Finck NTAPI
3320c2c66affSColin Finck RtlPushFrame(
3321c2c66affSColin Finck     _In_ PTEB_ACTIVE_FRAME Frame
3322c2c66affSColin Finck );
3323c2c66affSColin Finck 
3324c2c66affSColin Finck NTSYSAPI
3325c2c66affSColin Finck PTEB_ACTIVE_FRAME
3326c2c66affSColin Finck NTAPI
3327c2c66affSColin Finck RtlGetFrame(
3328c2c66affSColin Finck     VOID
3329c2c66affSColin Finck );
3330c2c66affSColin Finck 
3331c2c66affSColin Finck //
3332c2c66affSColin Finck // Debug Info Functions
3333c2c66affSColin Finck //
3334c2c66affSColin Finck NTSYSAPI
3335c2c66affSColin Finck PRTL_DEBUG_INFORMATION
3336c2c66affSColin Finck NTAPI
3337c2c66affSColin Finck RtlCreateQueryDebugBuffer(
3338c2c66affSColin Finck     _In_ ULONG Size,
3339c2c66affSColin Finck     _In_ BOOLEAN EventPair
3340c2c66affSColin Finck );
3341c2c66affSColin Finck 
3342c2c66affSColin Finck NTSYSAPI
3343c2c66affSColin Finck NTSTATUS
3344c2c66affSColin Finck NTAPI
3345c2c66affSColin Finck RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer);
3346c2c66affSColin Finck 
3347c2c66affSColin Finck NTSYSAPI
3348c2c66affSColin Finck NTSTATUS
3349c2c66affSColin Finck NTAPI
3350c2c66affSColin Finck RtlQueryProcessDebugInformation(
3351c2c66affSColin Finck     _In_ ULONG ProcessId,
3352c2c66affSColin Finck     _In_ ULONG DebugInfoClassMask,
3353c2c66affSColin Finck     _Inout_ PRTL_DEBUG_INFORMATION DebugBuffer
3354c2c66affSColin Finck );
3355c2c66affSColin Finck 
3356c2c66affSColin Finck //
3357c2c66affSColin Finck // Bitmap Functions
3358c2c66affSColin Finck //
3359c2c66affSColin Finck #ifdef NTOS_MODE_USER
3360c2c66affSColin Finck 
3361c2c66affSColin Finck NTSYSAPI
3362c2c66affSColin Finck BOOLEAN
3363c2c66affSColin Finck NTAPI
3364c2c66affSColin Finck RtlAreBitsClear(
3365c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3366c2c66affSColin Finck     _In_ ULONG StartingIndex,
3367c2c66affSColin Finck     _In_ ULONG Length
3368c2c66affSColin Finck );
3369c2c66affSColin Finck 
3370c2c66affSColin Finck NTSYSAPI
3371c2c66affSColin Finck BOOLEAN
3372c2c66affSColin Finck NTAPI
3373c2c66affSColin Finck RtlAreBitsSet(
3374c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3375c2c66affSColin Finck     _In_ ULONG StartingIndex,
3376c2c66affSColin Finck     _In_ ULONG Length
3377c2c66affSColin Finck );
3378c2c66affSColin Finck 
3379c2c66affSColin Finck NTSYSAPI
3380c2c66affSColin Finck VOID
3381c2c66affSColin Finck NTAPI
3382c2c66affSColin Finck RtlClearAllBits(
3383c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader
3384c2c66affSColin Finck );
3385c2c66affSColin Finck 
3386c2c66affSColin Finck NTSYSAPI
3387c2c66affSColin Finck VOID
3388c2c66affSColin Finck NTAPI
3389c2c66affSColin Finck RtlClearBit(
3390c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3391c2c66affSColin Finck     _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3392c2c66affSColin Finck );
3393c2c66affSColin Finck 
3394c2c66affSColin Finck NTSYSAPI
3395c2c66affSColin Finck VOID
3396c2c66affSColin Finck NTAPI
3397c2c66affSColin Finck RtlClearBits(
3398c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3399c2c66affSColin Finck     _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToClear) ULONG StartingIndex,
3400c2c66affSColin Finck     _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToClear
3401c2c66affSColin Finck );
3402c2c66affSColin Finck 
3403c2c66affSColin Finck NTSYSAPI
3404c2c66affSColin Finck ULONG
3405c2c66affSColin Finck NTAPI
3406c2c66affSColin Finck RtlFindClearBits(
3407c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3408c2c66affSColin Finck     _In_ ULONG NumberToFind,
3409c2c66affSColin Finck     _In_ ULONG HintIndex
3410c2c66affSColin Finck );
3411c2c66affSColin Finck 
3412c2c66affSColin Finck NTSYSAPI
3413c2c66affSColin Finck ULONG
3414c2c66affSColin Finck NTAPI
3415c2c66affSColin Finck RtlFindClearBitsAndSet(
3416c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3417c2c66affSColin Finck     _In_ ULONG NumberToFind,
3418c2c66affSColin Finck     _In_ ULONG HintIndex
3419c2c66affSColin Finck );
3420c2c66affSColin Finck 
3421c2c66affSColin Finck NTSYSAPI
3422c2c66affSColin Finck ULONG
3423c2c66affSColin Finck NTAPI
3424c2c66affSColin Finck RtlFindFirstRunClear(
3425c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3426c2c66affSColin Finck     _Out_ PULONG StartingIndex
3427c2c66affSColin Finck );
3428c2c66affSColin Finck 
3429c2c66affSColin Finck NTSYSAPI
3430c2c66affSColin Finck ULONG
3431c2c66affSColin Finck NTAPI
3432c2c66affSColin Finck RtlFindClearRuns(
3433c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3434c2c66affSColin Finck     _Out_writes_to_(SizeOfRunArray, return) PRTL_BITMAP_RUN RunArray,
3435c2c66affSColin Finck     _In_range_(>, 0) ULONG SizeOfRunArray,
3436c2c66affSColin Finck     _In_ BOOLEAN LocateLongestRuns
3437c2c66affSColin Finck );
3438c2c66affSColin Finck 
3439c2c66affSColin Finck NTSYSAPI
3440c2c66affSColin Finck ULONG
3441c2c66affSColin Finck NTAPI
3442c2c66affSColin Finck RtlFindLastBackwardRunClear(
3443c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3444c2c66affSColin Finck     _In_ ULONG FromIndex,
3445c2c66affSColin Finck     _Out_ PULONG StartingRunIndex
3446c2c66affSColin Finck );
3447c2c66affSColin Finck 
3448c2c66affSColin Finck NTSYSAPI
3449c2c66affSColin Finck CCHAR
3450c2c66affSColin Finck NTAPI
3451c2c66affSColin Finck RtlFindLeastSignificantBit(
3452c2c66affSColin Finck     _In_ ULONGLONG Value
3453c2c66affSColin Finck );
3454c2c66affSColin Finck 
3455c2c66affSColin Finck NTSYSAPI
3456c2c66affSColin Finck ULONG
3457c2c66affSColin Finck NTAPI
3458c2c66affSColin Finck RtlFindLongestRunClear(
3459c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3460c2c66affSColin Finck     _Out_ PULONG StartingIndex
3461c2c66affSColin Finck );
3462c2c66affSColin Finck 
3463c2c66affSColin Finck NTSYSAPI
3464c2c66affSColin Finck CCHAR
3465c2c66affSColin Finck NTAPI
3466c2c66affSColin Finck RtlFindMostSignificantBit(
3467c2c66affSColin Finck     _In_ ULONGLONG Value
3468c2c66affSColin Finck );
3469c2c66affSColin Finck 
3470c2c66affSColin Finck NTSYSAPI
3471c2c66affSColin Finck ULONG
3472c2c66affSColin Finck NTAPI
3473c2c66affSColin Finck RtlFindNextForwardRunClear(
3474c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3475c2c66affSColin Finck     _In_ ULONG FromIndex,
3476c2c66affSColin Finck     _Out_ PULONG StartingRunIndex
3477c2c66affSColin Finck );
3478c2c66affSColin Finck 
3479c2c66affSColin Finck NTSYSAPI
3480c2c66affSColin Finck ULONG
3481c2c66affSColin Finck NTAPI
3482c2c66affSColin Finck RtlFindNextForwardRunSet(
3483c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3484c2c66affSColin Finck     _In_ ULONG FromIndex,
3485c2c66affSColin Finck     _Out_ PULONG StartingRunIndex
3486c2c66affSColin Finck );
3487c2c66affSColin Finck 
3488c2c66affSColin Finck NTSYSAPI
3489c2c66affSColin Finck ULONG
3490c2c66affSColin Finck NTAPI
3491c2c66affSColin Finck RtlFindSetBits(
3492c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3493c2c66affSColin Finck     _In_ ULONG NumberToFind,
3494c2c66affSColin Finck     _In_ ULONG HintIndex
3495c2c66affSColin Finck );
3496c2c66affSColin Finck 
3497c2c66affSColin Finck NTSYSAPI
3498c2c66affSColin Finck ULONG
3499c2c66affSColin Finck NTAPI
3500c2c66affSColin Finck RtlFindSetBitsAndClear(
3501c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3502c2c66affSColin Finck     _In_ ULONG NumberToFind,
3503c2c66affSColin Finck     _In_ ULONG HintIndex
3504c2c66affSColin Finck );
3505c2c66affSColin Finck 
3506bdb60afcSHermès Bélusca-Maïto #ifdef __REACTOS__ // ReactOS improvement
3507c2c66affSColin Finck _At_(BitMapHeader->SizeOfBitMap, _Post_equal_to_(SizeOfBitMap))
3508c2c66affSColin Finck _At_(BitMapHeader->Buffer, _Post_equal_to_(BitMapBuffer))
3509c2c66affSColin Finck #endif
3510c2c66affSColin Finck NTSYSAPI
3511c2c66affSColin Finck VOID
3512c2c66affSColin Finck NTAPI
3513c2c66affSColin Finck RtlInitializeBitMap(
3514c2c66affSColin Finck     _Out_ PRTL_BITMAP BitMapHeader,
3515c2c66affSColin Finck     _In_opt_ __drv_aliasesMem PULONG BitMapBuffer,
3516c2c66affSColin Finck     _In_opt_ ULONG SizeOfBitMap
3517c2c66affSColin Finck );
3518c2c66affSColin Finck 
3519c2c66affSColin Finck NTSYSAPI
3520c2c66affSColin Finck ULONG
3521c2c66affSColin Finck NTAPI
3522c2c66affSColin Finck RtlNumberOfClearBits(
3523c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader
3524c2c66affSColin Finck );
3525c2c66affSColin Finck 
3526c2c66affSColin Finck NTSYSAPI
3527c2c66affSColin Finck ULONG
3528c2c66affSColin Finck NTAPI
3529c2c66affSColin Finck RtlNumberOfSetBits(
3530c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader
3531c2c66affSColin Finck );
3532c2c66affSColin Finck 
3533c2c66affSColin Finck NTSYSAPI
3534c2c66affSColin Finck VOID
3535c2c66affSColin Finck NTAPI
3536c2c66affSColin Finck RtlSetBit(
3537c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3538c2c66affSColin Finck     _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3539c2c66affSColin Finck );
3540c2c66affSColin Finck 
3541c2c66affSColin Finck NTSYSAPI
3542c2c66affSColin Finck VOID
3543c2c66affSColin Finck NTAPI
3544c2c66affSColin Finck RtlSetBits(
3545c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3546c2c66affSColin Finck     _In_range_(0, BitMapHeader->SizeOfBitMap - NumberToSet) ULONG StartingIndex,
3547c2c66affSColin Finck     _In_range_(0, BitMapHeader->SizeOfBitMap - StartingIndex) ULONG NumberToSet
3548c2c66affSColin Finck );
3549c2c66affSColin Finck 
3550c2c66affSColin Finck NTSYSAPI
3551c2c66affSColin Finck VOID
3552c2c66affSColin Finck NTAPI
3553c2c66affSColin Finck RtlSetAllBits(
3554c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader
3555c2c66affSColin Finck );
3556c2c66affSColin Finck 
3557c2c66affSColin Finck _Must_inspect_result_
3558c2c66affSColin Finck NTSYSAPI
3559c2c66affSColin Finck BOOLEAN
3560c2c66affSColin Finck NTAPI
3561c2c66affSColin Finck RtlTestBit(
3562c2c66affSColin Finck     _In_ PRTL_BITMAP BitMapHeader,
3563c2c66affSColin Finck     _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitNumber
3564c2c66affSColin Finck );
3565c2c66affSColin Finck 
3566c2c66affSColin Finck #if defined(_M_AMD64)
3567c2c66affSColin Finck _Must_inspect_result_
3568c2c66affSColin Finck FORCEINLINE
3569c2c66affSColin Finck BOOLEAN
3570c2c66affSColin Finck RtlCheckBit(
3571c2c66affSColin Finck   _In_ PRTL_BITMAP BitMapHeader,
3572c2c66affSColin Finck   _In_range_(<, BitMapHeader->SizeOfBitMap) ULONG BitPosition)
3573c2c66affSColin Finck {
3574c2c66affSColin Finck   return BitTest64((LONG64 CONST*)BitMapHeader->Buffer, (LONG64)BitPosition);
3575c2c66affSColin Finck }
3576c2c66affSColin Finck #else
3577c2c66affSColin Finck #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP)/32]) >> ((BP)%32)) & 0x1)
3578c2c66affSColin Finck #endif /* defined(_M_AMD64) */
3579c2c66affSColin Finck 
3580c2c66affSColin Finck #endif // NTOS_MODE_USER
3581c2c66affSColin Finck 
3582c2c66affSColin Finck 
3583c2c66affSColin Finck //
3584c2c66affSColin Finck // Timer Functions
3585c2c66affSColin Finck //
3586c2c66affSColin Finck NTSYSAPI
3587c2c66affSColin Finck NTSTATUS
3588c2c66affSColin Finck NTAPI
3589c2c66affSColin Finck RtlCreateTimer(
3590c2c66affSColin Finck     _In_ HANDLE TimerQueue,
3591c2c66affSColin Finck     _In_ PHANDLE phNewTimer,
3592c2c66affSColin Finck     _In_ WAITORTIMERCALLBACKFUNC Callback,
3593c2c66affSColin Finck     _In_ PVOID Parameter,
3594c2c66affSColin Finck     _In_ ULONG DueTime,
3595c2c66affSColin Finck     _In_ ULONG Period,
3596c2c66affSColin Finck     _In_ ULONG Flags
3597c2c66affSColin Finck );
3598c2c66affSColin Finck 
3599c2c66affSColin Finck NTSYSAPI
3600c2c66affSColin Finck NTSTATUS
3601c2c66affSColin Finck NTAPI
3602c2c66affSColin Finck RtlCreateTimerQueue(PHANDLE TimerQueue);
3603c2c66affSColin Finck 
3604c2c66affSColin Finck NTSYSAPI
3605c2c66affSColin Finck NTSTATUS
3606c2c66affSColin Finck NTAPI
3607c2c66affSColin Finck RtlDeleteTimer(
3608c2c66affSColin Finck     _In_ HANDLE TimerQueue,
3609c2c66affSColin Finck     _In_ HANDLE Timer,
3610c2c66affSColin Finck     _In_ HANDLE CompletionEvent
3611c2c66affSColin Finck );
3612c2c66affSColin Finck 
3613c2c66affSColin Finck NTSYSAPI
3614c2c66affSColin Finck NTSTATUS
3615c2c66affSColin Finck NTAPI
3616c2c66affSColin Finck RtlUpdateTimer(
3617c2c66affSColin Finck     _In_ HANDLE TimerQueue,
3618c2c66affSColin Finck     _In_ HANDLE Timer,
3619c2c66affSColin Finck     _In_ ULONG DueTime,
3620c2c66affSColin Finck     _In_ ULONG Period
3621c2c66affSColin Finck );
3622c2c66affSColin Finck 
3623c2c66affSColin Finck NTSYSAPI
3624c2c66affSColin Finck NTSTATUS
3625c2c66affSColin Finck NTAPI
3626c2c66affSColin Finck RtlDeleteTimerQueueEx(
3627c2c66affSColin Finck     _In_ HANDLE TimerQueue,
3628c2c66affSColin Finck     _In_opt_ HANDLE CompletionEvent
3629c2c66affSColin Finck );
3630c2c66affSColin Finck 
3631c2c66affSColin Finck NTSYSAPI
3632c2c66affSColin Finck NTSTATUS
3633c2c66affSColin Finck NTAPI
3634c2c66affSColin Finck RtlDeleteTimerQueue(HANDLE TimerQueue);
3635c2c66affSColin Finck 
3636c2c66affSColin Finck //
3637c2c66affSColin Finck // SList functions
3638c2c66affSColin Finck //
3639c2c66affSColin Finck PSLIST_ENTRY
3640c2c66affSColin Finck FASTCALL
3641c2c66affSColin Finck InterlockedPushListSList(
3642c2c66affSColin Finck     _Inout_ PSLIST_HEADER ListHead,
3643c2c66affSColin Finck     _Inout_ __drv_aliasesMem PSLIST_ENTRY List,
3644c2c66affSColin Finck     _Inout_ PSLIST_ENTRY ListEnd,
3645c2c66affSColin Finck     _In_ ULONG Count
3646c2c66affSColin Finck );
3647c2c66affSColin Finck 
3648c2c66affSColin Finck //
3649c2c66affSColin Finck // Range List functions
3650c2c66affSColin Finck //
3651c2c66affSColin Finck NTSYSAPI
3652c2c66affSColin Finck VOID
3653c2c66affSColin Finck NTAPI
3654c2c66affSColin Finck RtlInitializeRangeList(
36552c4a554dSThomas Faber     _Out_ PRTL_RANGE_LIST RangeList
3656c2c66affSColin Finck );
3657c2c66affSColin Finck 
3658c2c66affSColin Finck NTSYSAPI
3659c2c66affSColin Finck VOID
3660c2c66affSColin Finck NTAPI
3661c2c66affSColin Finck RtlFreeRangeList(
3662c2c66affSColin Finck     _In_ PRTL_RANGE_LIST RangeList
3663c2c66affSColin Finck );
3664c2c66affSColin Finck 
3665c2c66affSColin Finck NTSYSAPI
3666c2c66affSColin Finck NTSTATUS
3667c2c66affSColin Finck NTAPI
36682c4a554dSThomas Faber RtlCopyRangeList(
36692c4a554dSThomas Faber     _Out_ PRTL_RANGE_LIST CopyRangeList,
36702c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList
36712c4a554dSThomas Faber );
36722c4a554dSThomas Faber 
36732c4a554dSThomas Faber NTSYSAPI
36742c4a554dSThomas Faber NTSTATUS
36752c4a554dSThomas Faber NTAPI
36762c4a554dSThomas Faber RtlMergeRangeLists(
36772c4a554dSThomas Faber     _Out_ PRTL_RANGE_LIST MergedRangeList,
36782c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList1,
36792c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList2,
36802c4a554dSThomas Faber     _In_ ULONG Flags
36812c4a554dSThomas Faber );
36822c4a554dSThomas Faber 
36832c4a554dSThomas Faber NTSYSAPI
36842c4a554dSThomas Faber NTSTATUS
36852c4a554dSThomas Faber NTAPI
36862c4a554dSThomas Faber RtlInvertRangeList(
36872c4a554dSThomas Faber     _Out_ PRTL_RANGE_LIST InvertedRangeList,
36882c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList
36892c4a554dSThomas Faber );
36902c4a554dSThomas Faber 
36912c4a554dSThomas Faber NTSYSAPI
36922c4a554dSThomas Faber NTSTATUS
36932c4a554dSThomas Faber NTAPI
3694c2c66affSColin Finck RtlAddRange(
3695c2c66affSColin Finck     _Inout_ PRTL_RANGE_LIST RangeList,
3696c2c66affSColin Finck     _In_ ULONGLONG Start,
3697c2c66affSColin Finck     _In_ ULONGLONG End,
3698c2c66affSColin Finck     _In_ UCHAR Attributes,
3699c2c66affSColin Finck     _In_ ULONG Flags,
3700c2c66affSColin Finck     _In_opt_ PVOID UserData,
3701c2c66affSColin Finck     _In_opt_ PVOID Owner
3702c2c66affSColin Finck );
3703c2c66affSColin Finck 
37042c4a554dSThomas Faber NTSYSAPI
37052c4a554dSThomas Faber NTSTATUS
37062c4a554dSThomas Faber NTAPI
37072c4a554dSThomas Faber RtlDeleteRange(
37082c4a554dSThomas Faber     _Inout_ PRTL_RANGE_LIST RangeList,
37092c4a554dSThomas Faber     _In_ ULONGLONG Start,
37102c4a554dSThomas Faber     _In_ ULONGLONG End,
37112c4a554dSThomas Faber     _In_ PVOID Owner
37122c4a554dSThomas Faber );
37132c4a554dSThomas Faber 
37142c4a554dSThomas Faber NTSYSAPI
37152c4a554dSThomas Faber NTSTATUS
37162c4a554dSThomas Faber NTAPI
37172c4a554dSThomas Faber RtlDeleteOwnersRanges(
37182c4a554dSThomas Faber     _Inout_ PRTL_RANGE_LIST RangeList,
37192c4a554dSThomas Faber     _In_ _Maybenull_ PVOID Owner
37202c4a554dSThomas Faber );
37212c4a554dSThomas Faber 
37222c4a554dSThomas Faber NTSYSAPI
37232c4a554dSThomas Faber NTSTATUS
37242c4a554dSThomas Faber NTAPI
37252c4a554dSThomas Faber RtlFindRange(
37262c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList,
37272c4a554dSThomas Faber     _In_ ULONGLONG Minimum,
37282c4a554dSThomas Faber     _In_ ULONGLONG Maximum,
37292c4a554dSThomas Faber     _In_ ULONG Length,
37302c4a554dSThomas Faber     _In_ ULONG Alignment,
37312c4a554dSThomas Faber     _In_ ULONG Flags,
37322c4a554dSThomas Faber     _In_ UCHAR AttributeAvailableMask,
37332c4a554dSThomas Faber     _In_opt_ PVOID Context,
37342c4a554dSThomas Faber     _In_opt_ PRTL_CONFLICT_RANGE_CALLBACK Callback,
37352c4a554dSThomas Faber     _Out_ PULONGLONG Start
37362c4a554dSThomas Faber );
37372c4a554dSThomas Faber 
37382c4a554dSThomas Faber NTSYSAPI
37392c4a554dSThomas Faber NTSTATUS
37402c4a554dSThomas Faber NTAPI
37412c4a554dSThomas Faber RtlIsRangeAvailable(
37422c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList,
37432c4a554dSThomas Faber     _In_ ULONGLONG Start,
37442c4a554dSThomas Faber     _In_ ULONGLONG End,
37452c4a554dSThomas Faber     _In_ ULONG Flags,
37462c4a554dSThomas Faber     _In_ UCHAR AttributeAvailableMask,
37472c4a554dSThomas Faber     _In_opt_ PVOID Context,
37482c4a554dSThomas Faber     _In_opt_ PRTL_CONFLICT_RANGE_CALLBACK Callback,
37492c4a554dSThomas Faber     _Out_ PBOOLEAN Available
37502c4a554dSThomas Faber );
37512c4a554dSThomas Faber 
37522c4a554dSThomas Faber NTSYSAPI
37532c4a554dSThomas Faber NTSTATUS
37542c4a554dSThomas Faber NTAPI
37552c4a554dSThomas Faber RtlGetFirstRange(
37562c4a554dSThomas Faber     _In_ PRTL_RANGE_LIST RangeList,
37572c4a554dSThomas Faber     _Out_ PRTL_RANGE_LIST_ITERATOR Iterator,
37582c4a554dSThomas Faber     _Outptr_ PRTL_RANGE *Range
37592c4a554dSThomas Faber );
37602c4a554dSThomas Faber 
37612c4a554dSThomas Faber NTSYSAPI
37622c4a554dSThomas Faber NTSTATUS
37632c4a554dSThomas Faber NTAPI
37642c4a554dSThomas Faber RtlGetNextRange(
37652c4a554dSThomas Faber     _Inout_ PRTL_RANGE_LIST_ITERATOR Iterator,
37662c4a554dSThomas Faber     _Outptr_ PRTL_RANGE *Range,
37672c4a554dSThomas Faber     _In_ BOOLEAN MoveForwards
37682c4a554dSThomas Faber );
37692c4a554dSThomas Faber 
3770c2c66affSColin Finck //
3771c2c66affSColin Finck // Debug Functions
3772c2c66affSColin Finck //
3773c2c66affSColin Finck ULONG
3774c2c66affSColin Finck __cdecl
3775c2c66affSColin Finck DbgPrint(
3776c2c66affSColin Finck     _In_z_ _Printf_format_string_ PCSTR Format,
3777c2c66affSColin Finck     ...
3778c2c66affSColin Finck );
3779c2c66affSColin Finck 
3780c2c66affSColin Finck NTSYSAPI
3781c2c66affSColin Finck ULONG
3782c2c66affSColin Finck __cdecl
3783c2c66affSColin Finck DbgPrintEx(
3784c2c66affSColin Finck     _In_ ULONG ComponentId,
3785c2c66affSColin Finck     _In_ ULONG Level,
3786c2c66affSColin Finck     _In_z_ _Printf_format_string_ PCSTR Format,
3787c2c66affSColin Finck     ...
3788c2c66affSColin Finck );
3789c2c66affSColin Finck 
3790c2c66affSColin Finck NTSYSAPI
3791c2c66affSColin Finck ULONG
3792c2c66affSColin Finck NTAPI
3793c2c66affSColin Finck DbgPrompt(
3794c2c66affSColin Finck     _In_z_ PCCH Prompt,
3795c2c66affSColin Finck     _Out_writes_bytes_(MaximumResponseLength) PCH Response,
3796c2c66affSColin Finck     _In_ ULONG MaximumResponseLength
3797c2c66affSColin Finck );
3798c2c66affSColin Finck 
3799c2c66affSColin Finck #undef DbgBreakPoint
3800c2c66affSColin Finck VOID
3801c2c66affSColin Finck NTAPI
3802c2c66affSColin Finck DbgBreakPoint(
3803c2c66affSColin Finck     VOID
3804c2c66affSColin Finck );
3805c2c66affSColin Finck 
3806c2c66affSColin Finck VOID
3807c2c66affSColin Finck NTAPI
3808c2c66affSColin Finck DbgLoadImageSymbols(
3809c2c66affSColin Finck     _In_ PSTRING Name,
3810c2c66affSColin Finck     _In_ PVOID Base,
3811c2c66affSColin Finck     _In_ ULONG_PTR ProcessId
3812c2c66affSColin Finck );
3813c2c66affSColin Finck 
3814c2c66affSColin Finck VOID
3815c2c66affSColin Finck NTAPI
3816c2c66affSColin Finck DbgUnLoadImageSymbols(
3817c2c66affSColin Finck     _In_ PSTRING Name,
3818c2c66affSColin Finck     _In_ PVOID Base,
3819c2c66affSColin Finck     _In_ ULONG_PTR ProcessId
3820c2c66affSColin Finck );
3821c2c66affSColin Finck 
3822c2c66affSColin Finck VOID
3823c2c66affSColin Finck NTAPI
3824c2c66affSColin Finck DbgCommandString(
3825c2c66affSColin Finck     _In_ PCCH Name,
3826c2c66affSColin Finck     _In_ PCCH Command
3827c2c66affSColin Finck );
3828c2c66affSColin Finck 
3829c2c66affSColin Finck //
3830c2c66affSColin Finck // Generic Table Functions
3831c2c66affSColin Finck //
3832c2c66affSColin Finck #if defined(NTOS_MODE_USER) || defined(_NTIFS_)
3833c2c66affSColin Finck NTSYSAPI
3834c2c66affSColin Finck PVOID
3835c2c66affSColin Finck NTAPI
3836c2c66affSColin Finck RtlInsertElementGenericTable(
3837c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
3838c2c66affSColin Finck     _In_reads_bytes_(BufferSize) PVOID Buffer,
3839c2c66affSColin Finck     _In_ CLONG BufferSize,
3840c2c66affSColin Finck     _Out_opt_ PBOOLEAN NewElement
3841c2c66affSColin Finck );
3842c2c66affSColin Finck 
3843c2c66affSColin Finck NTSYSAPI
3844c2c66affSColin Finck PVOID
3845c2c66affSColin Finck NTAPI
3846c2c66affSColin Finck RtlInsertElementGenericTableFull(
3847c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
3848c2c66affSColin Finck     _In_reads_bytes_(BufferSize) PVOID Buffer,
3849c2c66affSColin Finck     _In_ CLONG BufferSize,
3850c2c66affSColin Finck     _Out_opt_ PBOOLEAN NewElement,
3851c2c66affSColin Finck     _In_ PVOID NodeOrParent,
3852c2c66affSColin Finck     _In_ TABLE_SEARCH_RESULT SearchResult
3853c2c66affSColin Finck );
3854c2c66affSColin Finck 
3855c2c66affSColin Finck NTSYSAPI
3856c2c66affSColin Finck BOOLEAN
3857c2c66affSColin Finck NTAPI
3858c2c66affSColin Finck RtlIsGenericTableEmpty(
3859c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table
3860c2c66affSColin Finck );
3861c2c66affSColin Finck 
3862c2c66affSColin Finck NTSYSAPI
3863c2c66affSColin Finck PVOID
3864c2c66affSColin Finck NTAPI
3865c2c66affSColin Finck RtlLookupElementGenericTableFull(
3866c2c66affSColin Finck     _In_ PRTL_GENERIC_TABLE Table,
3867c2c66affSColin Finck     _In_ PVOID Buffer,
3868c2c66affSColin Finck     _Out_ PVOID *NodeOrParent,
3869c2c66affSColin Finck     _Out_ TABLE_SEARCH_RESULT *SearchResult
3870c2c66affSColin Finck );
3871c2c66affSColin Finck #endif
3872c2c66affSColin Finck 
3873c2c66affSColin Finck //
3874c2c66affSColin Finck // Handle Table Functions
3875c2c66affSColin Finck //
3876c2c66affSColin Finck NTSYSAPI
3877c2c66affSColin Finck PRTL_HANDLE_TABLE_ENTRY
3878c2c66affSColin Finck NTAPI
3879c2c66affSColin Finck RtlAllocateHandle(
3880c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE HandleTable,
3881c2c66affSColin Finck     _Inout_ PULONG Index
3882c2c66affSColin Finck );
3883c2c66affSColin Finck 
3884c2c66affSColin Finck NTSYSAPI
3885c2c66affSColin Finck VOID
3886c2c66affSColin Finck NTAPI
3887c2c66affSColin Finck RtlDestroyHandleTable(
3888c2c66affSColin Finck     _Inout_ PRTL_HANDLE_TABLE HandleTable);
3889c2c66affSColin Finck 
3890c2c66affSColin Finck NTSYSAPI
3891c2c66affSColin Finck BOOLEAN
3892c2c66affSColin Finck NTAPI
3893c2c66affSColin Finck RtlFreeHandle(
3894c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE HandleTable,
3895c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3896c2c66affSColin Finck );
3897c2c66affSColin Finck 
3898c2c66affSColin Finck NTSYSAPI
3899c2c66affSColin Finck VOID
3900c2c66affSColin Finck NTAPI
3901c2c66affSColin Finck RtlInitializeHandleTable(
3902c2c66affSColin Finck     _In_ ULONG TableSize,
3903c2c66affSColin Finck     _In_ ULONG HandleSize,
3904c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE HandleTable
3905c2c66affSColin Finck );
3906c2c66affSColin Finck 
3907c2c66affSColin Finck NTSYSAPI
3908c2c66affSColin Finck BOOLEAN
3909c2c66affSColin Finck NTAPI
3910c2c66affSColin Finck RtlIsValidHandle(
3911c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE HandleTable,
3912c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE_ENTRY Handle
3913c2c66affSColin Finck );
3914c2c66affSColin Finck 
3915c2c66affSColin Finck _Success_(return!=FALSE)
3916c2c66affSColin Finck NTSYSAPI
3917c2c66affSColin Finck BOOLEAN
3918c2c66affSColin Finck NTAPI
3919c2c66affSColin Finck RtlIsValidIndexHandle(
3920c2c66affSColin Finck     _In_ PRTL_HANDLE_TABLE HandleTable,
3921c2c66affSColin Finck     _In_ ULONG Index,
3922c2c66affSColin Finck     _Out_ PRTL_HANDLE_TABLE_ENTRY *Handle
3923c2c66affSColin Finck );
3924c2c66affSColin Finck 
3925c2c66affSColin Finck //
3926c2c66affSColin Finck // PE Functions
3927c2c66affSColin Finck //
3928c2c66affSColin Finck NTSYSAPI
3929c2c66affSColin Finck NTSTATUS
3930c2c66affSColin Finck NTAPI
3931c2c66affSColin Finck RtlFindMessage(
3932c2c66affSColin Finck     _In_ PVOID BaseAddress,
3933c2c66affSColin Finck     _In_ ULONG Type,
3934c2c66affSColin Finck     _In_ ULONG Language,
3935c2c66affSColin Finck     _In_ ULONG MessageId,
3936c2c66affSColin Finck     _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry
3937c2c66affSColin Finck );
3938c2c66affSColin Finck 
3939c2c66affSColin Finck NTSYSAPI
3940c2c66affSColin Finck ULONG
3941c2c66affSColin Finck NTAPI
3942c2c66affSColin Finck RtlGetNtGlobalFlags(VOID);
3943c2c66affSColin Finck 
3944c2c66affSColin Finck _Success_(return!=NULL)
3945c2c66affSColin Finck NTSYSAPI
3946c2c66affSColin Finck PVOID
3947c2c66affSColin Finck NTAPI
3948c2c66affSColin Finck RtlImageDirectoryEntryToData(
3949c2c66affSColin Finck     _In_ PVOID BaseAddress,
3950c2c66affSColin Finck     _In_ BOOLEAN MappedAsImage,
3951c2c66affSColin Finck     _In_ USHORT Directory,
3952c2c66affSColin Finck     _Out_ PULONG Size
3953c2c66affSColin Finck );
3954c2c66affSColin Finck 
3955c2c66affSColin Finck NTSYSAPI
3956c2c66affSColin Finck PVOID
3957c2c66affSColin Finck NTAPI
3958c2c66affSColin Finck RtlImageRvaToVa(
3959c2c66affSColin Finck     _In_ PIMAGE_NT_HEADERS NtHeader,
3960c2c66affSColin Finck     _In_ PVOID BaseAddress,
3961c2c66affSColin Finck     _In_ ULONG Rva,
3962c2c66affSColin Finck     _Inout_opt_ PIMAGE_SECTION_HEADER *SectionHeader
3963c2c66affSColin Finck );
3964c2c66affSColin Finck 
3965c2c66affSColin Finck NTSYSAPI
3966c2c66affSColin Finck PIMAGE_NT_HEADERS
3967c2c66affSColin Finck NTAPI
3968c2c66affSColin Finck RtlImageNtHeader(
3969c2c66affSColin Finck     _In_ PVOID BaseAddress);
3970c2c66affSColin Finck 
3971c2c66affSColin Finck NTSYSAPI
3972c2c66affSColin Finck NTSTATUS
3973c2c66affSColin Finck NTAPI
3974c2c66affSColin Finck RtlImageNtHeaderEx(
3975c2c66affSColin Finck     _In_ ULONG Flags,
3976c2c66affSColin Finck     _In_ PVOID BaseAddress,
3977c2c66affSColin Finck     _In_ ULONGLONG Size,
3978c2c66affSColin Finck     _Out_ PIMAGE_NT_HEADERS *NtHeader
3979c2c66affSColin Finck );
3980c2c66affSColin Finck 
3981c2c66affSColin Finck NTSYSAPI
3982c2c66affSColin Finck PIMAGE_SECTION_HEADER
3983c2c66affSColin Finck NTAPI
3984c2c66affSColin Finck RtlImageRvaToSection(
3985c2c66affSColin Finck     _In_ PIMAGE_NT_HEADERS NtHeader,
3986c2c66affSColin Finck     _In_ PVOID BaseAddress,
3987c2c66affSColin Finck     _In_ ULONG Rva
3988c2c66affSColin Finck );
3989c2c66affSColin Finck 
3990c2c66affSColin Finck ULONG
3991c2c66affSColin Finck NTAPI
3992c2c66affSColin Finck LdrRelocateImageWithBias(
3993bd0a5498SRatin Gao     _In_ PVOID BaseAddress,
3994c2c66affSColin Finck     _In_ LONGLONG AdditionalBias,
3995bd0a5498SRatin Gao     _In_opt_ PCSTR LoaderName,
3996c2c66affSColin Finck     _In_ ULONG Success,
3997c2c66affSColin Finck     _In_ ULONG Conflict,
3998c2c66affSColin Finck     _In_ ULONG Invalid
3999c2c66affSColin Finck );
4000c2c66affSColin Finck 
4001c2c66affSColin Finck //
4002c2c66affSColin Finck // Activation Context Functions
4003c2c66affSColin Finck //
4004c2c66affSColin Finck #ifdef NTOS_MODE_USER
4005c2c66affSColin Finck NTSYSAPI
4006c2c66affSColin Finck NTSTATUS
4007c2c66affSColin Finck NTAPI
4008c2c66affSColin Finck RtlActivateActivationContextEx(
4009c2c66affSColin Finck     _In_ ULONG Flags,
4010c2c66affSColin Finck     _In_ PTEB Teb,
4011c2c66affSColin Finck     _In_ PVOID Context,
4012c2c66affSColin Finck     _Out_ PULONG_PTR Cookie
4013c2c66affSColin Finck );
4014c2c66affSColin Finck 
4015c2c66affSColin Finck NTSYSAPI
4016c2c66affSColin Finck NTSTATUS
4017c2c66affSColin Finck NTAPI
4018c2c66affSColin Finck RtlActivateActivationContext(
4019c2c66affSColin Finck     _In_ ULONG Flags,
4020c2c66affSColin Finck     _In_ HANDLE Handle,
4021c2c66affSColin Finck     _Out_ PULONG_PTR Cookie
4022c2c66affSColin Finck );
4023c2c66affSColin Finck 
4024c2c66affSColin Finck NTSYSAPI
4025c2c66affSColin Finck VOID
4026c2c66affSColin Finck NTAPI
4027c2c66affSColin Finck RtlAddRefActivationContext(
4028c2c66affSColin Finck     _In_ PVOID Context
4029c2c66affSColin Finck );
4030c2c66affSColin Finck 
4031c2c66affSColin Finck NTSYSAPI
4032c2c66affSColin Finck PRTL_ACTIVATION_CONTEXT_STACK_FRAME
4033c2c66affSColin Finck FASTCALL
4034c2c66affSColin Finck RtlActivateActivationContextUnsafeFast(
4035c2c66affSColin Finck     _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
4036c2c66affSColin Finck     _In_ PVOID Context
4037c2c66affSColin Finck );
4038c2c66affSColin Finck 
4039c2c66affSColin Finck NTSYSAPI
4040c2c66affSColin Finck NTSTATUS
4041c2c66affSColin Finck NTAPI
4042c2c66affSColin Finck RtlAllocateActivationContextStack(
4043c2c66affSColin Finck     _In_ PACTIVATION_CONTEXT_STACK *Stack
4044c2c66affSColin Finck );
4045c2c66affSColin Finck 
4046c2c66affSColin Finck NTSYSAPI
4047c2c66affSColin Finck NTSTATUS
4048c2c66affSColin Finck NTAPI
4049c2c66affSColin Finck RtlCreateActivationContext(
4050c2c66affSColin Finck     _In_ ULONG Flags,
4051c2c66affSColin Finck     _In_ PACTIVATION_CONTEXT_DATA ActivationContextData,
4052c2c66affSColin Finck     _In_ ULONG ExtraBytes,
4053c2c66affSColin Finck     _In_ PVOID NotificationRoutine,
4054c2c66affSColin Finck     _In_ PVOID NotificationContext,
4055c2c66affSColin Finck     _Out_ PACTIVATION_CONTEXT *ActCtx
4056c2c66affSColin Finck );
4057c2c66affSColin Finck 
4058c2c66affSColin Finck NTSYSAPI
4059c2c66affSColin Finck NTSTATUS
4060c2c66affSColin Finck NTAPI
4061c2c66affSColin Finck RtlGetActiveActivationContext(
4062c2c66affSColin Finck     _In_ PVOID *Context
4063c2c66affSColin Finck );
4064c2c66affSColin Finck 
4065c2c66affSColin Finck NTSYSAPI
4066c2c66affSColin Finck VOID
4067c2c66affSColin Finck NTAPI
4068c2c66affSColin Finck RtlReleaseActivationContext(
4069c2c66affSColin Finck     _In_ HANDLE handle
4070c2c66affSColin Finck );
4071c2c66affSColin Finck 
4072c2c66affSColin Finck NTSYSAPI
4073c2c66affSColin Finck NTSTATUS
4074c2c66affSColin Finck NTAPI
4075c2c66affSColin Finck RtlDeactivateActivationContext(
4076c2c66affSColin Finck     _In_ ULONG dwFlags,
4077c2c66affSColin Finck     _In_ ULONG_PTR ulCookie
4078c2c66affSColin Finck );
4079c2c66affSColin Finck 
4080c2c66affSColin Finck NTSYSAPI
4081c2c66affSColin Finck VOID
4082c2c66affSColin Finck NTAPI
4083c2c66affSColin Finck RtlFreeActivationContextStack(
4084c2c66affSColin Finck     _In_ PACTIVATION_CONTEXT_STACK Stack
4085c2c66affSColin Finck );
4086c2c66affSColin Finck 
4087c2c66affSColin Finck NTSYSAPI
4088c2c66affSColin Finck VOID
4089c2c66affSColin Finck NTAPI
4090c2c66affSColin Finck RtlFreeThreadActivationContextStack(VOID);
4091c2c66affSColin Finck 
4092c2c66affSColin Finck NTSYSAPI
4093c2c66affSColin Finck PRTL_ACTIVATION_CONTEXT_STACK_FRAME
4094c2c66affSColin Finck FASTCALL
4095c2c66affSColin Finck RtlDeactivateActivationContextUnsafeFast(
4096c2c66affSColin Finck     _In_ PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
4097c2c66affSColin Finck );
4098c2c66affSColin Finck 
4099c2c66affSColin Finck NTSYSAPI
4100c2c66affSColin Finck NTSTATUS
4101c2c66affSColin Finck NTAPI
4102c2c66affSColin Finck RtlDosApplyFileIsolationRedirection_Ustr(
4103c2c66affSColin Finck     _In_ ULONG Flags,
4104c2c66affSColin Finck     _In_ PUNICODE_STRING OriginalName,
4105c2c66affSColin Finck     _In_ PUNICODE_STRING Extension,
4106c2c66affSColin Finck     _Inout_ PUNICODE_STRING StaticString,
4107c2c66affSColin Finck     _Inout_ PUNICODE_STRING DynamicString,
4108c2c66affSColin Finck     _Inout_ PUNICODE_STRING *NewName,
4109c2c66affSColin Finck     _In_ PULONG NewFlags,
4110c2c66affSColin Finck     _In_ PSIZE_T FileNameSize,
4111c2c66affSColin Finck     _In_ PSIZE_T RequiredLength
4112c2c66affSColin Finck );
4113c2c66affSColin Finck 
4114c2c66affSColin Finck NTSYSAPI
4115c2c66affSColin Finck NTSTATUS
4116c2c66affSColin Finck NTAPI
4117c2c66affSColin Finck RtlFindActivationContextSectionString(
4118c2c66affSColin Finck     _In_ ULONG dwFlags,
4119c2c66affSColin Finck     _In_ const GUID *ExtensionGuid,
4120c2c66affSColin Finck     _In_ ULONG SectionType,
4121c2c66affSColin Finck     _In_ const UNICODE_STRING *SectionName,
4122c2c66affSColin Finck     _Inout_ PVOID ReturnedData
4123c2c66affSColin Finck );
4124c2c66affSColin Finck 
4125c2c66affSColin Finck NTSYSAPI
4126c2c66affSColin Finck NTSTATUS
4127c2c66affSColin Finck NTAPI
4128c2c66affSColin Finck RtlQueryInformationActivationContext(
4129c2c66affSColin Finck     _In_ DWORD dwFlags,
4130c2c66affSColin Finck     _In_opt_ PVOID Context,
4131c2c66affSColin Finck     _In_opt_ PVOID pvSubInstance,
4132c2c66affSColin Finck     _In_ ULONG ulInfoClass,
4133c2c66affSColin Finck     _Out_bytecap_(cbBuffer) PVOID pvBuffer,
4134c2c66affSColin Finck     _In_opt_ SIZE_T cbBuffer,
4135c2c66affSColin Finck     _Out_opt_ SIZE_T *pcbWrittenOrRequired
4136c2c66affSColin Finck );
4137c2c66affSColin Finck 
4138c2c66affSColin Finck NTSYSAPI
4139c2c66affSColin Finck NTSTATUS
4140c2c66affSColin Finck NTAPI
4141c2c66affSColin Finck RtlQueryInformationActiveActivationContext(
4142c2c66affSColin Finck     _In_ ULONG ulInfoClass,
4143c2c66affSColin Finck     _Out_bytecap_(cbBuffer) PVOID pvBuffer,
4144c2c66affSColin Finck     _In_opt_ SIZE_T cbBuffer,
4145c2c66affSColin Finck     _Out_opt_ SIZE_T *pcbWrittenOrRequired
4146c2c66affSColin Finck );
4147c2c66affSColin Finck 
4148c2c66affSColin Finck NTSYSAPI
4149c2c66affSColin Finck NTSTATUS
4150c2c66affSColin Finck NTAPI
4151c2c66affSColin Finck RtlZombifyActivationContext(
4152c2c66affSColin Finck     PVOID Context
4153c2c66affSColin Finck );
4154c2c66affSColin Finck 
4155c2c66affSColin Finck //
4156c2c66affSColin Finck // WOW64 Functions
4157c2c66affSColin Finck //
4158c2c66affSColin Finck NTSYSAPI
4159c2c66affSColin Finck NTSTATUS
4160c2c66affSColin Finck NTAPI
4161c2c66affSColin Finck RtlWow64EnableFsRedirection(
4162c2c66affSColin Finck     _In_ BOOLEAN Wow64FsEnableRedirection
4163c2c66affSColin Finck );
4164c2c66affSColin Finck 
4165c2c66affSColin Finck NTSYSAPI
4166c2c66affSColin Finck NTSTATUS
4167c2c66affSColin Finck NTAPI
4168c2c66affSColin Finck RtlWow64EnableFsRedirectionEx(
4169c2c66affSColin Finck     _In_ PVOID Wow64FsEnableRedirection,
4170c2c66affSColin Finck     _Out_ PVOID *OldFsRedirectionLevel
4171c2c66affSColin Finck );
4172c2c66affSColin Finck 
4173c2c66affSColin Finck #endif
4174c2c66affSColin Finck 
4175c2c66affSColin Finck //
4176c2c66affSColin Finck // Registry Functions
4177c2c66affSColin Finck //
4178c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
4179c2c66affSColin Finck _Must_inspect_result_
4180c2c66affSColin Finck NTSYSAPI
4181c2c66affSColin Finck NTSTATUS
4182c2c66affSColin Finck NTAPI
4183c2c66affSColin Finck RtlCheckRegistryKey(
4184c2c66affSColin Finck     _In_ ULONG RelativeTo,
4185c2c66affSColin Finck     _In_ PWSTR Path
4186c2c66affSColin Finck );
4187c2c66affSColin Finck 
4188c2c66affSColin Finck NTSYSAPI
4189c2c66affSColin Finck NTSTATUS
4190c2c66affSColin Finck NTAPI
4191c2c66affSColin Finck RtlCreateRegistryKey(
4192c2c66affSColin Finck     _In_ ULONG RelativeTo,
4193c2c66affSColin Finck     _In_ PWSTR Path
4194c2c66affSColin Finck );
4195c2c66affSColin Finck 
4196c2c66affSColin Finck NTSYSAPI
4197c2c66affSColin Finck NTSTATUS
4198c2c66affSColin Finck NTAPI
4199c2c66affSColin Finck RtlFormatCurrentUserKeyPath(
4200c2c66affSColin Finck     _Out_ _At_(KeyPath->Buffer, __drv_allocatesMem(Mem) _Post_bytecap_(KeyPath->MaximumLength) _Post_bytecount_(KeyPath->Length))
4201c2c66affSColin Finck         PUNICODE_STRING KeyPath
4202c2c66affSColin Finck );
4203c2c66affSColin Finck 
4204c2c66affSColin Finck NTSYSAPI
4205c2c66affSColin Finck NTSTATUS
4206c2c66affSColin Finck NTAPI
4207c2c66affSColin Finck RtlOpenCurrentUser(
4208c2c66affSColin Finck     _In_ ACCESS_MASK DesiredAccess,
4209c2c66affSColin Finck     _Out_ PHANDLE KeyHandle
4210c2c66affSColin Finck );
4211c2c66affSColin Finck 
4212c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
4213c2c66affSColin Finck NTSYSAPI
4214c2c66affSColin Finck NTSTATUS
4215c2c66affSColin Finck NTAPI
4216c2c66affSColin Finck RtlQueryRegistryValues(
4217c2c66affSColin Finck     _In_ ULONG RelativeTo,
4218c2c66affSColin Finck     _In_ PCWSTR Path,
4219c2c66affSColin Finck     _Inout_ _At_(*(*QueryTable).EntryContext, _Pre_unknown_)
4220c2c66affSColin Finck         PRTL_QUERY_REGISTRY_TABLE QueryTable,
4221c2c66affSColin Finck     _In_opt_ PVOID Context,
4222c2c66affSColin Finck     _In_opt_ PVOID Environment
4223c2c66affSColin Finck );
4224c2c66affSColin Finck 
4225c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
4226c2c66affSColin Finck NTSYSAPI
4227c2c66affSColin Finck NTSTATUS
4228c2c66affSColin Finck NTAPI
4229c2c66affSColin Finck RtlWriteRegistryValue(
4230c2c66affSColin Finck     _In_ ULONG RelativeTo,
4231c2c66affSColin Finck     _In_ PCWSTR Path,
4232c2c66affSColin Finck     _In_z_ PCWSTR ValueName,
4233c2c66affSColin Finck     _In_ ULONG ValueType,
4234c2c66affSColin Finck     _In_reads_bytes_opt_(ValueLength) PVOID ValueData,
4235c2c66affSColin Finck     _In_ ULONG ValueLength
4236c2c66affSColin Finck );
4237c2c66affSColin Finck 
4238c2c66affSColin Finck #ifdef NTOS_MODE_USER
4239c2c66affSColin Finck NTSYSAPI
4240c2c66affSColin Finck NTSTATUS
4241c2c66affSColin Finck NTAPI
4242c2c66affSColin Finck RtlpNtCreateKey(
4243c2c66affSColin Finck     _Out_ HANDLE KeyHandle,
4244c2c66affSColin Finck     _In_ ACCESS_MASK DesiredAccess,
4245c2c66affSColin Finck     _In_ POBJECT_ATTRIBUTES ObjectAttributes,
4246c2c66affSColin Finck     _In_ ULONG TitleIndex,
4247c2c66affSColin Finck     _In_ PUNICODE_STRING Class,
4248c2c66affSColin Finck     _Out_ PULONG Disposition
4249c2c66affSColin Finck );
4250c2c66affSColin Finck 
4251c2c66affSColin Finck NTSYSAPI
4252c2c66affSColin Finck NTSTATUS
4253c2c66affSColin Finck NTAPI
4254c2c66affSColin Finck RtlpNtEnumerateSubKey(
4255c2c66affSColin Finck     _In_ HANDLE KeyHandle,
4256c2c66affSColin Finck     _Inout_ PUNICODE_STRING SubKeyName,
4257c2c66affSColin Finck     _In_ ULONG Index,
4258c2c66affSColin Finck     _In_ ULONG Unused
4259c2c66affSColin Finck );
4260c2c66affSColin Finck 
4261c2c66affSColin Finck NTSYSAPI
4262c2c66affSColin Finck NTSTATUS
4263c2c66affSColin Finck NTAPI
4264c2c66affSColin Finck RtlpNtMakeTemporaryKey(
4265c2c66affSColin Finck     _In_ HANDLE KeyHandle
4266c2c66affSColin Finck );
4267c2c66affSColin Finck 
4268c2c66affSColin Finck NTSYSAPI
4269c2c66affSColin Finck NTSTATUS
4270c2c66affSColin Finck NTAPI
4271c2c66affSColin Finck RtlpNtOpenKey(
4272c2c66affSColin Finck     _Out_ HANDLE KeyHandle,
4273c2c66affSColin Finck     _In_ ACCESS_MASK DesiredAccess,
4274c2c66affSColin Finck     _In_ POBJECT_ATTRIBUTES ObjectAttributes,
4275c2c66affSColin Finck     _In_ ULONG Unused
4276c2c66affSColin Finck );
4277c2c66affSColin Finck 
4278c2c66affSColin Finck NTSYSAPI
4279c2c66affSColin Finck NTSTATUS
4280c2c66affSColin Finck NTAPI
4281c2c66affSColin Finck RtlpNtQueryValueKey(
4282c2c66affSColin Finck     _In_ HANDLE KeyHandle,
4283c2c66affSColin Finck     _Out_opt_ PULONG Type,
4284c2c66affSColin Finck     _Out_opt_ PVOID Data,
4285c2c66affSColin Finck     _Inout_opt_ PULONG DataLength,
4286c2c66affSColin Finck     _In_ ULONG Unused
4287c2c66affSColin Finck );
4288c2c66affSColin Finck 
4289c2c66affSColin Finck NTSYSAPI
4290c2c66affSColin Finck NTSTATUS
4291c2c66affSColin Finck NTAPI
4292c2c66affSColin Finck RtlpNtSetValueKey(
4293c2c66affSColin Finck     _In_ HANDLE KeyHandle,
4294c2c66affSColin Finck     _In_ ULONG Type,
4295c2c66affSColin Finck     _In_ PVOID Data,
4296c2c66affSColin Finck     _In_ ULONG DataLength
4297c2c66affSColin Finck );
4298c2c66affSColin Finck #endif
4299c2c66affSColin Finck 
4300c2c66affSColin Finck //
4301c2c66affSColin Finck // NLS Functions
4302c2c66affSColin Finck //
4303c2c66affSColin Finck NTSYSAPI
4304c2c66affSColin Finck VOID
4305c2c66affSColin Finck NTAPI
4306c2c66affSColin Finck RtlGetDefaultCodePage(
4307c2c66affSColin Finck     _Out_ PUSHORT AnsiCodePage,
4308c2c66affSColin Finck     _Out_ PUSHORT OemCodePage
4309c2c66affSColin Finck );
4310c2c66affSColin Finck 
4311c2c66affSColin Finck NTSYSAPI
4312c2c66affSColin Finck VOID
4313c2c66affSColin Finck NTAPI
4314c2c66affSColin Finck RtlInitNlsTables(
4315c2c66affSColin Finck     _In_ PUSHORT AnsiTableBase,
4316c2c66affSColin Finck     _In_ PUSHORT OemTableBase,
4317c2c66affSColin Finck     _In_ PUSHORT CaseTableBase,
4318c2c66affSColin Finck     _Out_ PNLSTABLEINFO NlsTable
4319c2c66affSColin Finck );
4320c2c66affSColin Finck 
4321c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
4322c2c66affSColin Finck NTSYSAPI
4323c2c66affSColin Finck VOID
4324c2c66affSColin Finck NTAPI
4325c2c66affSColin Finck RtlInitCodePageTable(
4326c2c66affSColin Finck     _In_ PUSHORT TableBase,
4327c2c66affSColin Finck     _Out_ PCPTABLEINFO CodePageTable
4328c2c66affSColin Finck );
4329c2c66affSColin Finck 
4330c2c66affSColin Finck NTSYSAPI
4331c2c66affSColin Finck VOID
4332c2c66affSColin Finck NTAPI
4333c2c66affSColin Finck RtlResetRtlTranslations(
4334c2c66affSColin Finck     _In_ PNLSTABLEINFO NlsTable);
4335c2c66affSColin Finck 
4336c2c66affSColin Finck #if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
4337c2c66affSColin Finck 
4338c2c66affSColin Finck //
4339c2c66affSColin Finck // Misc conversion functions
4340c2c66affSColin Finck //
4341c2c66affSColin Finck static __inline
4342c2c66affSColin Finck LARGE_INTEGER
4343c2c66affSColin Finck NTAPI_INLINE
RtlConvertLongToLargeInteger(_In_ LONG SignedInteger)4344c2c66affSColin Finck RtlConvertLongToLargeInteger(
4345c2c66affSColin Finck     _In_ LONG SignedInteger
4346c2c66affSColin Finck )
4347c2c66affSColin Finck {
4348c2c66affSColin Finck     LARGE_INTEGER Result;
4349c2c66affSColin Finck 
4350c2c66affSColin Finck     Result.QuadPart = SignedInteger;
4351c2c66affSColin Finck     return Result;
4352c2c66affSColin Finck }
4353c2c66affSColin Finck 
4354c2c66affSColin Finck static __inline
4355c2c66affSColin Finck LARGE_INTEGER
4356c2c66affSColin Finck NTAPI_INLINE
RtlEnlargedIntegerMultiply(_In_ LONG Multiplicand,_In_ LONG Multiplier)4357c2c66affSColin Finck RtlEnlargedIntegerMultiply(
4358c2c66affSColin Finck     _In_ LONG Multiplicand,
4359c2c66affSColin Finck     _In_ LONG Multiplier
4360c2c66affSColin Finck )
4361c2c66affSColin Finck {
4362c2c66affSColin Finck     LARGE_INTEGER Product;
4363c2c66affSColin Finck 
4364c2c66affSColin Finck     Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
4365c2c66affSColin Finck     return Product;
4366c2c66affSColin Finck }
4367c2c66affSColin Finck 
4368c2c66affSColin Finck static __inline
4369c2c66affSColin Finck ULONG
4370c2c66affSColin Finck NTAPI_INLINE
RtlEnlargedUnsignedDivide(_In_ ULARGE_INTEGER Dividend,_In_ ULONG Divisor,_In_opt_ PULONG Remainder)4371c2c66affSColin Finck RtlEnlargedUnsignedDivide(
4372c2c66affSColin Finck     _In_ ULARGE_INTEGER Dividend,
4373c2c66affSColin Finck     _In_ ULONG Divisor,
4374c2c66affSColin Finck     _In_opt_ PULONG Remainder
4375c2c66affSColin Finck )
4376c2c66affSColin Finck {
4377c2c66affSColin Finck     ULONG Quotient;
4378c2c66affSColin Finck 
4379c2c66affSColin Finck     Quotient = (ULONG)(Dividend.QuadPart / Divisor);
4380c2c66affSColin Finck     if (Remainder) {
4381c2c66affSColin Finck         *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
4382c2c66affSColin Finck     }
4383c2c66affSColin Finck 
4384c2c66affSColin Finck     return Quotient;
4385c2c66affSColin Finck }
4386c2c66affSColin Finck 
4387c2c66affSColin Finck static __inline
4388c2c66affSColin Finck LARGE_INTEGER
4389c2c66affSColin Finck NTAPI_INLINE
RtlEnlargedUnsignedMultiply(_In_ ULONG Multiplicand,_In_ ULONG Multiplier)4390c2c66affSColin Finck RtlEnlargedUnsignedMultiply(
4391c2c66affSColin Finck     _In_ ULONG Multiplicand,
4392c2c66affSColin Finck     _In_ ULONG Multiplier
4393c2c66affSColin Finck )
4394c2c66affSColin Finck {
4395c2c66affSColin Finck     LARGE_INTEGER Product;
4396c2c66affSColin Finck 
4397c2c66affSColin Finck     Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
4398c2c66affSColin Finck     return Product;
4399c2c66affSColin Finck }
4400c2c66affSColin Finck 
4401c2c66affSColin Finck #if defined(_AMD64_) || defined(_IA64_)
4402c2c66affSColin Finck static __inline
4403c2c66affSColin Finck LARGE_INTEGER
4404c2c66affSColin Finck NTAPI_INLINE
RtlExtendedLargeIntegerDivide(_In_ LARGE_INTEGER Dividend,_In_ ULONG Divisor,_Out_opt_ PULONG Remainder)4405c2c66affSColin Finck RtlExtendedLargeIntegerDivide(
4406c2c66affSColin Finck     _In_ LARGE_INTEGER Dividend,
4407c2c66affSColin Finck     _In_ ULONG Divisor,
4408c2c66affSColin Finck     _Out_opt_ PULONG Remainder)
4409c2c66affSColin Finck {
4410c2c66affSColin Finck   LARGE_INTEGER ret;
4411c2c66affSColin Finck   ret.QuadPart = (ULONG64)Dividend.QuadPart / Divisor;
4412c2c66affSColin Finck   if (Remainder)
4413c2c66affSColin Finck     *Remainder = (ULONG)(Dividend.QuadPart % Divisor);
4414c2c66affSColin Finck   return ret;
4415c2c66affSColin Finck }
4416c2c66affSColin Finck 
4417c2c66affSColin Finck #else
4418c2c66affSColin Finck NTSYSAPI
4419c2c66affSColin Finck LARGE_INTEGER
4420c2c66affSColin Finck NTAPI
4421c2c66affSColin Finck RtlExtendedLargeIntegerDivide(
4422c2c66affSColin Finck     _In_ LARGE_INTEGER Dividend,
4423c2c66affSColin Finck     _In_ ULONG Divisor,
4424c2c66affSColin Finck     _Out_opt_ PULONG Remainder
4425c2c66affSColin Finck );
4426c2c66affSColin Finck 
4427c2c66affSColin Finck #endif /* defined(_AMD64_) || defined(_IA64_) */
4428c2c66affSColin Finck 
4429c2c66affSColin Finck #endif
4430c2c66affSColin Finck 
4431c2c66affSColin Finck 
4432c2c66affSColin Finck NTSYSAPI
4433c2c66affSColin Finck ULONG
4434c2c66affSColin Finck NTAPI
4435c2c66affSColin Finck RtlUniform(
4436c2c66affSColin Finck     _In_ PULONG Seed
4437c2c66affSColin Finck );
4438c2c66affSColin Finck 
4439c2c66affSColin Finck NTSYSAPI
4440c2c66affSColin Finck ULONG
4441c2c66affSColin Finck NTAPI
4442c2c66affSColin Finck RtlRandom(
4443c2c66affSColin Finck     _Inout_ PULONG Seed
4444c2c66affSColin Finck );
4445c2c66affSColin Finck 
4446c2c66affSColin Finck NTSYSAPI
4447c2c66affSColin Finck ULONG
4448c2c66affSColin Finck NTAPI
4449c2c66affSColin Finck RtlComputeCrc32(
4450c2c66affSColin Finck     _In_ ULONG InitialCrc,
445101fbf25dSSerge Gautherie     _In_ const UCHAR *Buffer,
4452c2c66affSColin Finck     _In_ ULONG Length
4453c2c66affSColin Finck );
4454c2c66affSColin Finck 
4455c2c66affSColin Finck //
4456c2c66affSColin Finck // Network Functions
4457c2c66affSColin Finck //
4458c2c66affSColin Finck NTSYSAPI
4459c2c66affSColin Finck PSTR
4460c2c66affSColin Finck NTAPI
4461c2c66affSColin Finck RtlIpv4AddressToStringA(
4462c2c66affSColin Finck     _In_ const struct in_addr *Addr,
4463c2c66affSColin Finck     _Out_writes_(16) PCHAR S
4464c2c66affSColin Finck );
4465c2c66affSColin Finck 
4466c2c66affSColin Finck NTSYSAPI
4467c2c66affSColin Finck PWSTR
4468c2c66affSColin Finck NTAPI
4469c2c66affSColin Finck RtlIpv4AddressToStringW(
4470c2c66affSColin Finck     _In_ const struct in_addr *Addr,
4471c2c66affSColin Finck     _Out_writes_(16) PWCHAR S
4472c2c66affSColin Finck );
4473c2c66affSColin Finck 
4474c2c66affSColin Finck NTSYSAPI
4475c2c66affSColin Finck NTSTATUS
4476c2c66affSColin Finck NTAPI
4477c2c66affSColin Finck RtlIpv4AddressToStringExA(
4478c2c66affSColin Finck     _In_ const struct in_addr *Address,
4479c2c66affSColin Finck     _In_ USHORT Port,
4480c2c66affSColin Finck     _Out_writes_to_(*AddressStringLength, *AddressStringLength) PCHAR AddressString,
4481c2c66affSColin Finck     _Inout_ PULONG AddressStringLength
4482c2c66affSColin Finck );
4483c2c66affSColin Finck 
4484c2c66affSColin Finck NTSTATUS
4485c2c66affSColin Finck NTAPI
4486c2c66affSColin Finck RtlIpv4AddressToStringExW(
4487c2c66affSColin Finck     _In_ const struct in_addr *Address,
4488c2c66affSColin Finck     _In_ USHORT Port,
4489c2c66affSColin Finck     _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWCHAR AddressString,
4490c2c66affSColin Finck     _Inout_ PULONG AddressStringLength
4491c2c66affSColin Finck );
4492c2c66affSColin Finck 
4493c2c66affSColin Finck NTSYSAPI
4494c2c66affSColin Finck NTSTATUS
4495c2c66affSColin Finck NTAPI
4496c2c66affSColin Finck RtlIpv4StringToAddressA(
4497c2c66affSColin Finck     _In_ PCSTR String,
4498c2c66affSColin Finck     _In_ BOOLEAN Strict,
4499c2c66affSColin Finck     _Out_ PCSTR *Terminator,
4500c2c66affSColin Finck     _Out_ struct in_addr *Addr
4501c2c66affSColin Finck );
4502c2c66affSColin Finck 
4503c2c66affSColin Finck NTSYSAPI
4504c2c66affSColin Finck NTSTATUS
4505c2c66affSColin Finck NTAPI
4506c2c66affSColin Finck RtlIpv4StringToAddressW(
4507c2c66affSColin Finck     _In_ PCWSTR String,
4508c2c66affSColin Finck     _In_ BOOLEAN Strict,
4509c2c66affSColin Finck     _Out_ PCWSTR *Terminator,
4510c2c66affSColin Finck     _Out_ struct in_addr *Addr
4511c2c66affSColin Finck );
4512c2c66affSColin Finck 
4513c2c66affSColin Finck NTSYSAPI
4514c2c66affSColin Finck NTSTATUS
4515c2c66affSColin Finck NTAPI
4516c2c66affSColin Finck RtlIpv4StringToAddressExA(
4517c2c66affSColin Finck     _In_ PCSTR AddressString,
4518c2c66affSColin Finck     _In_ BOOLEAN Strict,
4519c2c66affSColin Finck     _Out_ struct in_addr *Address,
4520c2c66affSColin Finck     _Out_ PUSHORT Port
4521c2c66affSColin Finck );
4522c2c66affSColin Finck 
4523c2c66affSColin Finck NTSYSAPI
4524c2c66affSColin Finck NTSTATUS
4525c2c66affSColin Finck NTAPI
4526c2c66affSColin Finck RtlIpv4StringToAddressExW(
4527c2c66affSColin Finck     _In_ PCWSTR AddressString,
4528c2c66affSColin Finck     _In_ BOOLEAN Strict,
4529c2c66affSColin Finck     _Out_ struct in_addr *Address,
4530c2c66affSColin Finck     _Out_ PUSHORT Port
4531c2c66affSColin Finck );
4532c2c66affSColin Finck 
4533c2c66affSColin Finck NTSYSAPI
4534c2c66affSColin Finck PSTR
4535c2c66affSColin Finck NTAPI
4536c2c66affSColin Finck RtlIpv6AddressToStringA(
4537c2c66affSColin Finck     _In_ const struct in6_addr *Addr,
4538c2c66affSColin Finck     _Out_writes_(46) PSTR S
4539c2c66affSColin Finck );
4540c2c66affSColin Finck 
4541c2c66affSColin Finck NTSYSAPI
4542c2c66affSColin Finck PWSTR
4543c2c66affSColin Finck NTAPI
4544c2c66affSColin Finck RtlIpv6AddressToStringW(
4545c2c66affSColin Finck     _In_ const struct in6_addr *Addr,
4546c2c66affSColin Finck     _Out_writes_(46) PWSTR S
4547c2c66affSColin Finck );
4548c2c66affSColin Finck 
4549c2c66affSColin Finck NTSYSAPI
4550c2c66affSColin Finck NTSTATUS
4551c2c66affSColin Finck NTAPI
4552c2c66affSColin Finck RtlIpv6AddressToStringExA(
4553c2c66affSColin Finck     _In_ const struct in6_addr *Address,
4554c2c66affSColin Finck     _In_ ULONG ScopeId,
4555c2c66affSColin Finck     _In_ USHORT Port,
4556c2c66affSColin Finck     _Out_writes_to_(*AddressStringLength, *AddressStringLength) PSTR AddressString,
4557c2c66affSColin Finck     _Inout_ PULONG AddressStringLength
4558c2c66affSColin Finck );
4559c2c66affSColin Finck 
4560c2c66affSColin Finck NTSYSAPI
4561c2c66affSColin Finck NTSTATUS
4562c2c66affSColin Finck NTAPI
4563c2c66affSColin Finck RtlIpv6AddressToStringExW(
4564c2c66affSColin Finck     _In_ const struct in6_addr *Address,
4565c2c66affSColin Finck     _In_ ULONG ScopeId,
4566c2c66affSColin Finck     _In_ USHORT Port,
4567c2c66affSColin Finck     _Out_writes_to_(*AddressStringLength, *AddressStringLength) PWCHAR AddressString,
4568c2c66affSColin Finck     _Inout_ PULONG AddressStringLength
4569c2c66affSColin Finck );
4570c2c66affSColin Finck 
4571c2c66affSColin Finck NTSYSAPI
4572c2c66affSColin Finck NTSTATUS
4573c2c66affSColin Finck NTAPI
4574c2c66affSColin Finck RtlIpv6StringToAddressA(
4575c2c66affSColin Finck     _In_ PCSTR String,
4576c2c66affSColin Finck     _Out_ PCSTR *Terminator,
4577c2c66affSColin Finck     _Out_ struct in6_addr *Addr
4578c2c66affSColin Finck );
4579c2c66affSColin Finck 
4580c2c66affSColin Finck NTSYSAPI
4581c2c66affSColin Finck NTSTATUS
4582c2c66affSColin Finck NTAPI
4583c2c66affSColin Finck RtlIpv6StringToAddressW(
4584c2c66affSColin Finck     _In_ PCWSTR String,
4585c2c66affSColin Finck     _Out_ PCWSTR *Terminator,
4586c2c66affSColin Finck     _Out_ struct in6_addr *Addr
4587c2c66affSColin Finck );
4588c2c66affSColin Finck 
4589c2c66affSColin Finck NTSYSAPI
4590c2c66affSColin Finck NTSTATUS
4591c2c66affSColin Finck NTAPI
4592c2c66affSColin Finck RtlIpv6StringToAddressExA(
4593c2c66affSColin Finck     _In_ PCSTR AddressString,
4594c2c66affSColin Finck     _Out_ struct in6_addr *Address,
4595c2c66affSColin Finck     _Out_ PULONG ScopeId,
4596c2c66affSColin Finck     _Out_ PUSHORT Port
4597c2c66affSColin Finck );
4598c2c66affSColin Finck 
4599c2c66affSColin Finck NTSYSAPI
4600c2c66affSColin Finck NTSTATUS
4601c2c66affSColin Finck NTAPI
4602c2c66affSColin Finck RtlIpv6StringToAddressExW(
4603c2c66affSColin Finck     _In_ PCWSTR AddressString,
4604c2c66affSColin Finck     _Out_ struct in6_addr *Address,
4605c2c66affSColin Finck     _Out_ PULONG ScopeId,
4606c2c66affSColin Finck     _Out_ PUSHORT Port
4607c2c66affSColin Finck );
4608c2c66affSColin Finck 
4609c2c66affSColin Finck 
4610c2c66affSColin Finck //
4611c2c66affSColin Finck // Time Functions
4612c2c66affSColin Finck //
4613c2c66affSColin Finck NTSYSAPI
4614c449929fSEric Kohl BOOLEAN
4615c449929fSEric Kohl NTAPI
4616c449929fSEric Kohl RtlCutoverTimeToSystemTime(
4617c449929fSEric Kohl     _In_ PTIME_FIELDS CutoverTimeFields,
4618c449929fSEric Kohl     _Out_ PLARGE_INTEGER SystemTime,
4619c449929fSEric Kohl     _In_ PLARGE_INTEGER CurrentTime,
4620c449929fSEric Kohl     _In_ BOOLEAN ThisYearsCutoverOnly);
4621c449929fSEric Kohl 
4622c449929fSEric Kohl NTSYSAPI
4623c2c66affSColin Finck NTSTATUS
4624c2c66affSColin Finck NTAPI
4625c2c66affSColin Finck RtlQueryTimeZoneInformation(
4626c2c66affSColin Finck     _Out_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
4627c2c66affSColin Finck 
4628c2c66affSColin Finck NTSYSAPI
4629c2c66affSColin Finck VOID
4630c2c66affSColin Finck NTAPI
4631c2c66affSColin Finck RtlSecondsSince1970ToTime(
4632c2c66affSColin Finck     _In_ ULONG SecondsSince1970,
4633c2c66affSColin Finck     _Out_ PLARGE_INTEGER Time
4634c2c66affSColin Finck );
4635c2c66affSColin Finck 
4636c2c66affSColin Finck NTSYSAPI
4637c2c66affSColin Finck NTSTATUS
4638c2c66affSColin Finck NTAPI
4639c2c66affSColin Finck RtlSetTimeZoneInformation(
4640c2c66affSColin Finck     _In_ PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
4641c2c66affSColin Finck 
4642c2c66affSColin Finck _Success_(return != FALSE)
4643c2c66affSColin Finck NTSYSAPI
4644c2c66affSColin Finck BOOLEAN
4645c2c66affSColin Finck NTAPI
4646c2c66affSColin Finck RtlTimeFieldsToTime(
4647c2c66affSColin Finck     _In_ PTIME_FIELDS TimeFields,
4648c2c66affSColin Finck     _Out_ PLARGE_INTEGER Time
4649c2c66affSColin Finck );
4650c2c66affSColin Finck 
4651a28a34f1SJérôme Gardou _Success_(return != FALSE)
4652c2c66affSColin Finck NTSYSAPI
4653c2c66affSColin Finck BOOLEAN
4654c2c66affSColin Finck NTAPI
4655c2c66affSColin Finck RtlTimeToSecondsSince1970(
4656c2c66affSColin Finck     _In_ PLARGE_INTEGER Time,
4657c2c66affSColin Finck     _Out_ PULONG ElapsedSeconds
4658c2c66affSColin Finck );
4659c2c66affSColin Finck 
4660c2c66affSColin Finck NTSYSAPI
4661c2c66affSColin Finck VOID
4662c2c66affSColin Finck NTAPI
4663c2c66affSColin Finck RtlTimeToTimeFields(
4664c2c66affSColin Finck     PLARGE_INTEGER Time,
4665c2c66affSColin Finck     PTIME_FIELDS TimeFields
4666c2c66affSColin Finck );
4667c2c66affSColin Finck 
4668c2c66affSColin Finck NTSYSAPI
4669c2c66affSColin Finck NTSTATUS
4670c2c66affSColin Finck NTAPI
4671c2c66affSColin Finck RtlSystemTimeToLocalTime(
4672c2c66affSColin Finck     _In_ PLARGE_INTEGER SystemTime,
4673c2c66affSColin Finck     _Out_ PLARGE_INTEGER LocalTime
4674c2c66affSColin Finck );
4675c2c66affSColin Finck 
4676c2c66affSColin Finck //
4677c2c66affSColin Finck // Version Functions
4678c2c66affSColin Finck //
4679c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
4680c2c66affSColin Finck _Must_inspect_result_
4681c2c66affSColin Finck NTSYSAPI
4682c2c66affSColin Finck NTSTATUS
4683c2c66affSColin Finck NTAPI
4684c2c66affSColin Finck RtlVerifyVersionInfo(
4685c2c66affSColin Finck     _In_ PRTL_OSVERSIONINFOEXW VersionInfo,
4686c2c66affSColin Finck     _In_ ULONG TypeMask,
4687c2c66affSColin Finck     _In_ ULONGLONG ConditionMask
4688c2c66affSColin Finck );
4689c2c66affSColin Finck 
4690c2c66affSColin Finck _IRQL_requires_max_(PASSIVE_LEVEL)
4691c2c66affSColin Finck NTSYSAPI
4692c2c66affSColin Finck NTSTATUS
4693c2c66affSColin Finck NTAPI
4694c2c66affSColin Finck RtlGetVersion(
4695c2c66affSColin Finck     _Out_
4696c2c66affSColin Finck     _At_(lpVersionInformation->dwOSVersionInfoSize, _Pre_ _Valid_)
4697c2c66affSColin Finck     _When_(lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW),
4698c2c66affSColin Finck         _At_((PRTL_OSVERSIONINFOEXW)lpVersionInformation, _Out_))
4699c2c66affSColin Finck         PRTL_OSVERSIONINFOW lpVersionInformation
4700c2c66affSColin Finck );
4701c2c66affSColin Finck 
4702f87fb4e3SGeorge Bișoc _IRQL_requires_max_(PASSIVE_LEVEL)
4703c2c66affSColin Finck NTSYSAPI
4704c2c66affSColin Finck BOOLEAN
4705c2c66affSColin Finck NTAPI
4706f44cb6deSSerge Gautherie RtlGetNtProductType(_Out_ PNT_PRODUCT_TYPE ProductType);
4707c2c66affSColin Finck 
4708bc6c731dSJustin Miller #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
4709bc6c731dSJustin Miller //
4710bc6c731dSJustin Miller // Synchronization functions
4711bc6c731dSJustin Miller //
4712bc6c731dSJustin Miller NTSYSAPI
4713bc6c731dSJustin Miller VOID
4714bc6c731dSJustin Miller NTAPI
4715bc6c731dSJustin Miller RtlInitializeConditionVariable(
4716bc6c731dSJustin Miller     _Out_ PRTL_CONDITION_VARIABLE ConditionVariable);
4717bc6c731dSJustin Miller 
4718bc6c731dSJustin Miller NTSYSAPI
4719bc6c731dSJustin Miller VOID
4720bc6c731dSJustin Miller NTAPI
4721bc6c731dSJustin Miller RtlWakeConditionVariable(
4722bc6c731dSJustin Miller     _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable);
4723bc6c731dSJustin Miller 
4724bc6c731dSJustin Miller NTSYSAPI
4725bc6c731dSJustin Miller VOID
4726bc6c731dSJustin Miller NTAPI
4727bc6c731dSJustin Miller RtlWakeAllConditionVariable(
4728bc6c731dSJustin Miller     _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable);
4729bc6c731dSJustin Miller 
4730bc6c731dSJustin Miller NTSYSAPI
4731bc6c731dSJustin Miller NTSTATUS
4732bc6c731dSJustin Miller NTAPI
4733bc6c731dSJustin Miller RtlSleepConditionVariableCS(
4734bc6c731dSJustin Miller     _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable,
4735bc6c731dSJustin Miller     _Inout_ PRTL_CRITICAL_SECTION CriticalSection,
4736bc6c731dSJustin Miller     _In_opt_ PLARGE_INTEGER TimeOut);
4737bc6c731dSJustin Miller 
4738bc6c731dSJustin Miller NTSYSAPI
4739bc6c731dSJustin Miller NTSTATUS
4740bc6c731dSJustin Miller NTAPI
4741bc6c731dSJustin Miller RtlSleepConditionVariableSRW(
4742bc6c731dSJustin Miller     _Inout_ PRTL_CONDITION_VARIABLE ConditionVariable,
4743bc6c731dSJustin Miller     _Inout_ PRTL_SRWLOCK SRWLock,
4744bc6c731dSJustin Miller     _In_opt_ PLARGE_INTEGER TimeOut,
4745bc6c731dSJustin Miller     _In_ ULONG Flags);
4746bc6c731dSJustin Miller #endif
4747bc6c731dSJustin Miller 
4748c2c66affSColin Finck //
4749c2c66affSColin Finck // Secure Memory Functions
4750c2c66affSColin Finck //
4751c2c66affSColin Finck #ifdef NTOS_MODE_USER
4752c2c66affSColin Finck NTSYSAPI
4753c2c66affSColin Finck NTSTATUS
4754c2c66affSColin Finck NTAPI
4755c2c66affSColin Finck RtlRegisterSecureMemoryCacheCallback(
4756c2c66affSColin Finck     _In_ PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback);
4757c2c66affSColin Finck 
4758c2c66affSColin Finck NTSYSAPI
4759c2c66affSColin Finck BOOLEAN
4760c2c66affSColin Finck NTAPI
4761c2c66affSColin Finck RtlFlushSecureMemoryCache(
4762c2c66affSColin Finck     _In_ PVOID MemoryCache,
4763c2c66affSColin Finck     _In_opt_ SIZE_T MemoryLength
4764c2c66affSColin Finck );
4765c2c66affSColin Finck #endif
4766c2c66affSColin Finck 
4767c2c66affSColin Finck //
4768c2c66affSColin Finck // Boot Status Data Functions
4769c2c66affSColin Finck //
4770c2c66affSColin Finck #ifdef NTOS_MODE_USER
4771c2c66affSColin Finck NTSYSAPI
4772c2c66affSColin Finck NTSTATUS
4773c2c66affSColin Finck NTAPI
4774c2c66affSColin Finck RtlCreateBootStatusDataFile(
4775c2c66affSColin Finck     VOID
4776c2c66affSColin Finck );
4777c2c66affSColin Finck 
4778c2c66affSColin Finck NTSYSAPI
4779c2c66affSColin Finck NTSTATUS
4780c2c66affSColin Finck NTAPI
4781c2c66affSColin Finck RtlGetSetBootStatusData(
4782c2c66affSColin Finck     _In_ HANDLE FileHandle,
4783c2c66affSColin Finck     _In_ BOOLEAN WriteMode,
4784c2c66affSColin Finck     _In_ RTL_BSD_ITEM_TYPE DataClass,
4785c2c66affSColin Finck     _In_ PVOID Buffer,
4786c2c66affSColin Finck     _In_ ULONG BufferSize,
4787c2c66affSColin Finck     _Out_opt_ PULONG ReturnLength
4788c2c66affSColin Finck );
4789c2c66affSColin Finck 
4790c2c66affSColin Finck NTSYSAPI
4791c2c66affSColin Finck NTSTATUS
4792c2c66affSColin Finck NTAPI
4793c2c66affSColin Finck RtlLockBootStatusData(
4794c2c66affSColin Finck     _Out_ PHANDLE FileHandle
4795c2c66affSColin Finck );
4796c2c66affSColin Finck 
4797c2c66affSColin Finck NTSYSAPI
4798c2c66affSColin Finck NTSTATUS
4799c2c66affSColin Finck NTAPI
4800c2c66affSColin Finck RtlUnlockBootStatusData(
4801c2c66affSColin Finck     _In_ HANDLE FileHandle
4802c2c66affSColin Finck );
4803c2c66affSColin Finck #endif
4804c2c66affSColin Finck 
4805c2c66affSColin Finck #ifdef NTOS_MODE_USER
4806c2c66affSColin Finck _Must_inspect_result_
4807c2c66affSColin Finck NTSYSAPI
4808c2c66affSColin Finck NTSTATUS
4809c2c66affSColin Finck NTAPI
4810c2c66affSColin Finck RtlGUIDFromString(
4811c2c66affSColin Finck     _In_ PUNICODE_STRING GuidString,
4812c2c66affSColin Finck     _Out_ GUID *Guid);
4813c2c66affSColin Finck 
4814c2c66affSColin Finck _Must_inspect_result_
4815c2c66affSColin Finck NTSYSAPI
4816c2c66affSColin Finck NTSTATUS
4817c2c66affSColin Finck NTAPI
4818c2c66affSColin Finck RtlStringFromGUID(
4819c2c66affSColin Finck   _In_ REFGUID Guid,
4820c2c66affSColin Finck   _Out_ _At_(GuidString->Buffer, __drv_allocatesMem(Mem))
4821c2c66affSColin Finck     PUNICODE_STRING GuidString);
4822c2c66affSColin Finck 
4823c2c66affSColin Finck NTSYSAPI
4824c2c66affSColin Finck NTSTATUS
4825c2c66affSColin Finck NTAPI
4826c2c66affSColin Finck RtlComputeImportTableHash(
4827c2c66affSColin Finck     _In_ HANDLE hFile,
4828c2c66affSColin Finck     _Out_ PCHAR Hash,
4829c2c66affSColin Finck     _In_ ULONG ImportTableHashRevision
4830c2c66affSColin Finck );
4831c2c66affSColin Finck #endif
4832c2c66affSColin Finck 
4833c2c66affSColin Finck //
4834c2c66affSColin Finck // MemoryStream functions
4835c2c66affSColin Finck //
4836c2c66affSColin Finck #ifdef NTOS_MODE_USER
4837c2c66affSColin Finck 
4838c2c66affSColin Finck NTSYSAPI
4839c2c66affSColin Finck VOID
4840c2c66affSColin Finck NTAPI
4841c2c66affSColin Finck RtlInitMemoryStream(
4842c2c66affSColin Finck     _Out_ PRTL_MEMORY_STREAM Stream
4843c2c66affSColin Finck );
4844c2c66affSColin Finck 
4845c2c66affSColin Finck NTSYSAPI
4846c2c66affSColin Finck VOID
4847c2c66affSColin Finck NTAPI
4848c2c66affSColin Finck RtlInitOutOfProcessMemoryStream(
4849c2c66affSColin Finck     _Out_ PRTL_MEMORY_STREAM Stream
4850c2c66affSColin Finck );
4851c2c66affSColin Finck 
4852c2c66affSColin Finck NTSYSAPI
4853c2c66affSColin Finck VOID
4854c2c66affSColin Finck NTAPI
4855c2c66affSColin Finck RtlFinalReleaseOutOfProcessMemoryStream(
4856c2c66affSColin Finck     _In_ PRTL_MEMORY_STREAM Stream
4857c2c66affSColin Finck );
4858c2c66affSColin Finck 
4859c2c66affSColin Finck NTSYSAPI
4860c2c66affSColin Finck HRESULT
4861c2c66affSColin Finck NTAPI
4862c2c66affSColin Finck RtlQueryInterfaceMemoryStream(
4863c2c66affSColin Finck     _In_ struct IStream *This,
4864c2c66affSColin Finck     _In_ REFIID RequestedIid,
4865c2c66affSColin Finck     _Outptr_ PVOID *ResultObject
4866c2c66affSColin Finck );
4867c2c66affSColin Finck 
4868c2c66affSColin Finck NTSYSAPI
4869c2c66affSColin Finck ULONG
4870c2c66affSColin Finck NTAPI
4871c2c66affSColin Finck RtlAddRefMemoryStream(
4872c2c66affSColin Finck     _In_ struct IStream *This
4873c2c66affSColin Finck );
4874c2c66affSColin Finck 
4875c2c66affSColin Finck NTSYSAPI
4876c2c66affSColin Finck ULONG
4877c2c66affSColin Finck NTAPI
4878c2c66affSColin Finck RtlReleaseMemoryStream(
4879c2c66affSColin Finck     _In_ struct IStream *This
4880c2c66affSColin Finck );
4881c2c66affSColin Finck 
4882c2c66affSColin Finck NTSYSAPI
4883c2c66affSColin Finck HRESULT
4884c2c66affSColin Finck NTAPI
4885c2c66affSColin Finck RtlReadMemoryStream(
4886c2c66affSColin Finck     _In_ struct IStream *This,
4887c2c66affSColin Finck     _Out_writes_bytes_(Length) PVOID Buffer,
4888c2c66affSColin Finck     _In_ ULONG Length,
4889c2c66affSColin Finck     _Out_opt_ PULONG BytesRead
4890c2c66affSColin Finck );
4891c2c66affSColin Finck 
4892c2c66affSColin Finck NTSYSAPI
4893c2c66affSColin Finck HRESULT
4894c2c66affSColin Finck NTAPI
4895c2c66affSColin Finck RtlReadOutOfProcessMemoryStream(
4896c2c66affSColin Finck     _In_ struct IStream *This,
4897c2c66affSColin Finck     _Out_writes_bytes_(Length) PVOID Buffer,
4898c2c66affSColin Finck     _In_ ULONG Length,
4899c2c66affSColin Finck     _Out_opt_ PULONG BytesRead
4900c2c66affSColin Finck );
4901c2c66affSColin Finck 
4902c2c66affSColin Finck NTSYSAPI
4903c2c66affSColin Finck HRESULT
4904c2c66affSColin Finck NTAPI
4905c2c66affSColin Finck RtlSeekMemoryStream(
4906c2c66affSColin Finck     _In_ struct IStream *This,
4907c2c66affSColin Finck     _In_ LARGE_INTEGER RelativeOffset,
4908c2c66affSColin Finck     _In_ ULONG Origin,
4909c2c66affSColin Finck     _Out_opt_ PULARGE_INTEGER ResultOffset
4910c2c66affSColin Finck );
4911c2c66affSColin Finck 
4912c2c66affSColin Finck NTSYSAPI
4913c2c66affSColin Finck HRESULT
4914c2c66affSColin Finck NTAPI
4915c2c66affSColin Finck RtlCopyMemoryStreamTo(
4916c2c66affSColin Finck     _In_ struct IStream *This,
4917c2c66affSColin Finck     _In_ struct IStream *Target,
4918c2c66affSColin Finck     _In_ ULARGE_INTEGER Length,
4919c2c66affSColin Finck     _Out_opt_ PULARGE_INTEGER BytesRead,
4920c2c66affSColin Finck     _Out_opt_ PULARGE_INTEGER BytesWritten
4921c2c66affSColin Finck );
4922c2c66affSColin Finck 
4923c2c66affSColin Finck NTSYSAPI
4924c2c66affSColin Finck HRESULT
4925c2c66affSColin Finck NTAPI
4926c2c66affSColin Finck RtlCopyOutOfProcessMemoryStreamTo(
4927c2c66affSColin Finck     _In_ struct IStream *This,
4928c2c66affSColin Finck     _In_ struct IStream *Target,
4929c2c66affSColin Finck     _In_ ULARGE_INTEGER Length,
4930c2c66affSColin Finck     _Out_opt_ PULARGE_INTEGER BytesRead,
4931c2c66affSColin Finck     _Out_opt_ PULARGE_INTEGER BytesWritten
4932c2c66affSColin Finck );
4933c2c66affSColin Finck 
4934c2c66affSColin Finck NTSYSAPI
4935c2c66affSColin Finck HRESULT
4936c2c66affSColin Finck NTAPI
4937c2c66affSColin Finck RtlStatMemoryStream(
4938c2c66affSColin Finck     _In_ struct IStream *This,
4939c2c66affSColin Finck     _Out_ struct tagSTATSTG *Stats,
4940c2c66affSColin Finck     _In_ ULONG Flags
4941c2c66affSColin Finck );
4942c2c66affSColin Finck 
4943c2c66affSColin Finck // Dummy functions
4944c2c66affSColin Finck NTSYSAPI
4945c2c66affSColin Finck HRESULT
4946c2c66affSColin Finck NTAPI
4947c2c66affSColin Finck RtlWriteMemoryStream(
4948c2c66affSColin Finck     _In_ struct IStream *This,
4949c2c66affSColin Finck     _In_reads_bytes_(Length) CONST VOID *Buffer,
4950c2c66affSColin Finck     _In_ ULONG Length,
4951c2c66affSColin Finck     _Out_opt_ PULONG BytesWritten
4952c2c66affSColin Finck );
4953c2c66affSColin Finck 
4954c2c66affSColin Finck NTSYSAPI
4955c2c66affSColin Finck HRESULT
4956c2c66affSColin Finck NTAPI
4957c2c66affSColin Finck RtlSetMemoryStreamSize(
4958c2c66affSColin Finck     _In_ struct IStream *This,
4959c2c66affSColin Finck     _In_ ULARGE_INTEGER NewSize
4960c2c66affSColin Finck );
4961c2c66affSColin Finck 
4962c2c66affSColin Finck NTSYSAPI
4963c2c66affSColin Finck HRESULT
4964c2c66affSColin Finck NTAPI
4965c2c66affSColin Finck RtlCommitMemoryStream(
4966c2c66affSColin Finck     _In_ struct IStream *This,
4967c2c66affSColin Finck     _In_ ULONG CommitFlags
4968c2c66affSColin Finck );
4969c2c66affSColin Finck 
4970c2c66affSColin Finck NTSYSAPI
4971c2c66affSColin Finck HRESULT
4972c2c66affSColin Finck NTAPI
4973c2c66affSColin Finck RtlRevertMemoryStream(
4974c2c66affSColin Finck     _In_ struct IStream *This
4975c2c66affSColin Finck );
4976c2c66affSColin Finck 
4977c2c66affSColin Finck NTSYSAPI
4978c2c66affSColin Finck HRESULT
4979c2c66affSColin Finck NTAPI
4980c2c66affSColin Finck RtlLockMemoryStreamRegion(
4981c2c66affSColin Finck     _In_ struct IStream *This,
4982c2c66affSColin Finck     _In_ ULARGE_INTEGER Offset,
4983c2c66affSColin Finck     _In_ ULARGE_INTEGER Length,
4984c2c66affSColin Finck     _In_ ULONG LockType
4985c2c66affSColin Finck );
4986c2c66affSColin Finck 
4987c2c66affSColin Finck NTSYSAPI
4988c2c66affSColin Finck HRESULT
4989c2c66affSColin Finck NTAPI
4990c2c66affSColin Finck RtlUnlockMemoryStreamRegion(
4991c2c66affSColin Finck     _In_ struct IStream *This,
4992c2c66affSColin Finck     _In_ ULARGE_INTEGER Offset,
4993c2c66affSColin Finck     _In_ ULARGE_INTEGER Length,
4994c2c66affSColin Finck     _In_ ULONG LockType
4995c2c66affSColin Finck );
4996c2c66affSColin Finck 
4997c2c66affSColin Finck NTSYSAPI
4998c2c66affSColin Finck HRESULT
4999c2c66affSColin Finck NTAPI
5000c2c66affSColin Finck RtlCloneMemoryStream(
5001c2c66affSColin Finck     _In_ struct IStream *This,
5002c2c66affSColin Finck     _Outptr_ struct IStream **ResultStream
5003c2c66affSColin Finck );
5004c2c66affSColin Finck 
50058c7b84bbSPierre Schweitzer NTSYSAPI
50068c7b84bbSPierre Schweitzer NTSTATUS
50078c7b84bbSPierre Schweitzer NTAPI
50088c7b84bbSPierre Schweitzer RtlGetNativeSystemInformation(
50098c7b84bbSPierre Schweitzer     _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
50108c7b84bbSPierre Schweitzer     _Out_writes_bytes_to_opt_(SystemInformationLength, *ReturnLength) PVOID SystemInformation,
50118c7b84bbSPierre Schweitzer     _In_ ULONG SystemInformationLength,
50128c7b84bbSPierre Schweitzer     _Out_opt_ PULONG ReturnLength
50138c7b84bbSPierre Schweitzer );
50148c7b84bbSPierre Schweitzer 
5015f491d7ccSRatin Gao #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
5016f491d7ccSRatin Gao 
5017f491d7ccSRatin Gao NTSYSAPI
5018f491d7ccSRatin Gao VOID
5019f491d7ccSRatin Gao NTAPI
5020f491d7ccSRatin Gao RtlRunOnceInitialize(
5021f491d7ccSRatin Gao     _Out_ PRTL_RUN_ONCE RunOnce);
5022f491d7ccSRatin Gao 
5023f491d7ccSRatin Gao _Maybe_raises_SEH_exception_
5024f491d7ccSRatin Gao NTSYSAPI
5025f491d7ccSRatin Gao NTSTATUS
5026f491d7ccSRatin Gao NTAPI
5027f491d7ccSRatin Gao RtlRunOnceExecuteOnce(
5028f491d7ccSRatin Gao     _Inout_ PRTL_RUN_ONCE RunOnce,
5029f491d7ccSRatin Gao     _In_ __inner_callback PRTL_RUN_ONCE_INIT_FN InitFn,
5030f491d7ccSRatin Gao     _Inout_opt_ PVOID Parameter,
5031f491d7ccSRatin Gao     _Outptr_opt_result_maybenull_ PVOID *Context);
5032f491d7ccSRatin Gao 
5033f491d7ccSRatin Gao _Must_inspect_result_
5034f491d7ccSRatin Gao NTSYSAPI
5035f491d7ccSRatin Gao NTSTATUS
5036f491d7ccSRatin Gao NTAPI
5037f491d7ccSRatin Gao RtlRunOnceBeginInitialize(
5038f491d7ccSRatin Gao     _Inout_ PRTL_RUN_ONCE RunOnce,
5039f491d7ccSRatin Gao     _In_ ULONG Flags,
5040f491d7ccSRatin Gao     _Outptr_opt_result_maybenull_ PVOID *Context);
5041f491d7ccSRatin Gao 
5042f491d7ccSRatin Gao NTSYSAPI
5043f491d7ccSRatin Gao NTSTATUS
5044f491d7ccSRatin Gao NTAPI
5045f491d7ccSRatin Gao RtlRunOnceComplete(
5046f491d7ccSRatin Gao     _Inout_ PRTL_RUN_ONCE RunOnce,
5047f491d7ccSRatin Gao     _In_ ULONG Flags,
5048f491d7ccSRatin Gao     _In_opt_ PVOID Context);
5049f491d7ccSRatin Gao 
5050f491d7ccSRatin Gao #endif
5051f491d7ccSRatin Gao 
50526a4c6ea5SJérôme Gardou #if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || (defined(__REACTOS__) && defined(_NTDLLBUILD_))
50536a4c6ea5SJérôme Gardou /* Put NTSYSAPI back when this will be really exported. Only statically linked for now */
50546a4c6ea5SJérôme Gardou // NTSYSAPI
50556a4c6ea5SJérôme Gardou VOID
50566a4c6ea5SJérôme Gardou NTAPI
50576a4c6ea5SJérôme Gardou RtlInitializeSRWLock(OUT PRTL_SRWLOCK SRWLock);
50586a4c6ea5SJérôme Gardou 
50596a4c6ea5SJérôme Gardou // NTSYSAPI
50606a4c6ea5SJérôme Gardou VOID
50616a4c6ea5SJérôme Gardou NTAPI
50626a4c6ea5SJérôme Gardou RtlAcquireSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock);
50636a4c6ea5SJérôme Gardou 
50646a4c6ea5SJérôme Gardou // NTSYSAPI
50656a4c6ea5SJérôme Gardou VOID
50666a4c6ea5SJérôme Gardou NTAPI
50676a4c6ea5SJérôme Gardou RtlAcquireSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock);
50686a4c6ea5SJérôme Gardou 
50696a4c6ea5SJérôme Gardou // NTSYSAPI
50706a4c6ea5SJérôme Gardou VOID
50716a4c6ea5SJérôme Gardou NTAPI
50726a4c6ea5SJérôme Gardou RtlReleaseSRWLockShared(IN OUT PRTL_SRWLOCK SRWLock);
50736a4c6ea5SJérôme Gardou 
50746a4c6ea5SJérôme Gardou // NTSYSAPI
50756a4c6ea5SJérôme Gardou VOID
50766a4c6ea5SJérôme Gardou NTAPI
50776a4c6ea5SJérôme Gardou RtlReleaseSRWLockExclusive(IN OUT PRTL_SRWLOCK SRWLock);
50786a4c6ea5SJérôme Gardou 
50796a4c6ea5SJérôme Gardou #endif /* Win vista or Reactos Ntdll build */
50806a4c6ea5SJérôme Gardou 
50816a4c6ea5SJérôme Gardou #if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) || (defined(__REACTOS__) && defined(_NTDLLBUILD_))
50826a4c6ea5SJérôme Gardou 
50836a4c6ea5SJérôme Gardou // NTSYSAPI
50846a4c6ea5SJérôme Gardou BOOLEAN
50856a4c6ea5SJérôme Gardou NTAPI
50866a4c6ea5SJérôme Gardou RtlTryAcquireSRWLockShared(PRTL_SRWLOCK SRWLock);
50876a4c6ea5SJérôme Gardou 
50886a4c6ea5SJérôme Gardou // NTSYSAPI
50896a4c6ea5SJérôme Gardou BOOLEAN
50906a4c6ea5SJérôme Gardou NTAPI
50916a4c6ea5SJérôme Gardou RtlTryAcquireSRWLockExclusive(PRTL_SRWLOCK SRWLock);
50926a4c6ea5SJérôme Gardou 
50936a4c6ea5SJérôme Gardou #endif /* Win7 or Reactos Ntdll build */
50946a4c6ea5SJérôme Gardou 
5095c2c66affSColin Finck #endif // NTOS_MODE_USER
5096c2c66affSColin Finck 
5097c2c66affSColin Finck NTSYSAPI
5098c2c66affSColin Finck NTSTATUS
5099c2c66affSColin Finck NTAPI
5100c2c66affSColin Finck RtlFindActivationContextSectionGuid(
5101c2c66affSColin Finck     ULONG flags,
5102c2c66affSColin Finck     const GUID *extguid,
5103c2c66affSColin Finck     ULONG section_kind,
5104c2c66affSColin Finck     const GUID *guid,
5105c2c66affSColin Finck     void *ptr
5106c2c66affSColin Finck );
5107c2c66affSColin Finck 
5108c2c66affSColin Finck #ifdef __cplusplus
5109c2c66affSColin Finck }
5110c2c66affSColin Finck #endif
5111c2c66affSColin Finck 
5112c2c66affSColin Finck #endif
5113