All pastes #96028 Raw Edit

Something

public text v1 · immutable
#96028 ·published 2006-07-22 16:25 UTC
rendered paste body
.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib


.code

start:
    
	;eax holds return value
	;ebx will hold function addresses
	;ecx will hold string pointers
	;edx will hold NULL

	
	xor eax,eax
	xor ebx,ebx			;zero out the registers
	xor ecx,ecx
	xor edx,edx
	
	jmp short GetLibrary
   
LibraryReturn:
	pop ecx				;get the library string
	mov [ecx + 10], dl		;insert NULL
	
      ;mov ebx, offset LoadLibraryA		;LoadLibraryA(libraryname);
	push ecx			;beginning of user32.dll
	;call ebx			;eax will hold the module handle
        call offset LoadLibraryA
	jmp short FunctionName

FunctionReturn:
	pop ecx				;get the address of the Function string
	xor edx,edx
	mov [ecx + 11],dl		;insert NULL
	push ecx
	push eax
	call offset GetProcAddress
    ;mov ebx, offset GetProcAddress		;GetProcAddress(hmodule,functionname);
	;call ebx			;eax now holds the address of MessageBoxA
	
	jmp short Message
    
MessageReturn:
	pop ecx				;get the message string
	xor edx,edx			
	mov [ecx+3],dl			;insert the NULL

	xor edx,edx
	
	push edx			;MB_OK
	push ecx			;title
	push ecx			;message
	push edx			;NULL window handle
	
	call eax			;MessageBoxA(windowhandle,msg,title,type); Address

ender:
	xor edx,edx
	push eax			
	call offset ExitProcess
       
     ;mov eax, offset ExitProcess 		;exitprocess(exitcode);
	;call eax			;exit cleanly so we don't crash the parent program
	

	;the N at the end of each string signifies the location of the NULL
	;character that needs to be inserted
	
GetLibrary:
	call offset LibraryReturn
	db 'user32.dllN'
FunctionName:
	call offset FunctionReturn
	db 'MessageBoxAN'
Message:
	call offset MessageReturn
	db 'HeyN'


end start