00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
#ifndef _NTRTLP_
00029
#define _NTRTLP_
00030
#include <ntos.h>
00031
#include <nturtl.h>
00032
#include <zwapi.h>
00033
00034
#ifdef _X86_
00035
#include "i386\ntrtl386.h"
00036
#endif
00037
00038
#ifdef _MIPS_
00039
#include "mips\ntrtlmip.h"
00040
#endif
00041
00042
#ifdef _PPC_
00043
#include "ppc\ntrtlppc.h"
00044
#endif
00045
00046
#ifdef _ALPHA_
00047
#include "alpha\ntrtlalp.h"
00048
#endif
00049
00050
#ifdef _IA64_
00051
#include "ia64\ntrtli64.h"
00052
#endif
00053
00054
#ifdef BLDR_KERNEL_RUNTIME
00055
#undef try
00056
#define try if(1)
00057
#undef except
00058
#define except(a) else if (0)
00059
#undef finally
00060
#define finally if (1)
00061
#undef GetExceptionCode
00062
#define GetExceptionCode() 1
00063
#define finally if (1)
00064
#endif
00065
00066
#include "string.h"
00067
#include "wchar.h"
00068
00069
00070
00071
00072
00073
VOID
00074
RtlpGetStackLimits (
00075 OUT PULONG_PTR LowLimit,
00076 OUT PULONG_PTR HighLimit
00077 );
00078
00079 LONG
00080
LdrpCompareResourceNames(
00081 IN ULONG ResourceName,
00082 IN PIMAGE_RESOURCE_DIRECTORY ResourceDirectory,
00083 IN PIMAGE_RESOURCE_DIRECTORY_ENTRY ResourceDirectoryEntry
00084 );
00085
00086
NTSTATUS
00087
LdrpSearchResourceSection(
00088 IN PVOID DllHandle,
00089 IN PULONG_PTR ResourceIdPath,
00090 IN ULONG ResourceIdPathLength,
00091 IN BOOLEAN FindDirectoryEntry,
00092 OUT PVOID *ResourceDirectoryOrData
00093 );
00094
00095 LONG
00096
LdrpCompareResourceNames_U(
00097 IN ULONG_PTR ResourceName,
00098 IN PIMAGE_RESOURCE_DIRECTORY ResourceDirectory,
00099 IN PIMAGE_RESOURCE_DIRECTORY_ENTRY ResourceDirectoryEntry
00100 );
00101
00102
NTSTATUS
00103
LdrpSearchResourceSection_U(
00104 IN PVOID DllHandle,
00105 IN PULONG_PTR ResourceIdPath,
00106 IN ULONG ResourceIdPathLength,
00107 IN BOOLEAN FindDirectoryEntry,
00108 IN BOOLEAN ExactMatchOnly,
00109 OUT PVOID *ResourceDirectoryOrData
00110 );
00111
00112
NTSTATUS
00113
LdrpAccessResourceData(
00114 IN PVOID DllHandle,
00115 IN PIMAGE_RESOURCE_DATA_ENTRY ResourceDataEntry,
00116 OUT PVOID *Address OPTIONAL,
00117 OUT PULONG Size OPTIONAL
00118 );
00119
00120
00121
VOID
00122
RtlpAnsiPszToUnicodePsz(
00123 IN PCHAR AnsiString,
00124 IN WCHAR *UnicodeString,
00125 IN USHORT AnsiStringLength
00126 );
00127
00128 BOOLEAN
00129
RtlpDidUnicodeToOemWork(
00130 IN POEM_STRING OemString,
00131 IN PUNICODE_STRING UnicodeString
00132 );
00133
00134 extern CONST CCHAR
RtlpBitsClearAnywhere[256];
00135 extern CONST CCHAR
RtlpBitsClearLow[256];
00136 extern CONST CCHAR
RtlpBitsClearHigh[256];
00137 extern CONST CCHAR
RtlpBitsClearTotal[256];
00138
00139
00140
00141
00142
00143
00144 #define RtlpBitSetAnywhere( Byte ) RtlpBitsClearAnywhere[ (~(Byte) & 0xFF) ]
00145
00146
00147
00148
00149
00150
00151
00152 #define RtlpBitsSetLow( Byte ) RtlpBitsClearLow[ (~(Byte) & 0xFF) ]
00153
00154
00155
00156
00157
00158
00159
00160 #define RtlpBitsSetHigh( Byte ) RtlpBitsClearHigh[ (~(Byte) & 0xFF) ]
00161
00162
00163
00164
00165
00166
00167 #define RtlpBitsSetTotal( Byte ) RtlpBitsClearTotal[ (~(Byte) & 0xFF) ]
00168
00169
00170
00171
00172
00173
00174
00175 extern PUSHORT Nls844UnicodeUpcaseTable;
00176 extern PUSHORT Nls844UnicodeLowercaseTable;
00177
00178
00179
00180
00181
00182
00183 #define LOBYTE(w) ((UCHAR)((w)))
00184 #define HIBYTE(w) ((UCHAR)(((USHORT)((w)) >> 8) & 0xFF))
00185 #define GET8(w) ((ULONG)(((w) >> 8) & 0xff))
00186 #define GETHI4(w) ((ULONG)(((w) >> 4) & 0xf))
00187 #define GETLO4(w) ((ULONG)((w) & 0xf))
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 #define TRAVERSE844W(pTable, wch) \
00207
( (pTable)[(pTable)[(pTable)[GET8((wch))] + GETHI4((wch))] + GETLO4((wch))] )
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 #define NLS_UPCASE(wch) ( \
00220
((wch) < 'a' ? \
00221
(wch) \
00222
: \
00223
((wch) <= 'z' ? \
00224
(wch) - ('a'-'A') \
00225
: \
00226
((WCHAR)((wch) + TRAVERSE844W(Nls844UnicodeUpcaseTable,(wch)))) \
00227
) \
00228
) \
00229
)
00230
00231 #define NLS_DOWNCASE(wch) ( \
00232
((wch) < 'A' ? \
00233
(wch) \
00234
: \
00235
((wch) <= 'Z' ? \
00236
(wch) + ('a'-'A') \
00237
: \
00238
((WCHAR)((wch) + TRAVERSE844W(Nls844UnicodeLowercaseTable,(wch)))) \
00239
) \
00240
) \
00241
)
00242
00243
#if DBG && defined(NTOS_KERNEL_RUNTIME)
00244
#define RTL_PAGED_CODE() PAGED_CODE()
00245
#else
00246 #define RTL_PAGED_CODE()
00247
#endif
00248
00249
00250
00251
00252
00253
00254
00255
00256 typedef NTSTATUS (*
PRTL_COMPRESS_WORKSPACE_SIZE) (
00257 IN
USHORT CompressionEngine,
00258 OUT PULONG CompressBufferWorkSpaceSize,
00259 OUT PULONG CompressFragmentWorkSpaceSize
00260 );
00261
00262 typedef NTSTATUS (*
PRTL_COMPRESS_BUFFER) (
00263 IN
USHORT CompressionEngine,
00264 IN PUCHAR UncompressedBuffer,
00265 IN ULONG UncompressedBufferSize,
00266 OUT PUCHAR CompressedBuffer,
00267 IN ULONG CompressedBufferSize,
00268 IN ULONG UncompressedChunkSize,
00269 OUT PULONG FinalCompressedSize,
00270 IN PVOID WorkSpace
00271 );
00272
00273 typedef NTSTATUS (*
PRTL_DECOMPRESS_BUFFER) (
00274 OUT PUCHAR UncompressedBuffer,
00275 IN ULONG UncompressedBufferSize,
00276 IN PUCHAR CompressedBuffer,
00277 IN ULONG CompressedBufferSize,
00278 OUT PULONG FinalUncompressedSize
00279 );
00280
00281 typedef NTSTATUS (*
PRTL_DECOMPRESS_FRAGMENT) (
00282 OUT PUCHAR UncompressedFragment,
00283 IN ULONG UncompressedFragmentSize,
00284 IN PUCHAR CompressedBuffer,
00285 IN ULONG CompressedBufferSize,
00286 IN ULONG FragmentOffset,
00287 OUT PULONG FinalUncompressedSize,
00288 IN PVOID WorkSpace
00289 );
00290
00291 typedef NTSTATUS (*
PRTL_DESCRIBE_CHUNK) (
00292 IN OUT PUCHAR *CompressedBuffer,
00293 IN PUCHAR EndOfCompressedBufferPlus1,
00294 OUT PUCHAR *ChunkBuffer,
00295 OUT PULONG ChunkSize
00296 );
00297
00298 typedef NTSTATUS (*
PRTL_RESERVE_CHUNK) (
00299 IN OUT PUCHAR *CompressedBuffer,
00300 IN PUCHAR EndOfCompressedBufferPlus1,
00301 OUT PUCHAR *ChunkBuffer,
00302 IN ULONG ChunkSize
00303 );
00304
00305
00306
00307
00308
00309
NTSTATUS
00310
RtlCompressWorkSpaceSizeLZNT1 (
00311 IN USHORT CompressionEngine,
00312 OUT PULONG CompressBufferWorkSpaceSize,
00313 OUT PULONG CompressFragmentWorkSpaceSize
00314 );
00315
00316
NTSTATUS
00317
RtlCompressBufferLZNT1 (
00318 IN USHORT CompressionEngine,
00319 IN PUCHAR UncompressedBuffer,
00320 IN ULONG UncompressedBufferSize,
00321 OUT PUCHAR CompressedBuffer,
00322 IN ULONG CompressedBufferSize,
00323 IN ULONG UncompressedChunkSize,
00324 OUT PULONG FinalCompressedSize,
00325 IN PVOID WorkSpace
00326 );
00327
00328
NTSTATUS
00329
RtlDecompressBufferLZNT1 (
00330 OUT PUCHAR UncompressedBuffer,
00331 IN ULONG UncompressedBufferSize,
00332 IN PUCHAR CompressedBuffer,
00333 IN ULONG CompressedBufferSize,
00334 OUT PULONG FinalUncompressedSize
00335 );
00336
00337
NTSTATUS
00338
RtlDecompressFragmentLZNT1 (
00339 OUT PUCHAR UncompressedFragment,
00340 IN ULONG UncompressedFragmentSize,
00341 IN PUCHAR CompressedBuffer,
00342 IN ULONG CompressedBufferSize,
00343 IN ULONG FragmentOffset,
00344 OUT PULONG FinalUncompressedSize,
00345 IN PVOID WorkSpace
00346 );
00347
00348
NTSTATUS
00349
RtlDescribeChunkLZNT1 (
00350 IN OUT PUCHAR *CompressedBuffer,
00351 IN PUCHAR EndOfCompressedBufferPlus1,
00352 OUT PUCHAR *ChunkBuffer,
00353 OUT PULONG ChunkSize
00354 );
00355
00356
NTSTATUS
00357
RtlReserveChunkLZNT1 (
00358 IN OUT PUCHAR *CompressedBuffer,
00359 IN PUCHAR EndOfCompressedBufferPlus1,
00360 OUT PUCHAR *ChunkBuffer,
00361 IN ULONG ChunkSize
00362 );
00363
00364
00365
00366
00367
00368
NTSTATUS
00369
DebugPrint(
00370 IN PSTRING Output
00371 );
00372
00373 ULONG
00374
DebugPrompt(
00375 IN PSTRING Output,
00376 IN PSTRING Input
00377 );
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 #define RtlpInitializeSListHead(_listhead_) (_listhead_)->Alignment = 0
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431 #define RtlpQueryDepthSList(_listhead_) (_listhead_)->Depth
00432
00433 PVOID
00434
FASTCALL
00435
RtlpInterlockedPopEntrySList (
00436 IN
PSLIST_HEADER ListHead
00437 );
00438
00439 PVOID
00440
FASTCALL
00441
RtlpInterlockedPushEntrySList (
00442 IN
PSLIST_HEADER ListHead,
00443 IN PVOID ListEntry
00444 );
00445
00446
00447
#if defined(NTOS_KERNEL_RUNTIME) || defined(BLDR_KERNEL_RUNTIME)
00448
00449
VOID
00450
DebugLoadImageSymbols(
00451 IN PSTRING FileName,
00452 IN
PKD_SYMBOLS_INFO SymbolInfo
00453 );
00454
00455
VOID
00456
DebugUnLoadImageSymbols(
00457 IN PSTRING FileName,
00458 IN
PKD_SYMBOLS_INFO SymbolInfo
00459 );
00460
00461
#endif // defined(NTOS_KERNEL_RUNTIME)
00462
00463
#endif // _NTRTLP_
00464
00465
00466
00467
00468 ULONG
00469
RtlpLogExceptionHandler(
00470 IN PEXCEPTION_RECORD ExceptionRecord,
00471 IN PCONTEXT ContextRecord,
00472 IN ULONG_PTR ControlPc,
00473 IN PVOID HandlerData,
00474 IN ULONG Size
00475 );
00476
00477
VOID
00478
RtlpLogLastExceptionDisposition(
00479 IN ULONG LogIndex,
00480 IN EXCEPTION_DISPOSITION Disposition
00481 );
00482
00483
#ifndef NTOS_KERNEL_RUNTIME
00484
00485 #define NO_ALTERNATE_RESOURCE_MODULE (PVOID)(-1)
00486
00487 typedef struct _ALT_RESOURCE_MODULE {
00488
00489
00490
00491
00492 PVOID
ModuleBase;
00493
00494
00495
00496
00497
00498
00499
00500 PVOID
AlternateModule;
00501 }
ALT_RESOURCE_MODULE, *
PALT_RESOURCE_MODULE;
00502
00503 BOOLEAN
00504
LdrpVerifyAlternateResourceModule(
00505 IN PVOID Module,
00506 IN PVOID AlternateModule
00507 );
00508
00509 BOOLEAN
00510
LdrpSetAlternateResourceModuleHandle(
00511 IN PVOID Module,
00512 IN PVOID AlternateModule
00513 );
00514
#endif