flat assembler
Message board for the users of flat assembler.

Index > Windows > @ScriptDir

Author
Thread Post new topic Reply to topic
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
http://www.autoitscript.com/

Code:
Run("regedit.exe",@ScriptDir)    

What's API to get @ScriptDir in asm?
Not @WorkingDir (GetCurrentDirectory,MAX_PATH,lpBuffer)!

Please, help! Confused

_________________
Memory=8388608
Post 21 Nov 2009, 22:35
View user's profile Send private message ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
try the AUtoScript forums.
Post 22 Nov 2009, 03:26
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
for win32 assembly? Sad

Thanks!
Code:
; GetModulePath function Wink
include '%fasm%\win32ax.inc'
entry start

section '.idata' import data readable writeable
        library kernel32,'KERNEL32.DLL',user32,'USER32.DLL'
        include '%fasm%\api\kernel32.inc'
        include '%fasm%\api\user32.inc'

start:
        invoke GetModuleFileName,NULL,lpFilename,MAX_PATH
        add eax,lpFilename
        mov byte[eax-10],0 ; module.exe
        invoke MessageBox,NULL,lpFilename,'Genuine:',MB_OK
exit:
        invoke ExitProcess,0

        lpFilename dd ?
    
Post 22 Nov 2009, 13:46
View user's profile Send private message ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I think you want this:
Code:
start:
        invoke GetModuleFileName,NULL,filename,MAX_PATH
        mov byte [eax+filename-10], 0 ; module.exe
        invoke MessageBox,NULL,filename,'Genuine:',MB_OK
exit:
        invoke ExitProcess,0

        filename rb MAX_PATH+1    


I know your code worked, but it was just because after lpFilename there was (undeclared) space available.

So, @ScriptDir is equivalent to GetModuleFileName(NULL, ...)?

[edit]If the above question is true you may want this more general solution:
Code:
include 'win32ax.inc'
entry start

start:
      invoke  GetModuleFileName,NULL,filename,MAX_PATH
      mov     ecx, eax
      lea     edi, [filename+eax-1]
      std
      mov     al, '\'
      repne   scasb
      mov     byte [edi+1], 0
      cld ; Important, besides it is documented my system crashed without this.

      invoke  MessageBox,NULL,filename,'Genuine:',MB_OK
      invoke  ExitProcess,0

filename rb MAX_PATH+1

section '.idata' import data readable writeable
        library kernel32,'KERNEL32.DLL',user32,'USER32.DLL'
        include 'api\kernel32.inc'
        include 'api\user32.inc'    
[/edit]
Post 22 Nov 2009, 16:38
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
@LocoDelAssembly, thank You!

I see this code is parsing slash symbol - well, good!
But usally long of file name is known, it's usally module self name.

any knowledge to my favor! Smile
Post 22 Nov 2009, 17:25
View user's profile Send private message ICQ Number 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.

Powered by rwasa.