1/* 2 * PROJECT: ReactOS API Tests 3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later) 4 * PURPOSE: x86 ASM helper functions for syscall tests 5 * COPYRIGHT: Copyright 2024 Timo Kreuzer <timo.kreuzer@reactos.org> 6 */ 7 8#include <asm.inc> 9#include <ks386.inc> 10 11.code 12 13#define STACK_ARGUMENT_SPACE 16*4 14 15 EXTERN _RtlCaptureContext@4:PROC 16 17DoSyscall: 18 mov edx, esp 19 sysenter 20 ret 21 22/* 23 * VOID 24 * DoSyscallAndCaptureContext( 25 * _In_ ULONG64 SyscallNumber, 26 * _Out_ PCONTEXT PreContext, 27 * _Out_ PCONTEXT PostContext); 28 */ 29PUBLIC _DoSyscallAndCaptureContext 30.PROC _DoSyscallAndCaptureContext 31 push ebp 32 mov ebp, esp 33 34 /* Allocate enough space for the system call handler */ 35 sub esp, STACK_ARGUMENT_SPACE 36 37 /* Save the pre-context */ 38 push [ebp + 12] 39 call _RtlCaptureContext@4 40 41 /* Do the system call */ 42 mov eax, [ebp + 8] 43 Call DoSyscall 44 45 /* Save eax */ 46 push eax 47 48 /* Save the post-context */ 49 push dword ptr [ebp + 16] 50 call _RtlCaptureContext@4 51 52 /* Restore eax and save it in the context */ 53 pop eax 54 mov ecx, [ebp + 16] 55 mov [ecx + CsEax], eax 56 57 mov esp, ebp 58 pop ebp 59 ret 60.ENDP 61 62/* 63 * ULONG64 64 * DoSyscallWithUnalignedStack( 65 * _In_ ULONG64 SyscallNumber); 66 */ 67PUBLIC _DoSyscallWithUnalignedStack 68.PROC _DoSyscallWithUnalignedStack 69 push ebp 70 mov ebp, esp 71 72 /* Allocate enough space for the system call handler */ 73 sub esp, STACK_ARGUMENT_SPACE 74 75 /* Do the sysenter */ 76 mov eax, [ebp + 8] 77 sysenter 78 79 mov esp, ebp 80 pop ebp 81 ret 82.ENDP 83 84END 85