2020-05-25 22:48:33 +02:00
|
|
|
(*
|
|
|
|
BSD 2-Clause License
|
|
|
|
|
|
|
|
Copyright (c) 2019-2020, Anton Krotov
|
|
|
|
All rights reserved.
|
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE WINAPI;
|
|
|
|
|
|
|
|
IMPORT SYSTEM, API;
|
|
|
|
|
|
|
|
|
|
|
|
CONST
|
|
|
|
|
|
|
|
OFS_MAXPATHNAME* = 128;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
KERNEL = "kernel32.dll";
|
|
|
|
USER = "user32.dll";
|
|
|
|
MSVCRT = "msvcrt.dll";
|
|
|
|
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
TYPE
|
|
|
|
|
|
|
|
DLL_ENTRY* = API.DLL_ENTRY;
|
|
|
|
|
|
|
|
STRING = ARRAY 260 OF CHAR;
|
|
|
|
|
|
|
|
TCoord* = RECORD
|
|
|
|
|
|
|
|
X*, Y*: WCHAR
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
TSmallRect* = RECORD
|
|
|
|
|
|
|
|
Left*, Top*, Right*, Bottom*: WCHAR
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
TConsoleScreenBufferInfo* = RECORD
|
|
|
|
|
|
|
|
dwSize*: TCoord;
|
|
|
|
dwCursorPosition*: TCoord;
|
|
|
|
wAttributes*: WCHAR;
|
|
|
|
srWindow*: TSmallRect;
|
|
|
|
dwMaximumWindowSize*: TCoord
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
TSystemTime* = RECORD
|
|
|
|
|
|
|
|
Year*,
|
|
|
|
Month*,
|
|
|
|
DayOfWeek*,
|
|
|
|
Day*,
|
|
|
|
Hour*,
|
|
|
|
Min*,
|
|
|
|
Sec*,
|
|
|
|
MSec*: WCHAR
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
tm* = RECORD
|
|
|
|
|
|
|
|
sec*,
|
|
|
|
min*,
|
|
|
|
hour*,
|
|
|
|
mday*,
|
|
|
|
mon*,
|
|
|
|
year*,
|
|
|
|
wday*,
|
|
|
|
yday*,
|
|
|
|
isdst*: SYSTEM.CARD32
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
2020-05-25 22:48:33 +02:00
|
|
|
PSecurityAttributes* = POINTER TO TSecurityAttributes;
|
|
|
|
|
|
|
|
TSecurityAttributes* = RECORD
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
nLength*: SYSTEM.CARD32;
|
2020-05-25 22:48:33 +02:00
|
|
|
lpSecurityDescriptor*: INTEGER;
|
2020-10-13 09:58:51 +02:00
|
|
|
bInheritHandle*: SYSTEM.CARD32 (* BOOL *)
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
TFileTime* = RECORD
|
|
|
|
|
|
|
|
dwLowDateTime*,
|
2020-10-13 09:58:51 +02:00
|
|
|
dwHighDateTime*: SYSTEM.CARD32
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
TWin32FindData* = RECORD
|
|
|
|
|
|
|
|
dwFileAttributes*: SYSTEM.CARD32;
|
|
|
|
ftCreationTime*: TFileTime;
|
|
|
|
ftLastAccessTime*: TFileTime;
|
|
|
|
ftLastWriteTime*: TFileTime;
|
|
|
|
nFileSizeHigh*: SYSTEM.CARD32;
|
|
|
|
nFileSizeLow*: SYSTEM.CARD32;
|
|
|
|
dwReserved0*: SYSTEM.CARD32;
|
|
|
|
dwReserved1*: SYSTEM.CARD32;
|
|
|
|
cFileName*: STRING;
|
|
|
|
cAlternateFileName*: ARRAY 14 OF CHAR;
|
|
|
|
dwFileType*: SYSTEM.CARD32;
|
|
|
|
dwCreatorType*: SYSTEM.CARD32;
|
|
|
|
wFinderFlags*: WCHAR
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
OFSTRUCT* = RECORD
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
cBytes*: BYTE;
|
|
|
|
fFixedDisk*: BYTE;
|
2020-05-25 22:48:33 +02:00
|
|
|
nErrCode*: WCHAR;
|
|
|
|
Reserved1*: WCHAR;
|
|
|
|
Reserved2*: WCHAR;
|
|
|
|
szPathName*: ARRAY OFS_MAXPATHNAME OF CHAR
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
POverlapped* = POINTER TO OVERLAPPED;
|
|
|
|
|
|
|
|
OVERLAPPED* = RECORD
|
|
|
|
|
|
|
|
Internal*: INTEGER;
|
|
|
|
InternalHigh*: INTEGER;
|
2020-10-13 09:58:51 +02:00
|
|
|
Offset*: SYSTEM.CARD32;
|
|
|
|
OffsetHigh*: SYSTEM.CARD32;
|
2020-05-25 22:48:33 +02:00
|
|
|
hEvent*: INTEGER
|
|
|
|
|
|
|
|
END;
|
|
|
|
|
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] SetConsoleCursorPosition* (hConsoleOutput, dwCursorPosition: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetConsoleScreenBufferInfo* (hConsoleOutput: INTEGER; ConsoleScreenBufferInfo: TConsoleScreenBufferInfo): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] FillConsoleOutputCharacterA* (hConsoleOutput, cCaracter, nLength, dwWriteCoord, lpNumberOfCharsWritten: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] FillConsoleOutputAttribute* (hConsoleOutput, wAttribute, nLength, dwWriteCoord, lpNumberOfAttrsWritten: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] SetConsoleTextAttribute* (hConsoleOutput, wAttributes: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetStdHandle* (nStdHandle: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] CloseHandle* (hObject: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] WriteFile* (hFile, Buffer, nNumberOfBytesToRead, lpNumberOfBytesRead: INTEGER; lpOverlapped: POverlapped): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] ReadFile* (hFile, Buffer, nNumberOfBytesToRead, lpNumberOfBytesRead: INTEGER; lpOverlapped: POverlapped): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetCommandLineA* (): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GlobalAlloc* (uFlags, dwBytes: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GlobalFree* (hMem: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] ExitProcess* (code: INTEGER);
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetTickCount* (): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] Sleep* (dwMilliseconds: INTEGER);
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] FreeLibrary* (hLibModule: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetProcAddress* (hModule, name: INTEGER): INTEGER;
|
|
|
|
|
|
|
|
PROCEDURE [windows-, KERNEL, ""] LoadLibraryA* (name: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] AllocConsole* (): BOOLEAN;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] FreeConsole* (): BOOLEAN;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetLocalTime* (T: TSystemTime);
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] RemoveDirectoryA* (lpPathName: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] GetFileAttributesA* (lpPathName: INTEGER): SET;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] CreateDirectoryA* (lpPathName: INTEGER; lpSecurityAttributes: PSecurityAttributes): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] FindFirstFileA* (lpFileName: INTEGER; lpFindFileData: TWin32FindData): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] DeleteFileA* (lpFileName: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] FindClose* (hFindFile: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] CreateFileA* (
|
|
|
|
lpFileName, dwDesiredAccess, dwShareMode: INTEGER;
|
|
|
|
lpSecurityAttributes: PSecurityAttributes;
|
|
|
|
dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] OpenFile* (lpFileName: INTEGER; lpReOpenBuff: OFSTRUCT; uStyle: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] SetFilePointer* (hFile, lDistanceToMove, lpDistanceToMoveHigh, dwMoveMethod: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] ReadConsoleA* (hConsoleInput, lpBuffer, nNumberOfCharsToRead, lpNumberOfCharsRead, lpReserved: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] WriteConsoleW* (hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, KERNEL, ""] WriteConsoleA* (hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, USER, ""] MessageBoxA* (hWnd, lpText, lpCaption, uType: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, USER, ""] MessageBoxW* (hWnd, lpText, lpCaption, uType: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, USER, ""] CreateWindowExA* (
|
|
|
|
dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y,
|
|
|
|
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, MSVCRT, ""] time* (ptr: INTEGER): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
2020-10-13 09:58:51 +02:00
|
|
|
PROCEDURE [windows-, MSVCRT, ""] mktime* (time: tm): INTEGER;
|
2020-05-25 22:48:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE SetDllEntry* (process_detach, thread_detach, thread_attach: DLL_ENTRY);
|
|
|
|
BEGIN
|
|
|
|
API.SetDll(process_detach, thread_detach, thread_attach)
|
|
|
|
END SetDllEntry;
|
|
|
|
|
|
|
|
|
|
|
|
END WINAPI.
|