flat assembler
Message board for the users of flat assembler.

Index > Windows > read command line and all parameters

Author
Thread Post new topic Reply to topic
thirteen



Joined: 17 Oct 2004
Posts: 15
thirteen 17 Oct 2004, 21:23
hello all, i have a problem and dont know what i have to do, i have written this code:

Code:
include "%fasminc%\win32ax.inc"                           
                                                          
                                                          
TinyDownloader:                                           
        invoke GetCommandLine                             
        mov esi, eax                                      
        inc esi                                           
                                                          
FindSpace:                                                
        cmp byte [esi], 32d                               
        je GetURL                                         
                                                          
        cmp byte [esi], 34d                               
        je Exit                                           
                                                          
        inc esi                                           
        jmp FindSpace                                     
                                                          
GetURL:                                                   
        inc esi                                           
        xor ecx, ecx                                      
        inc ecx                                           
                                                          
FindSemicolon1:                                           
        cmp byte [esi], 59d                               
        je SaveURL                                        
                                                          
        inc esi                                           
        inc ecx                                           
        jmp FindSemicolon1                                
                                                          
SaveURL:                                                  
        inc esi                                           
        push esi                                          
        sub esi, ecx                                      
        invoke lstrcpyn,\                                 
               FileURL,\                                  
               esi,\                                      
               ecx                                        
                                                          
GetSaveAs:                                                
        pop esi                                           
        xor ecx, ecx                                      
        inc ecx                                           
                                                          
FindSemicolon2:                                           
        cmp byte [esi], 59d                               
        je SaveSaveAs                                     
                                                          
        inc esi                                           
        inc ecx                                           
        jmp FindSemicolon2                                
                                                          
SaveSaveAs:                                               
        inc esi                                           
        push esi                                          
        sub esi, ecx                                      
        invoke lstrcpyn,\                                 
               SaveAs,\                                   
               esi,\                                      
               ecx                                        
                                                          
        invoke MessageBox, 0, FileURL, SaveAs, 0          
                                                          
Exit:                                                     
        invoke ExitProcess, 0                             
                                                          
Datas:                                                    
        FileURL     db 255d                               
        SaveAs      db 255d                               
                                                          
                                                          
                                                          
                                                          
        data import                                       
             library kernel32, "KERNEL32.DLL",\           
                     user32, "USER32.DLL"                 
                                                          
             import kernel32,\                            
                    GetCommandLine, "GetCommandLineA",\   
                    lstrcpyn, "lstrcpynA",\               
                    ExitProcess, "ExitProcess"            
                                                          
             import user32,\                              
                    MessageBox, "MessageBoxA"             
        end data                                              


this would be a command line tool, called by this:

Quote:
tool.exe http://whatever.com/yeah.jpg;C:\yeah_downloaded.jpg

the parameters are ending with ";"


But when i run this program with such parameters there is a problem with the first one, please, can anybody help me?

thx at this point, thirteen
Post 17 Oct 2004, 21:23
View user's profile Send private message Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 17 Oct 2004, 22:44
Quote:

http://whatever.com/yeah.jpg;C:\yeah_downloaded.jpg


the link is broken

by the way,
i am advised not to use the ESI , unless i know what i am doing Smile
even if i need to use it, i should push it and pop it later Smile

and by the way also,
here is my command line

http://sulaiman.thefreebizhost.com/software/cmd_parser.rar
Post 17 Oct 2004, 22:44
View user's profile Send private message Visit poster's website Reply with quote
thirteen



Joined: 17 Oct 2004
Posts: 15
thirteen 17 Oct 2004, 22:50
the link is only a example for the parameter, "http://whatever.com/yeah.jpg" is the first parameter ";" shows that the next parameter comes and "C:/yeah_downloaded.jpg" is the last parameter
Post 17 Oct 2004, 22:50
View user's profile Send private message Reply with quote
thirteen



Joined: 17 Oct 2004
Posts: 15
thirteen 17 Oct 2004, 23:56
hehe, me is a dumbass Smile :

Code:
Datas:                     
        FileURL     rb 255d
        SaveAs      rb 255d    


and not:

Code:
Datas:                     
        FileURL     db 255d
        SaveAs      db 255d    


i just startet out with fasm Wink thx anyway
Post 17 Oct 2004, 23:56
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 18 Oct 2004, 02:11
maybe you will have better luck next time...
Post 18 Oct 2004, 02:11
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner 18 Oct 2004, 08:01
http://whatever.com exists Smile

by the way,
i thought fasm treats number default to decimal therefore no need to add a "d" at the back ? unless h or b
Post 18 Oct 2004, 08:01
View user's profile Send private message Visit poster's website Reply with quote
thirteen



Joined: 17 Oct 2004
Posts: 15
thirteen 18 Oct 2004, 13:52
Hmm, dont know, i always set a "d" or "h" behind numbers...i know it from tasm, and when there it is not defined its hex.
Post 18 Oct 2004, 13:52
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.