flat assembler
Message board for the users of flat assembler.

Index > Windows > command line arguments

Author
Thread Post new topic Reply to topic
pjd



Joined: 15 Jul 2007
Posts: 47
pjd
Does anyone know which api call is used for retrieving command line arguments?
Post 07 Aug 2007, 08:47
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:27; edited 1 time in total
Post 07 Aug 2007, 08:54
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Here's some code:
Code:
local argc:DWORD, argv:DWORD, stringmem:DWORD

     invoke  GetCommandLine
     mov     [stringmem], eax
     ;argv = pointer to array of unicode strings, argc = number of string arguments
     invoke  CommandLineToArgvW, eax, addr argc
     mov     [argv], eax
     .
     .
     .
     invoke  LocalFree, [stringmem]
     invoke  ExitProcess, 0
    
Post 08 Aug 2007, 05:11
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
maybe this more correct (i've not tested it, just by docs):
Code:
     . 
     invoke  GlobalFree,[argv]
     invoke  ExitProcess, 0 
    
Post 08 Aug 2007, 06:10
View user's profile Send private message Visit poster's website Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan
Code:
invoke  LocalFree, [stringmem]    

wrong while
Code:
invoke  GlobalFree,[argv]    

is right.
GetCommandLine returns only pointer on already allocated by loader memory. While CommandLineToArgvW allocates additional memory for all args within commandline. Thus this allocated memory should be freed.

_________________
Any offers?
Post 08 Aug 2007, 07:39
View user's profile Send private message Reply with quote
pjd



Joined: 15 Jul 2007
Posts: 47
pjd
What I really wanted was something that gets one argument at a time and returns a pointer to a null-terminated string like on linux.

that won't be hard to write though.

Is there anything that will show me what important functions are in the api? using msdn is like stumbling blind until the solution appears out of nowhere
Post 08 Aug 2007, 16:33
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
Post 09 Aug 2007, 04:53
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.