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