xref: /reactos/sdk/lib/rtl/rtlp.h (revision d8c6ef5e)
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 VOID
47 NTAPI
48 RtlpGetStackLimits(PULONG_PTR LowLimit,
49                    PULONG_PTR HighLimit);
50 
51 PEXCEPTION_REGISTRATION_RECORD
52 NTAPI
53 RtlpGetExceptionList(VOID);
54 
55 VOID
56 NTAPI
57 RtlpSetHeapParameters(IN PRTL_HEAP_PARAMETERS Parameters);
58 
59 VOID
60 NTAPI
61 RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
62 
63 BOOLEAN
64 NTAPI
65 RtlCallVectoredExceptionHandlers(
66     IN PEXCEPTION_RECORD ExceptionRecord,
67     IN PCONTEXT Context
68 );
69 
70 VOID
71 NTAPI
72 RtlCallVectoredContinueHandlers(
73     IN PEXCEPTION_RECORD ExceptionRecord,
74     IN PCONTEXT Context
75 );
76 
77 #ifdef _M_IX86
78 typedef struct _DISPATCHER_CONTEXT
79 {
80     PEXCEPTION_REGISTRATION_RECORD RegistrationPointer;
81 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
82 #endif
83 
84 /* These provide support for sharing code between User and Kernel RTL */
85 PVOID
86 NTAPI
87 RtlpAllocateMemory(
88     SIZE_T Bytes,
89     ULONG Tag);
90 
91 VOID
92 NTAPI
93 RtlpFreeMemory(
94     PVOID Mem,
95     ULONG Tag);
96 
97 KPROCESSOR_MODE
98 NTAPI
99 RtlpGetMode(VOID);
100 
101 BOOLEAN
102 NTAPI
103 RtlpCaptureStackLimits(
104     IN ULONG_PTR Ebp,
105     IN ULONG_PTR *StackBegin,
106     IN ULONG_PTR *StackEnd
107 );
108 
109 NTSTATUS
110 NTAPI
111 RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock);
112 
113 NTSTATUS
114 NTAPI
115 RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
116 
117 BOOLEAN
118 NTAPI
119 RtlTryEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
120 
121 NTSTATUS
122 NTAPI
123 RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock);
124 
125 NTSTATUS
126 NTAPI
127 RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock);
128 
129 BOOLEAN
130 NTAPI
131 RtlpCheckForActiveDebugger(VOID);
132 
133 BOOLEAN
134 NTAPI
135 RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
136                             IN ULONG_PTR RegistrationFrameEnd,
137                             IN OUT PULONG_PTR StackLow,
138                             IN OUT PULONG_PTR StackHigh);
139 
140 #define RtlpAllocateStringMemory RtlpAllocateMemory
141 #define RtlpFreeStringMemory     RtlpFreeMemory
142 
143 ULONG
144 NTAPI
145 RtlGetTickCount(VOID);
146 #define NtGetTickCount RtlGetTickCount
147 
148 BOOLEAN
149 NTAPI
150 RtlpSetInDbgPrint(
151     VOID
152 );
153 
154 VOID
155 NTAPI
156 RtlpClearInDbgPrint(
157     VOID
158 );
159 
160 /* i386/except.S */
161 
162 #ifdef _M_IX86
163 EXCEPTION_DISPOSITION
164 NTAPI
165 RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord,
166                                PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
167                                PCONTEXT Context,
168                                PVOID DispatcherContext,
169                                PEXCEPTION_ROUTINE ExceptionHandler);
170 #endif
171 
172 EXCEPTION_DISPOSITION
173 NTAPI
174 RtlpExecuteHandlerForUnwind(PEXCEPTION_RECORD ExceptionRecord,
175                             PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
176                             PCONTEXT Context,
177                             PVOID DispatcherContext,
178                             PEXCEPTION_ROUTINE ExceptionHandler);
179 
180 VOID
181 NTAPI
182 RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
183                       IN PCONTEXT ContextRecord,
184                       IN PVOID ContextData,
185                       IN ULONG Size);
186 
187 VOID
188 NTAPI
189 RtlpCaptureContext(OUT PCONTEXT ContextRecord);
190 
191 //
192 // Debug Service calls
193 //
194 ULONG
195 NTAPI
196 DebugService(
197     IN ULONG Service,
198     IN PVOID Argument1,
199     IN PVOID Argument2,
200     IN PVOID Argument3,
201     IN PVOID Argument4
202 );
203 
204 VOID
205 NTAPI
206 DebugService2(
207     IN PVOID Argument1,
208     IN PVOID Argument2,
209     IN ULONG Service
210 );
211 
212 /* Tags for the String Allocators */
213 #define TAG_USTR        'RTSU'
214 #define TAG_ASTR        'RTSA'
215 #define TAG_OSTR        'RTSO'
216 
217 /* Timer Queue */
218 
219 extern HANDLE TimerThreadHandle;
220 
221 NTSTATUS
222 RtlpInitializeTimerThread(VOID);
223 
224 /* bitmap64.c */
225 typedef struct _RTL_BITMAP64
226 {
227     ULONG64 SizeOfBitMap;
228     PULONG64 Buffer;
229 } RTL_BITMAP64, *PRTL_BITMAP64;
230 
231 typedef struct _RTL_BITMAP_RUN64
232 {
233     ULONG64 StartingIndex;
234     ULONG64 NumberOfBits;
235 } RTL_BITMAP_RUN64, *PRTL_BITMAP_RUN64;
236 
237 /* nls.c */
238 WCHAR
239 NTAPI
240 RtlpUpcaseUnicodeChar(IN WCHAR Source);
241 
242 WCHAR
243 NTAPI
244 RtlpDowncaseUnicodeChar(IN WCHAR Source);
245 
246 /* ReactOS only */
247 VOID
248 NTAPI
249 LdrpInitializeProcessCompat(PVOID pProcessActctx, PVOID* pOldShimData);
250 
251 PVOID
252 NTAPI
253 RtlpDebugBufferCommit(_Inout_ PRTL_DEBUG_INFORMATION Buffer,
254                       _In_ SIZE_T Size);
255 
256 
257 /* EOF */
258