flat assembler
Message board for the users of flat assembler.

Index > Windows > GetCommandLine & ShellExecute

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
MHajduk



Joined: 30 Mar 2006
Posts: 6115
Location: Poland
MHajduk 27 Aug 2010, 18:48
I'm glad to hear that. Image
Post 27 Aug 2010, 18:48
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 27 Aug 2010, 20:31
Code:
...
        cmp word [ebx],'@r'
        jne @f

        invoke ShellExecute,NULL,NULL,'regedit.exe',NULL,NULL,SW_NORMAL
        jmp exit
@@:
        cmp word [ebx],'@@'
        jne @f

        invoke ShellExecute,NULL,NULL,'shutdown.exe','-r -f -t 00',NULL,SW_HIDE
        jmp exit
@@:
        cmp word [ebx],'@:'
        jne @sh

        invoke ShellExecute,NULL,NULL,'shutdown.exe','-s -f -t 00',NULL,SW_HIDE
        jmp exit

@sh:
        invoke ExpandEnvironmentStrings,'%ProgramFiles%',lpDir,MAX_PATH
        invoke ShellExecute,NULL,NULL,lpFile,ebx,lpDir,SW_NORMAL
exit:    

Cool ...


Last edited by semiono on 24 Oct 2010, 20:24; edited 6 times in total
Post 27 Aug 2010, 20:31
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 24 Oct 2010, 20:11
Code:
include '%fasm%\win32ax.inc'
section '.code' executable
start:
        invoke GetCommandLine
               mov [ebx],eax
        invoke GetModuleFileName,NULL,lpFile,MAX_PATH
        invoke lstrlen,lpFile
               sub [ebx],eax
               cmp byte [ebx],' '
               jne @f
               inc ebx
               cmp byte [ebx],'h'
               jne @f
        invoke TileWindows,NULL,MDITILE_HORIZONTAL,NULL,NULL,NULL
               jmp exit
@@:
        invoke TileWindows,NULL,MDITILE_VERTICAL,NULL,NULL,NULL
exit:
        invoke ExitProcess,NULL

.end start

section '.data' readable writable

        lpFile rb MAX_PATH    


Where is the problem? | Always jne @f Confused
Post 24 Oct 2010, 20:11
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 25 Oct 2010, 05:26
semiono,

You didn't initialize ebx, it's dangerous.

Executable name in command line can be enclosed in doublequotes. Module file name isn't.
Post 25 Oct 2010, 05:26
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 198
Location: section '.code' executable
semiono 25 Oct 2010, 20:41
Code:
include '%fasm%\win32ax.inc'
section '.code' executable
start:
        invoke GetCommandLine
               mov ebx,eax
@@:
               cmp byte [ebx],NULL
               je  exec
               cmp byte [ebx],'h'
               je  @f
               cmp byte [ebx],'H'
               je  @f
               inc ebx
               jmp @r
@@:
               inc ebx
               cmp byte [ebx],' '
               je  @r

        invoke TileWindows,NULL,MDITILE_HORIZONTAL,NULL,NULL,NULL
               jmp exit
exec:
        invoke TileWindows,NULL,MDITILE_VERTICAL,NULL,NULL,NULL
exit:
        invoke ExitProcess,NULL

.end start    

MB_OK Smile
Post 25 Oct 2010, 20:41
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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.