reactos/reactos/include/ndk/rtlfuncs.h

3332 lines
51 KiB
C
Raw Normal View History

/*++ NDK Version: 0098
Copyright (c) Alex Ionescu. All rights reserved.
Header Name:
rtlfuncs.h
Abstract:
Function definitions for the Run-Time Library
Author:
Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
--*/
#ifndef _RTLFUNCS_H
#define _RTLFUNCS_H
//
// Dependencies
//
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
#include <umtypes.h>
#include <ntnls.h>
- Update NDK to remove zwfuncs.h and place the native functions in their respective xxfuncs.h instead, so that applications can now include only what they need. Add more xxfuncs.h files for every API. - Make the NDK smarter so that using #define NTOS_MODE_USER isn't needed anymore: the NDK can now auto-detect the presence of windows.h or ntddk.h and make the appropriate decision. - re-arrange ntndk.h to include all types in alphabetical order, and then all functions, regardless of um/kmode usage. - Make each file auto-detect if this is NTOS_MODE_USER or not and include each files it needs, instead of depending on a predefined order inside ntndk.h This way, any file can be included from both user-mode or kmode as simply as #include <iofuncs.h>, wthout any adtional work. - Update FIXME list with these changes and delay NDK release date since my trip is lasting a day longer. - Fix ntsecapi.h to define UNICODE_STRING, like it does in the PSDK. - Fix apps including ntsecapi + winternl.h These two cause a conflict even on PSDK and shouldn't be included together. - Make winlogon include only the NDK files it needs (2) instead of the whole NDK, as test for this faster newly supported method. - Remove some NDK apps from the FIXME list (the ones that weren't being built/are on my rewrite branch/are better off including the whole NDK instead of file-by-file). - Update debug.h to define RtlAssert and DbgPrint in case the NDK or DDK aren't already included, which will allow some of the apps to stop using the NDK solely for DPRINT/DPRINT1. Diabled for now since a lot of code needs to be changed to #include <debug.h> *After* they include the other headers. (so that the anti-double-definition check can work). svn path=/trunk/; revision=19538
2005-11-25 00:17:40 +00:00
#include <rtltypes.h>
#include <pstypes.h>
#include <extypes.h>
#include "in6addr.h"
#include "inaddr.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef NTOS_MODE_USER
//
// List Functions
//
FORCEINLINE
VOID
InitializeListHead(
IN PLIST_ENTRY ListHead
)
{
ListHead->Flink = ListHead->Blink = ListHead;
}
FORCEINLINE
VOID
InsertHeadList(
IN PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry
)
{
PLIST_ENTRY OldFlink;
OldFlink = ListHead->Flink;
Entry->Flink = OldFlink;
Entry->Blink = ListHead;
OldFlink->Blink = Entry;
ListHead->Flink = Entry;
}
FORCEINLINE
VOID
InsertTailList(
IN PLIST_ENTRY ListHead,
IN PLIST_ENTRY Entry
)
{
PLIST_ENTRY OldBlink;
OldBlink = ListHead->Blink;
Entry->Flink = ListHead;
Entry->Blink = OldBlink;
OldBlink->Flink = Entry;
ListHead->Blink = Entry;
}
FORCEINLINE
BOOLEAN
IsListEmpty(
IN const LIST_ENTRY * ListHead
)
{
return (BOOLEAN)(ListHead->Flink == ListHead);
}
FORCEINLINE
PSINGLE_LIST_ENTRY
PopEntryList(
PSINGLE_LIST_ENTRY ListHead
)
{
PSINGLE_LIST_ENTRY FirstEntry;
FirstEntry = ListHead->Next;
if (FirstEntry != NULL) {
ListHead->Next = FirstEntry->Next;
}
return FirstEntry;
}
FORCEINLINE
VOID
PushEntryList(
PSINGLE_LIST_ENTRY ListHead,
PSINGLE_LIST_ENTRY Entry
)
{
Entry->Next = ListHead->Next;
ListHead->Next = Entry;
}
FORCEINLINE
BOOLEAN
RemoveEntryList(
IN PLIST_ENTRY Entry)
{
PLIST_ENTRY OldFlink;
PLIST_ENTRY OldBlink;
OldFlink = Entry->Flink;
OldBlink = Entry->Blink;
OldFlink->Blink = OldBlink;
OldBlink->Flink = OldFlink;
return (BOOLEAN)(OldFlink == OldBlink);
}
FORCEINLINE
PLIST_ENTRY
RemoveHeadList(
IN PLIST_ENTRY ListHead)
{
PLIST_ENTRY Flink;
PLIST_ENTRY Entry;
Entry = ListHead->Flink;
Flink = Entry->Flink;
ListHead->Flink = Flink;
Flink->Blink = ListHead;
return Entry;
}
FORCEINLINE
PLIST_ENTRY
RemoveTailList(
IN PLIST_ENTRY ListHead)
{
PLIST_ENTRY Blink;
PLIST_ENTRY Entry;
Entry = ListHead->Blink;
Blink = Entry->Blink;
ListHead->Blink = Blink;
Blink->Flink = ListHead;
return Entry;
}
//
// Unicode string macros
//
FORCEINLINE
VOID
RtlInitEmptyUnicodeString(OUT PUNICODE_STRING UnicodeString,
IN PWSTR Buffer,
IN USHORT BufferSize)
{
UnicodeString->Length = 0;
UnicodeString->MaximumLength = BufferSize;
UnicodeString->Buffer = Buffer;
}
//
// LUID Macros
//
#define RtlEqualLuid(L1, L2) (((L1)->HighPart == (L2)->HighPart) && \
((L1)->LowPart == (L2)->LowPart))
FORCEINLINE
LUID
NTAPI_INLINE
RtlConvertUlongToLuid(ULONG Ulong)
{
LUID TempLuid;
TempLuid.LowPart = Ulong;
TempLuid.HighPart = 0;
return TempLuid;
}
//
// ASSERT Macros
//
#ifndef ASSERT
#if DBG
#define ASSERT( exp ) \
((void)((!(exp)) ? \
(RtlAssert( #exp, __FILE__, __LINE__, NULL ),FALSE) : \
TRUE))
#define ASSERTMSG( msg, exp ) \
((void)((!(exp)) ? \
(RtlAssert( #exp, __FILE__, __LINE__, msg ),FALSE) : \
TRUE))
#else
#define ASSERT( exp ) ((void) 0)
#define ASSERTMSG( msg, exp ) ((void) 0)
#endif
#endif
#ifdef NTOS_KERNEL_RUNTIME
//
// Executing RTL functions at DISPATCH_LEVEL or higher will result in a
// bugcheck.
//
#define RTL_PAGED_CODE PAGED_CODE
#else
//
// This macro does nothing in user mode
//
#define RTL_PAGED_CODE NOP_FUNCTION
#endif
//
// RTL Splay Tree Functions
//
NTSYSAPI
PRTL_SPLAY_LINKS
NTAPI
RtlSplay(
IN PRTL_SPLAY_LINKS Links
);
NTSYSAPI
PRTL_SPLAY_LINKS
NTAPI
RtlDelete(IN PRTL_SPLAY_LINKS Links
);
NTSYSAPI
VOID
NTAPI
RtlDeleteNoSplay(
IN PRTL_SPLAY_LINKS Links,
OUT PRTL_SPLAY_LINKS *Root
);
NTSYSAPI
PRTL_SPLAY_LINKS
NTAPI
RtlSubtreeSuccessor(
IN PRTL_SPLAY_LINKS Links
);
NTSYSAPI
PRTL_SPLAY_LINKS
NTAPI
RtlSubtreePredecessor(
IN PRTL_SPLAY_LINKS Links
);
NTSYSAPI
PRTL_SPLAY_LINKS
NTAPI
RtlRealSuccessor(
IN PRTL_SPLAY_LINKS Links
);
NTSYSAPI
PRTL_SPLAY_LINKS
NTAPI
RtlRealPredecessor(
IN PRTL_SPLAY_LINKS Links
);
#define RtlIsLeftChild(Links) \
(RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
#define RtlIsRightChild(Links) \
(RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
#define RtlRightChild(Links) \
((PRTL_SPLAY_LINKS)(Links))->RightChild
#define RtlIsRoot(Links) \
(RtlParent(Links) == (PRTL_SPLAY_LINKS)(Links))
#define RtlLeftChild(Links) \
((PRTL_SPLAY_LINKS)(Links))->LeftChild
#define RtlParent(Links) \
((PRTL_SPLAY_LINKS)(Links))->Parent
#define RtlInitializeSplayLinks(Links) \
{ \
PRTL_SPLAY_LINKS _SplayLinks; \
_SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
_SplayLinks->Parent = _SplayLinks; \
_SplayLinks->LeftChild = NULL; \
_SplayLinks->RightChild = NULL; \
}
#define RtlInsertAsLeftChild(ParentLinks,ChildLinks) \
{ \
PRTL_SPLAY_LINKS _SplayParent; \
PRTL_SPLAY_LINKS _SplayChild; \
_SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
_SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
_SplayParent->LeftChild = _SplayChild; \
_SplayChild->Parent = _SplayParent; \
}
#define RtlInsertAsRightChild(ParentLinks,ChildLinks) \
{ \
PRTL_SPLAY_LINKS _SplayParent; \
PRTL_SPLAY_LINKS _SplayChild; \
_SplayParent = (PRTL_SPLAY_LINKS)(ParentLinks); \
_SplayChild = (PRTL_SPLAY_LINKS)(ChildLinks); \
_SplayParent->RightChild = _SplayChild; \
_SplayChild->Parent = _SplayParent; \
}
#endif
//
// Error and Exception Functions
//
NTSYSAPI
PVOID
NTAPI
RtlAddVectoredExceptionHandler(
IN ULONG FirstHandler,
IN PVECTORED_EXCEPTION_HANDLER VectoredHandler
);
NTSYSAPI
VOID
NTAPI
RtlAssert(
IN PVOID FailedAssertion,
IN PVOID FileName,
IN ULONG LineNumber,
IN PCHAR Message
);
Major refactoring of the exception handling code + misc fixes: - Fix/add prototypes for RtlCaptureContext, RtlDispatchException and RtlUnwind - Fix EXCEPTION_REGISTRATION_RECORD structure and PEXCEPTION_ROUTINE - Add w32api excpt.h (based on mingw) with PSDK compatibility fixes - Fix seriously broken User-Mode Ldr thunk and APC Callback prototypes - Fix KiUserExceptionDispatcher - Remove useless NTDLL entrypoint - Implement NTDLL Ki* callbacks in ASM - Implement RtlCaptureContext - Fix RtlRaiseException to handle cases when a user-mode debugger is present - Fix RtlRaiseStatus as above, plus set the exception address and capture context - Little cleanup of RTL headers - Implement RtlpGetStackLimits, RtlpGetExceptionList, RtlpSetExceptionList, RtlpGetExceptionAddress in ASM - Fix RtlDispatchException, add cases for exceptions in the DPC stack and validate the validity of the exception frames. Add support for exception logging by the global flag. Use TRAP_FRAME/EXCPETION_FRAME instead of Context. - Fix RtlUnwind logic, support cases where it's called with custom arguments instead of NULL. - Reimplement RtlpCaptureContext to work properly, convert exception handler calling functions to INTEL syntax and fix some bugs (like checking for the right unwind flag, clearing volatile register values, etc. Also use some optimizations to increase speed. - Modify some kernel functions (like KeContextToTrapFrame, KiDispatchException, KiInitializeUserApc, etc.) to support a PKEXCEPTION_FRAME for future PPC compatibility. - Reimplement RtlCaptureUnicodeString/FreeUnicodeString as inlined probe macros and optimize them. - Export ExRaiseStatus/Exception as Rtl* - Reimplement NtContinue to have more platform-independent code, and to protect and validate user-mode context and parameters with SEH. - Implement KiRaiseException, add SEH to all user-mode parameters and when copying data to the user-mode stack. - Fix KiInitializeUserApc to use KeTrapFrameToContext, to save the debug registers, not to deliver APCs during v86 mode, and to protect user-mode stack operations in SEH and probing. Also make it generate the proper stack for the user-mode callback. - Implement KiUnexpectedInterrupt and KiCoprocessorError - Reimplement NtRaiseException in ASM to take advantage of optimizations due to the trap frame being in the stack when called through System call interface. - Fix Ntcontinue to respect AlertThread paramter - Fix some functiosn to return with KiServiceExit2 instead of KiServiceExit when required/needed - Fix KiDispatchException's logic, fix hacks when calling KeUserExceptionDispatcher, use correct context flags,... - Make NTDLL Ki* callbacks have SEH to protect them and return to kernel-mode with notification of any exceptions (the kernel-mode code to handle this isn't written yet though) svn path=/trunk/; revision=17811
2005-09-11 22:32:20 +00:00
NTSYSAPI
PVOID
Major refactoring of the exception handling code + misc fixes: - Fix/add prototypes for RtlCaptureContext, RtlDispatchException and RtlUnwind - Fix EXCEPTION_REGISTRATION_RECORD structure and PEXCEPTION_ROUTINE - Add w32api excpt.h (based on mingw) with PSDK compatibility fixes - Fix seriously broken User-Mode Ldr thunk and APC Callback prototypes - Fix KiUserExceptionDispatcher - Remove useless NTDLL entrypoint - Implement NTDLL Ki* callbacks in ASM - Implement RtlCaptureContext - Fix RtlRaiseException to handle cases when a user-mode debugger is present - Fix RtlRaiseStatus as above, plus set the exception address and capture context - Little cleanup of RTL headers - Implement RtlpGetStackLimits, RtlpGetExceptionList, RtlpSetExceptionList, RtlpGetExceptionAddress in ASM - Fix RtlDispatchException, add cases for exceptions in the DPC stack and validate the validity of the exception frames. Add support for exception logging by the global flag. Use TRAP_FRAME/EXCPETION_FRAME instead of Context. - Fix RtlUnwind logic, support cases where it's called with custom arguments instead of NULL. - Reimplement RtlpCaptureContext to work properly, convert exception handler calling functions to INTEL syntax and fix some bugs (like checking for the right unwind flag, clearing volatile register values, etc. Also use some optimizations to increase speed. - Modify some kernel functions (like KeContextToTrapFrame, KiDispatchException, KiInitializeUserApc, etc.) to support a PKEXCEPTION_FRAME for future PPC compatibility. - Reimplement RtlCaptureUnicodeString/FreeUnicodeString as inlined probe macros and optimize them. - Export ExRaiseStatus/Exception as Rtl* - Reimplement NtContinue to have more platform-independent code, and to protect and validate user-mode context and parameters with SEH. - Implement KiRaiseException, add SEH to all user-mode parameters and when copying data to the user-mode stack. - Fix KiInitializeUserApc to use KeTrapFrameToContext, to save the debug registers, not to deliver APCs during v86 mode, and to protect user-mode stack operations in SEH and probing. Also make it generate the proper stack for the user-mode callback. - Implement KiUnexpectedInterrupt and KiCoprocessorError - Reimplement NtRaiseException in ASM to take advantage of optimizations due to the trap frame being in the stack when called through System call interface. - Fix Ntcontinue to respect AlertThread paramter - Fix some functiosn to return with KiServiceExit2 instead of KiServiceExit when required/needed - Fix KiDispatchException's logic, fix hacks when calling KeUserExceptionDispatcher, use correct context flags,... - Make NTDLL Ki* callbacks have SEH to protect them and return to kernel-mode with notification of any exceptions (the kernel-mode code to handle this isn't written yet though) svn path=/trunk/; revision=17811
2005-09-11 22:32:20 +00:00
NTAPI
RtlSetUnhandledExceptionFilter(
IN PVOID TopLevelExceptionFilter
);
Major refactoring of the exception handling code + misc fixes: - Fix/add prototypes for RtlCaptureContext, RtlDispatchException and RtlUnwind - Fix EXCEPTION_REGISTRATION_RECORD structure and PEXCEPTION_ROUTINE - Add w32api excpt.h (based on mingw) with PSDK compatibility fixes - Fix seriously broken User-Mode Ldr thunk and APC Callback prototypes - Fix KiUserExceptionDispatcher - Remove useless NTDLL entrypoint - Implement NTDLL Ki* callbacks in ASM - Implement RtlCaptureContext - Fix RtlRaiseException to handle cases when a user-mode debugger is present - Fix RtlRaiseStatus as above, plus set the exception address and capture context - Little cleanup of RTL headers - Implement RtlpGetStackLimits, RtlpGetExceptionList, RtlpSetExceptionList, RtlpGetExceptionAddress in ASM - Fix RtlDispatchException, add cases for exceptions in the DPC stack and validate the validity of the exception frames. Add support for exception logging by the global flag. Use TRAP_FRAME/EXCPETION_FRAME instead of Context. - Fix RtlUnwind logic, support cases where it's called with custom arguments instead of NULL. - Reimplement RtlpCaptureContext to work properly, convert exception handler calling functions to INTEL syntax and fix some bugs (like checking for the right unwind flag, clearing volatile register values, etc. Also use some optimizations to increase speed. - Modify some kernel functions (like KeContextToTrapFrame, KiDispatchException, KiInitializeUserApc, etc.) to support a PKEXCEPTION_FRAME for future PPC compatibility. - Reimplement RtlCaptureUnicodeString/FreeUnicodeString as inlined probe macros and optimize them. - Export ExRaiseStatus/Exception as Rtl* - Reimplement NtContinue to have more platform-independent code, and to protect and validate user-mode context and parameters with SEH. - Implement KiRaiseException, add SEH to all user-mode parameters and when copying data to the user-mode stack. - Fix KiInitializeUserApc to use KeTrapFrameToContext, to save the debug registers, not to deliver APCs during v86 mode, and to protect user-mode stack operations in SEH and probing. Also make it generate the proper stack for the user-mode callback. - Implement KiUnexpectedInterrupt and KiCoprocessorError - Reimplement NtRaiseException in ASM to take advantage of optimizations due to the trap frame being in the stack when called through System call interface. - Fix Ntcontinue to respect AlertThread paramter - Fix some functiosn to return with KiServiceExit2 instead of KiServiceExit when required/needed - Fix KiDispatchException's logic, fix hacks when calling KeUserExceptionDispatcher, use correct context flags,... - Make NTDLL Ki* callbacks have SEH to protect them and return to kernel-mode with notification of any exceptions (the kernel-mode code to handle this isn't written yet though) svn path=/trunk/; revision=17811
2005-09-11 22:32:20 +00:00
NTSYSAPI
VOID
NTAPI
RtlCaptureContext(
OUT PCONTEXT ContextRecord
);
NTSYSAPI
PVOID
NTAPI
RtlEncodePointer(
IN PVOID Pointer
);
NTSYSAPI
PVOID
NTAPI
RtlDecodePointer(
IN PVOID Pointer
);
NTSYSAPI
PVOID
NTAPI
RtlEncodeSystemPointer(
IN PVOID Pointer
);
NTSYSAPI
PVOID
NTAPI
RtlDecodeSystemPointer(
IN PVOID Pointer
);
Major refactoring of the exception handling code + misc fixes: - Fix/add prototypes for RtlCaptureContext, RtlDispatchException and RtlUnwind - Fix EXCEPTION_REGISTRATION_RECORD structure and PEXCEPTION_ROUTINE - Add w32api excpt.h (based on mingw) with PSDK compatibility fixes - Fix seriously broken User-Mode Ldr thunk and APC Callback prototypes - Fix KiUserExceptionDispatcher - Remove useless NTDLL entrypoint - Implement NTDLL Ki* callbacks in ASM - Implement RtlCaptureContext - Fix RtlRaiseException to handle cases when a user-mode debugger is present - Fix RtlRaiseStatus as above, plus set the exception address and capture context - Little cleanup of RTL headers - Implement RtlpGetStackLimits, RtlpGetExceptionList, RtlpSetExceptionList, RtlpGetExceptionAddress in ASM - Fix RtlDispatchException, add cases for exceptions in the DPC stack and validate the validity of the exception frames. Add support for exception logging by the global flag. Use TRAP_FRAME/EXCPETION_FRAME instead of Context. - Fix RtlUnwind logic, support cases where it's called with custom arguments instead of NULL. - Reimplement RtlpCaptureContext to work properly, convert exception handler calling functions to INTEL syntax and fix some bugs (like checking for the right unwind flag, clearing volatile register values, etc. Also use some optimizations to increase speed. - Modify some kernel functions (like KeContextToTrapFrame, KiDispatchException, KiInitializeUserApc, etc.) to support a PKEXCEPTION_FRAME for future PPC compatibility. - Reimplement RtlCaptureUnicodeString/FreeUnicodeString as inlined probe macros and optimize them. - Export ExRaiseStatus/Exception as Rtl* - Reimplement NtContinue to have more platform-independent code, and to protect and validate user-mode context and parameters with SEH. - Implement KiRaiseException, add SEH to all user-mode parameters and when copying data to the user-mode stack. - Fix KiInitializeUserApc to use KeTrapFrameToContext, to save the debug registers, not to deliver APCs during v86 mode, and to protect user-mode stack operations in SEH and probing. Also make it generate the proper stack for the user-mode callback. - Implement KiUnexpectedInterrupt and KiCoprocessorError - Reimplement NtRaiseException in ASM to take advantage of optimizations due to the trap frame being in the stack when called through System call interface. - Fix Ntcontinue to respect AlertThread paramter - Fix some functiosn to return with KiServiceExit2 instead of KiServiceExit when required/needed - Fix KiDispatchException's logic, fix hacks when calling KeUserExceptionDispatcher, use correct context flags,... - Make NTDLL Ki* callbacks have SEH to protect them and return to kernel-mode with notification of any exceptions (the kernel-mode code to handle this isn't written yet though) svn path=/trunk/; revision=17811
2005-09-11 22:32:20 +00:00
NTSYSAPI
BOOLEAN
NTAPI
RtlDispatchException(
IN PEXCEPTION_RECORD ExceptionRecord,
IN PCONTEXT Context
);
NTSYSAPI
ULONG
NTAPI
RtlNtStatusToDosError(
IN NTSTATUS Status
);
NTSYSAPI
ULONG
NTAPI
RtlNtStatusToDosErrorNoTeb(
IN NTSTATUS Status
);
NTSYSAPI
VOID
NTAPI
RtlSetLastWin32ErrorAndNtStatusFromNtStatus(
IN NTSTATUS Status
);
NTSYSAPI
VOID
NTAPI
RtlRaiseException(
IN PEXCEPTION_RECORD ExceptionRecord
);
DECLSPEC_NORETURN
NTSYSAPI
VOID
NTAPI
RtlRaiseStatus(
IN NTSTATUS Status
);
NTSYSAPI
LONG
NTAPI
RtlUnhandledExceptionFilter(
IN struct _EXCEPTION_POINTERS* ExceptionInfo
);
NTSYSAPI
VOID
NTAPI
RtlUnwind(
Major refactoring of the exception handling code + misc fixes: - Fix/add prototypes for RtlCaptureContext, RtlDispatchException and RtlUnwind - Fix EXCEPTION_REGISTRATION_RECORD structure and PEXCEPTION_ROUTINE - Add w32api excpt.h (based on mingw) with PSDK compatibility fixes - Fix seriously broken User-Mode Ldr thunk and APC Callback prototypes - Fix KiUserExceptionDispatcher - Remove useless NTDLL entrypoint - Implement NTDLL Ki* callbacks in ASM - Implement RtlCaptureContext - Fix RtlRaiseException to handle cases when a user-mode debugger is present - Fix RtlRaiseStatus as above, plus set the exception address and capture context - Little cleanup of RTL headers - Implement RtlpGetStackLimits, RtlpGetExceptionList, RtlpSetExceptionList, RtlpGetExceptionAddress in ASM - Fix RtlDispatchException, add cases for exceptions in the DPC stack and validate the validity of the exception frames. Add support for exception logging by the global flag. Use TRAP_FRAME/EXCPETION_FRAME instead of Context. - Fix RtlUnwind logic, support cases where it's called with custom arguments instead of NULL. - Reimplement RtlpCaptureContext to work properly, convert exception handler calling functions to INTEL syntax and fix some bugs (like checking for the right unwind flag, clearing volatile register values, etc. Also use some optimizations to increase speed. - Modify some kernel functions (like KeContextToTrapFrame, KiDispatchException, KiInitializeUserApc, etc.) to support a PKEXCEPTION_FRAME for future PPC compatibility. - Reimplement RtlCaptureUnicodeString/FreeUnicodeString as inlined probe macros and optimize them. - Export ExRaiseStatus/Exception as Rtl* - Reimplement NtContinue to have more platform-independent code, and to protect and validate user-mode context and parameters with SEH. - Implement KiRaiseException, add SEH to all user-mode parameters and when copying data to the user-mode stack. - Fix KiInitializeUserApc to use KeTrapFrameToContext, to save the debug registers, not to deliver APCs during v86 mode, and to protect user-mode stack operations in SEH and probing. Also make it generate the proper stack for the user-mode callback. - Implement KiUnexpectedInterrupt and KiCoprocessorError - Reimplement NtRaiseException in ASM to take advantage of optimizations due to the trap frame being in the stack when called through System call interface. - Fix Ntcontinue to respect AlertThread paramter - Fix some functiosn to return with KiServiceExit2 instead of KiServiceExit when required/needed - Fix KiDispatchException's logic, fix hacks when calling KeUserExceptionDispatcher, use correct context flags,... - Make NTDLL Ki* callbacks have SEH to protect them and return to kernel-mode with notification of any exceptions (the kernel-mode code to handle this isn't written yet though) svn path=/trunk/; revision=17811
2005-09-11 22:32:20 +00:00
IN PVOID TargetFrame OPTIONAL,
IN PVOID TargetIp OPTIONAL,
IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
IN PVOID ReturnValue
);
//
// Tracing Functions
//
NTSYSAPI
ULONG
NTAPI
RtlWalkFrameChain(
OUT PVOID *Callers,
IN ULONG Count,
IN ULONG Flags
);
NTSYSAPI
USHORT
NTAPI
RtlLogStackBackTrace(
VOID
);
//
// Heap Functions
//
NTSYSAPI
PVOID
NTAPI
RtlAllocateHeap(
IN HANDLE HeapHandle,
IN ULONG Flags,
IN SIZE_T Size
);
NTSYSAPI
PVOID
NTAPI
RtlCreateHeap(
IN ULONG Flags,
IN PVOID BaseAddress OPTIONAL,
IN SIZE_T SizeToReserve OPTIONAL,
IN SIZE_T SizeToCommit OPTIONAL,
IN PVOID Lock OPTIONAL,
IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL
);
NTSYSAPI
ULONG
NTAPI
RtlCreateTagHeap(
IN HANDLE HeapHandle,
IN ULONG Flags,
IN PWSTR TagName,
IN PWSTR TagSubName
);
ULONG
NTAPI
RtlCompactHeap(
HANDLE Heap,
ULONG Flags
);
NTSYSAPI
PVOID
NTAPI
RtlDebugCreateHeap(
IN ULONG Flags,
IN PVOID BaseAddress OPTIONAL,
IN SIZE_T SizeToReserve OPTIONAL,
IN SIZE_T SizeToCommit OPTIONAL,
IN PVOID Lock OPTIONAL,
IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL
);
NTSYSAPI
HANDLE
NTAPI
RtlDestroyHeap(
IN HANDLE Heap
);
NTSYSAPI
ULONG
NTAPI
RtlExtendHeap(
IN HANDLE Heap,
IN ULONG Flags,
IN PVOID P,
IN SIZE_T Size
);
NTSYSAPI
BOOLEAN
NTAPI
RtlFreeHeap(
IN HANDLE HeapHandle,
IN ULONG Flags,
IN PVOID P
);
NTSYSAPI
ULONG
NTAPI
RtlGetNtGlobalFlags(
VOID
);
ULONG
NTAPI
RtlGetProcessHeaps(
ULONG HeapCount,
HANDLE *HeapArray
);
BOOLEAN
NTAPI
RtlGetUserInfoHeap(
IN PVOID HeapHandle,
IN ULONG Flags,
IN PVOID BaseAddress,
OUT PVOID *UserValue,
OUT PULONG UserFlags
);
NTSYSAPI
PVOID
NTAPI
RtlProtectHeap(
IN PVOID HeapHandle,
IN BOOLEAN Protect
);
NTSYSAPI
PWSTR
NTAPI
RtlQueryTagHeap(
IN PVOID HeapHandle,
IN ULONG Flags,
IN USHORT TagIndex,
IN BOOLEAN ResetCounters,
OUT PRTL_HEAP_TAG_INFO HeapTagInfo
);
NTSYSAPI
PVOID
NTAPI
RtlReAllocateHeap(
HANDLE Heap,
ULONG Flags,
PVOID Ptr,
SIZE_T Size
);
NTSYSAPI
BOOLEAN
NTAPI
RtlLockHeap(
IN HANDLE Heap
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUsageHeap(
IN HANDLE Heap,
IN ULONG Flags,
OUT PRTL_HEAP_USAGE Usage
);
NTSYSAPI
BOOLEAN
NTAPI
RtlUnlockHeap(
IN HANDLE Heap
);
BOOLEAN
NTAPI
RtlSetUserValueHeap(
IN PVOID HeapHandle,
IN ULONG Flags,
IN PVOID BaseAddress,
IN PVOID UserValue
);
BOOLEAN
NTAPI
RtlSetUserFlagsHeap(
IN PVOID HeapHandle,
IN ULONG Flags,
IN PVOID BaseAddress,
IN ULONG UserFlags
);
NTSYSAPI
SIZE_T
NTAPI
RtlSizeHeap(
IN PVOID HeapHandle,
IN ULONG Flags,
IN PVOID MemoryPointer
);
NTSYSAPI
BOOLEAN
NTAPI
RtlValidateHeap(
HANDLE Heap,
ULONG Flags,
PVOID P
);
NTSYSAPI
NTSTATUS
NTAPI
RtlWalkHeap(
IN HANDLE HeapHandle,
IN PVOID HeapEntry
);
#define RtlGetProcessHeap() (NtCurrentPeb()->ProcessHeap)
//
// Security Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlAbsoluteToSelfRelativeSD(
IN PSECURITY_DESCRIPTOR AbsoluteSecurityDescriptor,
IN OUT PSECURITY_DESCRIPTOR SelfRelativeSecurityDescriptor,
IN PULONG BufferLength
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAccessAllowedAce(
PACL Acl,
ULONG Revision,
ACCESS_MASK AccessMask,
PSID Sid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAccessAllowedAceEx(
IN OUT PACL pAcl,
IN ULONG dwAceRevision,
IN ULONG AceFlags,
IN ACCESS_MASK AccessMask,
IN PSID pSid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAccessAllowedObjectAce(
IN OUT PACL pAcl,
IN ULONG dwAceRevision,
IN ULONG AceFlags,
IN ACCESS_MASK AccessMask,
IN GUID *ObjectTypeGuid OPTIONAL,
IN GUID *InheritedObjectTypeGuid OPTIONAL,
IN PSID pSid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAccessDeniedAce(
PACL Acl,
ULONG Revision,
ACCESS_MASK AccessMask,
PSID Sid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAccessDeniedAceEx(
IN OUT PACL Acl,
IN ULONG Revision,
IN ULONG Flags,
IN ACCESS_MASK AccessMask,
IN PSID Sid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAccessDeniedObjectAce(
IN OUT PACL pAcl,
IN ULONG dwAceRevision,
IN ULONG AceFlags,
IN ACCESS_MASK AccessMask,
IN GUID *ObjectTypeGuid OPTIONAL,
IN GUID *InheritedObjectTypeGuid OPTIONAL,
IN PSID pSid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAce(
PACL Acl,
ULONG AceRevision,
ULONG StartingAceIndex,
PVOID AceList,
ULONG AceListLength
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAuditAccessAce(
PACL Acl,
ULONG Revision,
ACCESS_MASK AccessMask,
PSID Sid,
BOOLEAN Success,
BOOLEAN Failure
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAcquirePrivilege(
IN PULONG Privilege,
IN ULONG NumPriv,
IN ULONG Flags,
OUT PVOID *ReturnedState
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAuditAccessAceEx(
IN OUT PACL Acl,
IN ULONG Revision,
IN ULONG Flags,
IN ACCESS_MASK AccessMask,
IN PSID Sid,
IN BOOLEAN Success,
IN BOOLEAN Failure
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAuditAccessObjectAce(
IN OUT PACL Acl,
IN ULONG Revision,
IN ULONG Flags,
IN ACCESS_MASK AccessMask,
IN GUID *ObjectTypeGuid OPTIONAL,
IN GUID *InheritedObjectTypeGuid OPTIONAL,
IN PSID Sid,
IN BOOLEAN Success,
IN BOOLEAN Failure
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAddMandatoryAce(
IN OUT PACL Acl,
IN ULONG Revision,
IN ULONG Flags,
IN ULONG MandatoryFlags,
IN ULONG AceType,
IN PSID LabelSid);
NTSYSAPI
NTSTATUS
NTAPI
RtlAdjustPrivilege(
IN ULONG Privilege,
IN BOOLEAN NewValue,
IN BOOLEAN ForThread,
OUT PBOOLEAN OldValue
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAllocateAndInitializeSid(
IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
IN UCHAR SubAuthorityCount,
IN ULONG SubAuthority0,
IN ULONG SubAuthority1,
IN ULONG SubAuthority2,
IN ULONG SubAuthority3,
IN ULONG SubAuthority4,
IN ULONG SubAuthority5,
IN ULONG SubAuthority6,
IN ULONG SubAuthority7,
OUT PSID *Sid
);
NTSYSAPI
BOOLEAN
NTAPI
RtlAreAllAccessesGranted(
ACCESS_MASK GrantedAccess,
ACCESS_MASK DesiredAccess
);
NTSYSAPI
BOOLEAN
NTAPI
RtlAreAnyAccessesGranted(
ACCESS_MASK GrantedAccess,
ACCESS_MASK DesiredAccess
);
NTSYSAPI
VOID
NTAPI
RtlCopyLuid(
IN PLUID LuidDest,
IN PLUID LuidSrc
);
NTSYSAPI
VOID
NTAPI
RtlCopyLuidAndAttributesArray(
ULONG Count,
PLUID_AND_ATTRIBUTES Src,
PLUID_AND_ATTRIBUTES Dest
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCopySidAndAttributesArray(
ULONG Count,
PSID_AND_ATTRIBUTES Src,
ULONG SidAreaSize,
PSID_AND_ATTRIBUTES Dest,
PVOID SidArea,
PVOID* RemainingSidArea,
PULONG RemainingSidAreaSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlConvertSidToUnicodeString(
OUT PUNICODE_STRING DestinationString,
IN PSID Sid,
IN BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCopySid(
IN ULONG Length,
IN PSID Destination,
IN PSID Source
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateAcl(
PACL Acl,
ULONG AclSize,
ULONG AclRevision
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateSecurityDescriptor(
OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN ULONG Revision
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateSecurityDescriptorRelative(
OUT PISECURITY_DESCRIPTOR_RELATIVE SecurityDescriptor,
IN ULONG Revision
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCopySecurityDescriptor(
IN PSECURITY_DESCRIPTOR pSourceSecurityDescriptor,
OUT PSECURITY_DESCRIPTOR pDestinationSecurityDescriptor
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteAce(
PACL Acl,
ULONG AceIndex
);
NTSYSAPI
BOOLEAN
NTAPI
RtlEqualPrefixSid(
PSID Sid1,
PSID Sid2
);
NTSYSAPI
BOOLEAN
NTAPI
RtlEqualSid (
IN PSID Sid1,
IN PSID Sid2
);
NTSYSAPI
BOOLEAN
NTAPI
RtlFirstFreeAce(
PACL Acl,
PACE* Ace
);
NTSYSAPI
PVOID
NTAPI
RtlFreeSid (
IN PSID Sid
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetAce(
PACL Acl,
ULONG AceIndex,
PVOID *Ace
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetControlSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PSECURITY_DESCRIPTOR_CONTROL Control,
OUT PULONG Revision
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetDaclSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PBOOLEAN DaclPresent,
OUT PACL *Dacl,
OUT PBOOLEAN DaclDefaulted
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetSaclSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PBOOLEAN SaclPresent,
OUT PACL* Sacl,
OUT PBOOLEAN SaclDefaulted
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetGroupSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PSID *Group,
OUT PBOOLEAN GroupDefaulted
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetOwnerSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PSID *Owner,
OUT PBOOLEAN OwnerDefaulted
);
NTSYSAPI
BOOLEAN
NTAPI
RtlGetSecurityDescriptorRMControl(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
OUT PUCHAR RMControl
);
NTSYSAPI
PSID_IDENTIFIER_AUTHORITY
NTAPI
RtlIdentifierAuthoritySid(PSID Sid);
NTSYSAPI
NTSTATUS
NTAPI
RtlImpersonateSelf(IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel);
NTSYSAPI
NTSTATUS
NTAPI
RtlInitializeSid(
IN OUT PSID Sid,
IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
IN UCHAR SubAuthorityCount
);
NTSYSAPI
ULONG
NTAPI
RtlLengthRequiredSid(IN ULONG SubAuthorityCount);
NTSYSAPI
ULONG
NTAPI
RtlLengthSid(IN PSID Sid);
NTSYSAPI
NTSTATUS
NTAPI
RtlMakeSelfRelativeSD(
IN PSECURITY_DESCRIPTOR AbsoluteSD,
OUT PSECURITY_DESCRIPTOR SelfRelativeSD,
IN OUT PULONG BufferLength);
NTSYSAPI
VOID
NTAPI
RtlMapGenericMask(
PACCESS_MASK AccessMask,
PGENERIC_MAPPING GenericMapping
);
#ifdef NTOS_MODE_USER
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryInformationAcl(
PACL Acl,
PVOID Information,
ULONG InformationLength,
ACL_INFORMATION_CLASS InformationClass
);
#endif
NTSYSAPI
VOID
NTAPI
RtlReleasePrivilege(
IN PVOID ReturnedState
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSelfRelativeToAbsoluteSD(
IN PSECURITY_DESCRIPTOR SelfRelativeSD,
OUT PSECURITY_DESCRIPTOR AbsoluteSD,
IN PULONG AbsoluteSDSize,
IN PACL Dacl,
IN PULONG DaclSize,
IN PACL Sacl,
IN PULONG SaclSize,
IN PSID Owner,
IN PULONG OwnerSize,
IN PSID PrimaryGroup,
IN PULONG PrimaryGroupSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSelfRelativeToAbsoluteSD2(
IN OUT PSECURITY_DESCRIPTOR SelfRelativeSD,
OUT PULONG BufferSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetAttributesSecurityDescriptor(
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN SECURITY_DESCRIPTOR_CONTROL Control,
OUT PULONG Revision
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetControlSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
IN SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetDaclSecurityDescriptor (
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN BOOLEAN DaclPresent,
IN PACL Dacl,
IN BOOLEAN DaclDefaulted
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetGroupSecurityDescriptor(
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN PSID Group,
IN BOOLEAN GroupDefaulted
);
#ifdef NTOS_MODE_USER
NTSYSAPI
NTSTATUS
NTAPI
RtlSetInformationAcl(
PACL Acl,
PVOID Information,
ULONG InformationLength,
ACL_INFORMATION_CLASS InformationClass
);
#endif
NTSYSAPI
NTSTATUS
NTAPI
RtlSetOwnerSecurityDescriptor(
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN PSID Owner,
IN BOOLEAN OwnerDefaulted
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetSaclSecurityDescriptor(
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN BOOLEAN SaclPresent,
IN PACL Sacl,
IN BOOLEAN SaclDefaulted
);
NTSYSAPI
VOID
NTAPI
RtlSetSecurityDescriptorRMControl(
IN OUT PSECURITY_DESCRIPTOR SecurityDescriptor,
IN PUCHAR RMControl
);
NTSYSAPI
PUCHAR
NTAPI
RtlSubAuthorityCountSid(
IN PSID Sid
);
NTSYSAPI
PULONG
NTAPI
RtlSubAuthoritySid(
IN PSID Sid,
IN ULONG SubAuthority
);
NTSYSAPI
BOOLEAN
NTAPI
RtlValidRelativeSecurityDescriptor(
IN PSECURITY_DESCRIPTOR SecurityDescriptorInput,
IN ULONG SecurityDescriptorLength,
IN SECURITY_INFORMATION RequiredInformation
);
NTSYSAPI
BOOLEAN
NTAPI
RtlValidSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor);
NTSYSAPI
BOOLEAN
NTAPI
RtlValidSid(IN PSID Sid);
NTSYSAPI
BOOLEAN
NTAPI
RtlValidAcl(PACL Acl);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteSecurityObject(
IN PSECURITY_DESCRIPTOR *ObjectDescriptor
);
NTSYSAPI
NTSTATUS
NTAPI
RtlNewSecurityObject(
IN PSECURITY_DESCRIPTOR ParentDescriptor,
IN PSECURITY_DESCRIPTOR CreatorDescriptor,
OUT PSECURITY_DESCRIPTOR *NewDescriptor,
IN BOOLEAN IsDirectoryObject,
IN HANDLE Token,
IN PGENERIC_MAPPING GenericMapping
);
NTSYSAPI
NTSTATUS
NTAPI
RtlQuerySecurityObject(
IN PSECURITY_DESCRIPTOR ObjectDescriptor,
IN SECURITY_INFORMATION SecurityInformation,
OUT PSECURITY_DESCRIPTOR ResultantDescriptor,
IN ULONG DescriptorLength,
OUT PULONG ReturnLength
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetSecurityObject(
IN SECURITY_INFORMATION SecurityInformation,
IN PSECURITY_DESCRIPTOR ModificationDescriptor,
OUT PSECURITY_DESCRIPTOR *ObjectsSecurityDescriptor,
IN PGENERIC_MAPPING GenericMapping,
IN HANDLE Token
);
//
// Single-Character Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlLargeIntegerToChar(
IN PLARGE_INTEGER Value,
IN ULONG Base,
IN ULONG Length,
IN OUT PCHAR String
);
NTSYSAPI
CHAR
NTAPI
RtlUpperChar(CHAR Source);
NTSYSAPI
WCHAR
NTAPI
RtlUpcaseUnicodeChar(WCHAR Source);
NTSYSAPI
WCHAR
NTAPI
RtlDowncaseUnicodeChar(IN WCHAR Source);
NTSYSAPI
NTSTATUS
NTAPI
RtlIntegerToChar(
IN ULONG Value,
IN ULONG Base,
IN ULONG Length,
IN OUT PCHAR String
);
NTSYSAPI
NTSTATUS
NTAPI
RtlIntegerToUnicode(
IN ULONG Value,
IN ULONG Base OPTIONAL,
IN ULONG Length OPTIONAL,
IN OUT LPWSTR String
);
NTSYSAPI
NTSTATUS
NTAPI
RtlIntegerToUnicodeString(
IN ULONG Value,
IN ULONG Base,
IN OUT PUNICODE_STRING String
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCharToInteger(
PCSZ String,
ULONG Base,
PULONG Value
);
//
// Byte Swap Functions
//
#ifdef NTOS_MODE_USER
#if (defined(_M_IX86) && (_MSC_FULL_VER > 13009037)) || \
((defined(_M_AMD64) || \
defined(_M_IA64)) && (_MSC_FULL_VER > 13009175))
unsigned short __cdecl _byteswap_ushort(unsigned short);
unsigned long __cdecl _byteswap_ulong (unsigned long);
unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64);
#pragma intrinsic(_byteswap_ushort)
#pragma intrinsic(_byteswap_ulong)
#pragma intrinsic(_byteswap_uint64)
#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
#define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
#elif defined (__GNUC__)
#define RtlUshortByteSwap(_x) _byteswap_ushort((USHORT)(_x))
#define RtlUlongByteSwap(_x) _byteswap_ulong((_x))
#define RtlUlonglongByteSwap(_x) _byteswap_uint64((_x))
#else
#if (NTDDI_VERSION >= NTDDI_WIN2K)
NTSYSAPI
USHORT
FASTCALL
RtlUshortByteSwap(IN USHORT Source);
NTSYSAPI
ULONG
FASTCALL
RtlUlongByteSwap(IN ULONG Source);
NTSYSAPI
ULONGLONG
FASTCALL
RtlUlonglongByteSwap(IN ULONGLONG Source);
#endif
#endif
#endif // NTOS_MODE_USER
//
// Unicode->Ansi String Functions
//
NTSYSAPI
ULONG
NTAPI
RtlxUnicodeStringToAnsiSize(IN PCUNICODE_STRING UnicodeString);
#ifdef NTOS_MODE_USER
#define RtlUnicodeStringToAnsiSize(STRING) ( \
NLS_MB_CODE_PAGE_TAG ? \
RtlxUnicodeStringToAnsiSize(STRING) : \
((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
)
#endif
NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeStringToAnsiString(
PANSI_STRING DestinationString,
PCUNICODE_STRING SourceString,
BOOLEAN AllocateDestinationString
);
//
// Unicode->OEM String Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlUpcaseUnicodeStringToOemString(
POEM_STRING DestinationString,
PCUNICODE_STRING SourceString,
BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUpcaseUnicodeStringToCountedOemString(
IN OUT POEM_STRING DestinationString,
IN PCUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeStringToOemString(
POEM_STRING DestinationString,
PCUNICODE_STRING SourceString,
BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUpcaseUnicodeToOemN(
PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PCWCH UnicodeString,
ULONG UnicodeSize
);
NTSYSAPI
ULONG
NTAPI
RtlxUnicodeStringToOemSize(IN PCUNICODE_STRING UnicodeString);
#ifdef NTOS_MODE_USER
#define RtlUnicodeStringToOemSize(STRING) ( \
NLS_MB_OEM_CODE_PAGE_TAG ? \
RtlxUnicodeStringToOemSize(STRING) : \
((STRING)->Length + sizeof(UNICODE_NULL)) / sizeof(WCHAR) \
)
#define RtlUnicodeStringToCountedOemSize(STRING) ( \
(ULONG)(RtlUnicodeStringToOemSize(STRING) - sizeof(ANSI_NULL)) \
)
#endif
NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeToOemN(
PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PCWCH UnicodeString,
ULONG UnicodeSize
);
//
// Unicode->MultiByte String Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeToMultiByteN(
PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUpcaseUnicodeToMultiByteN(
PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PCWCH UnicodeString,
ULONG UnicodeSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeToMultiByteSize(
PULONG MbSize,
PCWCH UnicodeString,
ULONG UnicodeSize
);
NTSYSAPI
ULONG
NTAPI
RtlxOemStringToUnicodeSize(IN PCOEM_STRING OemString);
//
// OEM to Unicode Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlOemStringToUnicodeString(
PUNICODE_STRING DestinationString,
PCOEM_STRING SourceString,
BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlOemToUnicodeN(
PWSTR UnicodeString,
ULONG MaxBytesInUnicodeString,
PULONG BytesInUnicodeString,
IN PCCH OemString,
ULONG BytesInOemString
);
#ifdef NTOS_MODE_USER
#define RtlOemStringToUnicodeSize(STRING) ( \
NLS_MB_OEM_CODE_PAGE_TAG ? \
RtlxOemStringToUnicodeSize(STRING) : \
((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
)
#define RtlOemStringToCountedUnicodeSize(STRING) ( \
(ULONG)(RtlOemStringToUnicodeSize(STRING) - sizeof(UNICODE_NULL)) \
)
#endif
//
// Ansi->Unicode String Functions
//
NTSYSAPI
ULONG
NTAPI
RtlxAnsiStringToUnicodeSize(
PCANSI_STRING AnsiString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAnsiStringToUnicodeString(
PUNICODE_STRING DestinationString,
PCANSI_STRING SourceString,
BOOLEAN AllocateDestinationString
);
#ifdef NTOS_MODE_USER
#define RtlAnsiStringToUnicodeSize(STRING) ( \
NLS_MB_CODE_PAGE_TAG ? \
RtlxAnsiStringToUnicodeSize(STRING) : \
((STRING)->Length + sizeof(ANSI_NULL)) * sizeof(WCHAR) \
)
#endif
NTSYSAPI
BOOLEAN
NTAPI
RtlCreateUnicodeStringFromAsciiz(
OUT PUNICODE_STRING Destination,
IN PCSZ Source
);
//
// Unicode String Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlAppendUnicodeToString(
PUNICODE_STRING Destination,
PCWSTR Source
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAppendUnicodeStringToString(
PUNICODE_STRING Destination,
PCUNICODE_STRING Source
);
NTSYSAPI
LONG
NTAPI
RtlCompareUnicodeString(
PCUNICODE_STRING String1,
PCUNICODE_STRING String2,
BOOLEAN CaseInsensitive
);
NTSYSAPI
VOID
NTAPI
RtlCopyUnicodeString(
PUNICODE_STRING DestinationString,
PCUNICODE_STRING SourceString
);
NTSYSAPI
BOOLEAN
NTAPI
RtlCreateUnicodeString(
PUNICODE_STRING DestinationString,
PCWSTR SourceString
);
#ifdef NTOS_MODE_USER
NTSYSAPI
NTSTATUS
NTAPI
RtlDowncaseUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN PCUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDuplicateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING SourceString,
OUT PUNICODE_STRING DestinationString
);
//
// Memory Functions
//
NTSYSAPI
VOID
NTAPI
RtlFillMemoryUlong(
IN PVOID Destination,
IN ULONG Length,
IN ULONG Fill
);
#endif
NTSYSAPI
BOOLEAN
NTAPI
RtlEqualUnicodeString(
PCUNICODE_STRING String1,
PCUNICODE_STRING String2,
BOOLEAN CaseInsensitive
);
NTSYSAPI
NTSTATUS
NTAPI
RtlFindCharInUnicodeString(
IN ULONG Flags,
IN PUNICODE_STRING SearchString,
IN PCUNICODE_STRING MatchString,
OUT PUSHORT Position
);
NTSYSAPI
VOID
NTAPI
RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString);
NTSYSAPI
NTSTATUS
NTAPI
RtlHashUnicodeString(
IN CONST UNICODE_STRING *String,
IN BOOLEAN CaseInSensitive,
IN ULONG HashAlgorithm,
OUT PULONG HashValue
);
NTSYSAPI
VOID
NTAPI
RtlInitUnicodeString(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlInitUnicodeStringEx(
OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString OPTIONAL
);
NTSYSAPI
BOOLEAN
NTAPI
RtlIsTextUnicode(
PVOID Buffer,
INT Length,
INT *Flags
);
NTSYSAPI
BOOLEAN
NTAPI
RtlPrefixString(
PCANSI_STRING String1,
PCANSI_STRING String2,
BOOLEAN CaseInsensitive
);
NTSYSAPI
BOOLEAN
NTAPI
RtlPrefixUnicodeString(
PCUNICODE_STRING String1,
PCUNICODE_STRING String2,
BOOLEAN CaseInsensitive
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUpcaseUnicodeString(
PUNICODE_STRING DestinationString,
PCUNICODE_STRING SourceString,
BOOLEAN AllocateDestinationString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUnicodeStringToInteger(
PCUNICODE_STRING String,
ULONG Base,
PULONG Value
);
NTSYSAPI
NTSTATUS
NTAPI
RtlValidateUnicodeString(
IN ULONG Flags,
IN PCUNICODE_STRING String
);
//
// Ansi String Functions
//
NTSYSAPI
VOID
NTAPI
RtlFreeAnsiString(IN PANSI_STRING AnsiString);
NTSYSAPI
VOID
NTAPI
RtlInitAnsiString(
PANSI_STRING DestinationString,
PCSZ SourceString
);
NTSYSAPI
NTSTATUS
NTAPI
RtlInitAnsiStringEx(
PANSI_STRING DestinationString,
PCSZ SourceString
);
//
// OEM String Functions
//
NTSYSAPI
VOID
NTAPI
RtlFreeOemString(IN POEM_STRING OemString);
//
// MultiByte->Unicode String Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlMultiByteToUnicodeN(
PWCHAR UnicodeString,
ULONG UnicodeSize,
PULONG ResultSize,
PCSTR MbString,
ULONG MbSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlMultiByteToUnicodeSize(
PULONG UnicodeSize,
PCSTR MbString,
ULONG MbSize
);
//
// Atom Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlAddAtomToAtomTable(
IN PRTL_ATOM_TABLE AtomTable,
IN PWSTR AtomName,
OUT PRTL_ATOM Atom
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateAtomTable(
IN ULONG TableSize,
IN OUT PRTL_ATOM_TABLE *AtomTable
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteAtomFromAtomTable(
IN PRTL_ATOM_TABLE AtomTable,
IN RTL_ATOM Atom
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDestroyAtomTable(IN PRTL_ATOM_TABLE AtomTable);
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryAtomInAtomTable(
IN PRTL_ATOM_TABLE AtomTable,
IN RTL_ATOM Atom,
IN OUT PULONG RefCount OPTIONAL,
IN OUT PULONG PinCount OPTIONAL,
IN OUT PWSTR AtomName OPTIONAL,
IN OUT PULONG NameLength OPTIONAL
);
NTSYSAPI
NTSTATUS
NTAPI
RtlPinAtomInAtomTable(
IN PRTL_ATOM_TABLE AtomTable,
IN RTL_ATOM Atom
);
NTSYSAPI
NTSTATUS
NTAPI
RtlLookupAtomInAtomTable(
IN PRTL_ATOM_TABLE AtomTable,
IN PWSTR AtomName,
OUT PRTL_ATOM Atom
);
//
// Process Management Functions
//
NTSYSAPI
PPEB
NTAPI
RtlGetCurrentPeb(
VOID
);
NTSYSAPI
VOID
NTAPI
RtlAcquirePebLock(VOID);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateProcessParameters (
OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
IN PUNICODE_STRING ImagePathName OPTIONAL,
IN PUNICODE_STRING DllPath OPTIONAL,
IN PUNICODE_STRING CurrentDirectory OPTIONAL,
IN PUNICODE_STRING CommandLine OPTIONAL,
IN PWSTR Environment OPTIONAL,
IN PUNICODE_STRING WindowTitle OPTIONAL,
IN PUNICODE_STRING DesktopInfo OPTIONAL,
IN PUNICODE_STRING ShellInfo OPTIONAL,
IN PUNICODE_STRING RuntimeInfo OPTIONAL
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateUserProcess(
IN PUNICODE_STRING ImageFileName,
IN ULONG Attributes,
IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters,
IN PSECURITY_DESCRIPTOR ProcessSecutityDescriptor OPTIONAL,
IN PSECURITY_DESCRIPTOR ThreadSecurityDescriptor OPTIONAL,
IN HANDLE ParentProcess OPTIONAL,
IN BOOLEAN CurrentDirectory,
IN HANDLE DebugPort OPTIONAL,
IN HANDLE ExceptionPort OPTIONAL,
OUT PRTL_USER_PROCESS_INFORMATION ProcessInfo
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateUserThread(
IN HANDLE ProcessHandle,
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
IN BOOLEAN CreateSuspended,
- Fix critical bugs in exception handling: Unwinding was completely broken, using the wrong SEH protector to detect collided unwinding. The correct protector itself also had a broken check. - Fix architectural bug in the entire TrapFrame<->Context conversion system and Ring Privilege Transitions (Inter-ring and intra-ring) which was lacking proper sanitation and validation of segments, flags and debug registers. Among other things, IOPL is now respected, CS is not KGDT_R0_CODE | RPL_MASK anymore, and the GPF code is now properly being called. This completely fixes exception handling being totally broken and crashing firefox installer, mirc, and other applications. - Rewrite the page fault handler base code in assembly instead of relying on a broken C routine. Detect VDM, V8086, detecting expected/normal fault in ExpInterlockedPopEntrySList and faults in the system handler code. Rewrite MmAccessFault to be the main function that calls out to other sub-fault functions, and use the same prototype as NT. - Fix the KGDT boot table to have proper granularity and big flags, and extend it to 256 entries. - Create proper thread context in RtlInitializeContext and cleanup Rtl Thread routines. - Remove all int3 and breakpoints from trap handlers, and replace them with a much better "UNHANDLED_PATH" macro which freezes the system, beeps, and displays a message with the line of code that's unhandled. This is to clearly tell the user that something is unhandled, instead of nesting infinite exceptions due to the int3. - Fix a bug in INT_PROLOG. - Sanitize EFLAGS and Code Segments in KeContextToTrapFrame and KeTrapFrameToContext. - Implement KiUpdateDr7 and KiRecordDr7 as well as DR_MASK and other DR-validation macros and functions to protect against DR-vulnerabilites as well as to properly account for each active hardware breakpoint in a per-thread fashion by using the dispatcher header. - Allow CR0_EM when running in a VDM. - Fix FPU/NPX Register handling in KeContextToTrapFrame and KeTrapFrameToContext, and also speed it up by manual copying instead of a memory move. - Properly give IOPL 3 to user-mode threads if they requested it. - Detect GPF during GPF. - Detect pagefault with a trap-frame spread over two or more pages and nested. - Properly sanitize and set correct trap frame in KiInitailizeUserApc. - Return STATUS_ACCESS_VIOLATION during page faults instead of STATUS_UNSUCESSFUL. - Fix assert in VdmSwapContext, as well as Code Selector check which was broken. - Fix delayed object deletion (ObDeferDeleteObject) and the Ob Repear Routine and list. - Update Kernel Fun. - BUGBUG: Temporaily hack VMWare to detection to always detect VMWare. svn path=/trunk/; revision=25238
2006-12-29 18:49:00 +00:00
IN ULONG StackZeroBits,
IN SIZE_T StackReserve,
IN SIZE_T StackCommit,
IN PTHREAD_START_ROUTINE StartAddress,
IN PVOID Parameter,
IN OUT PHANDLE ThreadHandle,
IN OUT PCLIENT_ID ClientId
);
NTSYSAPI
PRTL_USER_PROCESS_PARAMETERS
NTAPI
RtlDeNormalizeProcessParams(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
NTSYSAPI
NTSTATUS
NTAPI
RtlDestroyProcessParameters(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
NTSYSAPI
VOID
NTAPI
RtlExitUserThread(NTSTATUS Status);
NTSYSAPI
VOID
NTAPI
RtlInitializeContext(
IN HANDLE ProcessHandle,
OUT PCONTEXT ThreadContext,
IN PVOID ThreadStartParam OPTIONAL,
IN PTHREAD_START_ROUTINE ThreadStartAddress,
IN PINITIAL_TEB InitialTeb
);
NTSYSAPI
BOOLEAN
NTAPI
RtlIsThreadWithinLoaderCallout(VOID);
NTSYSAPI
PRTL_USER_PROCESS_PARAMETERS
NTAPI
RtlNormalizeProcessParams(IN PRTL_USER_PROCESS_PARAMETERS ProcessParameters);
NTSYSAPI
VOID
NTAPI
RtlReleasePebLock(VOID);
NTSYSAPI
NTSTATUS
NTAPI
RtlRemoteCall(
IN HANDLE Process,
IN HANDLE Thread,
IN PVOID CallSite,
IN ULONG ArgumentCount,
IN PULONG Arguments,
IN BOOLEAN PassContext,
IN BOOLEAN AlreadySuspended
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetProcessIsCritical(
IN BOOLEAN NewValue,
OUT PBOOLEAN OldValue OPTIONAL,
IN BOOLEAN NeedBreaks
);
NTSYSAPI
ULONG
NTAPI
RtlGetCurrentProcessorNumber(
VOID
);
#define NtCurrentPeb() (NtCurrentTeb()->ProcessEnvironmentBlock)
//
// Thread Pool Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlDeregisterWaitEx(
IN HANDLE hWaitHandle,
IN HANDLE hCompletionEvent
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeregisterWait(
IN HANDLE hWaitHandle
);
NTSYSAPI
NTSTATUS
NTAPI
RtlQueueWorkItem(
IN WORKERCALLBACKFUNC Function,
IN PVOID Context OPTIONAL,
IN ULONG Flags
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetIoCompletionCallback(
IN HANDLE FileHandle,
IN PIO_APC_ROUTINE Callback,
IN ULONG Flags
);
NTSYSAPI
NTSTATUS
NTAPI
RtlRegisterWait(
IN PHANDLE phNewWaitObject,
IN HANDLE hObject,
IN WAITORTIMERCALLBACKFUNC Callback,
IN PVOID pvContext,
IN ULONG ulMilliseconds,
IN ULONG ulFlags
);
//
// Environment/Path Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateEnvironment(
BOOLEAN Inherit,
PWSTR *Environment
);
NTSYSAPI
NTSTATUS
NTAPI
RtlComputePrivatizedDllName_U(
IN PUNICODE_STRING DllName,
OUT PUNICODE_STRING RealName,
OUT PUNICODE_STRING LocalName
);
NTSYSAPI
VOID
NTAPI
RtlDestroyEnvironment(
IN PWSTR Environment
);
NTSYSAPI
BOOLEAN
NTAPI
RtlDoesFileExists_U(
IN PCWSTR FileName
);
NTSYSAPI
BOOLEAN
NTAPI
RtlDoesFileExists_UstrEx(
IN PCUNICODE_STRING FileName,
IN BOOLEAN SucceedIfBusy
);
NTSYSAPI
ULONG
NTAPI
RtlDetermineDosPathNameType_U(
IN PCWSTR Path
);
NTSYSAPI
ULONG
NTAPI
RtlDetermineDosPathNameType_Ustr(
IN PCUNICODE_STRING Path
);
NTSYSAPI
ULONG
NTAPI
RtlDosSearchPath_U(
IN PCWSTR Path,
IN PCWSTR FileName,
IN PCWSTR Extension,
IN ULONG BufferSize,
OUT PWSTR Buffer,
OUT PWSTR *PartName
);
NTSYSAPI
BOOLEAN
NTAPI
RtlDosPathNameToNtPathName_U(
IN PCWSTR DosPathName,
OUT PUNICODE_STRING NtPathName,
OUT PCWSTR *NtFileNamePart,
OUT CURDIR *DirectoryInfo
);
NTSYSAPI
NTSTATUS
NTAPI
RtlExpandEnvironmentStrings_U(
PWSTR Environment,
PUNICODE_STRING Source,
PUNICODE_STRING Destination,
PULONG Length
);
NTSYSAPI
ULONG
NTAPI
RtlGetCurrentDirectory_U(
ULONG MaximumLength,
PWSTR Buffer
);
NTSYSAPI
ULONG
NTAPI
RtlGetFullPathName_U(
IN PCWSTR FileName,
IN ULONG Size,
IN PWSTR Buffer,
OUT PWSTR *ShortName
);
NTSYSAPI
ULONG
NTAPI
RtlGetFullPathName_Ustr(
IN PUNICODE_STRING FileName,
IN ULONG Size,
IN PWSTR Buffer,
OUT PWSTR *ShortName,
OUT PBOOLEAN InvalidName,
OUT RTL_PATH_TYPE *PathType
);
NTSYSAPI
ULONG
NTAPI
RtlIsDosDeviceName_U(
IN PWSTR Name
);
NTSYSAPI
ULONG
NTAPI
RtlIsDosDeviceName_Ustr(
IN PUNICODE_STRING Name
);
NTSYSAPI
BOOLEAN
NTAPI
RtlIsNameLegalDOS8Dot3(
IN PCUNICODE_STRING Name,
IN OUT POEM_STRING OemName OPTIONAL,
IN OUT PBOOLEAN NameContainsSpaces OPTIONAL
);
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryEnvironmentVariable_U(
PWSTR Environment,
PUNICODE_STRING Name,
PUNICODE_STRING Value
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetCurrentDirectory_U(
IN PUNICODE_STRING name
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetEnvironmentVariable(
PWSTR *Environment,
PUNICODE_STRING Name,
PUNICODE_STRING Value
);
//
// Critical Section/Resource Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteCriticalSection (
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
NTSTATUS
NTAPI
RtlEnterCriticalSection(
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
NTSTATUS
NTAPI
RtlInitializeCriticalSection(
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
NTSTATUS
NTAPI
RtlInitializeCriticalSectionAndSpinCount(
IN PRTL_CRITICAL_SECTION CriticalSection,
IN ULONG SpinCount
);
NTSYSAPI
NTSTATUS
NTAPI
RtlLeaveCriticalSection(
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
BOOLEAN
NTAPI
RtlTryEnterCriticalSection(
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
VOID
NTAPI
RtlpUnWaitCriticalSection(
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
NTSTATUS
NTAPI
RtlpWaitForCriticalSection(
IN PRTL_CRITICAL_SECTION CriticalSection
);
NTSYSAPI
BOOLEAN
NTAPI
RtlAcquireResourceExclusive(
IN PRTL_RESOURCE Resource,
IN BOOLEAN Wait
);
NTSYSAPI
BOOLEAN
NTAPI
RtlAcquireResourceShared(
IN PRTL_RESOURCE Resource,
IN BOOLEAN Wait
);
NTSYSAPI
VOID
NTAPI
RtlConvertExclusiveToShared(
IN PRTL_RESOURCE Resource
);
NTSYSAPI
VOID
NTAPI
RtlConvertSharedToExclusive(
IN PRTL_RESOURCE Resource
);
NTSYSAPI
VOID
NTAPI
RtlDeleteResource(
IN PRTL_RESOURCE Resource
);
NTSYSAPI
VOID
NTAPI
RtlDumpResource(
IN PRTL_RESOURCE Resource
);
NTSYSAPI
VOID
NTAPI
RtlInitializeResource(
IN PRTL_RESOURCE Resource
);
NTSYSAPI
VOID
NTAPI
RtlReleaseResource(
IN PRTL_RESOURCE Resource
);
//
// Compression Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlCompressBuffer(
IN USHORT CompressionFormatAndEngine,
IN PUCHAR UncompressedBuffer,
IN ULONG UncompressedBufferSize,
OUT PUCHAR CompressedBuffer,
IN ULONG CompressedBufferSize,
IN ULONG UncompressedChunkSize,
OUT PULONG FinalCompressedSize,
IN PVOID WorkSpace
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDecompressBuffer(
IN USHORT CompressionFormat,
OUT PUCHAR UncompressedBuffer,
IN ULONG UncompressedBufferSize,
IN PUCHAR CompressedBuffer,
IN ULONG CompressedBufferSize,
OUT PULONG FinalUncompressedSize
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetCompressionWorkSpaceSize(
IN USHORT CompressionFormatAndEngine,
OUT PULONG CompressBufferWorkSpaceSize,
OUT PULONG CompressFragmentWorkSpaceSize
);
//
// Debug Info Functions
//
NTSYSAPI
PRTL_DEBUG_INFORMATION
NTAPI
RtlCreateQueryDebugBuffer(
IN ULONG Size,
IN BOOLEAN EventPair
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION DebugBuffer);
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryProcessDebugInformation(
IN ULONG ProcessId,
IN ULONG DebugInfoClassMask,
IN OUT PRTL_DEBUG_INFORMATION DebugBuffer
);
//
// Bitmap Functions
//
NTSYSAPI
BOOLEAN
NTAPI
RtlAreBitsClear(
IN PRTL_BITMAP BitMapHeader,
IN ULONG StartingIndex,
IN ULONG Length
);
NTSYSAPI
BOOLEAN
NTAPI
RtlAreBitsSet(
IN PRTL_BITMAP BitMapHeader,
IN ULONG StartingIndex,
IN ULONG Length
);
NTSYSAPI
VOID
NTAPI
RtlClearBits(
IN PRTL_BITMAP BitMapHeader,
IN ULONG StartingIndex,
IN ULONG NumberToClear
);
NTSYSAPI
ULONG
NTAPI
RtlFindClearBits(
IN PRTL_BITMAP BitMapHeader,
IN ULONG NumberToFind,
IN ULONG HintIndex
);
NTSYSAPI
ULONG
NTAPI
RtlFindClearBitsAndSet(
IN PRTL_BITMAP BitMapHeader,
IN ULONG NumberToFind,
IN ULONG HintIndex
);
NTSYSAPI
ULONG
NTAPI
RtlFindNextForwardRunClear(
IN PRTL_BITMAP BitMapHeader,
IN ULONG FromIndex,
IN PULONG StartingRunIndex
);
NTSYSAPI
VOID
NTAPI
RtlInitializeBitMap(
IN PRTL_BITMAP BitMapHeader,
IN PULONG BitMapBuffer,
IN ULONG SizeOfBitMap
);
NTSYSAPI
ULONG
NTAPI
RtlNumberOfSetBits(
IN PRTL_BITMAP BitMapHeader
);
NTSYSAPI
VOID
NTAPI
RtlSetBit(
PRTL_BITMAP BitMapHeader,
ULONG BitNumber
);
NTSYSAPI
VOID
NTAPI
RtlSetBits(
IN PRTL_BITMAP BitMapHeader,
IN ULONG StartingIndex,
IN ULONG NumberToSet
);
NTSYSAPI
VOID
NTAPI
RtlSetAllBits(
PRTL_BITMAP BitMapHeader
);
NTSYSAPI
BOOLEAN
NTAPI
RtlTestBit(
PRTL_BITMAP BitMapHeader,
ULONG BitNumber
);
//
// Timer Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateTimer(
HANDLE TimerQueue,
PHANDLE phNewTimer,
WAITORTIMERCALLBACKFUNC Callback,
PVOID Parameter,
ULONG DueTime,
ULONG Period,
ULONG Flags
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateTimerQueue(PHANDLE TimerQueue);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteTimer(
HANDLE TimerQueue,
HANDLE Timer,
HANDLE CompletionEvent
);
NTSYSAPI
NTSTATUS
NTAPI
RtlUpdateTimer(
HANDLE TimerQueue,
HANDLE Timer,
ULONG DueTime,
ULONG Period
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteTimerQueueEx(
HANDLE TimerQueue,
HANDLE CompletionEvent
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeleteTimerQueue(HANDLE TimerQueue);
//
// SList functions
//
PSLIST_ENTRY
FASTCALL
InterlockedPushListSList(
IN PSLIST_HEADER ListHead,
IN PSLIST_ENTRY List,
IN PSLIST_ENTRY ListEnd,
IN ULONG Count
);
//
// Range List functions
//
NTSYSAPI
VOID
NTAPI
RtlFreeRangeList(IN PRTL_RANGE_LIST RangeList);
//
// Debug Functions
//
ULONG
__cdecl
DbgPrint(
IN PCCH Format,
IN ...
);
NTSYSAPI
ULONG
__cdecl
DbgPrintEx(
IN ULONG ComponentId,
IN ULONG Level,
IN PCCH Format,
IN ...
);
NTSYSAPI
ULONG
NTAPI
DbgPrompt(
IN PCCH Prompt,
OUT PCH Response,
IN ULONG MaximumResponseLength
);
VOID
NTAPI
DbgBreakPoint(
VOID
);
VOID
NTAPI
DbgLoadImageSymbols(
- DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Protocol 6 uses the DBGKD_ANY_WAIT_STATE_CHANGE structure which is sized according to the largest control-report structure (AMD64_DBGKD_CONTROL_REPORT currently), and is larger than DBGKD_WAIT_STATE_CHANGE64 on x86. This worked because our DBGKD_WAIT_STATE_CHANGE32/64 structures contained incorrect DBGKD_CONTROL_REPORT (used) and CONTEXT (unused) members that sized up the wait-state structure to pass WinDbg's length verification! It actually becomes larger than DBGKD_ANY_WAIT_STATE_CHANGE, but WinDbg only seems bail out only if the structure is too small. Remove the incorrect members from the protocol 5 structures and change to DBGKD_ANY_WAIT_STATE_CHANGE everywhere. - Correct the value of SIZE_OF_FX_REGISTERS -- it was 4 times too low which resulted in KeContextToTrapFrame not properly clearing out the XMM register area. Correct the define and move it out from ke.h to x86's ketypes.h and use it in the FXSAVE format structure. Also remove the IOPM definitions from ke.h as they have been in the NDK for a while. - KD uses STRINGs, not ANSI_STRINGs -- they are the same thing, but let's be consistent. - ExceptionRecord32To64 should be available for both 32 and 64 bit builds (and it shouldn't be a forceinline). Get rid of CopyExceptionRecord and determine if we need to convert or can just copy it directly instead. - Use _WIN64 instead of _M_AMD64 when determining if we need to set the DBGKD_VERS_FLAG_PTR64 flag. - Don't check Nt/DbgQueryDebugFilterState for zero or nonzero -- it actually returns TRUE, FALSE or STATUS_INVALID_PARAMETER_1! Check for != TRUE in preparation for proper implementation of NtSet/QueryDebugFilterState. - Fix Format parameter of DbgPrintReturnControlC -- it is const like the other DbgPrint* routines. - Be consistent with the types used in debug.c and don't set local variables to zero if we are going to return to caller -- this doesn't seem to be required anymore. - Fix DebugService and DebugService2: DebugService should take a ULONG followed by 4 pointers and DebugService2 doesn't return anything. - Use ZwCurrentProcess() instead of -1 or 0xFFFFFFFF (which is incorrect for 64-bit) for the ProcessId parameter of DbgLoad/UnloadImageSymbols to clarify what is being passed. Don't use ZwCurrentProcess() in KeBugCheckWithTf for the pointer parameter of DbgUnLoadImageSymbols either. Use MAXULONG_PTR casted to PVOID instead. - Use better named and sized variables in KdpTrap for setting the "return register" in the caller's CONTEXT. - Correct and clarify the comment documenting under what conditions we pass user mode exceptions to the kernel debugger. svn path=/trunk/; revision=43741
2009-10-25 15:56:38 +00:00
IN PSTRING Name,
IN PVOID Base,
IN ULONG_PTR ProcessId
);
VOID
NTAPI
DbgUnLoadImageSymbols(
- DBGKD_WAIT_STATE_CHANGE64 is used in KD protocol 5, not number 6 that we use. Protocol 6 uses the DBGKD_ANY_WAIT_STATE_CHANGE structure which is sized according to the largest control-report structure (AMD64_DBGKD_CONTROL_REPORT currently), and is larger than DBGKD_WAIT_STATE_CHANGE64 on x86. This worked because our DBGKD_WAIT_STATE_CHANGE32/64 structures contained incorrect DBGKD_CONTROL_REPORT (used) and CONTEXT (unused) members that sized up the wait-state structure to pass WinDbg's length verification! It actually becomes larger than DBGKD_ANY_WAIT_STATE_CHANGE, but WinDbg only seems bail out only if the structure is too small. Remove the incorrect members from the protocol 5 structures and change to DBGKD_ANY_WAIT_STATE_CHANGE everywhere. - Correct the value of SIZE_OF_FX_REGISTERS -- it was 4 times too low which resulted in KeContextToTrapFrame not properly clearing out the XMM register area. Correct the define and move it out from ke.h to x86's ketypes.h and use it in the FXSAVE format structure. Also remove the IOPM definitions from ke.h as they have been in the NDK for a while. - KD uses STRINGs, not ANSI_STRINGs -- they are the same thing, but let's be consistent. - ExceptionRecord32To64 should be available for both 32 and 64 bit builds (and it shouldn't be a forceinline). Get rid of CopyExceptionRecord and determine if we need to convert or can just copy it directly instead. - Use _WIN64 instead of _M_AMD64 when determining if we need to set the DBGKD_VERS_FLAG_PTR64 flag. - Don't check Nt/DbgQueryDebugFilterState for zero or nonzero -- it actually returns TRUE, FALSE or STATUS_INVALID_PARAMETER_1! Check for != TRUE in preparation for proper implementation of NtSet/QueryDebugFilterState. - Fix Format parameter of DbgPrintReturnControlC -- it is const like the other DbgPrint* routines. - Be consistent with the types used in debug.c and don't set local variables to zero if we are going to return to caller -- this doesn't seem to be required anymore. - Fix DebugService and DebugService2: DebugService should take a ULONG followed by 4 pointers and DebugService2 doesn't return anything. - Use ZwCurrentProcess() instead of -1 or 0xFFFFFFFF (which is incorrect for 64-bit) for the ProcessId parameter of DbgLoad/UnloadImageSymbols to clarify what is being passed. Don't use ZwCurrentProcess() in KeBugCheckWithTf for the pointer parameter of DbgUnLoadImageSymbols either. Use MAXULONG_PTR casted to PVOID instead. - Use better named and sized variables in KdpTrap for setting the "return register" in the caller's CONTEXT. - Correct and clarify the comment documenting under what conditions we pass user mode exceptions to the kernel debugger. svn path=/trunk/; revision=43741
2009-10-25 15:56:38 +00:00
IN PSTRING Name,
IN PVOID Base,
IN ULONG_PTR ProcessId
);
- Fix support for /CRASHDEBUG and /NODEBUG; we didn't respect those settings properly and would initialize KD at boot even if they were set. - Re-enable the breakpoint in vDbgPrintExWithPrefixInternal() as this works properly now. Without this breakpoint some break-in requests got lost if the break-in occurred when handling a debug print (happened a lot at boot). - Implement Command String support for DbgCommandString() -- we now handle every debug service call. - Implement NtSetDebugFilterState() and NtQueryDebugFilterState() for KD, meaning we now support debug filters properly. - Implement KdRefreshDebuggerNotPresent(), KdChangeOption() and KdPowerTransition(). Stub KdSystemDebugControl() to return error status instead of hanging the system. - Stub the rest of the KD API to print a warning and return a failure packet instead of hanging. - Set and respect KdpContextSent when getting and setting the thread context -- WinDbg doesn't seem to rely on this, but better safe than sorry. - Support MP when getting and setting the thread context too -- if the context is operation is for another processor than the current, just get it through the KiProcessorBlock array. - Initialize the MajorVersion in the KD version block more properly -- the high byte is the major identifier (0 for NT). Add the required DBGKD_MAJOR_TYPES enumeration to wdbgexts.h. - Simplify setting and clearing the InDbgPrint flag in the TEB to minimize the impact on kernel execution; use 2 dedicated routines instead of a generic one. - KdpSymbol doesn't return anything, so don't return an ignore status from KdpReportLoadSymbolsStateChange. - Expose the KdpDefaultRetries and Kd_WIN2000_Mask variables to the registry and add them to KDBG too (unused there). - No reason to implement KdpSysGetVersion per architecture; move it back to the generic code. - Add some ARM offsets to the debugger data block that (N/A on other architectures). - Fix the default size of the DbgPrint log buffer for free builds to save some space. It should be 4 KB for a free build and 32 KB for a checked build. - Move KeDisableInterrupts to cpu.c as it fits here more than in the IRQ support code in irqobj.c. - Use KeDisableInterrupts in KeFreezeExecution instead of checking the x86 EFLAG directly. svn path=/trunk/; revision=43912
2009-11-02 17:45:51 +00:00
VOID
NTAPI
DbgCommandString(
IN PCCH Name,
IN PCCH Command
);
//
// Generic Table Functions
//
#if defined(NTOS_MODE_USER) || defined(_NTIFS_)
- Fix the way NlsOemLeadByteInfo is exported. - Fix definition of PFAST_IO_UNLOCK_ALL_BY_KEY. - Add IO_REPARSE and IO_REMOUNT definitions. - Add IOCTL_CDROM_DISK_TYPE definition. - Add FlagOn, BooleanFlagOn, SetFlag and ClearFlag definitions. - Add FILE_READ_ONLY_VOLUME, FILE_SEQUENTIAL_WRITE_ONCE, FILE_SUPPORTS_TRANSACTIONS definitions. - Add FSRTL_FLAG_ADVANCED_HEADER definition. - Add FSRTL_FLAG2_PURGE_WHEN_MAPPED and FSRTL_FLAG2_IS_PAGING_FILE definitions. - Add FILE_ID_FULL_DIR_INFORMATION and FILE_ID_BOTH_DIR_INFORMATION structures. - Add FSRTL_FCB_HEADER_V0 and FSRTL_FCB_HEADER_V1 definitions. - Add FSRTL_COMPARISION_RESULT enumeration. - Add backwards compatibility support for non-AVL tree routines. - Add RtlInsertElementGenericTableAvl, RtlDeleteElementGenericTableAvl, RtlLookupElementGenericTableAvl, RtlEnumerateGenericTableWithoutSplayingAvl prototypes. - Add FsRtlSetupAdvancedHeader macro. - Add FsRtlIsFatDbcsLegal prototype. - Add FsRtlTeardownPerStreamContexts prototype. - Add RtlFreeOemString, RtlOemStringToCountedUnicodeString, RtlUnicodeStringToCountedOemString, RtlOemToUnicodeN prototypes. - Fix GenericTable prototypes in rtlfuncs.h - It seems the ntoskrnl_i386.def exports file is totally incorrect with respect to mingw -- most FsRtl functions are not properly exported. We fixed the ones we need, someone needs to go fix this entire file. - Add memcmp to the NTOS exports -- we're not entirely sure how you were even expecting 3rd party drivers to load in React? - Fix FastFat's "VfatFastIoUnlockAllByKey" prototype to match the fixed up PFAST_IO_UNLOCK_ALL_BY_KEY definition. - Clean-build-tested on i386. svn path=/trunk/; revision=34611
2008-07-20 19:19:02 +00:00
NTSYSAPI
PVOID
NTAPI
RtlInsertElementGenericTable(
IN PRTL_GENERIC_TABLE Table,
IN PVOID Buffer,
IN ULONG BufferSize,
OUT PBOOLEAN NewElement OPTIONAL
);
- Fix the way NlsOemLeadByteInfo is exported. - Fix definition of PFAST_IO_UNLOCK_ALL_BY_KEY. - Add IO_REPARSE and IO_REMOUNT definitions. - Add IOCTL_CDROM_DISK_TYPE definition. - Add FlagOn, BooleanFlagOn, SetFlag and ClearFlag definitions. - Add FILE_READ_ONLY_VOLUME, FILE_SEQUENTIAL_WRITE_ONCE, FILE_SUPPORTS_TRANSACTIONS definitions. - Add FSRTL_FLAG_ADVANCED_HEADER definition. - Add FSRTL_FLAG2_PURGE_WHEN_MAPPED and FSRTL_FLAG2_IS_PAGING_FILE definitions. - Add FILE_ID_FULL_DIR_INFORMATION and FILE_ID_BOTH_DIR_INFORMATION structures. - Add FSRTL_FCB_HEADER_V0 and FSRTL_FCB_HEADER_V1 definitions. - Add FSRTL_COMPARISION_RESULT enumeration. - Add backwards compatibility support for non-AVL tree routines. - Add RtlInsertElementGenericTableAvl, RtlDeleteElementGenericTableAvl, RtlLookupElementGenericTableAvl, RtlEnumerateGenericTableWithoutSplayingAvl prototypes. - Add FsRtlSetupAdvancedHeader macro. - Add FsRtlIsFatDbcsLegal prototype. - Add FsRtlTeardownPerStreamContexts prototype. - Add RtlFreeOemString, RtlOemStringToCountedUnicodeString, RtlUnicodeStringToCountedOemString, RtlOemToUnicodeN prototypes. - Fix GenericTable prototypes in rtlfuncs.h - It seems the ntoskrnl_i386.def exports file is totally incorrect with respect to mingw -- most FsRtl functions are not properly exported. We fixed the ones we need, someone needs to go fix this entire file. - Add memcmp to the NTOS exports -- we're not entirely sure how you were even expecting 3rd party drivers to load in React? - Fix FastFat's "VfatFastIoUnlockAllByKey" prototype to match the fixed up PFAST_IO_UNLOCK_ALL_BY_KEY definition. - Clean-build-tested on i386. svn path=/trunk/; revision=34611
2008-07-20 19:19:02 +00:00
NTSYSAPI
PVOID
NTAPI
RtlInsertElementGenericTableFull(
IN PRTL_GENERIC_TABLE Table,
IN PVOID Buffer,
IN ULONG BufferSize,
OUT PBOOLEAN NewElement OPTIONAL,
IN PVOID NodeOrParent,
IN TABLE_SEARCH_RESULT SearchResult
);
- Fix the way NlsOemLeadByteInfo is exported. - Fix definition of PFAST_IO_UNLOCK_ALL_BY_KEY. - Add IO_REPARSE and IO_REMOUNT definitions. - Add IOCTL_CDROM_DISK_TYPE definition. - Add FlagOn, BooleanFlagOn, SetFlag and ClearFlag definitions. - Add FILE_READ_ONLY_VOLUME, FILE_SEQUENTIAL_WRITE_ONCE, FILE_SUPPORTS_TRANSACTIONS definitions. - Add FSRTL_FLAG_ADVANCED_HEADER definition. - Add FSRTL_FLAG2_PURGE_WHEN_MAPPED and FSRTL_FLAG2_IS_PAGING_FILE definitions. - Add FILE_ID_FULL_DIR_INFORMATION and FILE_ID_BOTH_DIR_INFORMATION structures. - Add FSRTL_FCB_HEADER_V0 and FSRTL_FCB_HEADER_V1 definitions. - Add FSRTL_COMPARISION_RESULT enumeration. - Add backwards compatibility support for non-AVL tree routines. - Add RtlInsertElementGenericTableAvl, RtlDeleteElementGenericTableAvl, RtlLookupElementGenericTableAvl, RtlEnumerateGenericTableWithoutSplayingAvl prototypes. - Add FsRtlSetupAdvancedHeader macro. - Add FsRtlIsFatDbcsLegal prototype. - Add FsRtlTeardownPerStreamContexts prototype. - Add RtlFreeOemString, RtlOemStringToCountedUnicodeString, RtlUnicodeStringToCountedOemString, RtlOemToUnicodeN prototypes. - Fix GenericTable prototypes in rtlfuncs.h - It seems the ntoskrnl_i386.def exports file is totally incorrect with respect to mingw -- most FsRtl functions are not properly exported. We fixed the ones we need, someone needs to go fix this entire file. - Add memcmp to the NTOS exports -- we're not entirely sure how you were even expecting 3rd party drivers to load in React? - Fix FastFat's "VfatFastIoUnlockAllByKey" prototype to match the fixed up PFAST_IO_UNLOCK_ALL_BY_KEY definition. - Clean-build-tested on i386. svn path=/trunk/; revision=34611
2008-07-20 19:19:02 +00:00
NTSYSAPI
BOOLEAN
NTAPI
RtlIsGenericTableEmpty(
IN PRTL_GENERIC_TABLE Table
);
- Fix the way NlsOemLeadByteInfo is exported. - Fix definition of PFAST_IO_UNLOCK_ALL_BY_KEY. - Add IO_REPARSE and IO_REMOUNT definitions. - Add IOCTL_CDROM_DISK_TYPE definition. - Add FlagOn, BooleanFlagOn, SetFlag and ClearFlag definitions. - Add FILE_READ_ONLY_VOLUME, FILE_SEQUENTIAL_WRITE_ONCE, FILE_SUPPORTS_TRANSACTIONS definitions. - Add FSRTL_FLAG_ADVANCED_HEADER definition. - Add FSRTL_FLAG2_PURGE_WHEN_MAPPED and FSRTL_FLAG2_IS_PAGING_FILE definitions. - Add FILE_ID_FULL_DIR_INFORMATION and FILE_ID_BOTH_DIR_INFORMATION structures. - Add FSRTL_FCB_HEADER_V0 and FSRTL_FCB_HEADER_V1 definitions. - Add FSRTL_COMPARISION_RESULT enumeration. - Add backwards compatibility support for non-AVL tree routines. - Add RtlInsertElementGenericTableAvl, RtlDeleteElementGenericTableAvl, RtlLookupElementGenericTableAvl, RtlEnumerateGenericTableWithoutSplayingAvl prototypes. - Add FsRtlSetupAdvancedHeader macro. - Add FsRtlIsFatDbcsLegal prototype. - Add FsRtlTeardownPerStreamContexts prototype. - Add RtlFreeOemString, RtlOemStringToCountedUnicodeString, RtlUnicodeStringToCountedOemString, RtlOemToUnicodeN prototypes. - Fix GenericTable prototypes in rtlfuncs.h - It seems the ntoskrnl_i386.def exports file is totally incorrect with respect to mingw -- most FsRtl functions are not properly exported. We fixed the ones we need, someone needs to go fix this entire file. - Add memcmp to the NTOS exports -- we're not entirely sure how you were even expecting 3rd party drivers to load in React? - Fix FastFat's "VfatFastIoUnlockAllByKey" prototype to match the fixed up PFAST_IO_UNLOCK_ALL_BY_KEY definition. - Clean-build-tested on i386. svn path=/trunk/; revision=34611
2008-07-20 19:19:02 +00:00
NTSYSAPI
PVOID
NTAPI
RtlLookupElementGenericTableFull(
IN PRTL_GENERIC_TABLE Table,
IN PVOID Buffer,
OUT PVOID *NodeOrParent,
OUT TABLE_SEARCH_RESULT *SearchResult
);
#endif
//
// Handle Table Functions
//
NTSYSAPI
PRTL_HANDLE_TABLE_ENTRY
NTAPI
RtlAllocateHandle(
IN PRTL_HANDLE_TABLE HandleTable,
IN OUT PULONG Index
);
NTSYSAPI
VOID
NTAPI
RtlDestroyHandleTable(IN PRTL_HANDLE_TABLE HandleTable);
NTSYSAPI
BOOLEAN
NTAPI
RtlFreeHandle(
IN PRTL_HANDLE_TABLE HandleTable,
IN PRTL_HANDLE_TABLE_ENTRY Handle
);
NTSYSAPI
VOID
NTAPI
RtlInitializeHandleTable(
IN ULONG TableSize,
IN ULONG HandleSize,
IN PRTL_HANDLE_TABLE HandleTable
);
NTSYSAPI
BOOLEAN
NTAPI
RtlIsValidHandle(
IN PRTL_HANDLE_TABLE HandleTable,
IN PRTL_HANDLE_TABLE_ENTRY Handle
);
NTSYSAPI
BOOLEAN
NTAPI
RtlIsValidIndexHandle(
IN PRTL_HANDLE_TABLE HandleTable,
IN ULONG Index,
OUT PRTL_HANDLE_TABLE_ENTRY *Handle
);
//
// PE Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlFindMessage(
IN PVOID BaseAddress,
IN ULONG Type,
IN ULONG Language,
IN ULONG MessageId,
OUT PRTL_MESSAGE_RESOURCE_ENTRY *MessageResourceEntry
);
NTSYSAPI
ULONG
NTAPI
RtlGetNtGlobalFlags(VOID);
NTSYSAPI
PVOID
NTAPI
RtlImageDirectoryEntryToData(
PVOID BaseAddress,
BOOLEAN MappedAsImage,
USHORT Directory,
PULONG Size
);
NTSYSAPI
PVOID
NTAPI
RtlImageRvaToVa(
PIMAGE_NT_HEADERS NtHeader,
PVOID BaseAddress,
ULONG Rva,
PIMAGE_SECTION_HEADER *SectionHeader
);
NTSYSAPI
PIMAGE_NT_HEADERS
NTAPI
RtlImageNtHeader(IN PVOID BaseAddress);
NTSYSAPI
NTSTATUS
NTAPI
RtlImageNtHeaderEx(
IN ULONG Flags,
IN PVOID BaseAddress,
IN ULONGLONG Size,
IN PIMAGE_NT_HEADERS *NtHeader
);
NTSYSAPI
PIMAGE_SECTION_HEADER
NTAPI
RtlImageRvaToSection(
PIMAGE_NT_HEADERS NtHeader,
PVOID BaseAddress,
ULONG Rva
);
NTSYSAPI
ULONG
NTAPI
LdrRelocateImageWithBias(
IN PVOID NewAddress,
IN LONGLONG AdditionalBias,
IN PCCH LoaderName,
IN ULONG Success,
IN ULONG Conflict,
IN ULONG Invalid
);
//
// Activation Context Functions
//
#ifdef NTOS_MODE_USER
NTSYSAPI
NTSTATUS
NTAPI
RtlActivateActivationContext(
IN ULONG Unknown,
IN HANDLE Handle,
OUT PULONG_PTR Cookie
);
NTSYSAPI
VOID
NTAPI
RtlAddRefActivationContext(
PVOID Context
);
NTSYSAPI
NTSTATUS
NTAPI
RtlActivateActivationContextUnsafeFast(
IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame,
IN PVOID Context
);
NTSYSAPI
NTSTATUS
NTAPI
RtlAllocateActivationContextStack(
IN PVOID *Context
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateActivationContext(
OUT PHANDLE Handle,
IN OUT PVOID ReturnedData
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetActiveActivationContext(
IN PVOID *Context
);
NTSYSAPI
VOID
NTAPI
RtlReleaseActivationContext(
IN HANDLE handle
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeactivateActivationContext(
ULONG dwFlags,
ULONG_PTR ulCookie
);
NTSYSAPI
VOID
NTAPI
RtlFreeThreadActivationContextStack(void);
NTSYSAPI
NTSTATUS
NTAPI
RtlDeactivateActivationContextUnsafeFast(
IN PRTL_CALLER_ALLOCATED_ACTIVATION_CONTEXT_STACK_FRAME_EXTENDED Frame
);
NTSYSAPI
NTSTATUS
NTAPI
RtlDosApplyFileIsolationRedirection_Ustr(
IN BOOLEAN Unknown,
IN PUNICODE_STRING OriginalName,
IN PUNICODE_STRING Extension,
IN OUT PUNICODE_STRING RedirectedName,
IN OUT PUNICODE_STRING RedirectedName2,
IN OUT PUNICODE_STRING *OriginalName2,
IN PVOID Unknown1,
IN PVOID Unknown2,
IN PVOID Unknown3
);
NTSYSAPI
NTSTATUS
NTAPI
RtlFindActivationContextSectionString(
IN ULONG dwFlags,
IN const GUID *ExtensionGuid,
IN ULONG SectionType,
IN PUNICODE_STRING SectionName,
IN OUT PVOID ReturnedData
);
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryInformationActivationContext(
DWORD dwFlags,
PVOID Context,
PVOID pvSubInstance,
ULONG ulInfoClass,
PVOID pvBuffer,
SIZE_T cbBuffer OPTIONAL,
SIZE_T *pcbWrittenOrRequired OPTIONAL
);
NTSYSAPI
NTSTATUS
NTAPI
RtlZombifyActivationContext(
PVOID Context
);
#endif
//
// Registry Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlCheckRegistryKey(
ULONG RelativeTo,
PWSTR Path
);
NTSYSAPI
NTSTATUS
NTAPI
RtlCreateRegistryKey(
IN ULONG RelativeTo,
IN PWSTR Path
);
NTSYSAPI
NTSTATUS
NTAPI
RtlFormatCurrentUserKeyPath(
IN OUT PUNICODE_STRING KeyPath
);
NTSYSAPI
NTSTATUS
NTAPI
RtlpNtOpenKey(
OUT HANDLE KeyHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
IN ULONG Unused
);
NTSYSAPI
NTSTATUS
NTAPI
RtlOpenCurrentUser(
IN ACCESS_MASK DesiredAccess,
OUT PHANDLE KeyHandle
);
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryRegistryValues(
IN ULONG RelativeTo,
IN PCWSTR Path,
IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
IN PVOID Context,
IN PVOID Environment
);
NTSYSAPI
NTSTATUS
NTAPI
RtlWriteRegistryValue(
ULONG RelativeTo,
PCWSTR Path,
PCWSTR ValueName,
ULONG ValueType,
PVOID ValueData,
ULONG ValueLength
);
//
// NLS Functions
//
NTSYSAPI
VOID
NTAPI
RtlGetDefaultCodePage(
OUT PUSHORT AnsiCodePage,
OUT PUSHORT OemCodePage
);
NTSYSAPI
VOID
NTAPI
RtlInitNlsTables(
IN PUSHORT AnsiTableBase,
IN PUSHORT OemTableBase,
IN PUSHORT CaseTableBase,
OUT PNLSTABLEINFO NlsTable
);
NTSYSAPI
VOID
NTAPI
RtlInitCodePageTable(
IN PUSHORT TableBase,
OUT PCPTABLEINFO CodePageTable
);
NTSYSAPI
VOID
NTAPI
RtlResetRtlTranslations(IN PNLSTABLEINFO NlsTable);
#if defined(NTOS_MODE_USER) && !defined(NO_RTL_INLINES)
//
// Misc conversion functions
//
static __inline
LARGE_INTEGER
NTAPI_INLINE
RtlConvertLongToLargeInteger(
LONG SignedInteger
)
{
LARGE_INTEGER Result;
Result.QuadPart = SignedInteger;
return Result;
}
static __inline
LARGE_INTEGER
NTAPI_INLINE
RtlEnlargedIntegerMultiply(
LONG Multiplicand,
LONG Multiplier
)
{
LARGE_INTEGER Product;
Product.QuadPart = (LONGLONG)Multiplicand * (ULONGLONG)Multiplier;
return Product;
}
static __inline
ULONG
NTAPI_INLINE
RtlEnlargedUnsignedDivide(
IN ULARGE_INTEGER Dividend,
IN ULONG Divisor,
IN PULONG Remainder OPTIONAL
)
{
ULONG Quotient;
Quotient = (ULONG)(Dividend.QuadPart / Divisor);
if (Remainder) {
*Remainder = (ULONG)(Dividend.QuadPart % Divisor);
}
return Quotient;
}
static __inline
LARGE_INTEGER
NTAPI_INLINE
RtlEnlargedUnsignedMultiply(
ULONG Multiplicand,
ULONG Multiplier
)
{
LARGE_INTEGER Product;
Product.QuadPart = (ULONGLONG)Multiplicand * (ULONGLONG)Multiplier;
return Product;
}
#endif
NTSYSAPI
ULONG
NTAPI
RtlUniform(
IN PULONG Seed
);
NTSYSAPI
ULONG
NTAPI
RtlRandom(
IN OUT PULONG Seed
);
NTSYSAPI
ULONG
NTAPI
RtlComputeCrc32(
IN USHORT PartialCrc,
IN PUCHAR Buffer,
IN ULONG Length
);
//
// Network Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlIpv4StringToAddressW(
IN PCWSTR String,
IN BOOLEAN Strict,
OUT LPWSTR *Terminator,
OUT struct in_addr *Addr
);
NTSYSAPI
NTSTATUS
NTAPI
RtlIpv6StringToAddressA(
IN PCHAR Name,
OUT PCHAR *Terminator,
OUT struct in6_addr *Addr
);
NTSYSAPI
NTSTATUS
NTAPI
RtlIpv6StringToAddressW(
IN PWCHAR Name,
OUT PCHAR *Terminator,
OUT struct in6_addr *Addr
);
NTSYSAPI
NTSTATUS
NTAPI
RtlIpv6StringToAddressExA(
IN PCHAR AddressString,
IN struct in6_addr *Address,
IN PULONG ScopeId,
IN PUSHORT Port
);
NTSYSAPI
NTSTATUS
NTAPI
RtlIpv6StringToAddressExW(
IN PWCHAR AddressName,
IN struct in6_addr *Address,
IN PULONG ScopeId,
IN PUSHORT Port
);
//
// Time Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlQueryTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
NTSYSAPI
VOID
NTAPI
RtlSecondsSince1970ToTime(
IN ULONG SecondsSince1970,
OUT PLARGE_INTEGER Time
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation);
NTSYSAPI
BOOLEAN
NTAPI
RtlTimeFieldsToTime(
PTIME_FIELDS TimeFields,
PLARGE_INTEGER Time
);
NTSYSAPI
BOOLEAN
NTAPI
RtlTimeToSecondsSince1970(
PLARGE_INTEGER Time,
OUT PULONG SecondsSince1970
);
NTSYSAPI
VOID
NTAPI
RtlTimeToTimeFields(
PLARGE_INTEGER Time,
PTIME_FIELDS TimeFields
);
NTSYSAPI
NTSTATUS
NTAPI
RtlSystemTimeToLocalTime(
IN PLARGE_INTEGER SystemTime,
OUT PLARGE_INTEGER LocalTime
);
//
// Version Functions
//
NTSYSAPI
NTSTATUS
NTAPI
RtlVerifyVersionInfo(
IN PRTL_OSVERSIONINFOEXW VersionInfo,
IN ULONG TypeMask,
IN ULONGLONG ConditionMask
);
NTSYSAPI
NTSTATUS
NTAPI
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation);
NTSYSAPI
BOOLEAN
NTAPI
RtlGetNtProductType(OUT PNT_PRODUCT_TYPE ProductType);
//
// Secure Memory Functions
//
#ifdef NTOS_MODE_USER
NTSYSAPI
NTSTATUS
NTAPI
RtlRegisterSecureMemoryCacheCallback(
IN PRTL_SECURE_MEMORY_CACHE_CALLBACK Callback);
NTSYSAPI
BOOLEAN
NTAPI
RtlFlushSecureMemoryCache(
IN PVOID MemoryCache,
IN OPTIONAL SIZE_T MemoryLength
);
#endif
#ifdef __cplusplus
}
#endif
#endif