Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ntrtlp.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 ntrtlp.h 00008 00009 Abstract: 00010 00011 Include file for NT runtime routines that are callable by both 00012 kernel mode code in the executive and user mode code in various 00013 NT subsystems, but which are private interfaces. 00014 00015 Author: 00016 00017 David N. Cutler (davec) 15-Aug-1989 00018 00019 Environment: 00020 00021 These routines are statically linked in the caller's executable and 00022 are callable in either kernel mode or user mode. 00023 00024 Revision History: 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 // Machine state reporting. See machine specific includes for more. 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 // Macro that tells how many contiguous bits are set (i.e., 1) in 00141 // a byte 00142 // 00143 00144 #define RtlpBitSetAnywhere( Byte ) RtlpBitsClearAnywhere[ (~(Byte) & 0xFF) ] 00145 00146 00147 // 00148 // Macro that tells how many contiguous LOW order bits are set 00149 // (i.e., 1) in a byte 00150 // 00151 00152 #define RtlpBitsSetLow( Byte ) RtlpBitsClearLow[ (~(Byte) & 0xFF) ] 00153 00154 00155 // 00156 // Macro that tells how many contiguous HIGH order bits are set 00157 // (i.e., 1) in a byte 00158 // 00159 00160 #define RtlpBitsSetHigh( Byte ) RtlpBitsClearHigh[ (~(Byte) & 0xFF) ] 00161 00162 00163 // 00164 // Macro that tells how many set bits (i.e., 1) there are in a byte 00165 // 00166 00167 #define RtlpBitsSetTotal( Byte ) RtlpBitsClearTotal[ (~(Byte) & 0xFF) ] 00168 00169 00170 00171 // 00172 // Upcase data table 00173 // 00174 00175 extern PUSHORT Nls844UnicodeUpcaseTable; 00176 extern PUSHORT Nls844UnicodeLowercaseTable; 00177 00178 00179 // 00180 // Macros for Upper Casing a Unicode Code Point. 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 * TRAVERSE844W 00191 * 00192 * Traverses the 8:4:4 translation table for the given wide character. It 00193 * returns the final value of the 8:4:4 table, which is a WORD in length. 00194 * 00195 * Broken Down Version: 00196 * -------------------- 00197 * Incr = pTable[GET8(wch)]; 00198 * Incr = pTable[Incr + GETHI4(wch)]; 00199 * Value = pTable[Incr + GETLO4(wch)]; 00200 * 00201 * DEFINED AS A MACRO. 00202 * 00203 * 05-31-91 JulieB Created. 00204 \***************************************************************************/ 00205 00206 #define TRAVERSE844W(pTable, wch) \ 00207 ( (pTable)[(pTable)[(pTable)[GET8((wch))] + GETHI4((wch))] + GETLO4((wch))] ) 00208 00209 // 00210 // NLS_UPCASE - Based on julieb's macros in nls.h 00211 // 00212 // We will have this upcase macro quickly shortcircuit out if the value 00213 // is within the normal ANSI range (i.e., < 127). We actually won't bother 00214 // with the 5 values above 'z' because they won't happen very often and 00215 // coding it this way lets us get out after 1 compare for value less than 00216 // 'a' and 2 compares for lowercase a-z. 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 // The follow definition is used to support the Rtl compression engine 00252 // Every compression format that NT supports will need to supply 00253 // these set of routines in order to be called by NtRtl. 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 // Here is the declarations of the LZNT1 routines 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 // Define procedure prototypes for architecture specific debug support routines. 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 // Define procedure prototypes for slist manipulation and general lookaside lists 00382 // 00383 00384 /*++ 00385 00386 VOID 00387 RtlpInitializeSListHead ( 00388 IN PSLIST_HEADER SListHead 00389 ) 00390 00391 Routine Description: 00392 00393 This function initializes a sequenced singly linked listhead. 00394 00395 Arguments: 00396 00397 SListHead - Supplies a pointer to a sequenced singly linked listhead. 00398 00399 Return Value: 00400 00401 None. 00402 00403 --*/ 00404 00405 #define RtlpInitializeSListHead(_listhead_) (_listhead_)->Alignment = 0 00406 00407 /*++ 00408 00409 USHORT 00410 RtlpQueryDepthSListHead ( 00411 IN PSLIST_HEADERT SListHead 00412 ) 00413 00414 Routine Description: 00415 00416 This function queries the current number of entries contained in a 00417 sequenced single linked list. 00418 00419 Arguments: 00420 00421 SListHead - Supplies a pointer to the sequenced listhead which is 00422 be queried. 00423 00424 Return Value: 00425 00426 The current number of entries in the sequenced singly linked list is 00427 returned as the function value. 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 // Procedure prototype for exception logging routines. 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 // Module handle for module known to application, 00490 // whose resource accesses we want to redirect. 00491 // 00492 PVOID ModuleBase; 00493 // 00494 // Module handle for module we loaded under the covers, 00495 // to which resource access will be redirected; will be 00496 // NO_ALTERNATE_RESOURCE_MODULE if we tried and failed to load 00497 // the alternate resource module for the module represented by 00498 // ModuleBase. 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

Generated on Sat May 15 19:41:01 2004 for test by doxygen 1.3.7