Damn it. I tried different way and nothing works... I tried to have similar code from libc.
Here is the getrlimit function from the libc:
Code: Select all
[...]
0x0804845f <main+15>: sub esp,0x30
0x08048462 <main+18>: lea eax,[ebp-24]
0x08048465 <main+21>: mov DWORD PTR [esp+4],eax
0x08048469 <main+25>: mov DWORD PTR [esp],0x2
0x08048470 <main+32>: call 0x8048314 <_init+84>
[...]
(gdb) disass getrlimit
Dump of assembler code for function getrlimit:
0x28125180 <getrlimit+0>: mov eax,0xc2
0x28125185 <getrlimit+5>: int 0x80
0x28125187 <getrlimit+7>: jb 0x2812516c <sl_init+108>
0x28125189 <getrlimit+9>: ret
And here is my program:
Code: Select all
.intel_syntax noprefix
.global _start
.text
_start:
mov ebp,esp
sub esp, 0x30
lea eax,dword ptr [ebp-24]
mov dword ptr [esp+4],eax
mov dword ptr [esp], 0x02
mov eax, 194
int 0x80
mov eax, 0x01
int 0x80
Debugging and looking at the stack:
Code: Select all
(gdb) info reg
[...]
esp 0xbfbfe6b4 0xbfbfe6b4
ebp 0xbfbfe6e4 0xbfbfe6e4
[...]
(gdb) x/2gx 0xbfbfe6e4-24
0xbfbfe6cc: 0x0000000000000000 0x0000000000000000
(gdb)
So, what a hell is wrong ?