xref: /reactos/sdk/lib/rtl/rtlp.h (revision bbccad0e)
1 /*
2  * COPYRIGHT:       See COPYING in the top level directory
3  * PROJECT:         ReactOS System Libraries
4  * FILE:            lib/rtl/rtlp.h
5  * PURPOSE:         Run-Time Libary Internal Header
6  * PROGRAMMER:      Alex Ionescu
7  */
8 
9 /* INCLUDES ******************************************************************/
10 
11 /* PAGED_CODE equivalent for user-mode RTL */
12 #if DBG
13 extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
14 #define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
15 #else
16 #define PAGED_CODE_RTL()
17 #endif
18 
19 #ifdef _PPC_
20 #define SWAPD(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
21 #define SWAPW(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
22 #define SWAPQ(x) ((SWAPD((x)&0xffffffff) << 32) | (SWAPD((x)>>32)))
23 #else
24 #define SWAPD(x) (x)
25 #define SWAPW(x) (x)
26 #define SWAPQ(x) (x)
27 #endif
28 
29 #define ROUND_DOWN(n, align) \
30     (((ULONG_PTR)(n)) & ~((align) - 1l))
31 
32 #define ROUND_UP(n, align) \
33     ROUND_DOWN(((ULONG_PTR)(n)) + (align) - 1, (align))
34 
35 #define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
36 
37 extern PVOID MmHighestUserAddress;
38 
39 NTSTATUS
40 NTAPI
41 RtlpSafeCopyMemory(
42    _Out_writes_bytes_all_(Length) VOID UNALIGNED *Destination,
43    _In_reads_bytes_(Length) CONST VOID UNALIGNED *Source,
44    _In_ SIZE_T Length);
45 
46 #ifndef _BLDR_
47 
48 VOID
49 NTAPI
50 RtlpGetStackLimits(PULONG_PTR LowLimit,
51                    PULONG_PTR HighLimit);
52 
53 #ifdef _M_IX86
54 
55 PEXCEPTION_REGISTRATION_RECORD
56 NTAPI
57 RtlpGetExceptionList(VOID);
58 
59 VOID
60 NTAPI
61 RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
62 
63 #endif /* _M_IX86 */
64 
65 /* For heap.c */
66 VOID
67 NTAPI
68 RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters);
69 
70 /* For vectoreh.c */
71 BOOLEAN
72 NTAPI
73 RtlCallVectoredExceptionHandlers(
74     IN PEXCEPTION_RECORD ExceptionRecord,
75     IN PCONTEXT Context
76 );
77 
78 VOID
79 NTAPI
80 RtlCallVectoredContinueHandlers(
81     IN PEXCEPTION_RECORD ExceptionRecord,
82     IN PCONTEXT Context
83 );
84 
85 #ifdef _M_IX86
86 typedef struct _DISPATCHER_CONTEXT
87 {
88     PEXCEPTION_REGISTRATION_RECORD RegistrationPointer;
89 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
90 #endif
91 
92 #endif /* !_BLDR_ */
93 
94 /* These provide support for sharing code between User and Kernel RTL */
95 PVOID
96 NTAPI
97 RtlpAllocateMemory(
98     SIZE_T Bytes,
99     ULONG Tag);
100 
101 VOID
102 NTAPI
103 RtlpFreeMemory(
104     PVOID Mem,
105     ULONG Tag);
106 
107 #ifndef _BLDR_
108 
109 KPROCESSOR_MODE
110 NTAPI
111 RtlpGetMode(VOID);
112 
113 BOOLEAN
114 NTAPI
115 RtlpCaptureStackLimits(
116     IN ULONG_PTR Ebp,
117     IN ULONG_PTR *StackBegin,
118     IN ULONG_PTR *StackEnd
119 );
120 
121 /* For heap.c and heappage.c */
122 NTSTATUS
123 NTAPI
124 RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock);
125 
126 NTSTATUS
127 NTAPI
128 RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
129 
130 BOOLEAN
131 NTAPI
132 RtlTryEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
133 
134 NTSTATUS
135 NTAPI
136 RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock);
137 
138 NTSTATUS
139 NTAPI
140 RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock);
141 
142 BOOLEAN
143 NTAPI
144 RtlpCheckForActiveDebugger(VOID);
145 
146 BOOLEAN
147 NTAPI
148 RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
149                             IN ULONG_PTR RegistrationFrameEnd,
150                             IN OUT PULONG_PTR StackLow,
151                             IN OUT PULONG_PTR StackHigh);
152 
153 #endif /* !_BLDR_ */
154 
155 #define RtlpAllocateStringMemory RtlpAllocateMemory
156 #define RtlpFreeStringMemory     RtlpFreeMemory
157 
158 #ifndef _BLDR_
159 
160 ULONG
161 NTAPI
162 RtlGetTickCount(VOID);
163 #define NtGetTickCount RtlGetTickCount
164 
165 BOOLEAN
166 NTAPI
167 RtlpSetInDbgPrint(
168     VOID
169 );
170 
171 VOID
172 NTAPI
173 RtlpClearInDbgPrint(
174     VOID
175 );
176 
177 /* i386/except.S */
178 
179 #ifdef _M_IX86
180 EXCEPTION_DISPOSITION
181 NTAPI
182 RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord,
183                                PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
184                                PCONTEXT Context,
185                                PVOID DispatcherContext,
186                                PEXCEPTION_ROUTINE ExceptionHandler);
187 #endif
188 
189 EXCEPTION_DISPOSITION
190 NTAPI
191 RtlpExecuteHandlerForUnwind(PEXCEPTION_RECORD ExceptionRecord,
192                             PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
193                             PCONTEXT Context,
194                             PVOID DispatcherContext,
195                             PEXCEPTION_ROUTINE ExceptionHandler);
196 
197 VOID
198 NTAPI
199 RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
200                       IN PCONTEXT ContextRecord,
201                       IN PVOID ContextData,
202                       IN ULONG Size);
203 
204 VOID
205 NTAPI
206 RtlpCaptureContext(OUT PCONTEXT ContextRecord);
207 
208 //
209 // Debug Service calls
210 //
211 ULONG
212 NTAPI
213 DebugService(
214     IN ULONG Service,
215     IN PVOID Argument1,
216     IN PVOID Argument2,
217     IN PVOID Argument3,
218     IN PVOID Argument4
219 );
220 
221 VOID
222 NTAPI
223 DebugService2(
224     IN PVOID Argument1,
225     IN PVOID Argument2,
226     IN ULONG Service
227 );
228 
229 /* Timer Queue */
230 extern HANDLE TimerThreadHandle;
231 
232 NTSTATUS
233 RtlpInitializeTimerThread(VOID);
234 
235 #endif /* !_BLDR_ */
236 
237 /* bitmap64.c */
238 typedef struct _RTL_BITMAP64
239 {
240     ULONG64 SizeOfBitMap;
241     PULONG64 Buffer;
242 } RTL_BITMAP64, *PRTL_BITMAP64;
243 
244 typedef struct _RTL_BITMAP_RUN64
245 {
246     ULONG64 StartingIndex;
247     ULONG64 NumberOfBits;
248 } RTL_BITMAP_RUN64, *PRTL_BITMAP_RUN64;
249 
250 /* Tags for the String Allocators */
251 #define TAG_USTR        'RTSU'
252 #define TAG_ASTR        'RTSA'
253 #define TAG_OSTR        'RTSO'
254 
255 /* nls.c */
256 WCHAR
257 NTAPI
258 RtlpUpcaseUnicodeChar(IN WCHAR Source);
259 
260 WCHAR
261 NTAPI
262 RtlpDowncaseUnicodeChar(IN WCHAR Source);
263 
264 #ifndef _BLDR_
265 
266 /* ReactOS only */
267 VOID
268 NTAPI
269 LdrpInitializeProcessCompat(PVOID pProcessActctx, PVOID* pOldShimData);
270 
271 PVOID
272 NTAPI
273 RtlpDebugBufferCommit(_Inout_ PRTL_DEBUG_INFORMATION Buffer,
274                       _In_ SIZE_T Size);
275 
276 #endif /* !_BLDR_ */
277 
278 /* EOF */
279