Generic.Win32.Kernel32.Mod 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. (* Copyright (c) 1994 - 2000 Emil J. Zeller *)
  2. MODULE Kernel32; (** AUTHOR "ejz"; PURPOSE "Definition of the Win32 Kernel32 API used by (Win)Aos"; *)
  3. IMPORT SYSTEM;
  4. CONST
  5. Generic*= TRUE;
  6. (** NIL pointer/address value *)
  7. NULL* = 0;
  8. (** BOOL values *)
  9. False* = NULL; True* = 1;
  10. (** standard handles *)
  11. InvalidHandleValue* = -1; STDInput* = -10; STDOutput* = -11;
  12. STDError* = -12;
  13. (** generic access rights *)
  14. GenericWrite* = 30; GenericRead* = 31;
  15. (** file sharing *)
  16. FileShareRead* = 0; FileShareWrite* = 1; FileShareDelete*=2;
  17. (** file creation *)
  18. CreateAlways* = 2; OpenExisting* = 3;
  19. (** file attributes *)
  20. FileAttributeReadonly* = 0; FileAttributeHidden* = 1;
  21. FileAttributeSystem* = 2; FileAttributeDirectory* = 4;
  22. FileAttributeArchive* = 5; FileAttributeEncrypted* = 6;
  23. FileAttributeNormal* = 7; FileAttributeTemporary* = 8;
  24. FileAttributeSparseFILE* = 9; FileAttributeReparsePoint* = 10;
  25. FileAttributeCompressed* = 11; FileAttributeOffline* = 12;
  26. FileAttributeNotContentIndexed* = 13;
  27. (** file creation flags *)
  28. FileFlagDeleteOnClose*=26;
  29. FileFlagRandomAccess* = 28;
  30. FileFlagWriteThrough*= 31;
  31. (** move method *)
  32. FileBegin* = 0;
  33. (** move file flags *)
  34. MoveFileReplaceExisting* = 0; MoveFileCopyAllowed* = 1; MoveFileWriteThrough*= 3;
  35. (* (* reason for call values *)
  36. DLLProcessDetach = 0; DLLProcessAttach = 1; *)
  37. (** allocation/free type *)
  38. MEMCommit* = 12; MEMReserve* = 13; MEMDecommit* = 14;
  39. MEMRelease* = 15; CreateSuspended* = 2; TLSOutOfIndexes* = -1;
  40. (** heap allocation options *)
  41. HeapNoSerialize* = 2H;
  42. HeapGenerateExceptions* = 4H;
  43. HeapZeroMemory* = 8H;
  44. (** protect (VirtualAlloc) flags *)
  45. PageReadWrite* = 2; PageExecuteReadWrite* = 6;
  46. (** global memory flags *)
  47. GMemMoveable* = 1; GMemShare* = 13;
  48. GMemDDEShare* = GMemShare;
  49. (** maximum length of full path *)
  50. MaxPath* = 260;
  51. (** specifies the type of a drive *)
  52. DriveUnknown* = 0; DriveNoRootDir* = 1; DriveRemovable* = 2;
  53. DriveFixed* = 3; DriveRemote* = 4; DriveCDRom* = 5;
  54. DriveRamDisk* = 6; Infinite* = -1; WaitObject0* = 0;
  55. (** thread context and exception information *)
  56. SizeOf80387Registers* = 80; ExceptionMaximumParameters* = 15;
  57. ExceptionGuardPage* = LONGINT(080000001H);
  58. ExceptionBreakPoint* = LONGINT(080000003H);
  59. ExceptionSingleStep* = LONGINT(080000004H);
  60. ExceptionAccessViolation* = LONGINT(0C0000005H);
  61. ExceptionIllegalInstruction* = LONGINT(0C000001DH);
  62. ExceptionArrayBoundsExceeded* = LONGINT(0C000008CH);
  63. ExceptionFltDenormalOperand* = LONGINT(0C000008DH);
  64. ExceptionFltDivideByZero* = LONGINT(0C000008EH);
  65. ExceptionFltInexactResult* = LONGINT(0C000008FH);
  66. ExceptionFltInvalidOperation* = LONGINT(0C0000090H);
  67. ExceptionFltOverflow* = LONGINT(0C0000091H);
  68. ExceptionFltStackCheck* = LONGINT(0C0000092H);
  69. ExceptionFltUndeflow* = LONGINT(0C0000093H);
  70. ExceptionIntDivideByZero* = LONGINT(0C0000094H);
  71. ExceptionIntOverflow* =LONGINT(0C0000095H);
  72. ExceptionPrivInstruction* = LONGINT(0C0000096H);
  73. ExceptionStackOverflow* = LONGINT(0C00000FDH);
  74. ContextIntel = 16;
  75. ContextControl* = {0, ContextIntel}; (* SS:SP, CS:IP, FLAGS, BP *)
  76. ContextInteger* = {1, ContextIntel}; (* AX, BX, CX, DX, SI, DI *)
  77. ContextSegments* = {2, ContextIntel}; (* DS, ES, FS, GS *)
  78. ContextFloatingPoint* = {3, ContextIntel}; (* 387 state *)
  79. ContextDebugRegisters* = {4, ContextIntel}; (* DB 0-3,6,7 *)
  80. ContextFull* = ContextControl + ContextInteger + ContextSegments;
  81. (** exception frame handler return values *)
  82. ExceptionContinueExecution* = -1; ExceptionContinueSearch* = 0;
  83. ExceptionExecuteHandler* = 1;
  84. (** thread priorities *)
  85. ThreadPriorityIdle* = -15; ThreadPriorityBelowNormal* = -1;
  86. ThreadPriorityNormal* = 0; ThreadPriorityAboveNormal* = 1; ThreadPriorityHighest* = 2;
  87. ThreadPriorityTimeCritical* = 15; ThreadPriorityErrorReturn* = MAX( LONGINT );
  88. (** WaitForSingleObject return values *)
  89. WaitTimeout* = 0102H;
  90. (** SetErrorMode *)
  91. SEMFailCriticalErrors* = 0;
  92. (** DuplicateHandle *)
  93. DuplicateCloseSource* = 0; DuplicateSameAccess* = 1;
  94. (** StartupInfo flags *)
  95. StartFUseShowWindow* = 0; StartFUseSize* = 1; StartFUsePosition* = 2;
  96. (** OSVersionInfo dwPlatformId values *)
  97. VerPlatformWin32s* = 0; VerPlatformWin32Windows* = 1;
  98. VerPlatformWin32NT* = 2;
  99. (** EscapeCommFunction *)
  100. SETXOFF* = 1; SETXON* = 2; SETRTS* = 3; CLRRTS* = 4; SETDTR* = 5;
  101. CLRDTR* = 6; RESETDEV* = 7; SETBREAK* = 8; CLRBREAK* = 9;
  102. (** PurgeComm *)
  103. PurgeTXAbort* = 0; PurgeRXAbort* = 1; PurgeTXClear* = 2;
  104. PurgeRXClear* = 3;
  105. (** SetCommMask *)
  106. EVRXChar* = 0; EVRXFlag* = 1; EVTXEmpty* = 2; EVCTS* = 3;
  107. EVDSR* = 4; EVRLSD* = 5; EVBreak* = 6; EVErr* = 7; EVRing* = 8;
  108. EVPErr* = 9; EVRX80Full* = 10; EVEvent1* = 11; EVEvent2* = 12;
  109. (** GetCommModemStatus *)
  110. MSCTSOn* = 4; MSDSROn* = 5; MSRingOn* = 6; MSRLSDOn* = 7;
  111. (** DCB *)
  112. NoParity* = 0X; OddParity* = 1X; EvenParity* = 2X; MarkParity* = 3X;
  113. SpaceParity* = 4X; OneStopBit* = 0X; One5StopBits* = 1X;
  114. TwoStopBits* = 2X;
  115. (** GetLastError *)
  116. ErrorSuccess* = 0; ErrorFileNotFound* = 2; ErrorAccessDenied* = 5;
  117. ErrorInvalidParameter* = 87;
  118. TYPE
  119. (* OutputStringProc* = PROCEDURE (VAR str: ARRAY OF CHAR); *)
  120. BOOL* = LONGINT;
  121. HANDLE* = ADDRESS; HMODULE* = ADDRESS;
  122. HINSTANCE* = ADDRESS; ATOM* = INTEGER; HGLOBAL* = HANDLE;
  123. LPSTR* = ADDRESS;
  124. (** The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. *)
  125. FileTime* = RECORD
  126. dwLowDateTime*, dwHighDateTime*: LONGINT
  127. END;
  128. (** The FindData structure describes a file found by the FindFirstFile or FindNextFile function. *)
  129. FindData* = RECORD
  130. dwFileAttributes*: SET;
  131. ftCreationTime*, ftLastAccessTime*, ftLastWriteTime*: FileTime;
  132. nFileSizeHigh*, nFileSizeLow*: LONGINT;
  133. dwReserved0*, dwReserved1*: LONGINT;
  134. cFileName*: ARRAY MaxPath OF CHAR;
  135. cAlternateFileName*: ARRAY 14 OF CHAR
  136. END;
  137. (** The SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday,
  138. hour, minute, second, and millisecond. *)
  139. SystemTime* = RECORD
  140. wYear*, wMonth*, wDayOfWeek*, wDay*: INTEGER;
  141. wHour*, wMinute*, wSecond*, wMilliseconds*: INTEGER
  142. END;
  143. (** The SMALL_RECT structure defines the coordinates of the upper left and lower right corners of a rectangle. *)
  144. SmallRect* = RECORD
  145. left*, top*, right*, bottom*: INTEGER
  146. END;
  147. (** Critical-section object. *)
  148. CriticalSection* = RECORD
  149. a, b, c, d, e, f: LONGINT
  150. END;
  151. (** thread context and exception information *)
  152. FloatingSaveArea* = RECORD
  153. ControlWord*, StatusWord*, TagWord*, ErrorOffset*, ErrorSelector*, DataOffset*, DataSelector*: LONGINT;
  154. RegisterArea*: ARRAY SizeOf80387Registers OF SYSTEM.BYTE;
  155. Cr0NpxState*: LONGINT
  156. END;
  157. Context* = RECORD
  158. ContextFlags*: SET;
  159. DR0*, DR1*, DR2*, DR3*, DR6*, DR7*: LONGINT;
  160. FloatSave*: FloatingSaveArea;
  161. GS*, FS*, ES*, DS*: LONGINT;
  162. EDI*, ESI*, EBX*, EDX*, ECX*, EAX*: LONGINT;
  163. BP*, PC*, CS*, FLAGS*, SP*, SS*: LONGINT; (* whereas BP is EBP and SP is ESP *)
  164. END;
  165. ExceptionRecordPtr* = POINTER TO ExceptionRecord;
  166. ExceptionRecord* = RECORD
  167. ExceptionCode*, ExceptionFlags*: LONGINT;
  168. nextExceptionRecord*: ExceptionRecordPtr;
  169. ExceptionAddress*: ADDRESS;
  170. NumberParameters*: LONGINT;
  171. ExceptionInformation*: ARRAY ExceptionMaximumParameters OF LONGINT
  172. END;
  173. ExcpFrmPtr* = ADDRESS;
  174. ExcpFrmHandler* = PROCEDURE {WINAPI} ( VAR excpRec: ExceptionRecord;
  175. excpFrame: ExcpFrmPtr;
  176. VAR context: Context;
  177. dispatch: LONGINT ): LONGINT;
  178. ExcpFrm* = RECORD
  179. link*: ExcpFrmPtr;
  180. handler*: ExcpFrmHandler
  181. END;
  182. (** Synchronization Objects *)
  183. Object* = POINTER TO RECORD
  184. handle*: HANDLE
  185. END;
  186. (** A 64-bit signed integer value. *)
  187. LargeInteger* = RECORD
  188. LowPart*, HighPart*: LONGINT
  189. END;
  190. (** A 64-bit unsigned integer value. *)
  191. ULargeInteger* = LargeInteger;
  192. (* Added by Alexey *)
  193. MemoryStatusEx* = RECORD
  194. dwLength*: LONGINT;
  195. dwMemoryLoad*: LONGINT;
  196. ullTotalPhys*: HUGEINT;
  197. ullAvailPhys*: HUGEINT;
  198. ullTotalPageFile*: HUGEINT;
  199. ullAvailPageFile*: HUGEINT;
  200. ullTotalVirtual*: HUGEINT;
  201. ullAvailVirtual*: HUGEINT;
  202. ullAvailExtendedVirtual*: HUGEINT;
  203. END;
  204. (** CreateThread *)
  205. ThreadProc* = PROCEDURE {WINAPI} ( lpParameter: ANY ): LONGINT;
  206. (** CreateProcess *)
  207. ProcessInformation* = RECORD
  208. hProcess*, hThread*: HANDLE;
  209. dwProcessId*, dwThreadId*: LONGINT
  210. END;
  211. (** CreateProcess, GetStartupInfo *)
  212. StartupInfo* = RECORD
  213. cb*: LONGINT;
  214. lpReserved*, lpDesktop*, lpTitle*: LPSTR;
  215. dwX*, dwY*, dwXSize*, dwYSize*: LONGINT;
  216. dwXCountChars*, dwYCountChars*: LONGINT;
  217. dwFillAttribute*: LONGINT;
  218. dwFlags*: SET;
  219. wShowWindow*, cbReserved2*: INTEGER;
  220. lpReserved2*: ADDRESS;
  221. hStdInput*, hStdOutput*, hStdError*: HANDLE
  222. END;
  223. (** The OSVersionInfo data structure contains operating system version information. *)
  224. OSVersionInfo* = RECORD
  225. dwOSVersionInfoSize*, dwMajorVersion*, dwMinorVersion*, dwBuildNumber*, dwPlatformId*: LONGINT;
  226. szCSDVersion*: ARRAY 128 OF CHAR
  227. END;
  228. Exception* = RECORD
  229. exc*: ExceptionRecord;
  230. cont*: Context
  231. END;
  232. CommTimeouts* = RECORD
  233. ReadIntervalTimeout*, ReadTotalTimeoutMultiplier*, ReadTotalTimeoutConstant*, WriteTotalTimeoutMultiplier*, WriteTotalTimeoutConstant*: LONGINT
  234. END;
  235. DCB* = RECORD
  236. DCBlength*, BaudRate*: LONGINT;
  237. flags*: SET;
  238. wReserved*, XonLim*, XoffLim*: INTEGER;
  239. ByteSize*, Parity*, StopBits*, XonChar*, XoffChar*, ErrorChar*, EofChar*, EvtChar*: CHAR;
  240. wReserved1*: INTEGER
  241. END;
  242. ComStat* = RECORD
  243. status*: SET;
  244. cbInQue*, cbOutQue*: LONGINT
  245. END;
  246. SystemInfo* = RECORD
  247. wProcessorArchitecture*: INTEGER;
  248. wReserved: INTEGER;
  249. dwPageSize*: LONGINT;
  250. lpMinimumApplicationAddress*: LONGINT;
  251. lpMaximumApplicationAddress*: LONGINT;
  252. dwActiveProcessorMask*: LONGINT;
  253. dwNumberOfProcessors*: LONGINT;
  254. dwProcessorType*: LONGINT;
  255. dwAllocationGranularity*: LONGINT;
  256. wProcessorLevel*: INTEGER;
  257. wProcessorRevision*: INTEGER;
  258. END;
  259. (*ALEX 2005.10.18 The TIME_ZONE_INFORMATION as defined in winbase.h*)
  260. TimeZoneInformation* = RECORD
  261. Bias*: LONGINT;
  262. StandardName*: ARRAY 32 OF INTEGER;
  263. StandardDate*: SystemTime;
  264. StandardBias*: LONGINT;
  265. DaylightName*: ARRAY 32 OF INTEGER;
  266. DaylightDate*: SystemTime;
  267. DaylightBias*: LONGINT;
  268. END;
  269. VAR
  270. hInstance-: HINSTANCE; (* init by linker/loader *)
  271. isEXE-: BOOLEAN;
  272. (* the procedure variables getProcAddress and LoadLibrary must be patched by linker / PE loader *)
  273. (** The GetProcAddress function returns the address of the specified exported dynamic-link library (DLL) function.
  274. Use the GetProcAddress Oberon wrapper. *)
  275. getProcAddress-: PROCEDURE {WINAPI} ( hModule: HMODULE; CONST lpProcName: ARRAY OF CHAR ): ADDRESS;
  276. (** The LoadLibrary function maps the specified executable module into the address space of the calling process. *)
  277. LoadLibrary-: PROCEDURE {WINAPI} ( CONST lpLibFileName: ARRAY OF CHAR ): HINSTANCE; (* must be patched by linker / PE loader *)
  278. (** The AllocConsole function allocates a new console for the calling process. *)
  279. AllocConsole-: PROCEDURE {WINAPI} ( ): BOOL;
  280. (** The AttachConsole function attaches the calling process to the console of the specified process. *)
  281. AttachConsole-: PROCEDURE {WINAPI} (in: LONGINT): BOOL;
  282. (**The Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes.*)
  283. Beep-: PROCEDURE {WINAPI} ( dwFreq, dwDuration: LONGINT ): BOOL;
  284. (** The ClearCommBreak function restores character transmission for a specified communications device and places the transmission line in a nonbreak state. *)
  285. ClearCommBreak-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  286. (** The ClearCommError function retrieves information about a communications error and reports the current status of a communications device. *)
  287. ClearCommError-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpErrors: SET; VAR lpStat: ComStat ): BOOL;
  288. (** The CloseHandle function closes an open object handle. *)
  289. CloseHandle-: PROCEDURE {WINAPI} ( hObject: HANDLE ): BOOL;
  290. (** The CopyFile function copies an existing file to a new file. *)
  291. CopyFile-: PROCEDURE {WINAPI} ( VAR lpExistingFileName, lpNewFileName: ARRAY OF CHAR; bFailIfExists: BOOL ): BOOL;
  292. (** The CreateDirectory function creates a new directory. *)
  293. CreateDirectory-: PROCEDURE {WINAPI} ( VAR lpPathName: ARRAY OF CHAR;
  294. lpSecurityAttributes: ANY ): BOOL;
  295. (** The CreateEvent function creates a named or unnamed event object. *)
  296. CreateEvent-: PROCEDURE {WINAPI} ( lpEventAttributes: ANY;
  297. bManualReset, bInitialState: BOOL;
  298. CONST lpName: ARRAY OF CHAR ): HANDLE;
  299. (** The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object:
  300. files, pipes, mailslots, communications resources, disk devices (Windows NT only), consoles, directories (open only) *)
  301. CreateFile-: PROCEDURE {WINAPI} ( CONST lpFileName: ARRAY OF CHAR;
  302. dwDesiredAccess, dwShareMode: SET;
  303. lpSecurityAttributes: ANY;
  304. dwCreationDistribution: LONGINT;
  305. dwFlagsAndAttributes: SET;
  306. hTemplateFile: HANDLE ): HANDLE;
  307. (** The CreateProcess function creates a new process and its primary thread. The new process executes the specified
  308. executable file. *)
  309. CreateProcess-: PROCEDURE {WINAPI} ( CONST lpApplicationName, lpCommandLine: ARRAY OF CHAR;
  310. lpProcessAttributes, lpThreadAttributes: ANY;
  311. bInheritHandles: BOOL;
  312. dwCreationFlags: LONGINT;
  313. lpEnvironment: ANY;
  314. VAR lpCurrentDirectory: ARRAY OF CHAR;
  315. VAR lpStartupInfo: StartupInfo;
  316. VAR lpProcessInformation: ProcessInformation ): BOOL;
  317. (** The CreateThread function creates a thread to execute within the address space of the calling process. *)
  318. CreateThread-: PROCEDURE {WINAPI} ( lpThreadAttributes: ADDRESS;
  319. dwStackSize: LONGINT;
  320. lpStartAddress: ThreadProc;
  321. lpParameter: ANY; dwCreationFlags: SET;
  322. VAR lpThreadId: LONGINT ): HANDLE;
  323. (** The DeleteCriticalSection function releases all resources used by an unowned critical section object. *)
  324. DeleteCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  325. (** The DeleteFile function deletes an existing file. *)
  326. DeleteFile-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR ): BOOL;
  327. (** The DisableThreadLibraryCalls function disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications
  328. for the dynamic-link library (DLL) specified by hLibModule. *)
  329. DisableThreadLibraryCalls-: PROCEDURE {WINAPI} ( hLibModule: HMODULE ): BOOL;
  330. (** The DuplicateHandle function duplicates an object handle. *)
  331. DuplicateHandle-: PROCEDURE {WINAPI} ( hSourceProcessHandle, hSourceHandle, hTargetProcessHandle: HANDLE;
  332. VAR lpTargetHandle: HANDLE;
  333. dwDesiredAccess: SET;
  334. bInheritHandle: BOOL;
  335. dwOptions: SET ): BOOL;
  336. (** The EnterCriticalSection function waits for ownership of the specified critical section object. *)
  337. EnterCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  338. (** The EscapeCommFunction function directs a specified communications device to perform an extended function. *)
  339. EscapeCommFunction-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  340. dwFunc: LONGINT ): BOOL;
  341. (** The ExitProcess function ends a process and all its threads. *)
  342. ExitProcess-: PROCEDURE {WINAPI} ( uExitCode: LONGINT );
  343. (** The ExitThread function ends a thread. *)
  344. ExitThread-: PROCEDURE {WINAPI} ( dwExitCode: LONGINT );
  345. (** The FileTimeToLocalFileTime function converts a file time based on the Coordinated Universal Time (UTC) to a
  346. local file time. *)
  347. FileTimeToLocalFileTime-: PROCEDURE {WINAPI} ( VAR lpFileTime: FileTime;
  348. VAR lpLocalFileTime: FileTime ): BOOL;
  349. (** The FileTimeToSystemTime function converts a 64-bit file time to system time format. *)
  350. FileTimeToSystemTime-: PROCEDURE {WINAPI} ( VAR lpFileTime: FileTime;
  351. VAR lpSystemTime: SystemTime ): BOOL;
  352. (** The FindClose function closes the specified search handle. *)
  353. FindClose-: PROCEDURE {WINAPI} ( hFindFile: HANDLE ): BOOL;
  354. (** The FindFirstFile function searches a directory for a file whose name matches the specified filename. *)
  355. FindFirstFile-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR;
  356. VAR lpFindFileDate: FindData ): HANDLE;
  357. (** The FindNextFile function continues a file search from a previous call to the FindFirstFile function. *)
  358. FindNextFile-: PROCEDURE {WINAPI} ( hFindFile: HANDLE;
  359. VAR lpFindFileDate: FindData ): BOOL;
  360. (** The FlushFileBuffers function clears the buffers for the specified file and causes all buffered data to be written
  361. to the file. *)
  362. FlushFileBuffers-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  363. (** The FreeConsole function detaches the calling process from its console *)
  364. FreeConsole-: PROCEDURE {WINAPI} ( ): BOOL;
  365. (** The FreeLibrary function decrements the reference count of the loaded dynamic-link library (DLL) module.
  366. When the reference count reaches zero, the module is unmapped from the address space of the calling process
  367. and the handle is no longer valid. *)
  368. FreeLibrary-: PROCEDURE {WINAPI} ( hLibModule: HMODULE ): BOOL;
  369. (** The GetCommandLine function returns a pointer to the command-line string for the current process. *)
  370. GetCommandLine-: PROCEDURE {WINAPI} ( ): LPSTR;
  371. (** The GetCommModemStatus function retrieves modem control-register values. *)
  372. GetCommModemStatus-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  373. VAR lpModemStat: SET ): BOOL;
  374. (** The GetCommState function retrieves the current control settings for a specified communications device. *)
  375. GetCommState-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  376. VAR lpDCB: DCB ): BOOL;
  377. (** The GetComputerName function retrieves the NetBIOS name of the local computer. *)
  378. GetComputerName-: PROCEDURE {WINAPI} ( VAR lpBuffer: ARRAY OF CHAR;
  379. VAR lpnSize: LONGINT ): BOOL;
  380. (** The GetCurrentDirectory function retrieves the current directory for the current process. *)
  381. GetCurrentDirectory-: PROCEDURE {WINAPI} ( nBufferLength: LONGINT;
  382. VAR lpBuffer: ARRAY OF CHAR ): LONGINT;
  383. (** The GetConsoleWindow function retrieves the window handle used by the console associated with the calling process. *)
  384. (*
  385. GetConsoleWindow-: PROCEDURE{WINAPI} (): LONGINT ;
  386. (** The GetCurrentProcess function returns a pseudohandle for the current process. *)
  387. not in smaller versions than Win2000!
  388. *)
  389. GetCurrentProcess-: PROCEDURE {WINAPI} ( ): HANDLE;
  390. (** The GetCurrentProcessId function returns the process identifier of the calling process. *)
  391. GetCurrentProcessId-: PROCEDURE {WINAPI} ( ): LONGINT;
  392. (** The GetCurrentThread function returns a pseudohandle for the current thread. *)
  393. GetCurrentThread-: PROCEDURE {WINAPI} ( ): HANDLE;
  394. (** The GetCurrentThreadId function returns the thread identifier of the calling thread. *)
  395. GetCurrentThreadId-: PROCEDURE {WINAPI} ( ): LONGINT;
  396. (** The GetDiskFreeSpace function retrieves information about the specified disk, including the amount of
  397. free space on the disk. *)
  398. GetDiskFreeSpace-: PROCEDURE {WINAPI} ( VAR lpRootPathName: ARRAY OF CHAR;
  399. VAR lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: LONGINT ): BOOL;
  400. (** The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or
  401. network drive. *)
  402. GetDriveType-: PROCEDURE {WINAPI} ( VAR lpRootPathName: ARRAY OF CHAR ): LONGINT;
  403. (** The GetExitCodeProcess function retrieves the termination status of the specified process. *)
  404. GetExitCodeProcess-: PROCEDURE {WINAPI} ( hProcess: HANDLE;
  405. VAR lpExitCode: LONGINT ): BOOL;
  406. (** The GetFileAttributes function returns attributes for a specified file or directory. *)
  407. GetFileAttributes-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR ): SET;
  408. (** The GetFileSize function retrieves the size, in bytes, of the specified file. *)
  409. GetFileSize-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpFileSizeHigh: LONGINT ): LONGINT;
  410. (** The GetFileTime function retrieves the date and time that a file was created, last accessed, and last modified. *)
  411. GetFileTime-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  412. VAR lpCreationTime, lpLastAccessTime, lpLastWriteTime: FileTime ): BOOL;
  413. (** The GetFullPathName function retrieves the full path and filename of a specified file. *)
  414. GetFullPathName-: PROCEDURE {WINAPI} ( CONST lpFileName: ARRAY OF CHAR;
  415. nBufferLength: LONGINT;
  416. VAR lpBuffer: ARRAY OF CHAR;
  417. lpFilePart: LPSTR ): LONGINT;
  418. (** The GetLastError function returns the calling thread's last-error code value. *)
  419. GetLastError-: PROCEDURE {WINAPI} ( ): LONGINT;
  420. (** The GetLocalTime function retrieves the current local date and time. *)
  421. GetLocalTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime );
  422. (** The GetLogicalDriveStrings function retrieves a string containing the drive letters. *) (*ALEX 2005.02.10*)
  423. GetLogicalDriveStrings-: PROCEDURE {WINAPI} ( nBufferLength: LONGINT;
  424. VAR lpBuffer: ARRAY OF CHAR ): LONGINT;
  425. (** The GetModuleFileName function retrieves the full path and filename for the executable file containing the
  426. specified module. *)
  427. (* The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives.
  428. *)
  429. GetLogicalDrives-: PROCEDURE ( ): SET;
  430. GetModuleFileName-: PROCEDURE {WINAPI} ( hModule: HMODULE;
  431. VAR lpFileName: ARRAY OF CHAR;
  432. nSize: LONGINT ): LONGINT;
  433. (** The GetModuleHandle function returns a module handle for the specified module if the file has been mapped
  434. into the address space of the calling process. *)
  435. GetModuleHandle-: PROCEDURE {WINAPI} ( CONST lpModuleName: ARRAY OF CHAR ): HMODULE;
  436. (** The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.*)
  437. GetPrivateProfileString-: PROCEDURE {WINAPI} ( CONST lpAppName: ARRAY OF CHAR;
  438. CONST lpKeyName: ARRAY OF CHAR;
  439. CONST lpDefault: ARRAY OF CHAR;
  440. CONST lpReturnedString: ARRAY OF CHAR;
  441. nSize: LONGINT;
  442. CONST lpFileName: ARRAY OF CHAR): LONGINT;
  443. (** The GetProcessHeap function retrieves a handle to the default heap of the calling process. This handle can then be used in subsequent calls to the heap functions. *)
  444. GetProcessHeap- : PROCEDURE {WINAPI} (): HANDLE;
  445. (** The GetProcessTimes function returns the times spent in kernel mode, user mode ... for the specified process *)
  446. GetProcessTimes- : PROCEDURE {WINAPI} (CONST hProcess: HANDLE; VAR lpCreationTime, lpExitTime, lpKernelTime, lpUserTime: FileTime ): LONGINT;
  447. (** The GetStartupInfo function retrieves the contents of the StartupInfo structure that was specified when
  448. the calling process was created. *)
  449. GetStartupInfo-: PROCEDURE {WINAPI} ( VAR lpStartupInfo: StartupInfo );
  450. (** Retrieves information about the current system. *)
  451. GetSystemInfo-: PROCEDURE {WINAPI} ( VAR lpSystemInfo: SystemInfo );
  452. (** The GetStdHandle function returns a handle for the standard input, standard output, or standard error device. *)
  453. GetStdHandle-: PROCEDURE {WINAPI} ( nStdHandle: LONGINT ): HANDLE;
  454. (** The GetSystemTime function retrieves the current system date and time. The system time is expressed in
  455. Coordinated Universal Time (UTC). *)
  456. GetSystemTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime );
  457. (** The GetTempFileName function creates a name for a temporary file. The filename is the concatenation of
  458. specified path and prefix strings, a hexadecimal string formed from a specified integer, and the .TMP extension. *)
  459. GetTempFileName-: PROCEDURE {WINAPI} ( VAR lpPathName, lpPrefixName: ARRAY OF CHAR;
  460. uUnique: LONGINT;
  461. VAR lpTempFileName: ARRAY OF CHAR ): LONGINT;
  462. (** The GetTempPath function retrieves the path of the directory designated for temporary files. *)
  463. GetTempPath-: PROCEDURE {WINAPI} ( nBufferLength: LONGINT;
  464. VAR lpBuffer: ARRAY OF CHAR ): LONGINT;
  465. (** The GetThreadContext function retrieves the context of the specified thread. *)
  466. GetThreadContext-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  467. VAR lpContext: Context ): BOOL;
  468. (** The GetThreadPriority function returns the priority value for the specified thread. This value, together with
  469. the priority class of the thread's process, determines the thread's base-priority level. *)
  470. GetThreadPriority-: PROCEDURE {WINAPI} ( hThread: HANDLE ): LONGINT;
  471. (** The GetThreadTimes function returns the times spent in kernel mode, user mode ... specified thread. *)
  472. GetThreadTimes-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  473. VAR lpCreationTime, lpExitTime, lpKernelTime, lpUserTime: FileTime ): LONGINT; (*ALEX 2005.12.12*)
  474. (** The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. *)
  475. GetTickCount-: PROCEDURE {WINAPI} ( ): LONGINT;
  476. (** The GetTimeZoneInformation function retrieves information about timezone setup. *) (*ALEX 2005.10.18*)
  477. GetTimeZoneInformation-: PROCEDURE {WINAPI} ( VAR lpTimeZoneInformation: TimeZoneInformation ): LONGINT;
  478. (** The GetWindowsDir function retrieves the path of the Windows directory. *) (*ALEX 2006.06.05*)
  479. GetWindowsDirectory-: PROCEDURE {WINAPI} ( VAR lpBuffer: ARRAY OF CHAR; nBufferLength: LONGINT ): LONGINT;
  480. (** The GetVersion function returns the current version number of the operating system. *)
  481. GetVersion-: PROCEDURE {WINAPI} ( ): LONGINT;
  482. (** The GetVersionEx function obtains extended information about the version of the operating system that is
  483. currently running. *)
  484. GetVersionEx-: PROCEDURE {WINAPI} ( VAR lpVersionInfo: OSVersionInfo ): BOOL;
  485. (*The GetVolumeInformation function retrieves information about a file system and volume that have a specified
  486. root directory. *)
  487. GetVolumeInformation-: PROCEDURE {WINAPI} ( VAR lpRootPathName: ARRAY OF CHAR;
  488. VAR lpVolumeNameBuffer: ARRAY OF CHAR;
  489. nVolumeNameSize: LONGINT;
  490. VAR lpVolumeSerialNumber: LONGINT;
  491. VAR lpMaximumComponentLength: LONGINT;
  492. VAR lpFileSystemFlags: LONGINT;
  493. VAR lpFileSystemNameBuffer: ARRAY OF CHAR;
  494. nFileSystemNameSize: LONGINT ): LONGINT;
  495. (** The GlobalAddAtom function adds a character string to the global atom table and returns a unique value
  496. (an atom) identifying the string. *)
  497. GlobalAddAtom-: PROCEDURE {WINAPI} ( VAR lpString: ARRAY OF CHAR ): ATOM;
  498. (** The GlobalAlloc function allocates the specified number of bytes from the heap. *)
  499. GlobalAlloc-: PROCEDURE {WINAPI} ( uFlags: SET; dwBytes: LONGINT ): HGLOBAL;
  500. (** The GlobalDeleteAtom function decrements the reference count of a global string atom. *)
  501. GlobalDeleteAtom-: PROCEDURE {WINAPI} ( nAtom: ATOM ): ATOM;
  502. (** The GlobalLock function locks a global memory object and returns a pointer to the first byte of the
  503. object's memory block. *)
  504. GlobalLock-: PROCEDURE {WINAPI} ( hMem: HGLOBAL ): ADDRESS;
  505. (* Added by Alexey *)
  506. GlobalMemoryStatusEx-: PROCEDURE {WINAPI} (VAR lpBuffer: MemoryStatusEx): BOOL;
  507. (** The GlobalReAlloc function changes the size or attributes of a specified global memory object. *)
  508. GlobalReAlloc-: PROCEDURE {WINAPI} ( hMem: HGLOBAL; dwBytes: LONGINT;
  509. uFlags: SET ): HGLOBAL;
  510. (** The GlobalSize function retrieves the current size, in bytes, of the specified global memory object. *)
  511. GlobalSize-: PROCEDURE {WINAPI} ( hMem: HGLOBAL ): LONGINT;
  512. (** The GlobalUnlock function decrements the lock count associated with a memory object that was allocated with
  513. the GMEM_MOVEABLE flag. *)
  514. GlobalUnlock-: PROCEDURE {WINAPI} ( hMem: HGLOBAL ): BOOL;
  515. (** The HeapAlloc function allocates a block of memory from a heap. The allocated memory is not movable. *)
  516. HeapAlloc-: PROCEDURE {WINAPI} ( hHeap: HANDLE; dwFlags: LONGINT; size: SIZE): ADDRESS;
  517. (** The HeapFree function frees a memory block allocated from a heap by the HeapAlloc or HeapReAlloc function. *)
  518. HeapFree-: PROCEDURE {WINAPI} ( hHeap: HANDLE; dwFlags: LONGINT; lpMem: ADDRESS): ADDRESS;
  519. (** The InitializeCriticalSection function initializes a critical section object. *)
  520. InitializeCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  521. (** The InterlockedDecrement function both decrements (decreases by one) the value of the specified 32-bit
  522. variable and checks the resulting value. *)
  523. InterlockedDecrement-: PROCEDURE {WINAPI} ( VAR lpAddend: LONGINT ): LONGINT;
  524. (** The InterlockedIncrement function both increments (increases by one) the value of the specified 32-bit variable
  525. and checks the resulting value. *)
  526. InterlockedIncrement-: PROCEDURE {WINAPI} ( VAR lpAddend: LONGINT ): LONGINT;
  527. (** The LeaveCriticalSection function releases ownership of the specified critical section object. *)
  528. LeaveCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  529. (** The LocalFileTimeToFileTime function converts a local file time to a file time based on the Coordinated
  530. Universal Time (UTC). *)
  531. LocalFileTimeToFileTime-: PROCEDURE {WINAPI} ( VAR lpLocalFileTime: FileTime;
  532. VAR lpFileTime: FileTime ): BOOL;
  533. (** The MoveFileEx function renames an existing file or directory. *)
  534. MoveFileEx-: PROCEDURE {WINAPI} ( VAR lpExistingFileName, lpNewFileName: ARRAY OF CHAR;
  535. dwFlags: SET ): BOOL;
  536. (** The OutputDebugString function sends a string to the debugger for the current application. *)
  537. outputDebugString-: PROCEDURE {WINAPI} ( CONST lpOutputString: ARRAY OF CHAR );
  538. (* The IsDebuggerPresent Function determines whether the calling process is being debugged by a user-mode debugger. *)
  539. IsDebuggerPresent-: PROCEDURE {WINAPI}(): BOOL;
  540. (** The PurgeComm function discards all characters from the output or input buffer of a specified communications resource. *)
  541. PurgeComm-: PROCEDURE {WINAPI} ( hFile: HANDLE; dwFlags: SET ): BOOL;
  542. (** The QueryDosDevice function retrieves information about MS-DOS device names. *)
  543. QueryDosDevice-: PROCEDURE {WINAPI} ( lpDeviceName: ARRAY OF CHAR;
  544. VAR lpTargetPath: ARRAY OF CHAR;
  545. ucchMax: LONGINT ): LONGINT;
  546. (** The QueryPerformanceCounter function retrieves the current value of the high-resolution
  547. performance counter, if one exists. *)
  548. QueryPerformanceCounter-: PROCEDURE {WINAPI} ( VAR lpPerformaceCount: LargeInteger ): BOOL;
  549. (** The QueryPerformanceFrequency function retrieves the frequency of the high-resolution
  550. performance counter, if one exists. *)
  551. QueryPerformanceFrequency-: PROCEDURE {WINAPI} ( VAR lpFrequency: LargeInteger ): BOOL;
  552. (** Retrieves the cycle time for the specified thread (both user and kernel mode, Windows Vista and newer) *)
  553. QueryThreadCycleTime- : PROCEDURE {WINAPI} (hThread : HANDLE; VAR cycleTime : HUGEINT) : BOOL;
  554. (** The ReadFile function reads data from a file, starting at the position indicated by the file pointer. *)
  555. ReadFile-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  556. VAR lpBuffer: ARRAY OF SYSTEM.BYTE;
  557. nNumberOfBytesToRead: LONGINT;
  558. VAR lpNumberOfBytesRead: LONGINT;
  559. lpOverlapped: ANY ): BOOL;
  560. (** The ReadProcessMemory function reads data from an area of memory in a specified process. *)
  561. ReadProcessMemory-: PROCEDURE {WINAPI} ( hProcess: HANDLE;
  562. lpBaseAddress: ADDRESS;
  563. VAR lpBuffer: ARRAY OF SYSTEM.BYTE;
  564. nSize: LONGINT;
  565. VAR lpNumberOfBytesRead: LONGINT ): BOOL;
  566. (** The RemoveDirectory function deletes an existing empty directory. *)
  567. RemoveDirectory-: PROCEDURE {WINAPI} ( VAR lpPathName: ARRAY OF CHAR ): BOOL;
  568. (** The ResetEvent function sets the state of the specified event object to nonsignaled. *)
  569. ResetEvent-: PROCEDURE {WINAPI} ( hEvent: HANDLE ): BOOL;
  570. (** The ResumeThread function decrements a thread's suspend count. *)
  571. ResumeThread-: PROCEDURE {WINAPI} ( hThread: HANDLE ): LONGINT;
  572. (** The SearchPath function searches for the specified file. *)
  573. SearchPath-: PROCEDURE {WINAPI} ( CONST lpPath, lpFileName, lpExtension: ARRAY OF CHAR;
  574. nBufferLength: LONGINT;
  575. VAR lpBuffer: ARRAY OF CHAR;
  576. VAR lpFilePart: LPSTR ): LONGINT;
  577. (** The SetCommBreak function suspends character transmission for a specified communications device and places the transmission line in a break state until the ClearCommBreak function is called. *)
  578. SetCommBreak-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  579. (** The SetCommMask function specifies a set of events to be monitored for a communications device. *)
  580. SetCommMask-: PROCEDURE {WINAPI} ( hFile: HANDLE; dwEvtMask: SET ): BOOL;
  581. (** The SetCommState function configures a communications device according to the specifications in a device-control block (a DCB structure)*)
  582. SetCommState-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  583. VAR lpDCB: DCB ): BOOL;
  584. (** The SetCommTimeouts function sets the time-out parameters for all read and write operations on a specified communications device. *)
  585. SetCommTimeouts-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  586. VAR lpCommTimeouts: CommTimeouts ): BOOL;
  587. (** the SetConsoleCursorPosition sets the cursor position in the specified console screen buffer. *)
  588. SetConsoleCursorPosition-: PROCEDURE {WINAPI} ( hConsoleOutput: HANDLE; dwCursorPosition: (* imitate Coord=RECORD x,y: INTEGER END; *) LONGINT ): BOOL;
  589. (** The SetConsoleScreenBufferSize function changes the size of the specified console screen buffer. *)
  590. SetConsoleScreenBufferSize-: PROCEDURE {WINAPI} ( hConsoleOuput: HANDLE;
  591. dwSize: LONGINT ): BOOL;
  592. (** The SetConsoleTitle function sets the title bar string for the current console window. *)
  593. SetConsoleTitle-: PROCEDURE {WINAPI} ( VAR lpConsoleTitle: ARRAY OF CHAR ): BOOL;
  594. (** The SetConsoleWindowInfo function sets the current size and position of a console screen buffer's window. *)
  595. SetConsoleWindowInfo-: PROCEDURE {WINAPI} ( hConsoleOuput: HANDLE;
  596. bAbsolute: BOOL;
  597. VAR lpConsoleWindow: SmallRect ): BOOL;
  598. (** The SetCurrentDirectory function changes the current directory for the current process. *)
  599. SetCurrentDirectory-: PROCEDURE {WINAPI} ( VAR lpPathName: ARRAY OF CHAR ): BOOL;
  600. (** The SetErrorMode function controls whether the system will handle the specified types of serious errors,
  601. or whether the process will handle them. *)
  602. SetErrorMode-: PROCEDURE {WINAPI} ( uMode: SET ): SET;
  603. (** The SetEndOfFile function moves the end-of-file (EOF) position for the specified file to the current position of the file pointer. *)
  604. SetEndOfFile-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  605. (** The SetEvent function sets the state of the specified event object to signaled. *)
  606. SetEvent-: PROCEDURE {WINAPI} ( hEvent: HANDLE ): BOOL;
  607. (** The SetFileAttributes function sets a file's attributes. *)
  608. SetFileAttributes-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR;
  609. dwFileAttributes: SET ): BOOL;
  610. (** The SetFilePointer function moves the file pointer of an open file. *)
  611. SetFilePointer-: PROCEDURE {WINAPI} ( hFile: HANDLE; lDistanceToMove: LONGINT;
  612. VAR lpDistanceToMoveHigh: LONGINT;
  613. dwMoveMethod: LONGINT ): LONGINT;
  614. (** The SetFileTime function sets the date and time that a file was created, last accessed, or last modified. *)
  615. SetFileTime-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  616. VAR lpCreationTime, lpLastAccessTime, lpLastWriteTime: FileTime ): BOOL;
  617. (** The SetLocalTime function sets the current local time and date. *)
  618. SetLocalTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime ): BOOL;
  619. (** The SetThreadContext function sets the context in the specified thread. *)
  620. SetThreadContext-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  621. VAR lpContext: Context ): BOOL;
  622. (** The SetThreadPriority function sets the priority value for the specified thread. *)
  623. SetThreadPriority-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  624. nPriority: LONGINT ): BOOL;
  625. (** The SetupComm function initializes the communications parameters for a specified communications device. *)
  626. SetupComm-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  627. dwInQueue, dwOutQueue: LONGINT ): BOOL;
  628. (** The Sleep function suspends the execution of the current thread for a specified interval. *)
  629. Sleep-: PROCEDURE {WINAPI} ( dwMilliseconds: LONGINT );
  630. (** The SuspendThread function suspends the specified thread. *)
  631. SuspendThread-: PROCEDURE {WINAPI} ( hThread: HANDLE ): LONGINT;
  632. (** The SystemTimeToFileTime function converts a system time to a file time. *)
  633. SystemTimeToFileTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime;
  634. VAR lpFileTime: FileTime ): BOOL;
  635. (** The TerminateThread function terminates a thread. *)
  636. TerminateThread-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  637. dwExitCode: LONGINT ): BOOL;
  638. TlsAlloc-: PROCEDURE {WINAPI} ( ): LONGINT;
  639. TlsFree-: PROCEDURE {WINAPI} ( dwTlsIndex: LONGINT ): BOOL;
  640. TlsGetValue-: PROCEDURE {WINAPI} ( dwTlsIndex: LONGINT ): LONGINT;
  641. TlsSetValue-: PROCEDURE {WINAPI} ( dwTlsIndex, lpTlsValue: LONGINT ): BOOL;
  642. (** The TryEnterCriticalSection function attempts to enter a critical section without blocking. *)
  643. TryEnterCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection ): BOOL;
  644. (** The VirtualAlloc function reserves or commits a region of pages in the virtual address space of the calling process. *)
  645. VirtualAlloc-: PROCEDURE {WINAPI} ( lpAddress: ADDRESS; dwSize: LONGINT;
  646. flAllocationType, flProtect: SET ): ADDRESS;
  647. (** The VirtualFree function releases or decommits (or both) a region of pages within the virtual address space of the
  648. calling process. *)
  649. VirtualFree-: PROCEDURE {WINAPI} ( lpAddress: ADDRESS; dwSize: LONGINT;
  650. dwFreeType: SET ): BOOL;
  651. (** The WaitForSingleObject function returns when one of the following occurs:
  652. The specified object is in the signaled state.
  653. The time-out interval elapses. *)
  654. WaitForSingleObject-: PROCEDURE {WINAPI} ( hHandle: HANDLE;
  655. dwMilliseconds: LONGINT ): LONGINT;
  656. (** The WriteFile function writes data to a file and is designed for both synchronous and asynchronous operation. *)
  657. WriteFile-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  658. CONST lpBuffer: ARRAY OF SYSTEM.BYTE;
  659. nNumberOfBytesToWrite: LONGINT;
  660. VAR lpNumberOfBytesWritten: LONGINT;
  661. lpOverlapped: ANY ): BOOL;
  662. (** Thread abort notifier, parameter is the threads id. Note this should only be used in modules which
  663. can't use the exception handling mechanism provided by module Exceptions. *)
  664. (** Method used to write text to the Console. *)
  665. OutputString*: PROCEDURE ( CONST a: ARRAY OF CHAR );
  666. (* OutputString*: OutputStringProc; *)
  667. Shutdown*: PROCEDURE ( code: LONGINT );
  668. (** Wrapper for getProcAddress. *)
  669. PROCEDURE GetProcAddress*( hModule: HMODULE; procName: ARRAY OF CHAR; VAR adr: ADDRESS );
  670. BEGIN
  671. adr := getProcAddress( hModule, procName )
  672. END GetProcAddress;
  673. (** Copy a zero-terminated string from address lpString. *)
  674. PROCEDURE CopyString*( lpString: LPSTR; VAR str: ARRAY OF CHAR );
  675. VAR i: LONGINT; ch: CHAR;
  676. BEGIN
  677. i := 0;
  678. IF lpString # NULL THEN
  679. SYSTEM.GET( lpString, ch );
  680. WHILE ch # 0X DO
  681. str[i] := ch; INC( i ); INC( lpString ); SYSTEM.GET( lpString, ch )
  682. END
  683. END;
  684. str[i] := 0X
  685. END CopyString;
  686. PROCEDURE OutputDebugString*( CONST str: ARRAY OF CHAR );
  687. BEGIN
  688. outputDebugString( str );
  689. END OutputDebugString;
  690. PROCEDURE NoOutputString(CONST str: ARRAY OF CHAR);
  691. BEGIN
  692. END NoOutputString;
  693. PROCEDURE SendToDebugger*(str: ARRAY OF CHAR; x: LONGINT );
  694. VAR s: ARRAY 16 OF CHAR;
  695. d, i: LONGINT;
  696. BEGIN
  697. outputDebugString( str ); s[8] := 0X;
  698. FOR i := 7 TO 0 BY -1 DO
  699. d := x MOD 16;
  700. IF d < 10 THEN s[i] := CHR( d + ORD( "0" ) ) ELSE s[i] := CHR( d - 10 + ORD( "A" ) ) END;
  701. x := x DIV 16
  702. END;
  703. outputDebugString( s ); s[0] := 0AX; s[1] := 0X; outputDebugString( s )
  704. END SendToDebugger;
  705. PROCEDURE ShutdownP(l: LONGINT);
  706. BEGIN
  707. outputDebugString("Kernel32.Shutdown");
  708. ExitProcess(l);
  709. END ShutdownP;
  710. PROCEDURE Init*;
  711. VAR mod: HMODULE;
  712. BEGIN
  713. Shutdown := ShutdownP;
  714. mod := LoadLibrary("Kernel32.DLL");
  715. GetProcAddress(mod, "AllocConsole",SYSTEM.VAL(ADDRESS,AllocConsole));
  716. GetProcAddress(mod, "AttachConsole",SYSTEM.VAL(ADDRESS,AttachConsole));
  717. GetProcAddress(mod, "Beep",SYSTEM.VAL(ADDRESS,Beep));
  718. GetProcAddress(mod, "ClearCommBreak",SYSTEM.VAL(ADDRESS,ClearCommBreak));
  719. GetProcAddress(mod, "ClearCommError",SYSTEM.VAL(ADDRESS,ClearCommError));
  720. GetProcAddress(mod, "CloseHandle",SYSTEM.VAL(ADDRESS,CloseHandle));
  721. GetProcAddress(mod, "CopyFileA",SYSTEM.VAL(ADDRESS,CopyFile));
  722. GetProcAddress(mod, "CreateDirectoryA",SYSTEM.VAL(ADDRESS,CreateDirectory));
  723. GetProcAddress(mod, "CreateEventA",SYSTEM.VAL(ADDRESS,CreateEvent));
  724. GetProcAddress(mod, "CreateFileA",SYSTEM.VAL(ADDRESS,CreateFile));
  725. GetProcAddress(mod, "CreateProcessA",SYSTEM.VAL(ADDRESS,CreateProcess));
  726. GetProcAddress(mod, "CreateThread",SYSTEM.VAL(ADDRESS,CreateThread));
  727. GetProcAddress(mod, "DeleteCriticalSection",SYSTEM.VAL(ADDRESS,DeleteCriticalSection));
  728. GetProcAddress(mod, "DeleteFileA",SYSTEM.VAL(ADDRESS,DeleteFile));
  729. GetProcAddress(mod, "DisableThreadLibraryCalls",SYSTEM.VAL(ADDRESS,DisableThreadLibraryCalls));
  730. GetProcAddress(mod, "DuplicateHandle",SYSTEM.VAL(ADDRESS,DuplicateHandle));
  731. GetProcAddress(mod, "EnterCriticalSection",SYSTEM.VAL(ADDRESS,EnterCriticalSection));
  732. GetProcAddress(mod, "EscapeCommFunction",SYSTEM.VAL(ADDRESS,EscapeCommFunction));
  733. GetProcAddress(mod, "ExitProcess",SYSTEM.VAL(ADDRESS,ExitProcess));
  734. GetProcAddress(mod, "ExitThread",SYSTEM.VAL(ADDRESS,ExitThread));
  735. GetProcAddress(mod, "FindClose",SYSTEM.VAL(ADDRESS,FindClose));
  736. GetProcAddress(mod, "FileTimeToLocalFileTime",SYSTEM.VAL(ADDRESS,FileTimeToLocalFileTime));
  737. GetProcAddress(mod, "FileTimeToSystemTime",SYSTEM.VAL(ADDRESS,FileTimeToSystemTime));
  738. GetProcAddress(mod, "FindFirstFileA",SYSTEM.VAL(ADDRESS,FindFirstFile));
  739. GetProcAddress(mod, "FindNextFileA",SYSTEM.VAL(ADDRESS,FindNextFile));
  740. GetProcAddress(mod, "FlushFileBuffers",SYSTEM.VAL(ADDRESS,FlushFileBuffers));
  741. GetProcAddress(mod, "FreeConsole",SYSTEM.VAL(ADDRESS,FreeConsole));
  742. GetProcAddress(mod, "FreeLibrary",SYSTEM.VAL(ADDRESS,FreeLibrary));
  743. GetProcAddress(mod, "GetCommandLineA",SYSTEM.VAL(ADDRESS,GetCommandLine));
  744. GetProcAddress(mod, "GetCommModemStatus",SYSTEM.VAL(ADDRESS,GetCommModemStatus));
  745. GetProcAddress(mod, "GetCommState",SYSTEM.VAL(ADDRESS,GetCommState));
  746. GetProcAddress(mod, "GetComputerNameA",SYSTEM.VAL(ADDRESS,GetComputerName));
  747. GetProcAddress(mod, "GetCurrentDirectoryA",SYSTEM.VAL(ADDRESS,GetCurrentDirectory));
  748. GetProcAddress(mod, "GetCurrentProcess",SYSTEM.VAL(ADDRESS,GetCurrentProcess));
  749. GetProcAddress(mod, "GetCurrentProcessId",SYSTEM.VAL(ADDRESS,GetCurrentProcessId));
  750. GetProcAddress(mod, "GetCurrentThread",SYSTEM.VAL(ADDRESS,GetCurrentThread));
  751. GetProcAddress(mod, "GetCurrentThreadId",SYSTEM.VAL(ADDRESS,GetCurrentThreadId));
  752. GetProcAddress(mod, "GetDiskFreeSpaceA",SYSTEM.VAL(ADDRESS,GetDiskFreeSpace));
  753. GetProcAddress(mod, "GetDriveTypeA",SYSTEM.VAL(ADDRESS,GetDriveType));
  754. GetProcAddress(mod, "GetExitCodeProcess",SYSTEM.VAL(ADDRESS,GetExitCodeProcess));
  755. GetProcAddress(mod, "GetFileAttributesA",SYSTEM.VAL(ADDRESS,GetFileAttributes));
  756. GetProcAddress(mod, "GetFileSize",SYSTEM.VAL(ADDRESS,GetFileSize));
  757. GetProcAddress(mod, "GetFileTime",SYSTEM.VAL(ADDRESS,GetFileTime));
  758. GetProcAddress(mod, "GetFullPathNameA",SYSTEM.VAL(ADDRESS,GetFullPathName));
  759. GetProcAddress(mod, "GetLastError",SYSTEM.VAL(ADDRESS,GetLastError));
  760. GetProcAddress(mod, "GetLocalTime",SYSTEM.VAL(ADDRESS,GetLocalTime));
  761. GetProcAddress(mod, "GetLogicalDriveStringsA",SYSTEM.VAL(ADDRESS,GetLogicalDriveStrings));
  762. GetProcAddress(mod, "GetLogicalDrives",SYSTEM.VAL(ADDRESS,GetLogicalDrives));
  763. GetProcAddress(mod, "GetModuleFileNameA",SYSTEM.VAL(ADDRESS,GetModuleFileName));
  764. GetProcAddress(mod, "GetModuleHandleA",SYSTEM.VAL(ADDRESS,GetModuleHandle));
  765. GetProcAddress(mod, "GetPrivateProfileStringA",SYSTEM.VAL(ADDRESS,GetPrivateProfileString));
  766. (* must be done by linker: GetProcAddress(mod, "GetProcAddress",SYSTEM.VAL(ADDRESS,getProcAddress)); *)
  767. GetProcAddress(mod, "GetProcessHeap",SYSTEM.VAL(ADDRESS,GetProcessHeap));
  768. GetProcAddress(mod, "GetProcessTimes", SYSTEM.VAL(ADDRESS, GetProcessTimes));
  769. GetProcAddress(mod, "GetStartupInfoA",SYSTEM.VAL(ADDRESS,GetStartupInfo));
  770. GetProcAddress(mod, "GetStdHandle",SYSTEM.VAL(ADDRESS,GetStdHandle));
  771. GetProcAddress(mod, "GetSystemInfo",SYSTEM.VAL(ADDRESS,GetSystemInfo));
  772. GetProcAddress(mod, "GetSystemTime",SYSTEM.VAL(ADDRESS,GetSystemTime));
  773. GetProcAddress(mod, "GetTempFileNameA",SYSTEM.VAL(ADDRESS,GetTempFileName));
  774. GetProcAddress(mod, "GetTempPathA",SYSTEM.VAL(ADDRESS,GetTempPath));
  775. GetProcAddress(mod, "GetThreadContext",SYSTEM.VAL(ADDRESS,GetThreadContext));
  776. GetProcAddress(mod, "GetThreadPriority",SYSTEM.VAL(ADDRESS,GetThreadPriority));
  777. GetProcAddress(mod, "GetThreadTimes",SYSTEM.VAL(ADDRESS,GetThreadTimes));
  778. GetProcAddress(mod, "GetTickCount",SYSTEM.VAL(ADDRESS,GetTickCount));
  779. GetProcAddress(mod, "GetWindowsDirectoryA",SYSTEM.VAL(ADDRESS,GetWindowsDirectory));
  780. GetProcAddress(mod, "GetTimeZoneInformation",SYSTEM.VAL(ADDRESS,GetTimeZoneInformation));
  781. GetProcAddress(mod, "GetVersion",SYSTEM.VAL(ADDRESS,GetVersion));
  782. GetProcAddress(mod, "GetVersionExA",SYSTEM.VAL(ADDRESS,GetVersionEx));
  783. GetProcAddress(mod, "GetVolumeInformationA",SYSTEM.VAL(ADDRESS,GetVolumeInformation));
  784. GetProcAddress(mod, "GlobalAddAtomA",SYSTEM.VAL(ADDRESS,GlobalAddAtom));
  785. GetProcAddress(mod, "GlobalAlloc",SYSTEM.VAL(ADDRESS,GlobalAlloc));
  786. GetProcAddress(mod, "GlobalDeleteAtom",SYSTEM.VAL(ADDRESS,GlobalDeleteAtom));
  787. GetProcAddress(mod, "GlobalLock",SYSTEM.VAL(ADDRESS,GlobalLock));
  788. GetProcAddress(mod, "GlobalReAlloc",SYSTEM.VAL(ADDRESS,GlobalReAlloc));
  789. GetProcAddress(mod, "GlobalSize",SYSTEM.VAL(ADDRESS,GlobalSize));
  790. GetProcAddress(mod, "GlobalUnlock",SYSTEM.VAL(ADDRESS,GlobalUnlock));
  791. GetProcAddress(mod, "HeapAlloc",SYSTEM.VAL(ADDRESS,HeapAlloc));
  792. GetProcAddress(mod, "HeapFree",SYSTEM.VAL(ADDRESS,HeapFree));
  793. GetProcAddress(mod, "InitializeCriticalSection",SYSTEM.VAL(ADDRESS,InitializeCriticalSection));
  794. GetProcAddress(mod, "InterlockedDecrement",SYSTEM.VAL(ADDRESS,InterlockedDecrement));
  795. GetProcAddress(mod, "InterlockedIncrement",SYSTEM.VAL(ADDRESS,InterlockedIncrement));
  796. GetProcAddress(mod, "IsDebuggerPresent",SYSTEM.VAL(ADDRESS,IsDebuggerPresent));
  797. GetProcAddress(mod, "LeaveCriticalSection",SYSTEM.VAL(ADDRESS,LeaveCriticalSection));
  798. (* must be done by linker: GetProcAddress(mod, "LoadLibraryA",SYSTEM.VAL(ADDRESS,LoadLibrary)); *)
  799. GetProcAddress(mod, "LocalFileTimeToFileTime",SYSTEM.VAL(ADDRESS,LocalFileTimeToFileTime));
  800. GetProcAddress(mod, "MoveFileExA",SYSTEM.VAL(ADDRESS,MoveFileEx));
  801. GetProcAddress(mod, "OutputDebugStringA",SYSTEM.VAL(ADDRESS,outputDebugString));
  802. GetProcAddress(mod, "PurgeComm",SYSTEM.VAL(ADDRESS,PurgeComm));
  803. GetProcAddress(mod, "QueryDosDeviceA",SYSTEM.VAL(ADDRESS,QueryDosDevice));
  804. GetProcAddress(mod, "QueryPerformanceCounter",SYSTEM.VAL(ADDRESS,QueryPerformanceCounter));
  805. GetProcAddress(mod, "QueryPerformanceFrequency",SYSTEM.VAL(ADDRESS,QueryPerformanceFrequency));
  806. GetProcAddress(mod, "QueryThreadCycleTime", SYSTEM.VAL(ADDRESS, QueryThreadCycleTime));
  807. GetProcAddress(mod, "ReadFile",SYSTEM.VAL(ADDRESS,ReadFile));
  808. GetProcAddress(mod, "ReadProcessMemory",SYSTEM.VAL(ADDRESS,ReadProcessMemory));
  809. GetProcAddress(mod, "RemoveDirectoryA",SYSTEM.VAL(ADDRESS,RemoveDirectory));
  810. GetProcAddress(mod, "ResetEvent",SYSTEM.VAL(ADDRESS,ResetEvent));
  811. GetProcAddress(mod, "ResumeThread",SYSTEM.VAL(ADDRESS,ResumeThread));
  812. GetProcAddress(mod, "SearchPathA",SYSTEM.VAL(ADDRESS,SearchPath));
  813. GetProcAddress(mod, "SetCommBreak",SYSTEM.VAL(ADDRESS,SetCommBreak));
  814. GetProcAddress(mod, "SetCommMask",SYSTEM.VAL(ADDRESS,SetCommMask));
  815. GetProcAddress(mod, "SetCommState",SYSTEM.VAL(ADDRESS,SetCommState));
  816. GetProcAddress(mod, "SetCommTimeouts",SYSTEM.VAL(ADDRESS,SetCommTimeouts));
  817. GetProcAddress(mod, "SetConsoleCursorPosition",SYSTEM.VAL(ADDRESS,SetConsoleCursorPosition));
  818. GetProcAddress(mod, "SetConsoleScreenBufferSize",SYSTEM.VAL(ADDRESS,SetConsoleScreenBufferSize));
  819. GetProcAddress(mod, "SetConsoleTitleA",SYSTEM.VAL(ADDRESS,SetConsoleTitle));
  820. GetProcAddress(mod, "SetConsoleWindowInfo",SYSTEM.VAL(ADDRESS,SetConsoleWindowInfo));
  821. GetProcAddress(mod, "SetCurrentDirectoryA",SYSTEM.VAL(ADDRESS,SetCurrentDirectory));
  822. GetProcAddress(mod, "SetEndOfFile",SYSTEM.VAL(ADDRESS,SetEndOfFile));
  823. GetProcAddress(mod, "SetErrorMode",SYSTEM.VAL(ADDRESS,SetErrorMode));
  824. GetProcAddress(mod, "SetEvent",SYSTEM.VAL(ADDRESS,SetEvent));
  825. GetProcAddress(mod, "SetFileAttributesA",SYSTEM.VAL(ADDRESS,SetFileAttributes));
  826. GetProcAddress(mod, "SetFilePointer",SYSTEM.VAL(ADDRESS,SetFilePointer));
  827. GetProcAddress(mod, "SetFileTime",SYSTEM.VAL(ADDRESS,SetFileTime));
  828. GetProcAddress(mod, "SetLocalTime",SYSTEM.VAL(ADDRESS,SetLocalTime));
  829. GetProcAddress(mod, "SetThreadContext",SYSTEM.VAL(ADDRESS,SetThreadContext));
  830. GetProcAddress(mod, "SetThreadPriority",SYSTEM.VAL(ADDRESS,SetThreadPriority));
  831. GetProcAddress(mod, "SetupComm",SYSTEM.VAL(ADDRESS,SetupComm));
  832. GetProcAddress(mod, "Sleep",SYSTEM.VAL(ADDRESS,Sleep));
  833. GetProcAddress(mod, "SuspendThread",SYSTEM.VAL(ADDRESS,SuspendThread));
  834. GetProcAddress(mod, "SystemTimeToFileTime",SYSTEM.VAL(ADDRESS,SystemTimeToFileTime));
  835. GetProcAddress(mod, "TerminateThread",SYSTEM.VAL(ADDRESS,TerminateThread));
  836. GetProcAddress(mod, "TlsAlloc",SYSTEM.VAL(ADDRESS,TlsAlloc));
  837. GetProcAddress(mod, "TlsFree",SYSTEM.VAL(ADDRESS,TlsFree));
  838. GetProcAddress(mod, "TlsGetValue",SYSTEM.VAL(ADDRESS,TlsGetValue));
  839. GetProcAddress(mod, "TlsSetValue",SYSTEM.VAL(ADDRESS,TlsSetValue));
  840. GetProcAddress(mod, "TryEnterCriticalSection", SYSTEM.VAL(ADDRESS, TryEnterCriticalSection));
  841. GetProcAddress(mod, "VirtualAlloc",SYSTEM.VAL(ADDRESS,VirtualAlloc));
  842. GetProcAddress(mod, "VirtualFree",SYSTEM.VAL(ADDRESS,VirtualFree));
  843. GetProcAddress(mod, "WaitForSingleObject",SYSTEM.VAL(ADDRESS,WaitForSingleObject));
  844. GetProcAddress(mod, "WriteFile",SYSTEM.VAL(ADDRESS,WriteFile));
  845. GetProcAddress(mod, "GlobalMemoryStatusEx",SYSTEM.VAL(ADDRESS,GlobalMemoryStatusEx));
  846. isEXE := hInstance = NULL;
  847. IF isEXE THEN hInstance := GetModuleHandle( NIL ) END;
  848. IF IsDebuggerPresent()=True THEN
  849. OutputString := OutputDebugString
  850. ELSE
  851. OutputString := NoOutputString
  852. END;
  853. END Init;
  854. (* The following procedure is linked as the first block in the code section of a PE32 executable file
  855. It contains the import table for the two procedures Kernel32.GetProcAddress and Kernel32.LoadLibrary that
  856. are patched by the PE linker.
  857. [CF. Microsoft Portable Executable and Common Object File Format Specification]
  858. *)
  859. PROCEDURE {NOPAF, FIXED(401000H)} EntryPoint;
  860. CODE{SYSTEM.i386}
  861. JMP DWORD end;
  862. DB 0
  863. DB 0
  864. DB 0
  865. ImportTable:
  866. DD Kernel32Import + 1000H
  867. DD 0
  868. DD -1
  869. DD Kernel32Name + 1000H
  870. DD Kernel32Import + 1000H
  871. DD 0, 0, 0, 0, 0
  872. Kernel32Import:
  873. adrLoadLibrary:
  874. DD LoadLibraryA + 1000H
  875. adrGetProcAddress:
  876. DD GetProcAddress + 1000H
  877. DD 0
  878. Kernel32Name:
  879. DB 'KERNEL32.DLL' , 0
  880. LoadLibraryA:
  881. DW 0
  882. DB 'LoadLibraryA',0,0
  883. GetProcAddress:
  884. DW 0
  885. DB 'GetProcAddress',0
  886. end:
  887. MOV EAX,[401000H+adrLoadLibrary]
  888. MOV LoadLibrary, EAX
  889. MOV EAX,[401000H+adrGetProcAddress]
  890. MOV getProcAddress, EAX
  891. END EntryPoint;
  892. END Kernel32.