Message board for the users of flat assembler.
> Linux > Command line
Can someone please explain how to get the lenght of last
command line argument. Yes I did look at Fasm source, but
still i don't get it.
|04 Jun 2006, 22:13||
./executable hoho zzzzzz
dword [esp+4*0] = argc = number of arguments = 3 in above sample
dword [esp+4*1] = address of param0, points to string './executable',0 somewhere in the stack space
dword [esp+4*2] = address of param1, points to string 'hoho',0 somewhere in the stack space
dword [esp+4*3] = address of param2, points to string 'zzzzzz',0 somewhere in the stack space
dword [esp+4*4] = 0 end of arguments
dword [esp+4*5] = pointer to first 0-termintated string of environment
dword [esp+4*6] = pointer to second ...
dword [esp+4*...] = 0 end of environment
pop ecx ; number of arguments, is never 0, because at least arg0 = name of executable
mov edi,dword [esp+ecx*4]
; now we have address of string pointing to the last argument with 0-terminator
mov ecx,0FFFFFFFFh ; large enough, string is everytime shorter
mov al,0 ; find 0-terminator
; edx = size of string
AMD64 is similar
dword [rsp+8*0] = argc
qword [rsp+8*1] = argv
qword [rsp+8*(argc+1)]=0 end of arguments
qword [rsp+8*(argc+2)] address of first 0-terminated string of environment
qword [rsp+8*...] = 0 end of environment
mov ecx,dword [rsp]
mov rdi,qword [rsp+8+rcx*8]
Last edited by Feryno on 05 Jun 2006, 12:22; edited 1 time in total
|05 Jun 2006, 07:52||
Yes that was just what i suspected.
But it didn't worked.
I gues I have bun in code,
Tanks, for info.
Now I'm 100% shore.
|05 Jun 2006, 09:29||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.
Website powered by rwasa.