2021-01-06 21:50:22 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
|
|
* PURPOSE: ReactOS AMD64 user mode callback helper
|
|
|
|
* COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
|
|
*/
|
2018-02-05 00:26:11 +00:00
|
|
|
|
|
|
|
#include <ksamd64.inc>
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/*
|
|
|
|
* NTSTATUS
|
|
|
|
* KiUserModeCallout (
|
|
|
|
* _Inout_ PKCALLOUT_FRAME CalloutFrame);
|
|
|
|
*/
|
2018-02-05 00:26:11 +00:00
|
|
|
EXTERN KiUserModeCallout:PROC
|
|
|
|
|
|
|
|
.code64
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/*
|
|
|
|
* NTSTATUS
|
|
|
|
* KiCallUserMode (
|
|
|
|
* _In_ PVOID *OutputBuffer@<rcx>,
|
|
|
|
* _In_ PULONG OutputLength@<rdx>);
|
|
|
|
*/
|
2018-02-05 00:26:11 +00:00
|
|
|
PUBLIC KiCallUserMode
|
|
|
|
.PROC KiCallUserMode
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Generate a KEXCEPTION_FRAME on the stack */
|
|
|
|
/* This is identical to a KCALLOUT_FRAME */
|
2018-02-05 00:26:11 +00:00
|
|
|
GENERATE_EXCEPTION_FRAME
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Save OutputBuffer and OutputLength */
|
2018-02-05 00:26:11 +00:00
|
|
|
mov [rsp + ExOutputBuffer], rcx
|
|
|
|
mov [rsp + ExOutputLength], rdx
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Call the C function */
|
2018-02-05 00:26:11 +00:00
|
|
|
mov rcx, rsp
|
|
|
|
call KiUserModeCallout
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Restore the registers from the KEXCEPTION_FRAME */
|
2018-02-05 00:26:11 +00:00
|
|
|
RESTORE_EXCEPTION_STATE
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Return */
|
2018-02-05 00:26:11 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
.ENDP
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/*
|
|
|
|
* DECLSPEC_NORETURN
|
|
|
|
* VOID
|
|
|
|
* KiCallbackReturn (
|
|
|
|
* _In_ PVOID Stack,
|
|
|
|
* _In_ NTSTATUS Status);
|
|
|
|
*/
|
2018-02-05 00:26:11 +00:00
|
|
|
PUBLIC KiCallbackReturn
|
|
|
|
.PROC KiCallbackReturn
|
|
|
|
|
|
|
|
.ENDPROLOG
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Restore the stack */
|
2018-02-05 00:26:11 +00:00
|
|
|
mov rsp, rcx
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Set return status */
|
2018-02-05 00:26:11 +00:00
|
|
|
mov eax, edx
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Restore the registers from the KEXCEPTION_FRAME */
|
2018-02-05 00:26:11 +00:00
|
|
|
RESTORE_EXCEPTION_STATE
|
|
|
|
|
2021-01-06 21:50:22 +00:00
|
|
|
/* Return */
|
2018-02-05 00:26:11 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
.ENDP
|
|
|
|
|
|
|
|
|
|
|
|
END
|