add flat assembler toolchain
This commit is contained in:
59
toolchain/fasmw17332/EXAMPLES/DLL/ERRORMSG.ASM
Normal file
59
toolchain/fasmw17332/EXAMPLES/DLL/ERRORMSG.ASM
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
; DLL creation example
|
||||
|
||||
format PE GUI 4.0 DLL
|
||||
entry DllEntryPoint
|
||||
|
||||
include 'win32a.inc'
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
proc DllEntryPoint hinstDLL,fdwReason,lpvReserved
|
||||
mov eax,TRUE
|
||||
ret
|
||||
endp
|
||||
|
||||
; VOID ShowErrorMessage(HWND hWnd,DWORD dwError);
|
||||
|
||||
proc ShowErrorMessage hWnd,dwError
|
||||
local lpBuffer:DWORD
|
||||
lea eax,[lpBuffer]
|
||||
invoke FormatMessage,FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM,0,[dwError],LANG_NEUTRAL,eax,0,0
|
||||
invoke MessageBox,[hWnd],[lpBuffer],NULL,MB_ICONERROR+MB_OK
|
||||
invoke LocalFree,[lpBuffer]
|
||||
ret
|
||||
endp
|
||||
|
||||
; VOID ShowLastError(HWND hWnd);
|
||||
|
||||
proc ShowLastError hWnd
|
||||
invoke GetLastError
|
||||
stdcall ShowErrorMessage,[hWnd],eax
|
||||
ret
|
||||
endp
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel,'KERNEL32.DLL',\
|
||||
user,'USER32.DLL'
|
||||
|
||||
import kernel,\
|
||||
GetLastError,'GetLastError',\
|
||||
SetLastError,'SetLastError',\
|
||||
FormatMessage,'FormatMessageA',\
|
||||
LocalFree,'LocalFree'
|
||||
|
||||
import user,\
|
||||
MessageBox,'MessageBoxA'
|
||||
|
||||
section '.edata' export data readable
|
||||
|
||||
export 'ERRORMSG.DLL',\
|
||||
ShowErrorMessage,'ShowErrorMessage',\
|
||||
ShowLastError,'ShowLastError'
|
||||
|
||||
section '.reloc' fixups data readable discardable
|
||||
|
||||
if $=$$
|
||||
dd 0,8 ; if there are no fixups, generate dummy entry
|
||||
end if
|
24
toolchain/fasmw17332/EXAMPLES/DLL/LASTERR.ASM
Normal file
24
toolchain/fasmw17332/EXAMPLES/DLL/LASTERR.ASM
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
format PE GUI 4.0
|
||||
entry start
|
||||
|
||||
include 'win32a.inc'
|
||||
|
||||
section '.text' code readable executable
|
||||
|
||||
start:
|
||||
invoke SetLastError,0
|
||||
invoke ShowLastError,HWND_DESKTOP
|
||||
invoke ExitProcess,0
|
||||
|
||||
section '.idata' import data readable writeable
|
||||
|
||||
library kernel,'KERNEL32.DLL',\
|
||||
errormsg,'ERRORMSG.DLL'
|
||||
|
||||
import kernel,\
|
||||
SetLastError,'SetLastError',\
|
||||
ExitProcess,'ExitProcess'
|
||||
|
||||
import errormsg,\
|
||||
ShowLastError,'ShowLastError'
|
Reference in New Issue
Block a user