2006-11-08 11:47:44 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS System Libraries
|
|
|
|
* FILE: lib/rtl/rtlp.h
|
|
|
|
* PURPOSE: Run-Time Libary Internal Header
|
|
|
|
* PROGRAMMER: Alex Ionescu
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
/* PAGED_CODE equivalent for user-mode RTL */
|
|
|
|
#ifdef DBG
|
|
|
|
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
|
|
|
|
#define PAGED_CODE_RTL() CHECK_PAGED_CODE_RTL(__FILE__, __LINE__)
|
|
|
|
#else
|
|
|
|
#define PAGED_CODE_RTL()
|
|
|
|
#endif
|
|
|
|
|
2007-10-14 23:09:12 +00:00
|
|
|
#ifdef _PPC_
|
|
|
|
#define SWAPD(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff))
|
|
|
|
#define SWAPW(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff))
|
|
|
|
#else
|
|
|
|
#define SWAPD(x) x
|
|
|
|
#define SWAPW(x) x
|
|
|
|
#endif
|
|
|
|
|
- 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
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpGetStackLimits(PULONG_PTR StackBase,
|
|
|
|
PULONG_PTR StackLimit);
|
|
|
|
|
|
|
|
PEXCEPTION_REGISTRATION_RECORD
|
|
|
|
NTAPI
|
|
|
|
RtlpGetExceptionList(VOID);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
|
|
|
|
|
|
|
|
typedef struct _DISPATCHER_CONTEXT
|
|
|
|
{
|
|
|
|
PEXCEPTION_REGISTRATION_RECORD RegistrationPointer;
|
|
|
|
} DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT;
|
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
/* These provide support for sharing code between User and Kernel RTL */
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
RtlpAllocateMemory(
|
|
|
|
ULONG Bytes,
|
|
|
|
ULONG Tag);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpFreeMemory(
|
|
|
|
PVOID Mem,
|
|
|
|
ULONG Tag);
|
|
|
|
|
|
|
|
KPROCESSOR_MODE
|
|
|
|
NTAPI
|
|
|
|
RtlpGetMode(VOID);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
RtlpCaptureStackLimits(
|
|
|
|
IN ULONG_PTR Ebp,
|
|
|
|
IN ULONG_PTR *StackBegin,
|
|
|
|
IN ULONG_PTR *StackEnd
|
|
|
|
);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
RtlDeleteHeapLock(PRTL_CRITICAL_SECTION CriticalSection);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
RtlEnterHeapLock(PRTL_CRITICAL_SECTION CriticalSection);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
RtlInitializeHeapLock(PRTL_CRITICAL_SECTION CriticalSection);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
RtlLeaveHeapLock(PRTL_CRITICAL_SECTION CriticalSection);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
RtlpCheckForActiveDebugger(BOOLEAN Type);
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
RtlpHandleDpcStackException(IN PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
|
|
|
|
IN ULONG_PTR RegistrationFrameEnd,
|
|
|
|
IN OUT PULONG_PTR StackLow,
|
|
|
|
IN OUT PULONG_PTR StackHigh);
|
|
|
|
|
|
|
|
#define RtlpAllocateStringMemory RtlpAllocateMemory
|
|
|
|
#define RtlpFreeStringMemory RtlpFreeMemory
|
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
RtlpSetInDbgPrint(IN BOOLEAN NewValue);
|
|
|
|
|
|
|
|
/* i386/except.S */
|
|
|
|
|
|
|
|
EXCEPTION_DISPOSITION
|
|
|
|
NTAPI
|
|
|
|
RtlpExecuteHandlerForException(PEXCEPTION_RECORD ExceptionRecord,
|
|
|
|
PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
|
|
|
|
PCONTEXT Context,
|
|
|
|
PVOID DispatcherContext,
|
|
|
|
PEXCEPTION_ROUTINE ExceptionHandler);
|
|
|
|
|
|
|
|
EXCEPTION_DISPOSITION
|
|
|
|
NTAPI
|
|
|
|
RtlpExecuteHandlerForUnwind(PEXCEPTION_RECORD ExceptionRecord,
|
|
|
|
PEXCEPTION_REGISTRATION_RECORD RegistrationFrame,
|
|
|
|
PCONTEXT Context,
|
|
|
|
PVOID DispatcherContext,
|
|
|
|
PEXCEPTION_ROUTINE ExceptionHandler);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpCheckLogException(IN PEXCEPTION_RECORD ExceptionRecord,
|
|
|
|
IN PCONTEXT ContextRecord,
|
|
|
|
IN PVOID ContextData,
|
|
|
|
IN ULONG Size);
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
NTAPI
|
|
|
|
RtlpGetExceptionAddress(VOID);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpCaptureContext(OUT PCONTEXT ContextRecord);
|
|
|
|
|
|
|
|
/* i386/debug.S */
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
DebugService(IN ULONG Service,
|
- 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 const void* Buffer,
|
2006-11-08 11:47:44 +00:00
|
|
|
IN ULONG Length,
|
|
|
|
IN PVOID Argument1,
|
|
|
|
IN PVOID Argument2);
|
|
|
|
|
2007-01-24 19:48:34 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
DebugService2(IN PVOID Argument1,
|
|
|
|
IN PVOID Argument2,
|
|
|
|
IN ULONG Service);
|
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
/* Tags for the String Allocators */
|
|
|
|
#define TAG_USTR TAG('U', 'S', 'T', 'R')
|
|
|
|
#define TAG_ASTR TAG('A', 'S', 'T', 'R')
|
|
|
|
#define TAG_OSTR TAG('O', 'S', 'T', 'R')
|
|
|
|
|
|
|
|
/* Timer Queue */
|
|
|
|
|
|
|
|
extern HANDLE TimerThreadHandle;
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
RtlpInitializeTimerThread(VOID);
|
|
|
|
|
|
|
|
/* EOF */
|