1 ; ========================
2 ; AcssMicro - System Calls
3 ; ========================
15 add esp, 4 ; // Base address
25 push esi ; // DI and SI must be maintained, CX doesn't
37 #define SYSCALL0(_name,_num) SYSCALL0 _name, _num
38 #define SYSCALL1(_name,_num) SYSCALL1 _name, _num
39 #define SYSCALL2(_name,_num) SYSCALL2 _name, _num
40 #define SYSCALL3(_name,_num) SYSCALL3 _name, _num
41 #define SYSCALL4(_name,_num) SYSCALL4 _name, _num
42 #define SYSCALL5(_name,_num) SYSCALL5 _name, _num
43 #define SYSCALL6(_name,_num) SYSCALL6 _name, _num
45 ;%define SYSCALL_OP jmp 0xCFFF0000
46 %define SYSCALL_OP int 0xAC
48 ; System Call - No Arguments
60 %macro _SYSCALL_HEAD 2
68 %macro _SYSCALL_TAIL 0
75 ; System Call - 1 Argument
83 ; System Call - 2 Arguments
93 ; System Call - 3 Arguments
103 ; System Call - 4 Arguments
116 ; System Call - 5 Arguments
132 ; System Call - 6 Arguments
149 ; // Override the clone syscall
150 #define clone _clone_raw
151 #include "syscalls.s.h"
161 mov ebx, [ebp+12] ; Get new stack pointer
163 ; Check if the new stack is being used
166 ; Modify it to include the calling function (and this)
168 mov eax, [ebp] ; Get old stack frame
169 sub eax, ebp ; Get size
170 sub ebx, eax ; Alter new stack pointer
172 push DWORD [ebp] ; < Source
175 add esp, 4*3 ; Restore stack
176 ; EBX should still be the new stack pointer
177 mov eax, [ebp] ; Save old stack frame pointer in new stack
179 mov eax, [ebp-4] ; Save EBX there too
181 sub ebx, 8 ; Update stack pointer for system
183 ; Quick hack, just this stack frame
185 mov [ebx-4], eax ; Return
186 mov [ebx-8], ebx ; EBP
187 mov DWORD [ebx-12], 0 ; EBX
191 mov edx, ebx ; Save new stack
194 mov ebx, [ebp+8] ; Flags