forked from KolibriOS/kolibrios
4f802a86ba
git-svn-id: svn://kolibrios.org@7696 a494cfbc-eb01-0410-851d-a64ba20cac60
73 lines
1.5 KiB
Plaintext
73 lines
1.5 KiB
Plaintext
(*
|
|
BSD 2-Clause License
|
|
|
|
Copyright (c) 2018-2019, Anton Krotov
|
|
All rights reserved.
|
|
*)
|
|
|
|
MODULE API;
|
|
|
|
IMPORT SYSTEM;
|
|
|
|
|
|
CONST
|
|
|
|
SectionAlignment = 1000H;
|
|
|
|
|
|
VAR
|
|
|
|
eol*: ARRAY 3 OF CHAR;
|
|
base*: INTEGER;
|
|
heap: INTEGER;
|
|
|
|
|
|
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);
|
|
|
|
PROCEDURE [windows-, "user32.dll", "MessageBoxA"] MessageBoxA (hWnd, lpText, lpCaption, uType: INTEGER): INTEGER;
|
|
|
|
|
|
PROCEDURE DebugMsg* (lpText, lpCaption: INTEGER);
|
|
BEGIN
|
|
MessageBoxA(0, lpText, lpCaption, 16)
|
|
END DebugMsg;
|
|
|
|
|
|
PROCEDURE _NEW* (size: INTEGER): INTEGER;
|
|
RETURN HeapAlloc(heap, 8, size)
|
|
END _NEW;
|
|
|
|
|
|
PROCEDURE _DISPOSE* (p: INTEGER): INTEGER;
|
|
BEGIN
|
|
HeapFree(heap, 0, p)
|
|
RETURN 0
|
|
END _DISPOSE;
|
|
|
|
|
|
PROCEDURE init* (reserved, code: INTEGER);
|
|
BEGIN
|
|
eol[0] := 0DX; eol[1] := 0AX; eol[2] := 0X;
|
|
base := code - SectionAlignment;
|
|
heap := GetProcessHeap()
|
|
END init;
|
|
|
|
|
|
PROCEDURE exit* (code: INTEGER);
|
|
BEGIN
|
|
ExitProcess(code)
|
|
END exit;
|
|
|
|
|
|
PROCEDURE exit_thread* (code: INTEGER);
|
|
BEGIN
|
|
ExitThread(code)
|
|
END exit_thread;
|
|
|
|
|
|
END API.
|