All pastes #809015 Raw Edit

Something

public text v1 · immutable
·published 2007-12-08 03:43 UTC
rendered paste body
.386
.model flat, stdcall
option casemap:none

;include \masm32\include\windows.inc						; Windows Constants (required)
include ..\K32B.INC						; Macros and Procedures used in simplification.

.data
	K32BASE	DD 0					; Handle to Kernel32.DLL in memory
	U32BASE	DD 0					; Handle to User32.DLL returned from LoadLibrary

	USER32DLL	DB "USER32.DLL", 0			; String to be passed to LoadLibrary

	DEFINE_API	LoadLibrary,	"LoadLibraryA"	; Setup the LoadLibrary data
	DEFINE_API	FreeLibrary,	"FreeLibrary"		; Setup the FreeLibrary data
	DEFINE_API	ExitProcess,	"ExitProcess"		; Setup the ExitProcess data
	DEFINE_API	MessageBox,	"MessageBoxA"		; Setup the MessageBox data

	MyTitle	DB "No Imports!", 0			; The title of our MessageBox
	MyMessage	DB "Hello World in 1.50KBs!", 0	; The contents of our MessageBox

.code
start:	K32B	K32BASE					; Get Kernel32.DLL base address and store it
	LdAPI	K32BASE, LoadLibrary				; Obtain LoadLibrary from Kernel32.DLL
	LdAPI	K32BASE, FreeLibrary				; Obtain FreeLibrary from Kernel32.DLL
	LdAPI	K32BASE, ExitProcess				; Obtain ExitProcess from Kernel32.DLL

	ACall	LoadLibrary, OFFSET USER32DLL		; Load User32.DLL into memory
	MOV	U32BASE, EAX					; And store the handle in U32BASE

	LdAPI	U32BASE, MessageBox				; Obtain MessageBox from User32.DLL

								; Display our MessageBox
	ACall	MessageBox, NULL, OFFSET MyMessage, OFFSET MyTitle, MB_OK + MB_ICONINFORMATION

	ACall	FreeLibrary, U32BASE				; Free User32.DLL since we are done with it
	ACall	ExitProcess, NULL				; Exit our application
end start							; Easy, huh?