Commit graph

7 commits

Author SHA1 Message Date
Timo Kreuzer
29721ac552 [NTOS:KE/x64] Fix unwinding in KiUserApcDispatcher
This adds a MACHINE_FRAME to the user mode APC dispatcher stack frame.
2024-12-16 16:19:32 +02:00
Timo Kreuzer
91948dea80 [NTOS:KE/x64] Fix handling of PCR::UserRsp
This is a temporary helper for the system call entry point to store the user mode stack, before switching to the kernel mode stack. Initially it was copied to the trap frame inside KiSystemCallHandler. This has been moved to the system call entry point, but some remnants remained. The problem is that KiSystemCallHandler can be called twice in a system call (when the call is the first GUI call and the stack needs to be extended). In that scenario, when the thread was preempted, a new value could be saved in the PCR before running KiSystemCallHandler again, and then overwriting the proper value with a bogus one from a different thread. This rarely seemed to happen on UP, but happens a lot with SMP.
2024-12-16 16:18:45 +02:00
Timo Kreuzer
34576c7015 [NTOS:KE/x64] Implement KiUserCallbackExit
This is used in KiUserModeCallout instead of KiServiceExit2. The latter is broken, leaks non-volatile registers and will need to be modified to handle an exception frame, which we don't need/have here. It will also use sysret instead of iret and is generally simpler/faster.
Eventually it would be desirable to skip the entire trap frame setup and do everything in KiCallUserMode. This requires some cleanup and special handling for user APC delivery.
2024-04-07 09:13:58 +02:00
Timo Kreuzer
69e8cb635a [NTOS:KE] Fix stack alignment issues 2021-05-28 11:52:42 +02:00
Timo Kreuzer
fdc1261fb7 [NTOS:KE:X64][NTDLL:X64] Implement x64 version of user callback code 2020-10-31 14:23:16 +01:00
Timo Kreuzer
52d1bb5ec9 [NTOS:KE:X64] Simplify KiInitializeUserApc 2020-10-31 14:23:16 +01:00
Timo Kreuzer
aaa86d078e [NTOS:KE:X64] Move KiInitializeUserApc to usercall.c 2020-10-31 14:23:16 +01:00