2 つの作業サンプルを次に示します (Windows 用の FASM 1.70.03 を使用)。
Ansi バージョン、
dll:
library testdll;
uses
windows;
procedure xMain(MSG: PAnsiChar); export; stdcall;
begin
MessageBoxA(0, PAnsiChar(MSG), 'Title', 0);
end;
exports xMain;
begin
end.
EXE:
format PE CONSOLE 4.0
entry start
include 'win32a.inc'
section '.code' code readable executable
start:
invoke xMain, szMSG
invoke ExitProcess, 0
section '.data' data readable writeable
szMSG db 'Message from FASM application!', 0
section '.idata' import data readable writeable
library kernel32, 'kernel32.dll',\
dllfile, 'testdll.dll'
include 'api\kernel32.inc'
import dllfile,\
xMain, 'xMain'
Unicode バージョン、
dll:
library testdll;
uses
windows;
procedure xMain(MSG: PChar); export; stdcall;
begin
MessageBox(0, PChar(MSG), 'Title', 0);
end;
exports xMain;
begin
end.
EXE:
format PE CONSOLE 4.0
entry start
include 'win32w.inc'
section '.code' code readable executable
start:
invoke xMain, szMSG
invoke ExitProcess, 0
section '.data' data readable writeable
szMSG du 'Message from FASM application!', 0
section '.idata' import data readable writeable
library kernel32, 'kernel32.dll',\
dllfile, 'testdll.dll'
include 'api\kernel32.inc'
import dllfile,\
xMain, 'xMain'