|
From: tin.cans.and.string on 19 Apr 2008 14:01 I am having the *damndest* time finding asm-oriented documentation on linux syscalls in general, but port binding in particular. Do any of you know where I can see examples of this being done in ASM?
From: Chuck Crayne on 19 Apr 2008 15:28 On Sat, 19 Apr 2008 11:01:19 -0700 (PDT) tin.cans.and.string(a)gmail.com wrote: > I am having the *damndest* time finding asm-oriented documentation on > linux syscalls in general, but port binding in particular. For everything but port binding, you can download a demonstration graphics game from my web site. For port binding in particular, here is a working snippet: syscall equ int 80h ;initialize listening fd ;create socket descriptor mov [p0],PF_INET mov [p1],SOCK_STREAM mov [p2],0 mov eax,__NR_socketcall mov ebx,SYS_SOCKET mov ecx,sparms syscall mov [fd],eax ;socket file descriptor or eax,eax ;test return code jns ibind ;ok err 302 ;bind to port ibind: mov ecx,[fd] ;socket file descriptor mov [p0],ecx ;socket file descriptor mov [p1],sin ;socket address structure mov [p2],sinl ;length of structure mov eax,__NR_socketcall mov ebx,SYS_BIND mov ecx,sparms syscall or eax,eax ;test return code jns ilistn ;ok err 303 ;listen for connections ilistn: mov ecx,[fd] ;socket file descriptor mov [p0],ecx ;socket file descriptor mov [p1],5 ;max queue length mov eax,__NR_socketcall mov ebx,SYS_LISTEN mov ecx,sparms syscall or eax,eax ;test return code jns tstwrm ;ok err 304 -- Chuck http://www.pacificsites.com/~ccrayne/charles.html
From: tin.cans.and.string on 19 Apr 2008 17:46 On Apr 19, 1:28 pm, Chuck Crayne <ccra...(a)crayne.org> wrote: > For everything but port binding, you can download a demonstration > graphics game from my web site. For port binding in particular, here is > a working snippet: Thank you, Chuck; I really appreicate this. It looks like you've got an include file performing some constant definitions there - can you post that as well, please?
From: Chuck Crayne on 19 Apr 2008 18:41 On Sat, 19 Apr 2008 14:46:48 -0700 (PDT) tin.cans.and.string(a)gmail.com wrote: > It looks like you've got > an include file performing some constant definitions there - can you > post that as well, please? As the file is well over 500 lines, I am reluctant to post it in its entirety, but here are the key definitions: __NR_socketcall = 102 SYS_SOCKET = 1 ;sys_socket(2) SYS_BIND = 2 ;sys_bind(2) SYS_CONNECT = 3 ;sys_connect(2) SYS_LISTEN = 4 ;sys_listen(2) SYS_ACCEPT = 5 ;sys_accept(2) SOCK_STREAM = 1 PF_INET = 2 And the data declarations: ;-------------------------------------------- ;network fields & structures ;-------------------------------------------- fd dd 0 ;listening socket fd paddrl dd 16 ;length of active structure sin dw PF_INET ;address family dw 4206h ;port 1602 dd 0 ;INADDR_ANY dq 0 ;padding sinl = $-sin apin dw 0 ;address family dw 0 ;port dd 0 ;address dq 0 ;padding apinl = $-apin sparms rd 6 ;sys_socketcall parm list -- Chuck http://www.pacificsites.com/~ccrayne/charles.html
From: tin.cans.and.string on 19 Apr 2008 18:53 On Apr 19, 3:46 pm, tin.cans.and.str...(a)gmail.com wrote: > On Apr 19, 1:28 pm, Chuck Crayne <ccra...(a)crayne.org> wrote: > > > For everything but port binding, you can download a demonstration > > graphics game from my web site. For port binding in particular, here is > > a working snippet: > > Thank you, Chuck; I really appreicate this. It looks like you've got > an include file performing some constant definitions there - can you > post that as well, please? Actually, disregard, please - found the generic include file on your website. This is good stuff. Thank you!
|
Next
|
Last
Pages: 1 2 3 Prev: Calling libraries from assembler. Next: OT: Has anyone seen Miss Liberty? |