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 */
|
2009-06-17 12:44:05 +00:00
|
|
|
#if DBG
|
2006-11-08 11:47:44 +00:00
|
|
|
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))
|
Merge freeldr from amd64 branch:
34725, 34726, 34727, 34728, 34733, 34735, 34747, 34748, 34888, 34937, 34968, 35021, 35351, 35360, 35445, 35493, 35495, 35505, 35547, 35696, 35704, 36343, 36355, 36865, 37306, 37896, 38332, 38942, 38950, 38951, 38959, 39073, 39278
svn path=/trunk/; revision=39638
2009-02-17 04:05:26 +00:00
|
|
|
#define SWAPQ(x) ((SWAPD((x)&0xffffffff) << 32) | (SWAPD((x)>>32)))
|
2007-10-14 23:09:12 +00:00
|
|
|
#else
|
Merge freeldr from amd64 branch:
34725, 34726, 34727, 34728, 34733, 34735, 34747, 34748, 34888, 34937, 34968, 35021, 35351, 35360, 35445, 35493, 35495, 35505, 35547, 35696, 35704, 36343, 36355, 36865, 37306, 37896, 38332, 38942, 38950, 38951, 38959, 39073, 39278
svn path=/trunk/; revision=39638
2009-02-17 04:05:26 +00:00
|
|
|
#define SWAPD(x) (x)
|
|
|
|
#define SWAPW(x) (x)
|
|
|
|
#define SWAPQ(x) (x)
|
2007-10-14 23:09:12 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-25 16:13:16 +00:00
|
|
|
#define ROUND_DOWN(n, align) \
|
2010-10-05 19:33:42 +00:00
|
|
|
(((ULONG)(n)) & ~((align) - 1l))
|
2009-01-25 16:13:16 +00:00
|
|
|
|
|
|
|
#define ROUND_UP(n, align) \
|
2010-10-05 19:33:42 +00:00
|
|
|
ROUND_DOWN(((ULONG)(n)) + (align) - 1, (align))
|
2009-01-25 16:13:16 +00:00
|
|
|
|
[RTL]
Merge from amd64 branch
35738,37004,37308,37324,37330,37331,37332,37370,37419,37424,37425,37428,37473,37492,37844,37911,37987,40604,41006,43686,43951,43953,43980,43993,44001,44289,44295,44296,44428,44966,44967,44968
- Implement amd64 specific RTL functions: RtlLookupFunctionTable, RtlLookupFunctionEntry, RtlCaptureContext, RtlVirtualUnwind, RtlWalkFrameChain, RtlGetCallersAddress, RtlRaiseException (Timo Kreuzer)
- Implement amd64 asm functions: RtlCompareMemory, DebugService, RtlInterlockedPopEntrySList, RtlInterlockedPushEntrySList and RtlInterlockedFlushSList (Timo Kreuzer)
- Don't use double in rtl's sprintf / swprintf, use double_t union instead. (Stefan Ginsberg)
svn path=/trunk/; revision=44970
2010-01-06 00:39:07 +00:00
|
|
|
#define RVA(m, b) ((PVOID)((ULONG_PTR)(b) + (ULONG_PTR)(m)))
|
|
|
|
|
- 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
|
[RTL]
Merge from amd64 branch
35738,37004,37308,37324,37330,37331,37332,37370,37419,37424,37425,37428,37473,37492,37844,37911,37987,40604,41006,43686,43951,43953,43980,43993,44001,44289,44295,44296,44428,44966,44967,44968
- Implement amd64 specific RTL functions: RtlLookupFunctionTable, RtlLookupFunctionEntry, RtlCaptureContext, RtlVirtualUnwind, RtlWalkFrameChain, RtlGetCallersAddress, RtlRaiseException (Timo Kreuzer)
- Implement amd64 asm functions: RtlCompareMemory, DebugService, RtlInterlockedPopEntrySList, RtlInterlockedPushEntrySList and RtlInterlockedFlushSList (Timo Kreuzer)
- Don't use double in rtl's sprintf / swprintf, use double_t union instead. (Stefan Ginsberg)
svn path=/trunk/; revision=44970
2010-01-06 00:39:07 +00:00
|
|
|
RtlpGetStackLimits(PULONG_PTR LowLimit,
|
|
|
|
PULONG_PTR HighLimit);
|
- 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
|
|
|
|
|
|
|
PEXCEPTION_REGISTRATION_RECORD
|
|
|
|
NTAPI
|
|
|
|
RtlpGetExceptionList(VOID);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpSetExceptionList(PEXCEPTION_REGISTRATION_RECORD NewExceptionList);
|
|
|
|
|
2008-11-01 19:48:52 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
RtlCallVectoredExceptionHandlers(
|
|
|
|
IN PEXCEPTION_RECORD ExceptionRecord,
|
|
|
|
IN PCONTEXT Context
|
|
|
|
);
|
|
|
|
|
- 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
|
|
|
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
|
2010-10-05 19:33:42 +00:00
|
|
|
RtlDeleteHeapLock(PHEAP_LOCK Lock);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2010-10-05 19:33:42 +00:00
|
|
|
RtlEnterHeapLock(PHEAP_LOCK Lock);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2010-10-05 19:33:42 +00:00
|
|
|
RtlInitializeHeapLock(PHEAP_LOCK Lock);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
2010-10-05 19:33:42 +00:00
|
|
|
RtlLeaveHeapLock(PHEAP_LOCK Lock);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
2009-10-23 22:51:39 +00:00
|
|
|
RtlpCheckForActiveDebugger(VOID);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
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
|
2009-11-02 17:45:51 +00:00
|
|
|
RtlpSetInDbgPrint(
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpClearInDbgPrint(
|
|
|
|
VOID
|
|
|
|
);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlpCaptureContext(OUT PCONTEXT ContextRecord);
|
|
|
|
|
2009-10-25 15:56:38 +00:00
|
|
|
//
|
|
|
|
// Debug Service calls
|
|
|
|
//
|
|
|
|
ULONG
|
|
|
|
NTAPI
|
|
|
|
DebugService(
|
|
|
|
IN ULONG Service,
|
|
|
|
IN PVOID Argument1,
|
|
|
|
IN PVOID Argument2,
|
|
|
|
IN PVOID Argument3,
|
|
|
|
IN PVOID Argument4
|
|
|
|
);
|
2006-11-08 11:47:44 +00:00
|
|
|
|
2009-10-25 15:56:38 +00:00
|
|
|
VOID
|
2007-01-24 19:48:34 +00:00
|
|
|
NTAPI
|
2009-10-25 15:56:38 +00:00
|
|
|
DebugService2(
|
|
|
|
IN PVOID Argument1,
|
|
|
|
IN PVOID Argument2,
|
|
|
|
IN ULONG Service
|
|
|
|
);
|
2007-01-24 19:48:34 +00:00
|
|
|
|
2006-11-08 11:47:44 +00:00
|
|
|
/* Tags for the String Allocators */
|
2009-08-24 17:12:25 +00:00
|
|
|
#define TAG_USTR 'RTSU'
|
|
|
|
#define TAG_ASTR 'RTSA'
|
|
|
|
#define TAG_OSTR 'RTSO'
|
2006-11-08 11:47:44 +00:00
|
|
|
|
|
|
|
/* Timer Queue */
|
|
|
|
|
|
|
|
extern HANDLE TimerThreadHandle;
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
RtlpInitializeTimerThread(VOID);
|
|
|
|
|
|
|
|
/* EOF */
|