kim taeyun
kim taeyun

Reputation: 1847

print exe file's name assembly

hello I am learning assembly language in windows 7, nasm, alink environment

I wonder how can I popup MessageBoxA with title its filename

what I tried is here

%include "win32n.inc"

extern MessageBoxA
import MessageBoxA user32.dll
extern ExitProcess
import ExitProcess kernel32.dll
segment .data USE32

message db "is opened",0

empty: 
times 128 db 0

segment .bss USE32

var1 resb 32

segment .code USE32

..start:

mov eax,empty
mov ebx, [ebp+4]
mov [eax],ebx

push dword MB_OK
push dword empty
push dword message
push dword 0
call [MessageBoxA]

push dword 0
call [ExitProcess]

I tried [ebp+4] to [ebp], [ebp+8], [ebp+12]

but have no luck.

thanks!

Upvotes: 1

Views: 155

Answers (1)

Jens Björnhager
Jens Björnhager

Reputation: 5649

You can get the path of the executabe by using GetCommandLine. Arguments are not put on stack by the Windows loader.

Upvotes: 1

Related Questions