Generic.Win64.Kernel32.Mod 56 KB

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