Author Topic: linux nasm syscall 11 problem  (Read 6684 times)

nobody

  • Guest
linux nasm syscall 11 problem
« on: July 05, 2005, 12:56:11 PM »
I am having difficulties getting execve (syscall 11) working in Linux NASM, I don't clearly understand what ecx and edx should contain.
I am trying to call an assembly routine from another assembly routine and pass one value.
Here is the (last) code I've used:
.....
   mov eax,11
   mov ebx,j3
   mov ecx,ctr11
   mov edx,dumy
   int 0x80
.....
j3   db   "j3",0,0
ctr11   db   "any value",0,0,0
dumy   db   0,0,0,0,0,0,0,0
.....
and here is the result:
[rene@lt cgi-bin]$ strace ./j2
execve("./j2", ["./j2"], [/* 34 vars */]) = 0
write(1, "This is --- J2 --- \n", 20This is --- J2 ---
)   = 20
execve("/var/www/cgi-bin/j3", [umovestr: Input/output error
0x20796e61, umovestr: Input/output error
0x756c6176, umovestr: Input/output error
0x65], [/* 0 vars */]) = -1 EFAULT (Bad address)
_exit(0)                                = ?
[rene@lt cgi-bin]$

Thank you for your help.

nobody

  • Guest
Re: linux nasm syscall 11 problem
« Reply #1 on: July 06, 2005, 12:07:21 PM »
Thanks to Frank for the answer to this post that I accidently added at the end of another post (syscalls under linux).
Your suggestion works fine and I'm beginning to understand how this call works. Yes, I understand there is no return and that's what I need.

nobody

  • Guest
Re: linux nasm syscall 11 problem
« Reply #2 on: July 06, 2005, 12:29:35 PM »
This is my revised code. j3 is the name of the second assembly routine (called), the value to be passed is a 2 character value that is loaded into 'value_to_pass" at some stage.
Can I optimise (make smaller) anything? Perhaps dumy?
I'm trying to make these 2 routines as fast as possible.
   mov eax,11
   mov ebx,j3
   mov ecx,ctr11
   mov edx,env_strings
   int 0x80   

j3   db   "j3",0,0
dumy   db   0,0,0,0,0,0,0,0
value_to_pass   db   ,0,0
ctr11       dd   j3, value_to_pass,0
env_strings   dd   dumy,0    

Thank you again.