[MASM] GetModuleFileName Example (Beginner)

Iniciado por ANTRAX, Junio 09, 2010, 12:31:17 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Junio 09, 2010, 12:31:17 PM Ultima modificación: Junio 03, 2013, 11:37:08 AM por Expermicid
Código: asm
; Simple Example of how to use GetModuleFileName in MASM
; Coded By DeadlyVermilion
; For Education Purposes
.386

.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc   ; Needed for GetModuleFileName
includelib \masm32\lib\kernel32.lib    ; Library for Kernel32
include \masm32\include\user32.inc     ; Needed For MessageBox
includelib \masm32\lib\user32.lib      ; Library for User32

.data ;Data Section
MsgBoxCaption  db "File Location",0    ; Caption Used In MessageBox
MsgBoxText       db "This file is located in.",0  ; Text String
mPath byte 256 dup (0) ; Variable in which EXE Path will be stored

.code ; This Is The Section Where The Actual Code Is
start:

invoke GetModuleFileName, 0, offset mPath, 256 ; Invokes GetModuleFileName and stores address in variable mPath

invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK ; MessageBox Displaying The String MsgBoxText
invoke MessageBox, NULL, addr mPath, addr MsgBoxCaption, MB_OK ; MessageBox Displaying the actual Executeable Location
invoke ExitProcess, NULL ; Closes The Application Properly Without Errors
end start