47ae13576e4d19c5d685463d0def84bc6c07bd4a
[reactos.git] / reactos / lib / rtl / rtlp.h
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)(n)) & ~((align) - 1l))
31
32 #define ROUND_UP(n, align) \
33 ROUND_DOWN(((ULONG)(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 typedef struct _DISPATCHER_CONTEXT
71 {
72 PEXCEPTION_REGISTRATION_RECORD RegistrationPointer;
73 } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
74
75 /* These provide support for sharing code between User and Kernel RTL */
76 PVOID
77 NTAPI
78 RtlpAllocateMemory(
79 SIZE_T Bytes,
80 ULONG Tag);
81
82 VOID
83 NTAPI
84 RtlpFreeMemory(
85 PVOID Mem,
86 ULONG Tag);
87
88 KPROCESSOR_MODE
89 NTAPI
90 RtlpGetMode(VOID);
91
92 BOOLEAN
93 NTAPI
94 RtlpCaptureStackLimits(
95 IN ULONG_PTR Ebp,
96 IN ULONG_PTR *StackBegin,
97 IN ULONG_PTR *StackEnd
98 );
99
100 NTSTATUS
101 NTAPI
102 RtlDeleteHeapLock(IN OUT PHEAP_LOCK Lock);
103
104 NTSTATUS
105 NTAPI
106 RtlEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
107
108 BOOLEAN
109 NTAPI
110 RtlTryEnterHeapLock(IN OUT PHEAP_LOCK Lock, IN BOOLEAN Exclusive);
111
112 NTSTATUS
113 NTAPI
114 RtlInitializeHeapLock(IN OUT PHEAP_LOCK *Lock);
115
116 NTSTATUS
117 NTAPI
118 RtlLeaveHeapLock(IN OUT PHEAP_LOCK Lock);
119
120 BOOLEAN
121 NTAPI
122 RtlpCheckForActiveDebugger(VOID);
123
124 BOOLEAN
125 NTAPI
126 RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
127 IN ULONG_PTR RegistrationFrameEnd,
128 IN OUT PULONG_PTR StackLow,
129 IN OUT PULONG_PTR StackHigh);
130
131 #define RtlpAllocateStringMemory RtlpAllocateMemory
132 #define RtlpFreeStringMemory RtlpFreeMemory
133
134 ULONG
135 NTAPI
136 RtlGetTickCount(VOID);
137 #define NtGetTickCount RtlGetTickCount
138
139 BOOLEAN
140 NTAPI
141 RtlpSetInDbgPrint(
142 VOID
143 );
144
145 VOID
146 NTAPI
147 RtlpClearInDbgPrint(
148 VOID
149 );
150
151 /* i386/except.S */
152
153 EXCEPTION_DISPOSITION
154 NTAPI
155 RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord,
156 PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
157 PCONTEXT Context,
158 PVOID DispatcherContext,
159 PEXCEPTION_ROUTINE ExceptionHandler);
160
161 EXCEPTION_DISPOSITION
162 NTAPI
163 RtlpExecuteHandlerForUnwind(PEXCEPTION_RECORD ExceptionRecord,
164 PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
165 PCONTEXT Context,
166 PVOID DispatcherContext,
167 PEXCEPTION_ROUTINE ExceptionHandler);
168
169 VOID
170 NTAPI
171 RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
172 IN PCONTEXT ContextRecord,
173 IN PVOID ContextData,
174 IN ULONG Size);
175
176 VOID
177 NTAPI
178 RtlpCaptureContext(OUT PCONTEXT ContextRecord);
179
180 //
181 // Debug Service calls
182 //
183 ULONG
184 NTAPI
185 DebugService(
186 IN ULONG Service,
187 IN PVOID Argument1,
188 IN PVOID Argument2,
189 IN PVOID Argument3,
190 IN PVOID Argument4
191 );
192
193 VOID
194 NTAPI
195 DebugService2(
196 IN PVOID Argument1,
197 IN PVOID Argument2,
198 IN ULONG Service
199 );
200
201 /* Tags for the String Allocators */
202 #define TAG_USTR 'RTSU'
203 #define TAG_ASTR 'RTSA'
204 #define TAG_OSTR 'RTSO'
205
206 /* Timer Queue */
207
208 extern HANDLE TimerThreadHandle;
209
210 NTSTATUS
211 RtlpInitializeTimerThread(VOID);
212
213 /* bitmap64.c */
214 typedef struct _RTL_BITMAP64
215 {
216 ULONG64 SizeOfBitMap;
217 PULONG64 Buffer;
218 } RTL_BITMAP64, *PRTL_BITMAP64;
219
220 typedef struct _RTL_BITMAP_RUN64
221 {
222 ULONG64 StartingIndex;
223 ULONG64 NumberOfBits;
224 } RTL_BITMAP_RUN64, *PRTL_BITMAP_RUN64;
225
226 /* EOF */