Log in

View Full Version : arguments


Anonymous
May 11th, 2003, 17:56
hello,

when setting the program argunts, i set something like "test123" when i run the program, and use GetCommandLine to check its arguments, it does return "c:\myprogram.exe test123" while it should return just test123, am i wrong ?

Anonymous
May 12th, 2003, 02:39
GetCommandLine returns executable with path and parameters. you should extract the parameters yourself. or use CommandLineToArgvW (UNICODE only)

Anonymous
May 12th, 2003, 04:23
the first command line arg is always the executable filename, the programs args start from the second.

Anonymous
May 12th, 2003, 05:36
Hello, as far as i've seen its not like that or im doing something wrong, i've written a program to illustrate what i said:

-- launch.asm --
cmdline db "this is the command line",0
arquivo db "host.exe",0

invoke CreateProcess,addr exefile,addr cmdline,NULL,NULL,NULL,NULL,NULL, NULL,ADDR st_info,ADDR pr_info
-- launch.asm --

-- host.asm --

invoke GetCommandLineA
invoke MessageBox,0,eax,eax,0

-- host.asm --

after running launch.exe, host.exe will give the command line which is "this is the command line" and NOT "host.exe this is the command line"

can u clarify this to me ? am i doing something wrong ?

Anonymous
May 12th, 2003, 05:38
arquivo = exefile in the thread above

Anonymous
May 12th, 2003, 15:15
If your using CreateProcess, you'll get exactly what you are passing to that as your command line. So by passing "this is the command line" in your CreateProcess call, you'll get "this is the command line" from GetCommandLineA.

However, when the OS loads your process, you'll get "host.exe this is the command line" as it prepends the exe name first before calling CreateProcess.

Anonymous
May 12th, 2003, 19:01
ah ok, thanks a lot,
is there any way to get "this is the command line" in ollydbg ? maybe olly can create the process with the CreateProcess api ?

Anonymous
May 13th, 2003, 00:16
Ollydbg does create the process with the CreateProcess API, but always prepends the executable filename onto it, just like Windows does. It would therefore be easier if you did the same.