181 lines
3.7 KiB
NASM
181 lines
3.7 KiB
NASM
; syscall_stubs.asm - user-mode INT 0x2E stubs exported by syscall.dll (MASM64)
|
|
; Microsoft x64 ABI: args in RCX, RDX, R8, R9; args 5+6 in R10, R11.
|
|
|
|
INCLUDE syscall_nr.inc ; SYS_* constants
|
|
|
|
.CODE
|
|
|
|
SysExitThread PROC
|
|
mov rax, SYS_EXIT_THREAD
|
|
int 40h
|
|
ret
|
|
SysExitThread ENDP
|
|
|
|
SysExitProcess PROC
|
|
mov rax, SYS_EXIT_PROCESS
|
|
int 40h
|
|
ret
|
|
SysExitProcess ENDP
|
|
|
|
SysYield PROC
|
|
mov rax, SYS_YIELD
|
|
int 40h
|
|
ret
|
|
SysYield ENDP
|
|
|
|
SysSleep PROC ; RCX = milliseconds
|
|
mov rax, SYS_SLEEP
|
|
int 40h
|
|
ret
|
|
SysSleep ENDP
|
|
|
|
SysAlloc PROC ; RCX = size -> RAX = ptr
|
|
mov rax, SYS_ALLOC
|
|
int 40h
|
|
ret
|
|
SysAlloc ENDP
|
|
|
|
SysFree PROC ; RCX = ptr, RDX = size
|
|
mov rax, SYS_FREE
|
|
int 40h
|
|
ret
|
|
SysFree ENDP
|
|
|
|
SysCreateThread PROC ; RCX=entry, RDX=arg, R8=priority -> RAX=handle
|
|
mov rax, SYS_CREATE_THREAD
|
|
int 40h
|
|
ret
|
|
SysCreateThread ENDP
|
|
|
|
SysCloseHandle PROC ; RCX = handle
|
|
mov rax, SYS_CLOSE_HANDLE
|
|
int 40h
|
|
ret
|
|
SysCloseHandle ENDP
|
|
|
|
SysDbgPrint PROC ; RCX = string ptr
|
|
mov rax, SYS_DBG_PRINT
|
|
int 40h
|
|
ret
|
|
SysDbgPrint ENDP
|
|
|
|
SysMutexCreate PROC ; -> RAX = handle
|
|
mov rax, SYS_MUTEX_CREATE
|
|
int 40h
|
|
ret
|
|
SysMutexCreate ENDP
|
|
|
|
SysMutexAcquire PROC ; RCX = handle
|
|
mov rax, SYS_MUTEX_ACQUIRE
|
|
int 40h
|
|
ret
|
|
SysMutexAcquire ENDP
|
|
|
|
SysMutexRelease PROC ; RCX = handle
|
|
mov rax, SYS_MUTEX_RELEASE
|
|
int 40h
|
|
ret
|
|
SysMutexRelease ENDP
|
|
|
|
SysSemCreate PROC ; RCX=initial, RDX=max -> RAX=handle
|
|
mov rax, SYS_SEM_CREATE
|
|
int 40h
|
|
ret
|
|
SysSemCreate ENDP
|
|
|
|
SysSemWait PROC ; RCX = handle
|
|
mov rax, SYS_SEM_WAIT
|
|
int 40h
|
|
ret
|
|
SysSemWait ENDP
|
|
|
|
SysSemSignal PROC ; RCX = handle
|
|
mov rax, SYS_SEM_SIGNAL
|
|
int 40h
|
|
ret
|
|
SysSemSignal ENDP
|
|
|
|
SysEventCreate PROC ; RCX=manualReset, RDX=initialState -> RAX=handle
|
|
mov rax, SYS_EVENT_CREATE
|
|
int 40h
|
|
ret
|
|
SysEventCreate ENDP
|
|
|
|
SysEventSet PROC ; RCX = handle
|
|
mov rax, SYS_EVENT_SET
|
|
int 40h
|
|
ret
|
|
SysEventSet ENDP
|
|
|
|
SysEventWait PROC ; RCX = handle
|
|
mov rax, SYS_EVENT_WAIT
|
|
int 40h
|
|
ret
|
|
SysEventWait ENDP
|
|
|
|
SysQueueCreate PROC ; -> RAX = handle
|
|
mov rax, SYS_QUEUE_CREATE
|
|
int 40h
|
|
ret
|
|
SysQueueCreate ENDP
|
|
|
|
SysQueueSend PROC ; RCX=handle, RDX=*msg, R8=blocking
|
|
mov rax, SYS_QUEUE_SEND
|
|
int 40h
|
|
ret
|
|
SysQueueSend ENDP
|
|
|
|
SysQueueRecv PROC ; RCX=handle, RDX=*msg, R8=blocking
|
|
mov rax, SYS_QUEUE_RECV
|
|
int 40h
|
|
ret
|
|
SysQueueRecv ENDP
|
|
|
|
SysScreenBlit PROC
|
|
; RCX=x, RDX=y, R8=w, R9=h
|
|
; The 5th arg (pixels) is on the stack above the 32-byte shadow space and return address.
|
|
mov r10, [rsp + 40]
|
|
|
|
mov rax, SYS_SCREEN_BLIT
|
|
int 40h
|
|
ret
|
|
SysScreenBlit ENDP
|
|
|
|
SysGetTick PROC ; -> RAX = milliseconds
|
|
mov rax, SYS_GET_TICK
|
|
int 40h
|
|
ret
|
|
SysGetTick ENDP
|
|
|
|
SysOpen PROC ; RCX = *path -> RAX = handle (0 = failure)
|
|
mov rax, SYS_OPEN
|
|
int 40h
|
|
ret
|
|
SysOpen ENDP
|
|
|
|
SysRead PROC ; RCX = handle, RDX = *buf, R8 = size -> RAX = bytes read
|
|
mov rax, SYS_READ
|
|
int 40h
|
|
ret
|
|
SysRead ENDP
|
|
|
|
SysFClose PROC ; RCX = handle
|
|
mov rax, SYS_FCLOSE
|
|
int 40h
|
|
ret
|
|
SysFClose ENDP
|
|
|
|
SysFSeek PROC ; RCX = handle, RDX = offset
|
|
mov rax, SYS_FSEEK
|
|
int 40h
|
|
ret
|
|
SysFSeek ENDP
|
|
|
|
SysFSize PROC ; RCX = handle -> RAX = size in bytes
|
|
mov rax, SYS_FSIZE
|
|
int 40h
|
|
ret
|
|
SysFSize ENDP
|
|
|
|
END
|