flat assembler
Message board for the users of flat assembler.
Index
> Windows > Trying to get the command line |
Author |
|
Borsuc 15 Feb 2006, 21:19
Well, you're testing for ';' character AFTER you test the '"' character.. I think that might be the problem, or did I misunderstand something?
EDIT: what's with the movsb there? edi is not initialized to anything there until that point.. maybe you wanted lodsb? ps: i'm not sure, but the command line is not quoted, or is it? ps2: a decent command line reader ignores spaces.. spaces can be either tabs, spaces or both. and you can have multiple space characters one after another, not just one. I think you gotta redesign this |
|||
15 Feb 2006, 21:19 |
|
OzzY 15 Feb 2006, 21:41
I think it was just bug in my code.
Now it works: Code: include '%fasminc%\win32ax.inc' main: invoke GetCommandLine ;get cmd line. Looks like: "prog something" mov esi,eax ;put it in esi cmp byte[esi],'"' ;if user didn't provide command line. eg: clicked on the program icon, it will be quoted... jz exit ;...so exit! @@: cmp byte[esi],' ' ;is it a space? jz @f ;Yes? found! inc esi jmp @b ;Otherwise try again @@: invoke MessageBox,0,esi,esi,0 ;found argument, display it! exit: ret ;exit program .end main Yes, the command line is quoted. Now checked for this. Anyway, it was just a test for a bigger program, and I'll design it better. |
|||
15 Feb 2006, 21:41 |
|
Borsuc 15 Feb 2006, 21:46
it's much more logical right now
I did a command line reader long ago only for test purposes, but it is in C.. if I ever program something in asm with cmd line, i'll probably do the conversion. |
|||
15 Feb 2006, 21:46 |
|
Reverend 16 Feb 2006, 14:13
I'm not 100% sure, but in win 98 if commandline had no white characters there was no quoteing characters. I tested it now on win xp and these chars are always present, but in win 9x? I can't say for sure
|
|||
16 Feb 2006, 14:13 |
|
Borsuc 16 Feb 2006, 17:29
In Win9x I think is like this: if you put commands enclosed with quotes, then they're gonna be there, otherwise they won't!
|
|||
16 Feb 2006, 17:29 |
|
Sem 17 Feb 2006, 06:05
Work with UNICODE string and use
Code: LPWSTR *CommandLineToArgvW( LPCWSTR lpCmdLine, int *pNumArgs ); |
|||
17 Feb 2006, 06:05 |
|
0x4e71 18 Feb 2006, 13:46
Or..
..you can always use __GetMainArgs from old clunky CRTDLL.DLL. Very, very handy. L |
|||
18 Feb 2006, 13:46 |
|
chris 22 Feb 2006, 05:00
or __getmainargs and __wgetmainargs (UNICODE) in msvcrt.dll
TO 0x4e71: I think __GetMainArgs calls __getmainargs with envp set to 0, right? |
|||
22 Feb 2006, 05:00 |
|
0x4e71 22 Feb 2006, 17:56
Hi,
no actually there is a cmdline parser in crtdll itself and __GetMainArgs does take envp as an argument. Sorry I did not post the prototype for __GetMainArgs before. For clarity, here it is: Code: __GetMainArgs( int *argc, char ***argv, char ***envp, int wildcard_flag ) To firsttime users: both __getmainargs and __GetMainArgs are __cdecl of course so the stack has to be cleaned up after the call. +L |
|||
22 Feb 2006, 17:56 |
|
Vortex 22 Feb 2006, 18:52
I coded a procedure to get the command line parameters in console applications :
Code: proc ParseCmdLine,buffer push esi push edi invoke GetCommandLine @@: lea edx,[eax-1] xor eax,eax mov esi,[buffer] lea edi,[esi+256] mov ch,32 scan: inc edx mov cl,byte [edx] or cl,cl jz finish cmp cl,32 je scan inc eax mov [esi],edi add esi,4 restart: mov cl,byte [edx] or cl,cl jz finish cmp cl,ch je end_of_line cmp cl,34 jne @f xor ch,32 jmp next_char @@: mov byte [edi],cl inc edi next_char: inc edx jmp restart end_of_line: mov byte [edi],0 inc edi jmp scan finish: pop edi pop esi ret endp
_________________ Code it... That's all... |
|||||||||||
22 Feb 2006, 18:52 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.