reactos/ntoskrnl/ke/amd64
Timo Kreuzer 18b1aafd82 [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.
2020-10-31 14:23:16 +01:00
..
boot.S
context.c [NTOS:KE:X64] Fix bugs in KeContextToTrapFrame and KeTrapFrameToContext 2020-10-31 14:23:16 +01:00
cpu.c
ctxswitch.S
except.c
interrupt.c
irql.c
kiinit.c
krnlinit.c
spinlock.c
stubs.c [NTOS:KE:X64] Improve kernel stack switching on GUI system calls 2020-10-31 14:23:16 +01:00
thrdini.c
trap.S [NTOS:KE:X64] Improve kernel stack switching on GUI system calls 2020-10-31 14:23:16 +01:00