1;++ 2; PROJECT: ReactOS Kernel 3; LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4; PURPOSE: ReactOS AMD64 user mode callback helper 5; COPYRIGHT: Timo Kreuzer (timo.kreuzer@reactos.org) 6;-- 7 8#include <ksamd64.inc> 9 10; 11; NTSTATUS 12; KiUserModeCallout ( 13; _Inout_ PKCALLOUT_FRAME CalloutFrame); 14; 15EXTERN KiUserModeCallout:PROC 16 17.code64 18 19; 20; NTSTATUS 21; KiCallUserMode ( 22; _In_ PVOID *OutputBuffer@<rcx>, 23; _In_ PULONG OutputLength@<rdx>); 24; 25PUBLIC KiCallUserMode 26.PROC KiCallUserMode 27 28 ; Generate a KEXCEPTION_FRAME on the stack 29 ; This is identical to a KCALLOUT_FRAME 30 GENERATE_EXCEPTION_FRAME 31 32 ; Save OutputBuffer and OutputLength 33 mov [rsp + ExOutputBuffer], rcx 34 mov [rsp + ExOutputLength], rdx 35 36 ; Call the C function 37 mov rcx, rsp 38 call KiUserModeCallout 39 40 ; Restore the registers from the KEXCEPTION_FRAME 41 RESTORE_EXCEPTION_STATE 42 43 ; Return 44 ret 45 46.ENDP 47 48; 49; DECLSPEC_NORETURN 50; VOID 51; KiCallbackReturn ( 52; _In_ PVOID Stack, 53; _In_ NTSTATUS Status); 54; 55PUBLIC KiCallbackReturn 56.PROC KiCallbackReturn 57 58 .ENDPROLOG 59 60 ; Restore the stack 61 mov rsp, rcx 62 63 ; Set return status 64 mov eax, edx 65 66 ; Restore the registers from the KEXCEPTION_FRAME 67 RESTORE_EXCEPTION_STATE 68 69 ; Return 70 ret 71 72.ENDP 73 74 75END 76