Steward
分享是一種喜悅、更是一種幸福
程式語言 - Netwide Assembler (NASM) - Assembly (x86) - Hello, world!(sysenter)
參考資訊:
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/constants/syscalls.md
https://reverseengineering.stackexchange.com/questions/2869/how-to-use-sysenter-under-linux
System Call
NR | syscall name | eax | arg0(ebx) | arg1(ecx) | arg2(edx) |
---|---|---|---|---|---|
1 | exit | 1 | int error_code | ||
4 | write | 4 | unsigned int fd | const char *buf | size_t count |
main.s
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | global _start section . data msg db " hello , world!", 10 len equ $ - msg section . text _start : push ebp mov ebp , esp mov eax , 4 mov ebx , 1 mov ecx , msg mov edx , len push ret push ecx push edx push ebp mov ebp , esp sysenter ret : mov eax , 1 mov ebx , 0 push ret push ecx push edx push ebp mov ebp , esp sysenter |
編譯、執行
$ nasm -f elf32 main.s $ gcc -m32 main.o -o main -nostdlib $ ./main hello, world!
P.S. Debian x64環境測試