How does Subsystem for Unix Application on Windows implements System Calls in assembly?
Such as this linux system call int $0x80
.
Does SUA implement something similar? If so, what are the commands?
this particular code is the one I want to change to use on SUA
#cpuid.s Sample program to extract the processor Vendor ID
.section .data
output:
.ascii "The processor Vendor ID is 'xxxxxxxxxxxxx'\n"
.section .text
.globl _start
_start:
movl $0, %eax
cpuid
movl $output, %edi
movl %ebx, 28(%edi)
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax开发者_如何学编程
movl $1, %ebx
movl $output, %ecx
movl $42, %edx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80
It's the Subsystem for Unix, not an Entire Computer Running Linux.
int 0x80 is a way to invoke system calls on Linux. It's an implementation detail as far as POSIX is concerned, and POSIX is really what Linux and SUA have in common. So I'd say that while Linux (on x86) does support 0x80 for system calls, I see no reason why SUA on Windows would need to. That's because SUA isn't a system that includes that level of compatibility with Linux. If you build a program on Linux it may use int 0x80 but you may find it does something quite different if you build it under SUA to achieve the goal of making a system call.
What are you trying to accomplish?
Windows does have system calls, analogous to linux, in order to access kernel services from user-mode. Normally you don't use the syscall
or int
instruction directly though, you use one of the wrappers in ntdll.dll
.
There definitely isn't any 1:1 correlation between linux system calls and windows system calls.
The various subsystems (Win32, e.g. kernel32.dll and user32.dll and POSIX, e.g. the SUA libraries) call ntdll.dll
functions when they need to make syscalls.
精彩评论