2019-10-06 19:55:12 +02:00
|
|
|
(*
|
2019-03-11 09:59:55 +01:00
|
|
|
BSD 2-Clause License
|
2016-10-24 01:30:27 +02:00
|
|
|
|
2019-10-06 19:55:12 +02:00
|
|
|
Copyright (c) 2018-2019, Anton Krotov
|
2019-03-11 09:59:55 +01:00
|
|
|
All rights reserved.
|
2016-10-24 01:30:27 +02:00
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE API;
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
IMPORT SYSTEM;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
2019-10-06 19:55:12 +02:00
|
|
|
|
|
|
|
CONST
|
|
|
|
|
|
|
|
SectionAlignment = 1000H;
|
|
|
|
|
|
|
|
|
2016-10-24 01:30:27 +02:00
|
|
|
VAR
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
eol*: ARRAY 3 OF CHAR;
|
|
|
|
base*: INTEGER;
|
2019-09-26 22:23:06 +02:00
|
|
|
heap: INTEGER;
|
2019-03-11 09:59:55 +01:00
|
|
|
|
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE [windows-, "kernel32.dll", "ExitProcess"] ExitProcess (code: INTEGER);
|
|
|
|
PROCEDURE [windows-, "kernel32.dll", "ExitThread"] ExitThread (code: INTEGER);
|
|
|
|
PROCEDURE [windows-, "kernel32.dll", "GetProcessHeap"] GetProcessHeap (): INTEGER;
|
|
|
|
PROCEDURE [windows-, "kernel32.dll", "HeapAlloc"] HeapAlloc (hHeap, dwFlags, dwBytes: INTEGER): INTEGER;
|
|
|
|
PROCEDURE [windows-, "kernel32.dll", "HeapFree"] HeapFree(hHeap, dwFlags, lpMem: INTEGER);
|
2016-10-24 01:30:27 +02:00
|
|
|
|
2019-09-26 22:23:06 +02:00
|
|
|
PROCEDURE [windows-, "user32.dll", "MessageBoxA"] MessageBoxA (hWnd, lpText, lpCaption, uType: INTEGER): INTEGER;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
PROCEDURE DebugMsg* (lpText, lpCaption: INTEGER);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2019-03-11 09:59:55 +01:00
|
|
|
MessageBoxA(0, lpText, lpCaption, 16)
|
2016-10-24 01:30:27 +02:00
|
|
|
END DebugMsg;
|
|
|
|
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
PROCEDURE _NEW* (size: INTEGER): INTEGER;
|
2019-09-26 22:23:06 +02:00
|
|
|
RETURN HeapAlloc(heap, 8, size)
|
2016-10-24 01:30:27 +02:00
|
|
|
END _NEW;
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
|
|
|
|
PROCEDURE _DISPOSE* (p: INTEGER): INTEGER;
|
2019-09-26 22:23:06 +02:00
|
|
|
BEGIN
|
|
|
|
HeapFree(heap, 0, p)
|
|
|
|
RETURN 0
|
2016-10-24 01:30:27 +02:00
|
|
|
END _DISPOSE;
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
|
|
|
|
PROCEDURE init* (reserved, code: INTEGER);
|
2016-10-24 01:30:27 +02:00
|
|
|
BEGIN
|
2019-03-11 09:59:55 +01:00
|
|
|
eol[0] := 0DX; eol[1] := 0AX; eol[2] := 0X;
|
2019-10-06 19:55:12 +02:00
|
|
|
base := code - SectionAlignment;
|
2019-09-26 22:23:06 +02:00
|
|
|
heap := GetProcessHeap()
|
2019-03-11 09:59:55 +01:00
|
|
|
END init;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
PROCEDURE exit* (code: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
ExitProcess(code)
|
|
|
|
END exit;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE exit_thread* (code: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
ExitThread(code)
|
|
|
|
END exit_thread;
|
2016-10-24 01:30:27 +02:00
|
|
|
|
|
|
|
|
2019-03-11 09:59:55 +01:00
|
|
|
END API.
|