# Copyright 2022-2023 Gabriel Jensen. # This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. # If a copy of the MPL was not distributed with this file, You can obtain one at . .globl zap_syscall zap_syscall: # System calls on IA-32 use the following registers: # eax : System call identifier # ebx : First parameter # ecx : Second parameter # edx : Third parameter # esi : Fourth parameter # edi : Fifth parameter # ebp : Sixth parameter # eax : Return value pushl %ebx # Remember to save the registers. pushl %esi pushl %edi pushl %ebp # Remember that the provided paramters are now further up the stack. movl 0x14(%esp),%eax # Move the first parameter (the identifier) to eax. movl 0x18(%esp),%ebx # Move the remaining parameters into their designated registers. This will read "out of bounds" memory if the number of passed parameters is less than six, but this shouldn't matter as long as the data isn't being used, which it won't be as long as the expected ammount of parameters have been passed. movl 0x1C(%esp),%ecx movl 0x20(%esp),%edx movl 0x24(%esp),%esi movl 0x28(%esp),%edi movl 0x2C(%esp),%ebp int $0x80 # Flying city popl %ebp # Restore the registers. popl %edi popl %esi popl %ebx # No need to move the return value. ret