2010-07-24 01:12:13 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: stubs
|
|
|
|
* PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
|
|
|
#include <ntoskrnl.h>
|
2018-02-04 22:44:43 +00:00
|
|
|
#include <fltkernel.h>
|
2010-07-24 01:12:13 +00:00
|
|
|
|
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
|
|
|
|
2018-02-09 19:59:33 +00:00
|
|
|
ULONG ProcessCount;
|
|
|
|
SIZE_T KeXStateLength = sizeof(XSAVE_FORMAT);
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
VOID
|
|
|
|
KiRetireDpcListInDpcStack(
|
|
|
|
PKPRCB Prcb,
|
|
|
|
PVOID DpcStack);
|
|
|
|
|
2018-02-04 22:44:43 +00:00
|
|
|
NTSTATUS
|
|
|
|
KiConvertToGuiThread(
|
|
|
|
VOID);
|
|
|
|
|
2021-06-07 08:23:01 +00:00
|
|
|
_Requires_lock_not_held_(Prcb->PrcbLock)
|
2011-09-16 18:39:55 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
KiDpcInterruptHandler(VOID)
|
2011-09-16 18:39:55 +00:00
|
|
|
{
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
|
|
|
PKTHREAD NewThread, OldThread;
|
|
|
|
KIRQL OldIrql;
|
|
|
|
|
|
|
|
/* Raise to DISPATCH_LEVEL */
|
|
|
|
OldIrql = KfRaiseIrql(DISPATCH_LEVEL);
|
|
|
|
|
|
|
|
/* Send an EOI */
|
|
|
|
KiSendEOI();
|
|
|
|
|
|
|
|
/* Check for pending timers, pending DPCs, or pending ready threads */
|
|
|
|
if ((Prcb->DpcData[0].DpcQueueDepth) ||
|
|
|
|
(Prcb->TimerRequest) ||
|
|
|
|
(Prcb->DeferredReadyListHead.Next))
|
|
|
|
{
|
|
|
|
/* Retire DPCs while under the DPC stack */
|
|
|
|
KiRetireDpcListInDpcStack(Prcb, Prcb->DpcStack);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable interrupts */
|
|
|
|
_enable();
|
|
|
|
|
|
|
|
/* Check for quantum end */
|
|
|
|
if (Prcb->QuantumEnd)
|
|
|
|
{
|
|
|
|
/* Handle quantum end */
|
|
|
|
Prcb->QuantumEnd = FALSE;
|
|
|
|
KiQuantumEnd();
|
|
|
|
}
|
|
|
|
else if (Prcb->NextThread)
|
|
|
|
{
|
2021-06-07 08:23:01 +00:00
|
|
|
/* Acquire the PRCB lock */
|
|
|
|
KiAcquirePrcbLock(Prcb);
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Capture current thread data */
|
|
|
|
OldThread = Prcb->CurrentThread;
|
|
|
|
NewThread = Prcb->NextThread;
|
|
|
|
|
|
|
|
/* Set new thread data */
|
|
|
|
Prcb->NextThread = NULL;
|
|
|
|
Prcb->CurrentThread = NewThread;
|
|
|
|
|
|
|
|
/* The thread is now running */
|
|
|
|
NewThread->State = Running;
|
|
|
|
OldThread->WaitReason = WrDispatchInt;
|
|
|
|
|
|
|
|
/* Make the old thread ready */
|
|
|
|
KxQueueReadyThread(OldThread, Prcb);
|
|
|
|
|
|
|
|
/* Swap to the new thread */
|
|
|
|
KiSwapContext(APC_LEVEL, OldThread);
|
|
|
|
}
|
|
|
|
|
2018-03-09 20:07:10 +00:00
|
|
|
/* Disable interrupts and go back to old irql */
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
_disable();
|
2018-03-09 20:07:10 +00:00
|
|
|
KeLowerIrql(OldIrql);
|
2011-09-16 18:39:55 +00:00
|
|
|
}
|
|
|
|
|
2018-02-04 22:44:43 +00:00
|
|
|
PVOID
|
|
|
|
KiSwitchKernelStackHelper(
|
|
|
|
LONG_PTR StackOffset,
|
|
|
|
PVOID OldStackBase);
|
|
|
|
|
2018-02-09 19:59:33 +00:00
|
|
|
/*
|
|
|
|
* Kernel stack layout (example pointers):
|
|
|
|
* 0xFFFFFC0F'2D008000 KTHREAD::StackBase
|
|
|
|
* [XSAVE_AREA size == KeXStateLength = 0x440]
|
|
|
|
* 0xFFFFFC0F'2D007BC0 KTHREAD::StateSaveArea _XSAVE_FORMAT
|
|
|
|
* 0xFFFFFC0F'2D007B90 KTHREAD::InitialStack
|
|
|
|
* [0x190 bytes KTRAP_FRAME]
|
|
|
|
* 0xFFFFFC0F'2D007A00 KTHREAD::TrapFrame
|
|
|
|
* [KSTART_FRAME] or ...
|
|
|
|
* [KSWITCH_FRAME]
|
|
|
|
* 0xFFFFFC0F'2D007230 KTHREAD::KernelStack
|
|
|
|
*/
|
|
|
|
|
2010-07-24 01:12:13 +00:00
|
|
|
PVOID
|
|
|
|
NTAPI
|
2018-02-09 19:59:33 +00:00
|
|
|
KiSwitchKernelStack(PVOID StackBase, PVOID StackLimit)
|
2010-07-24 01:12:13 +00:00
|
|
|
{
|
2018-02-04 22:44:43 +00:00
|
|
|
PKTHREAD CurrentThread;
|
|
|
|
PVOID OldStackBase;
|
|
|
|
LONG_PTR StackOffset;
|
|
|
|
SIZE_T StackSize;
|
2018-02-09 19:59:33 +00:00
|
|
|
PKIPCR Pcr;
|
2022-07-23 11:21:18 +00:00
|
|
|
ULONG Eflags;
|
2018-02-04 22:44:43 +00:00
|
|
|
|
|
|
|
/* Get the current thread */
|
|
|
|
CurrentThread = KeGetCurrentThread();
|
|
|
|
|
|
|
|
/* Save the old stack base */
|
|
|
|
OldStackBase = CurrentThread->StackBase;
|
|
|
|
|
|
|
|
/* Get the size of the current stack */
|
|
|
|
StackSize = (ULONG_PTR)CurrentThread->StackBase - CurrentThread->StackLimit;
|
|
|
|
ASSERT(StackSize <= (ULONG_PTR)StackBase - (ULONG_PTR)StackLimit);
|
|
|
|
|
|
|
|
/* Copy the current stack contents to the new stack */
|
|
|
|
RtlCopyMemory((PUCHAR)StackBase - StackSize,
|
|
|
|
(PVOID)CurrentThread->StackLimit,
|
|
|
|
StackSize);
|
|
|
|
|
|
|
|
/* Calculate the offset between the old and the new stack */
|
|
|
|
StackOffset = (PUCHAR)StackBase - (PUCHAR)CurrentThread->StackBase;
|
|
|
|
|
|
|
|
/* Disable interrupts while messing with the stack */
|
2022-07-23 11:21:18 +00:00
|
|
|
Eflags = __readeflags();
|
2018-02-04 22:44:43 +00:00
|
|
|
_disable();
|
|
|
|
|
|
|
|
/* Set the new trap frame */
|
|
|
|
CurrentThread->TrapFrame = (PKTRAP_FRAME)Add2Ptr(CurrentThread->TrapFrame,
|
|
|
|
StackOffset);
|
|
|
|
|
|
|
|
/* Set the new initial stack */
|
|
|
|
CurrentThread->InitialStack = Add2Ptr(CurrentThread->InitialStack,
|
|
|
|
StackOffset);
|
|
|
|
|
|
|
|
/* Set the new stack limits */
|
|
|
|
CurrentThread->StackBase = StackBase;
|
|
|
|
CurrentThread->StackLimit = (ULONG_PTR)StackLimit;
|
|
|
|
CurrentThread->LargeStack = TRUE;
|
|
|
|
|
2018-02-09 19:59:33 +00:00
|
|
|
/* Adjust RspBase in the PCR */
|
|
|
|
Pcr = (PKIPCR)KeGetPcr();
|
|
|
|
Pcr->Prcb.RspBase += StackOffset;
|
2018-02-04 22:44:43 +00:00
|
|
|
|
2018-02-09 19:59:33 +00:00
|
|
|
/* Adjust Rsp0 in the TSS */
|
|
|
|
Pcr->TssBase->Rsp0 += StackOffset;
|
2018-02-04 22:44:43 +00:00
|
|
|
|
2022-07-23 11:21:18 +00:00
|
|
|
/* Restore interrupts */
|
|
|
|
__writeeflags(Eflags);
|
|
|
|
|
2018-02-04 22:44:43 +00:00
|
|
|
return OldStackBase;
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 01:46:56 +00:00
|
|
|
DECLSPEC_NORETURN
|
2010-07-24 01:12:13 +00:00
|
|
|
VOID
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
KiIdleLoop(VOID)
|
2010-07-24 01:12:13 +00:00
|
|
|
{
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
PKPRCB Prcb = KeGetCurrentPrcb();
|
|
|
|
PKTHREAD OldThread, NewThread;
|
|
|
|
|
|
|
|
/* Now loop forever */
|
|
|
|
while (TRUE)
|
|
|
|
{
|
2017-03-27 20:23:37 +00:00
|
|
|
/* Start of the idle loop: disable interrupts */
|
|
|
|
_enable();
|
|
|
|
YieldProcessor();
|
|
|
|
YieldProcessor();
|
|
|
|
_disable();
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Check for pending timers, pending DPCs, or pending ready threads */
|
|
|
|
if ((Prcb->DpcData[0].DpcQueueDepth) ||
|
|
|
|
(Prcb->TimerRequest) ||
|
|
|
|
(Prcb->DeferredReadyListHead.Next))
|
|
|
|
{
|
|
|
|
/* Quiesce the DPC software interrupt */
|
|
|
|
HalClearSoftwareInterrupt(DISPATCH_LEVEL);
|
|
|
|
|
|
|
|
/* Handle it */
|
|
|
|
KiRetireDpcList(Prcb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if a new thread is scheduled for execution */
|
|
|
|
if (Prcb->NextThread)
|
|
|
|
{
|
2016-02-04 20:27:44 +00:00
|
|
|
/* Enable interrupts */
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
_enable();
|
|
|
|
|
|
|
|
/* Capture current thread data */
|
|
|
|
OldThread = Prcb->CurrentThread;
|
|
|
|
NewThread = Prcb->NextThread;
|
|
|
|
|
|
|
|
/* Set new thread data */
|
|
|
|
Prcb->NextThread = NULL;
|
|
|
|
Prcb->CurrentThread = NewThread;
|
|
|
|
|
|
|
|
/* The thread is now running */
|
|
|
|
NewThread->State = Running;
|
|
|
|
|
|
|
|
/* Do the swap at SYNCH_LEVEL */
|
|
|
|
KfRaiseIrql(SYNCH_LEVEL);
|
|
|
|
|
|
|
|
/* Switch away from the idle thread */
|
|
|
|
KiSwapContext(APC_LEVEL, OldThread);
|
|
|
|
|
|
|
|
/* Go back to DISPATCH_LEVEL */
|
|
|
|
KeLowerIrql(DISPATCH_LEVEL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Continue staying idle. Note the HAL returns with interrupts on */
|
|
|
|
Prcb->PowerState.IdleFunction(&Prcb->PowerState);
|
|
|
|
}
|
|
|
|
}
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
KiSwapProcess(IN PKPROCESS NewProcess,
|
|
|
|
IN PKPROCESS OldProcess)
|
|
|
|
{
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
PKIPCR Pcr = (PKIPCR)KeGetPcr();
|
|
|
|
|
2018-02-10 19:30:14 +00:00
|
|
|
#ifdef CONFIG_SMP
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Update active processor mask */
|
2018-02-10 19:30:14 +00:00
|
|
|
InterlockedXor64((PLONG64)&NewProcess->ActiveProcessors, Pcr->Prcb.SetMember);
|
|
|
|
InterlockedXor64((PLONG64)&OldProcess->ActiveProcessors, Pcr->Prcb.SetMember);
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Update CR3 */
|
|
|
|
__writecr3(NewProcess->DirectoryTableBase[0]);
|
|
|
|
|
|
|
|
/* Update IOPM offset */
|
|
|
|
Pcr->TssBase->IoMapBase = NewProcess->IopmOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MAX_SYSCALL_PARAMS 16
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NtSyscallFailure(void)
|
|
|
|
{
|
|
|
|
/* This is the failure function */
|
[NTOS:KE:X64] Improve kernel stack switching on GUI system calls
To be 100% correct and not rely on assumptions, stack switching can only be done when all previous code - starting with the syscall entry point - is pure asm code, since we can't rely on the C compiler to not use stack addresses in a way that is not transparent. Therefore the new code uses the same mechanism as for normal system calls, returning the address of the asm function KiConvertToGuiThread, which is then called like an Nt* function would be called normally. KiConvertToGuiThread then allocated a new stack, switches to it (which is now fine, since all the code is asm), frees the old stack, calls PsConvertToGuiThread (which now will not try to allocate another stack, since we already have one) and then jumps into the middle of KiSystemCallEntry64, where the system call is handled again.
Also simplify KiSystemCallEntry64 a bit by copying the first parameters into the trap frame, avoiding to allocate additional stack space for the call to KiSystemCallHandler, which now overlaps with the space that is allocated for the Nt* function.
Finally fix the locations where r10 and r11 are stored, which is TrapFrame->Rcx and TrapFrame->EFlags, based on the situation in user mode.
2018-02-06 19:52:16 +00:00
|
|
|
return (NTSTATUS)KeGetCurrentThread()->TrapFrame->Rax;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PVOID
|
|
|
|
KiSystemCallHandler(
|
2018-03-08 11:23:45 +00:00
|
|
|
VOID)
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
{
|
[NTOS:KE:X64] Improve kernel stack switching on GUI system calls
To be 100% correct and not rely on assumptions, stack switching can only be done when all previous code - starting with the syscall entry point - is pure asm code, since we can't rely on the C compiler to not use stack addresses in a way that is not transparent. Therefore the new code uses the same mechanism as for normal system calls, returning the address of the asm function KiConvertToGuiThread, which is then called like an Nt* function would be called normally. KiConvertToGuiThread then allocated a new stack, switches to it (which is now fine, since all the code is asm), frees the old stack, calls PsConvertToGuiThread (which now will not try to allocate another stack, since we already have one) and then jumps into the middle of KiSystemCallEntry64, where the system call is handled again.
Also simplify KiSystemCallEntry64 a bit by copying the first parameters into the trap frame, avoiding to allocate additional stack space for the call to KiSystemCallHandler, which now overlaps with the space that is allocated for the Nt* function.
Finally fix the locations where r10 and r11 are stored, which is TrapFrame->Rcx and TrapFrame->EFlags, based on the situation in user mode.
2018-02-06 19:52:16 +00:00
|
|
|
PKTRAP_FRAME TrapFrame;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
PKSERVICE_TABLE_DESCRIPTOR DescriptorTable;
|
|
|
|
PKTHREAD Thread;
|
|
|
|
PULONG64 KernelParams, UserParams;
|
|
|
|
ULONG ServiceNumber, Offset, Count;
|
|
|
|
ULONG64 UserRsp;
|
[NTOS:KE:X64] Improve kernel stack switching on GUI system calls
To be 100% correct and not rely on assumptions, stack switching can only be done when all previous code - starting with the syscall entry point - is pure asm code, since we can't rely on the C compiler to not use stack addresses in a way that is not transparent. Therefore the new code uses the same mechanism as for normal system calls, returning the address of the asm function KiConvertToGuiThread, which is then called like an Nt* function would be called normally. KiConvertToGuiThread then allocated a new stack, switches to it (which is now fine, since all the code is asm), frees the old stack, calls PsConvertToGuiThread (which now will not try to allocate another stack, since we already have one) and then jumps into the middle of KiSystemCallEntry64, where the system call is handled again.
Also simplify KiSystemCallEntry64 a bit by copying the first parameters into the trap frame, avoiding to allocate additional stack space for the call to KiSystemCallHandler, which now overlaps with the space that is allocated for the Nt* function.
Finally fix the locations where r10 and r11 are stored, which is TrapFrame->Rcx and TrapFrame->EFlags, based on the situation in user mode.
2018-02-06 19:52:16 +00:00
|
|
|
|
|
|
|
/* Get a pointer to the trap frame */
|
|
|
|
TrapFrame = (PKTRAP_FRAME)((PULONG64)_AddressOfReturnAddress() + 1 + MAX_SYSCALL_PARAMS);
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Increase system call count */
|
|
|
|
__addgsdword(FIELD_OFFSET(KIPCR, Prcb.KeSystemCalls), 1);
|
|
|
|
|
|
|
|
/* Get the current thread */
|
|
|
|
Thread = KeGetCurrentThread();
|
|
|
|
|
|
|
|
/* Set previous mode */
|
|
|
|
Thread->PreviousMode = TrapFrame->PreviousMode = UserMode;
|
|
|
|
|
|
|
|
/* Save the old trap frame and set the new */
|
|
|
|
TrapFrame->TrapFrame = (ULONG64)Thread->TrapFrame;
|
|
|
|
Thread->TrapFrame = TrapFrame;
|
|
|
|
|
2018-05-15 10:43:37 +00:00
|
|
|
/* We don't have an exception frame yet */
|
|
|
|
TrapFrame->ExceptionFrame = 0;
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Before enabling interrupts get the user rsp from the KPCR */
|
|
|
|
UserRsp = __readgsqword(FIELD_OFFSET(KIPCR, UserRsp));
|
|
|
|
TrapFrame->Rsp = UserRsp;
|
|
|
|
|
|
|
|
/* Enable interrupts */
|
|
|
|
_enable();
|
|
|
|
|
|
|
|
/* If the usermode rsp was not a usermode address, prepare an exception */
|
|
|
|
if (UserRsp > MmUserProbeAddress) UserRsp = MmUserProbeAddress;
|
|
|
|
|
|
|
|
/* Get the address of the usermode and kernelmode parameters */
|
|
|
|
UserParams = (PULONG64)UserRsp + 1;
|
|
|
|
KernelParams = (PULONG64)TrapFrame - MAX_SYSCALL_PARAMS;
|
|
|
|
|
|
|
|
/* Get the system call number from the trap frame and decode it */
|
|
|
|
ServiceNumber = (ULONG)TrapFrame->Rax;
|
|
|
|
Offset = (ServiceNumber >> SERVICE_TABLE_SHIFT) & SERVICE_TABLE_MASK;
|
|
|
|
ServiceNumber &= SERVICE_NUMBER_MASK;
|
|
|
|
|
2019-05-28 09:06:56 +00:00
|
|
|
/* Check for win32k system calls */
|
|
|
|
if (Offset & SERVICE_TABLE_TEST)
|
|
|
|
{
|
|
|
|
ULONG GdiBatchCount;
|
|
|
|
|
|
|
|
/* Read the GDI batch count from the TEB */
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
GdiBatchCount = NtCurrentTeb()->GdiBatchCount;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
GdiBatchCount = 0;
|
|
|
|
}
|
2021-01-05 18:22:21 +00:00
|
|
|
_SEH2_END;
|
2019-05-28 09:06:56 +00:00
|
|
|
|
|
|
|
/* Flush batch, if there are entries */
|
|
|
|
if (GdiBatchCount != 0)
|
|
|
|
{
|
|
|
|
KeGdiFlushUserBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Get descriptor table */
|
|
|
|
DescriptorTable = (PVOID)((ULONG_PTR)Thread->ServiceTable + Offset);
|
|
|
|
|
2018-02-04 22:44:43 +00:00
|
|
|
/* Validate the system call number */
|
|
|
|
if (ServiceNumber >= DescriptorTable->Limit)
|
|
|
|
{
|
|
|
|
/* Check if this is a GUI call */
|
|
|
|
if (!(Offset & SERVICE_TABLE_TEST))
|
|
|
|
{
|
|
|
|
/* Fail the call */
|
|
|
|
TrapFrame->Rax = STATUS_INVALID_SYSTEM_SERVICE;
|
|
|
|
return (PVOID)NtSyscallFailure;
|
|
|
|
}
|
|
|
|
|
2021-06-11 12:29:21 +00:00
|
|
|
/* Convert us to a GUI thread
|
[NTOS:KE:X64] Improve kernel stack switching on GUI system calls
To be 100% correct and not rely on assumptions, stack switching can only be done when all previous code - starting with the syscall entry point - is pure asm code, since we can't rely on the C compiler to not use stack addresses in a way that is not transparent. Therefore the new code uses the same mechanism as for normal system calls, returning the address of the asm function KiConvertToGuiThread, which is then called like an Nt* function would be called normally. KiConvertToGuiThread then allocated a new stack, switches to it (which is now fine, since all the code is asm), frees the old stack, calls PsConvertToGuiThread (which now will not try to allocate another stack, since we already have one) and then jumps into the middle of KiSystemCallEntry64, where the system call is handled again.
Also simplify KiSystemCallEntry64 a bit by copying the first parameters into the trap frame, avoiding to allocate additional stack space for the call to KiSystemCallHandler, which now overlaps with the space that is allocated for the Nt* function.
Finally fix the locations where r10 and r11 are stored, which is TrapFrame->Rcx and TrapFrame->EFlags, based on the situation in user mode.
2018-02-06 19:52:16 +00:00
|
|
|
To be entirely correct. we return KiConvertToGuiThread,
|
|
|
|
which allocates a new stack, switches to it, calls
|
|
|
|
PsConvertToGuiThread and resumes in the middle of
|
|
|
|
KiSystemCallEntry64 to restart the system call handling. */
|
|
|
|
return (PVOID)KiConvertToGuiThread;
|
2018-02-04 22:44:43 +00:00
|
|
|
}
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Get stack bytes and calculate argument count */
|
|
|
|
Count = DescriptorTable->Number[ServiceNumber] / 8;
|
|
|
|
|
2021-01-05 18:22:21 +00:00
|
|
|
_SEH2_TRY
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
{
|
|
|
|
switch (Count)
|
|
|
|
{
|
|
|
|
case 16: KernelParams[15] = UserParams[15];
|
|
|
|
case 15: KernelParams[14] = UserParams[14];
|
|
|
|
case 14: KernelParams[13] = UserParams[13];
|
|
|
|
case 13: KernelParams[12] = UserParams[12];
|
|
|
|
case 12: KernelParams[11] = UserParams[11];
|
|
|
|
case 11: KernelParams[10] = UserParams[10];
|
|
|
|
case 10: KernelParams[9] = UserParams[9];
|
|
|
|
case 9: KernelParams[8] = UserParams[8];
|
|
|
|
case 8: KernelParams[7] = UserParams[7];
|
|
|
|
case 7: KernelParams[6] = UserParams[6];
|
|
|
|
case 6: KernelParams[5] = UserParams[5];
|
|
|
|
case 5: KernelParams[4] = UserParams[4];
|
[NTOS:KE:X64] Improve kernel stack switching on GUI system calls
To be 100% correct and not rely on assumptions, stack switching can only be done when all previous code - starting with the syscall entry point - is pure asm code, since we can't rely on the C compiler to not use stack addresses in a way that is not transparent. Therefore the new code uses the same mechanism as for normal system calls, returning the address of the asm function KiConvertToGuiThread, which is then called like an Nt* function would be called normally. KiConvertToGuiThread then allocated a new stack, switches to it (which is now fine, since all the code is asm), frees the old stack, calls PsConvertToGuiThread (which now will not try to allocate another stack, since we already have one) and then jumps into the middle of KiSystemCallEntry64, where the system call is handled again.
Also simplify KiSystemCallEntry64 a bit by copying the first parameters into the trap frame, avoiding to allocate additional stack space for the call to KiSystemCallHandler, which now overlaps with the space that is allocated for the Nt* function.
Finally fix the locations where r10 and r11 are stored, which is TrapFrame->Rcx and TrapFrame->EFlags, based on the situation in user mode.
2018-02-06 19:52:16 +00:00
|
|
|
case 4:
|
|
|
|
case 3:
|
|
|
|
case 2:
|
|
|
|
case 1:
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-03-08 11:23:45 +00:00
|
|
|
ASSERT(FALSE);
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-03-08 11:23:45 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
{
|
|
|
|
TrapFrame->Rax = _SEH2_GetExceptionCode();
|
|
|
|
return (PVOID)NtSyscallFailure;
|
|
|
|
}
|
2021-01-05 18:22:21 +00:00
|
|
|
_SEH2_END;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
|
|
|
|
return (PVOID)DescriptorTable->Base[ServiceNumber];
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
|
|
|
|
// FIXME: we need to
|
2010-07-24 01:12:13 +00:00
|
|
|
VOID
|
|
|
|
KiSystemService(IN PKTHREAD Thread,
|
|
|
|
IN PKTRAP_FRAME TrapFrame,
|
|
|
|
IN ULONG Instruction)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
2011-09-16 18:39:55 +00:00
|
|
|
__debugbreak();
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NtSetLdtEntries
|
|
|
|
(ULONG Selector1, LDT_ENTRY LdtEntry1, ULONG Selector2, LDT_ENTRY LdtEntry2)
|
|
|
|
{
|
|
|
|
UNIMPLEMENTED;
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
__debugbreak();
|
2010-07-24 01:12:13 +00:00
|
|
|
return STATUS_UNSUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NtVdmControl(IN ULONG ControlCode,
|
|
|
|
IN PVOID ControlData)
|
|
|
|
{
|
[NTOSKRNL/KE/AMD64]
- Fix stack alignment in KiSwitchToBootStack
- Handle ExceptionFrame == NULL in KeContextToTrapFrame and KeTrapFrameToContext
- Implement KiSwapContextInternal
- Fix KiSwapContext and KiThreadStartup
- Implement dispatching of user mode exceptions including in-paging of module data used by the kernel-debugger
- Implement KeInitializeInterrupt, KeConnectInterrupt, KeSynchronizeExecution
- Don't zero more than the actual PCR size in KiInitializePcr
- Add asm function KiInitializeSegments to initialize the segment selectors to proper values
- Initialize system call entrypoints in KiInitializeCpu
- Implement KiDpcInterruptHandler, KiIdleLoop, KiInitializeUserApc, KiSwapProcess, KiSystemCallHandler, KiInitializeContextThread, KiSwapContextResume
- Implement asm functions KiRetireDpcList, KiInterruptDispatch, KiSystemCallEntry64, KiZwSystemService
svn path=/trunk/; revision=55405
2012-02-04 11:32:13 +00:00
|
|
|
/* Not supported */
|
|
|
|
return STATUS_NOT_IMPLEMENTED;
|
2010-07-24 01:12:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|