The socketcall
system call is a special case, so don't rely on this one to learn the general format. Furthermore, it only exist on x86-32, and other platforms use separate system calls for each functions/procedures of the socket operations (with these platforms, there is no socketcall
, but socket
, bind
, and so on).
For the special case which is socketcall
: it expects __NR_socketcall
in eax
, the sub‑function (ex SYS_SOCKET
, SYS_BIND
, etc) number in ebx
and the address of the other arguments in ecx
. You will have to store an array of as an example, 3 words for the socket operation (creating a socket), store the family in my_array[0]
, the type in my_array[1]
, and the protocol (usually 0) in my_array[2]
, the pass the address of my_array to ecx
(you don't pass the number of element in my_array
in any explicit way, it's implied by the socket sub‑function you call).
You may like these documents:
Now, for other system calls, which are not the socketcall
exception, you just have to get the reference of the correspoding POSIX function (see reference), or of the corresponding description of the function from man(2)
(man(2)
is section of the manual pages, which is dedicated to the system calls), which you may find as an example, here: man-pages section 2. Then, you have to note the order of the arguments. You will pass the system call number in eax
, then all other arguments in the same order as described by either man(2)
or POSIX, to, in order, ebx
, ecx
, edx
, esi
, edi
, ebp
(up to six arguments). The status/result is returned in eax
.
Note the above applies to Linux on Intel architecture only (you guess other processors have other registers), and also note the system call numbers differs between x86-32 and x86-64.