Windows.Kernel32.Mod 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  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. DWORD* = LONGINT;
  130. ULONG*= UNSIGNED32;
  131. (** The FILETIME structure is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601. *)
  132. FileTime* = RECORD
  133. dwLowDateTime*, dwHighDateTime*: LONGINT
  134. END;
  135. (** The FindData structure describes a file found by the FindFirstFile or FindNextFile function. *)
  136. FindData* = RECORD
  137. dwFileAttributes*: WORDSET;
  138. ftCreationTime*, ftLastAccessTime*, ftLastWriteTime*: FileTime;
  139. nFileSizeHigh*, nFileSizeLow*: LONGINT;
  140. dwReserved0*, dwReserved1*: LONGINT;
  141. cFileName*: ARRAY MaxPath OF CHAR;
  142. cAlternateFileName*: ARRAY 14 OF CHAR
  143. END;
  144. (** The SYSTEMTIME structure represents a date and time using individual members for the month, day, year, weekday,
  145. hour, minute, second, and millisecond. *)
  146. SystemTime* = RECORD
  147. wYear*, wMonth*, wDayOfWeek*, wDay*: INTEGER;
  148. wHour*, wMinute*, wSecond*, wMilliseconds*: INTEGER
  149. END;
  150. (** The SMALL_RECT structure defines the coordinates of the upper left and lower right corners of a rectangle. *)
  151. SmallRect* = RECORD
  152. left*, top*, right*, bottom*: INTEGER
  153. END;
  154. (** Critical-section object. *)
  155. CriticalSection* = RECORD
  156. a, b, c, d, e, f: SIZE;
  157. END;
  158. (** thread context and exception information *)
  159. FloatingSaveArea* = RECORD
  160. ControlWord*, StatusWord*, TagWord*, ErrorOffset*, ErrorSelector*, DataOffset*, DataSelector*: LONGINT;
  161. RegisterArea*: ARRAY SizeOf80387Registers OF SYSTEM.BYTE;
  162. Cr0NpxState*: LONGINT
  163. END;
  164. ContextPtr*= POINTER {UNSAFE,UNTRACED} TO Context;
  165. #IF I386 THEN
  166. Context* = RECORD
  167. ContextFlags*: WORDSET;
  168. DR0*, DR1*, DR2*, DR3*, DR6*, DR7*: SIZE;
  169. FloatSave*: FloatingSaveArea;
  170. GS*, FS*, ES*, DS*: ADDRESS;
  171. EDI*, ESI*, EBX*, EDX*, ECX*, EAX*: ADDRESS;
  172. BP*, PC*, CS*, FLAGS*, SP*, SS*: ADDRESS; (* whereas BP is EBP and SP is ESP *)
  173. END;
  174. #ELSIF AMD64 THEN
  175. Context*= RECORD
  176. P1Home, P2Home, P3Home, P4Home, P5Home, P6Home: SIZE;
  177. ContextFlags*: WORDSET;
  178. MxCsr*: DWORD;
  179. CS*, DS*, ES*, FS*, GS*, SS*: INTEGER;
  180. FLAGS*: DWORD;
  181. Dr0*, Dr1*, Dr2*, Dr3*, Dr6*, Dr7*: SIZE;
  182. RAX*, RCX*, RDX*, RBX*, SP*, BP*, RSI*, RDI*, R8*, R9*, R10*, R11*, R12*, R13*, R14*, R15*: ADDRESS;
  183. PC*: ADDRESS;
  184. remainder (* leave enough space for the rest here *): ARRAY 1024 OF CHAR;
  185. (* union {
  186. XMM_SAVE_AREA32 FltSave;
  187. struct {
  188. M128A Header[2];
  189. M128A Legacy[8];
  190. M128A Xmm0;
  191. M128A Xmm1;
  192. M128A Xmm2;
  193. M128A Xmm3;
  194. M128A Xmm4;
  195. M128A Xmm5;
  196. M128A Xmm6;
  197. M128A Xmm7;
  198. M128A Xmm8;
  199. M128A Xmm9;
  200. M128A Xmm10;
  201. M128A Xmm11;
  202. M128A Xmm12;
  203. M128A Xmm13;
  204. M128A Xmm14;
  205. M128A Xmm15;
  206. };
  207. };
  208. M128A VectorRegister[26];
  209. DWORD64 VectorControl;
  210. DWORD64 DebugControl;
  211. DWORD64 LastBranchToRip;
  212. DWORD64 LastBranchFromRip;
  213. DWORD64 LastExceptionToRip;
  214. DWORD64 LastExceptionFromRip;
  215. } CONTEXT, *PCONTEXT;
  216. *)
  217. END;
  218. #END;
  219. ExceptionRecordPtr* = POINTER {UNSAFE,UNTRACED} TO ExceptionRecord;
  220. ExceptionRecord* = RECORD
  221. ExceptionCode*, ExceptionFlags*: LONGINT;
  222. nextExceptionRecord* {UNTRACED}: ExceptionRecordPtr;
  223. ExceptionAddress*: ADDRESS;
  224. NumberParameters*: LONGINT;
  225. ExceptionInformation*: ARRAY ExceptionMaximumParameters OF LONGINT
  226. END;
  227. ExcpFrmPtr* = ADDRESS;
  228. ExcpFrmHandler* = PROCEDURE {WINAPI} ( VAR excpRec: ExceptionRecord;
  229. excpFrame: ExcpFrmPtr;
  230. VAR context: Context;
  231. dispatch: LONGINT ): LONGINT;
  232. ExceptionPointers* = RECORD
  233. exception* {UNTRACED}: ExceptionRecordPtr;
  234. context*: ContextPtr;
  235. END;
  236. VectoredExceptionHandler* = PROCEDURE {WINAPI} ( CONST e: ExceptionPointers): DWORD;
  237. ExcpFrm* = RECORD
  238. link*: ExcpFrmPtr;
  239. handler*: ExcpFrmHandler
  240. END;
  241. (** Synchronization Objects *)
  242. Object* = POINTER TO RECORD
  243. handle*: HANDLE
  244. END;
  245. (** A 64-bit signed integer value. *)
  246. LargeInteger* = RECORD
  247. LowPart*, HighPart*: LONGINT
  248. END;
  249. (** A 64-bit unsigned integer value. *)
  250. ULargeInteger* = LargeInteger;
  251. (* Added by Alexey *)
  252. MemoryStatusEx* = RECORD
  253. dwLength*: LONGINT;
  254. dwMemoryLoad*: LONGINT;
  255. ullTotalPhys*: HUGEINT;
  256. ullAvailPhys*: HUGEINT;
  257. ullTotalPageFile*: HUGEINT;
  258. ullAvailPageFile*: HUGEINT;
  259. ullTotalVirtual*: HUGEINT;
  260. ullAvailVirtual*: HUGEINT;
  261. ullAvailExtendedVirtual*: HUGEINT;
  262. END;
  263. (** CreateThread *)
  264. ThreadProc* = PROCEDURE {WINAPI} ( lpParameter: ANY ): LONGINT;
  265. (** CreateProcess *)
  266. ProcessInformation* = RECORD
  267. hProcess*, hThread*: HANDLE;
  268. dwProcessId*, dwThreadId*: LONGINT
  269. END;
  270. (** CreateProcess, GetStartupInfo *)
  271. StartupInfo* = RECORD
  272. cb*: LONGINT;
  273. lpReserved*, lpDesktop*, lpTitle*: LPSTR;
  274. dwX*, dwY*, dwXSize*, dwYSize*: LONGINT;
  275. dwXCountChars*, dwYCountChars*: LONGINT;
  276. dwFillAttribute*: LONGINT;
  277. dwFlags*: WORDSET;
  278. wShowWindow*, cbReserved2*: INTEGER;
  279. lpReserved2*: ADDRESS;
  280. hStdInput*, hStdOutput*, hStdError*: HANDLE
  281. END;
  282. (** The OSVersionInfo data structure contains operating system version information. *)
  283. OSVersionInfo* = RECORD
  284. dwOSVersionInfoSize*, dwMajorVersion*, dwMinorVersion*, dwBuildNumber*, dwPlatformId*: LONGINT;
  285. szCSDVersion*: ARRAY 128 OF CHAR
  286. END;
  287. Exception* = RECORD
  288. exc*: ExceptionRecord;
  289. cont*: Context
  290. END;
  291. CommTimeouts* = RECORD
  292. ReadIntervalTimeout*, ReadTotalTimeoutMultiplier*, ReadTotalTimeoutConstant*, WriteTotalTimeoutMultiplier*, WriteTotalTimeoutConstant*: LONGINT
  293. END;
  294. DCB* = RECORD
  295. DCBlength*, BaudRate*: LONGINT;
  296. flags*: DWORD;
  297. wReserved*, XonLim*, XoffLim*: INTEGER;
  298. ByteSize*, Parity*, StopBits*, XonChar*, XoffChar*, ErrorChar*, EofChar*, EvtChar*: CHAR;
  299. wReserved1*: INTEGER
  300. END;
  301. ComStat* = RECORD
  302. status*: DWORD;
  303. cbInQue*, cbOutQue*: LONGINT
  304. END;
  305. SystemInfo* = RECORD
  306. wProcessorArchitecture*: INTEGER;
  307. wReserved: INTEGER;
  308. dwPageSize*: LONGINT;
  309. lpMinimumApplicationAddress*: ADDRESS;
  310. lpMaximumApplicationAddress*: ADDRESS;
  311. dwActiveProcessorMask*: ADDRESS;
  312. dwNumberOfProcessors*: LONGINT;
  313. dwProcessorType*: LONGINT;
  314. dwAllocationGranularity*: LONGINT;
  315. wProcessorLevel*: INTEGER;
  316. wProcessorRevision*: INTEGER;
  317. END;
  318. (*ALEX 2005.10.18 The TIME_ZONE_INFORMATION as defined in winbase.h*)
  319. TimeZoneInformation* = RECORD
  320. Bias*: LONGINT;
  321. StandardName*: ARRAY 32 OF INTEGER;
  322. StandardDate*: SystemTime;
  323. StandardBias*: LONGINT;
  324. DaylightName*: ARRAY 32 OF INTEGER;
  325. DaylightDate*: SystemTime;
  326. DaylightBias*: LONGINT;
  327. END;
  328. (** Contains information used in asynchronous (or overlapped) input and output (I/O). *)
  329. Overlapped* = RECORD
  330. Internal*: LONGINT;
  331. InternalHigh*: LONGINT;
  332. Offset*: LONGINT;
  333. OffsetHigh*: LONGINT;
  334. hEvent*: HANDLE;
  335. END;
  336. VAR
  337. hInstance-: HINSTANCE; (* init by linker/loader *)
  338. isEXE-: BOOLEAN;
  339. (* the procedure variables getProcAddress and LoadLibrary must be patched by linker / PE loader *)
  340. (** The GetProcAddress function returns the address of the specified exported dynamic-link library (DLL) function.
  341. Use the GetProcAddress Oberon wrapper. *)
  342. getProcAddress-: PROCEDURE {WINAPI} ( hModule: HMODULE; CONST lpProcName: ARRAY OF CHAR ): ADDRESS;
  343. (** The LoadLibrary function maps the specified executable module into the address space of the calling process. *)
  344. LoadLibrary-: PROCEDURE {WINAPI} ( CONST lpLibFileName: ARRAY OF CHAR ): HINSTANCE; (* must be patched by linker / PE loader *)
  345. (** registers a vectored continue handler. **)
  346. AddVectoredContinueHandler-: PROCEDURE {WINAPI} (firstHandler: ULONG; vectoredHandler: VectoredExceptionHandler);
  347. (** registers a vectored exception handler. **)
  348. AddVectoredExceptionHandler-: PROCEDURE {WINAPI} (firstHandler: ULONG; vectoredHandler: VectoredExceptionHandler);
  349. (** The AllocConsole function allocates a new console for the calling process. *)
  350. AllocConsole-: PROCEDURE {WINAPI} ( ): BOOL;
  351. (** The AttachConsole function attaches the calling process to the console of the specified process. *)
  352. AttachConsole-: PROCEDURE {WINAPI} (in: LONGINT): BOOL;
  353. (** 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.*)
  354. Beep-: PROCEDURE {WINAPI} ( dwFreq, dwDuration: LONGINT ): BOOL;
  355. (** Marks any outstanding I/O operations for the specified file handle. The function only cancels I/O operations in the current process, regardless of which thread created the I/O operation. *)
  356. CancelIoEx-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpOverlapped: Overlapped): BOOL;
  357. (** The ClearCommBreak function restores character transmission for a specified communications device and places the transmission line in a nonbreak state. *)
  358. ClearCommBreak-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  359. (** The ClearCommError function retrieves information about a communications error and reports the current status of a communications device. *)
  360. ClearCommError-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpErrors: DWORD; VAR lpStat: ComStat ): BOOL;
  361. (** The CloseHandle function closes an open object handle. *)
  362. CloseHandle-: PROCEDURE {WINAPI} ( hObject: HANDLE ): BOOL;
  363. (** The CopyFile function copies an existing file to a new file. *)
  364. CopyFile-: PROCEDURE {WINAPI} ( VAR lpExistingFileName, lpNewFileName: ARRAY OF CHAR; bFailIfExists: BOOL ): BOOL;
  365. (** The CreateDirectory function creates a new directory. *)
  366. CreateDirectory-: PROCEDURE {WINAPI} ( VAR lpPathName: ARRAY OF CHAR;
  367. lpSecurityAttributes: ANY ): BOOL;
  368. (** The CreateEvent function creates a named or unnamed event object. *)
  369. CreateEvent-: PROCEDURE {WINAPI} ( lpEventAttributes: ANY;
  370. bManualReset, bInitialState: BOOL;
  371. CONST lpName: ARRAY OF CHAR ): HANDLE;
  372. (** The CreateFile function creates or opens the following objects and returns a handle that can be used to access the object:
  373. files, pipes, mailslots, communications resources, disk devices (Windows NT only), consoles, directories (open only) *)
  374. CreateFile-: PROCEDURE {WINAPI} ( CONST lpFileName: ARRAY OF CHAR;
  375. dwDesiredAccess, dwShareMode: WORDSET;
  376. lpSecurityAttributes: ANY;
  377. dwCreationDistribution: LONGINT;
  378. dwFlagsAndAttributes: WORDSET;
  379. hTemplateFile: HANDLE ): HANDLE;
  380. (** The CreateProcess function creates a new process and its primary thread. The new process executes the specified
  381. executable file. *)
  382. CreateProcess-: PROCEDURE {WINAPI} ( CONST lpApplicationName, lpCommandLine: ARRAY OF CHAR;
  383. lpProcessAttributes, lpThreadAttributes: ANY;
  384. bInheritHandles: BOOL;
  385. dwCreationFlags: LONGINT;
  386. lpEnvironment: ANY;
  387. VAR lpCurrentDirectory: ARRAY OF CHAR;
  388. VAR lpStartupInfo: StartupInfo;
  389. VAR lpProcessInformation: ProcessInformation ): BOOL;
  390. (** The CreateSemaphore function creates or opens a named or unnamed semaphore object. *)
  391. CreateSemaphore-: PROCEDURE {WINAPI} ( lpThreadAttributes: ADDRESS; lInitialCount: LONGINT; lMaximumCount: LONGINT; lpName: LPSTR): HANDLE;
  392. (** The CreateThread function creates a thread to execute within the address space of the calling process. *)
  393. CreateThread-: PROCEDURE {WINAPI} ( lpThreadAttributes: ADDRESS;
  394. dwStackSize: LONGINT;
  395. lpStartAddress: ThreadProc;
  396. lpParameter: ANY; dwCreationFlags: WORDSET;
  397. VAR lpThreadId: LONGINT ): HANDLE;
  398. (** The DeleteCriticalSection function releases all resources used by an unowned critical section object. *)
  399. DeleteCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  400. (** The DeleteFile function deletes an existing file. *)
  401. DeleteFile-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR ): BOOL;
  402. (** The DisableThreadLibraryCalls function disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications
  403. for the dynamic-link library (DLL) specified by hLibModule. *)
  404. DisableThreadLibraryCalls-: PROCEDURE {WINAPI} ( hLibModule: HMODULE ): BOOL;
  405. (** The DuplicateHandle function duplicates an object handle. *)
  406. DuplicateHandle-: PROCEDURE {WINAPI} ( hSourceProcessHandle, hSourceHandle, hTargetProcessHandle: HANDLE;
  407. VAR lpTargetHandle: HANDLE;
  408. dwDesiredAccess: WORDSET;
  409. bInheritHandle: BOOL;
  410. dwOptions: WORDSET ): BOOL;
  411. (** The EnterCriticalSection function waits for ownership of the specified critical section object. *)
  412. EnterCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  413. (** The EscapeCommFunction function directs a specified communications device to perform an extended function. *)
  414. EscapeCommFunction-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  415. dwFunc: LONGINT ): BOOL;
  416. (** The ExitProcess function ends a process and all its threads. *)
  417. ExitProcess-: PROCEDURE {WINAPI} ( uExitCode: LONGINT );
  418. (** The ExitThread function ends a thread. *)
  419. ExitThread-: PROCEDURE {WINAPI} ( dwExitCode: LONGINT );
  420. (** The FileTimeToLocalFileTime function converts a file time based on the Coordinated Universal Time (UTC) to a
  421. local file time. *)
  422. FileTimeToLocalFileTime-: PROCEDURE {WINAPI} ( VAR lpFileTime: FileTime;
  423. VAR lpLocalFileTime: FileTime ): BOOL;
  424. (** The FileTimeToSystemTime function converts a 64-bit file time to system time format. *)
  425. FileTimeToSystemTime-: PROCEDURE {WINAPI} ( VAR lpFileTime: FileTime;
  426. VAR lpSystemTime: SystemTime ): BOOL;
  427. (** The FindClose function closes the specified search handle. *)
  428. FindClose-: PROCEDURE {WINAPI} ( hFindFile: HANDLE ): BOOL;
  429. (** The FindFirstFile function searches a directory for a file whose name matches the specified filename. *)
  430. FindFirstFile-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR;
  431. VAR lpFindFileDate: FindData ): HANDLE;
  432. (** The FindNextFile function continues a file search from a previous call to the FindFirstFile function. *)
  433. FindNextFile-: PROCEDURE {WINAPI} ( hFindFile: HANDLE;
  434. VAR lpFindFileDate: FindData ): BOOL;
  435. (** The FlushFileBuffers function clears the buffers for the specified file and causes all buffered data to be written
  436. to the file. *)
  437. FlushFileBuffers-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  438. (** The FreeConsole function detaches the calling process from its console *)
  439. FreeConsole-: PROCEDURE {WINAPI} ( ): BOOL;
  440. (** The FreeLibrary function decrements the reference count of the loaded dynamic-link library (DLL) module.
  441. When the reference count reaches zero, the module is unmapped from the address space of the calling process
  442. and the handle is no longer valid. *)
  443. FreeLibrary-: PROCEDURE {WINAPI} ( hLibModule: HMODULE ): BOOL;
  444. (** The GetCommandLine function returns a pointer to the command-line string for the current process. *)
  445. GetCommandLine-: PROCEDURE {WINAPI} ( ): LPSTR;
  446. (** The GetCommModemStatus function retrieves modem control-register values. *)
  447. GetCommModemStatus-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  448. VAR lpModemStat: WORDSET ): BOOL;
  449. (** The GetCommState function retrieves the current control settings for a specified communications device. *)
  450. GetCommState-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  451. VAR lpDCB: DCB ): BOOL;
  452. (** The GetComputerName function retrieves the NetBIOS name of the local computer. *)
  453. GetComputerName-: PROCEDURE {WINAPI} ( VAR lpBuffer: ARRAY OF CHAR;
  454. VAR lpnSize: LONGINT ): BOOL;
  455. (** The GetCurrentDirectory function retrieves the current directory for the current process. *)
  456. GetCurrentDirectory-: PROCEDURE {WINAPI} ( nBufferLength: LONGINT;
  457. VAR lpBuffer: ARRAY OF CHAR ): LONGINT;
  458. (** The GetConsoleWindow function retrieves the window handle used by the console associated with the calling process. *)
  459. (*
  460. GetConsoleWindow-: PROCEDURE{WINAPI} (): LONGINT ;
  461. (** The GetCurrentProcess function returns a pseudohandle for the current process. *)
  462. not in smaller versions than Win2000!
  463. *)
  464. GetCurrentProcess-: PROCEDURE {WINAPI} ( ): HANDLE;
  465. (** The GetCurrentProcessId function returns the process identifier of the calling process. *)
  466. GetCurrentProcessId-: PROCEDURE {WINAPI} ( ): LONGINT;
  467. (** The GetCurrentThread function returns a pseudohandle for the current thread. *)
  468. GetCurrentThread-: PROCEDURE {WINAPI} ( ): HANDLE;
  469. (** The GetCurrentThreadId function returns the thread identifier of the calling thread. *)
  470. GetCurrentThreadId-: PROCEDURE {WINAPI} ( ): LONGINT;
  471. (** The GetDiskFreeSpace function retrieves information about the specified disk, including the amount of
  472. free space on the disk. *)
  473. GetDiskFreeSpace-: PROCEDURE {WINAPI} ( VAR lpRootPathName: ARRAY OF CHAR;
  474. VAR lpSectorsPerCluster, lpBytesPerSector, lpNumberOfFreeClusters, lpTotalNumberOfClusters: LONGINT ): BOOL;
  475. (** The GetDriveType function determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or
  476. network drive. *)
  477. GetDriveType-: PROCEDURE {WINAPI} ( VAR lpRootPathName: ARRAY OF CHAR ): LONGINT;
  478. (** The GetExitCodeProcess function retrieves the termination status of the specified process. *)
  479. GetExitCodeProcess-: PROCEDURE {WINAPI} ( hProcess: HANDLE;
  480. VAR lpExitCode: LONGINT ): BOOL;
  481. (** The GetFileAttributes function returns attributes for a specified file or directory. *)
  482. GetFileAttributes-: PROCEDURE {WINAPI} ( CONST lpFileName: ARRAY OF CHAR ): WORDSET;
  483. (** The GetFileSize function retrieves the size, in bytes, of the specified file. *)
  484. GetFileSize-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpFileSizeHigh: LONGINT ): LONGINT;
  485. GetFileSizeEx-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpFileSize: HUGEINT ): BOOL;
  486. (** The GetFileTime function retrieves the date and time that a file was created, last accessed, and last modified. *)
  487. GetFileTime-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  488. VAR lpCreationTime, lpLastAccessTime, lpLastWriteTime: FileTime ): BOOL;
  489. (** The GetFullPathName function retrieves the full path and filename of a specified file. *)
  490. GetFullPathName-: PROCEDURE {WINAPI} ( CONST lpFileName: ARRAY OF CHAR;
  491. nBufferLength: LONGINT;
  492. VAR lpBuffer: ARRAY OF CHAR;
  493. lpFilePart: LPSTR ): LONGINT;
  494. (** The GetLastError function returns the calling thread's last-error code value. *)
  495. GetLastError-: PROCEDURE {WINAPI} ( ): LONGINT;
  496. (** The GetLocalTime function retrieves the current local date and time. *)
  497. GetLocalTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime );
  498. (** The GetLogicalDriveStrings function retrieves a string containing the drive letters. *) (*ALEX 2005.02.10*)
  499. GetLogicalDriveStrings-: PROCEDURE {WINAPI} ( nBufferLength: LONGINT;
  500. VAR lpBuffer: ARRAY OF CHAR ): LONGINT;
  501. (** The GetModuleFileName function retrieves the full path and filename for the executable file containing the
  502. specified module. *)
  503. (* The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives.
  504. *)
  505. GetLogicalDrives-: PROCEDURE {WINAPI} ( ): WORDSET;
  506. GetModuleFileName-: PROCEDURE {WINAPI} ( hModule: HMODULE;
  507. VAR lpFileName: ARRAY OF CHAR;
  508. nSize: LONGINT ): LONGINT;
  509. (** The GetModuleHandle function returns a module handle for the specified module if the file has been mapped
  510. into the address space of the calling process. *)
  511. GetModuleHandle-: PROCEDURE {WINAPI} ( CONST lpModuleName: ARRAY OF CHAR ): HMODULE;
  512. (** Retrieves the results of an overlapped operation on the specified file, named pipe, or communications device.
  513. To specify a timeout interval or wait on an alertable thread. *)
  514. GetOverlappedResult-: PROCEDURE {WINAPI} ( hFile: HANDLE; VAR lpOverlapped: Overlapped; VAR lpNumberOfBytesTransferred: LONGINT; bWait: BOOL ): BOOL;
  515. (** The GetPrivateProfileString function retrieves a string from the specified section in an initialization file.*)
  516. GetPrivateProfileString-: PROCEDURE {WINAPI} ( CONST lpAppName: ARRAY OF CHAR;
  517. CONST lpKeyName: ARRAY OF CHAR;
  518. CONST lpDefault: ARRAY OF CHAR;
  519. VAR lpReturnedString: ARRAY OF CHAR;
  520. nSize: LONGINT;
  521. CONST lpFileName: ARRAY OF CHAR): LONGINT;
  522. (** The GetProcessAffinityMask function retrieves the process affinity mask for the specified process and the system affinity mask for the system. *)
  523. GetProcessAffinityMask- : PROCEDURE {WINAPI} ( hProcess: HANDLE; lpProcessAffinityMask: ADDRESS; lpSystemAffinityMask: ADDRESS ): BOOL;
  524. (** 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. *)
  525. GetProcessHeap- : PROCEDURE {WINAPI} (): HANDLE;
  526. (** The GetProcessTimes function returns the times spent in kernel mode, user mode ... for the specified process *)
  527. GetProcessTimes- : PROCEDURE {WINAPI} (CONST hProcess: HANDLE; VAR lpCreationTime, lpExitTime, lpKernelTime, lpUserTime: FileTime ): LONGINT;
  528. (** The GetStartupInfo function retrieves the contents of the StartupInfo structure that was specified when
  529. the calling process was created. *)
  530. GetStartupInfo-: PROCEDURE {WINAPI} ( VAR lpStartupInfo: StartupInfo );
  531. (** Retrieves information about the current system. *)
  532. GetSystemInfo-: PROCEDURE {WINAPI} ( VAR lpSystemInfo: SystemInfo );
  533. (** The GetStdHandle function returns a handle for the standard input, standard output, or standard error device. *)
  534. GetStdHandle-: PROCEDURE {WINAPI} ( nStdHandle: LONGINT ): HANDLE;
  535. (** The GetSystemTime function retrieves the current system date and time. The system time is expressed in
  536. Coordinated Universal Time (UTC). *)
  537. GetSystemTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime );
  538. (** The GetTempFileName function creates a name for a temporary file. The filename is the concatenation of
  539. specified path and prefix strings, a hexadecimal string formed from a specified integer, and the .TMP extension. *)
  540. GetTempFileName-: PROCEDURE {WINAPI} ( VAR lpPathName, lpPrefixName: ARRAY OF CHAR;
  541. uUnique: LONGINT;
  542. VAR lpTempFileName: ARRAY OF CHAR ): LONGINT;
  543. (** The GetTempPath function retrieves the path of the directory designated for temporary files. *)
  544. GetTempPath-: PROCEDURE {WINAPI} ( nBufferLength: LONGINT;
  545. VAR lpBuffer: ARRAY OF CHAR ): LONGINT;
  546. (** The GetThreadContext function retrieves the context of the specified thread. *)
  547. GetThreadContext-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  548. VAR lpContext: Context ): BOOL;
  549. (** The GetThreadPriority function returns the priority value for the specified thread. This value, together with
  550. the priority class of the thread's process, determines the thread's base-priority level. *)
  551. GetThreadPriority-: PROCEDURE {WINAPI} ( hThread: HANDLE ): LONGINT;
  552. (** The GetThreadTimes function returns the times spent in kernel mode, user mode ... specified thread. *)
  553. GetThreadTimes-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  554. VAR lpCreationTime, lpExitTime, lpKernelTime, lpUserTime: FileTime ): LONGINT; (*ALEX 2005.12.12*)
  555. (** The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. *)
  556. GetTickCount-: PROCEDURE {WINAPI} ( ): LONGINT;
  557. (** The GetTimeZoneInformation function retrieves information about timezone setup. *) (*ALEX 2005.10.18*)
  558. GetTimeZoneInformation-: PROCEDURE {WINAPI} ( VAR lpTimeZoneInformation: TimeZoneInformation ): LONGINT;
  559. (** The GetWindowsDir function retrieves the path of the Windows directory. *) (*ALEX 2006.06.05*)
  560. GetWindowsDirectory-: PROCEDURE {WINAPI} ( VAR lpBuffer: ARRAY OF CHAR; nBufferLength: LONGINT ): LONGINT;
  561. (** The GetVersion function returns the current version number of the operating system. *)
  562. GetVersion-: PROCEDURE {WINAPI} ( ): LONGINT;
  563. (** The GetVersionEx function obtains extended information about the version of the operating system that is
  564. currently running. *)
  565. GetVersionEx-: PROCEDURE {WINAPI} ( VAR lpVersionInfo: OSVersionInfo ): BOOL;
  566. (*The GetVolumeInformation function retrieves information about a file system and volume that have a specified
  567. root directory. *)
  568. GetVolumeInformation-: PROCEDURE {WINAPI} ( VAR lpRootPathName: ARRAY OF CHAR;
  569. VAR lpVolumeNameBuffer: ARRAY OF CHAR;
  570. nVolumeNameSize: LONGINT;
  571. VAR lpVolumeSerialNumber: LONGINT;
  572. VAR lpMaximumComponentLength: LONGINT;
  573. VAR lpFileSystemFlags: LONGINT;
  574. VAR lpFileSystemNameBuffer: ARRAY OF CHAR;
  575. nFileSystemNameSize: LONGINT ): LONGINT;
  576. (** The GlobalAddAtom function adds a character string to the global atom table and returns a unique value
  577. (an atom) identifying the string. *)
  578. GlobalAddAtom-: PROCEDURE {WINAPI} ( VAR lpString: ARRAY OF CHAR ): ATOM;
  579. (** The GlobalAlloc function allocates the specified number of bytes from the heap. *)
  580. GlobalAlloc-: PROCEDURE {WINAPI} ( uFlags: WORDSET; dwBytes: LONGINT ): HGLOBAL;
  581. (** The GlobalDeleteAtom function decrements the reference count of a global string atom. *)
  582. GlobalDeleteAtom-: PROCEDURE {WINAPI} ( nAtom: ATOM ): ATOM;
  583. (** The GlobalLock function locks a global memory object and returns a pointer to the first byte of the
  584. object's memory block. *)
  585. GlobalLock-: PROCEDURE {WINAPI} ( hMem: HGLOBAL ): ADDRESS;
  586. (* Added by Alexey *)
  587. GlobalMemoryStatusEx-: PROCEDURE {WINAPI} (VAR lpBuffer: MemoryStatusEx): BOOL;
  588. (** The GlobalReAlloc function changes the size or attributes of a specified global memory object. *)
  589. GlobalReAlloc-: PROCEDURE {WINAPI} ( hMem: HGLOBAL; dwBytes: LONGINT;
  590. uFlags: DWORD ): HGLOBAL;
  591. (** The GlobalSize function retrieves the current size, in bytes, of the specified global memory object. *)
  592. GlobalSize-: PROCEDURE {WINAPI} ( hMem: HGLOBAL ): LONGINT;
  593. (** The GlobalUnlock function decrements the lock count associated with a memory object that was allocated with
  594. the GMEM_MOVEABLE flag. *)
  595. GlobalUnlock-: PROCEDURE {WINAPI} ( hMem: HGLOBAL ): BOOL;
  596. (** The HeapAlloc function allocates a block of memory from a heap. The allocated memory is not movable. *)
  597. HeapAlloc-: PROCEDURE {WINAPI} ( hHeap: HANDLE; dwFlags: LONGINT; size: SIZE): ADDRESS;
  598. (** The HeapFree function frees a memory block allocated from a heap by the HeapAlloc or HeapReAlloc function. *)
  599. HeapFree-: PROCEDURE {WINAPI} ( hHeap: HANDLE; dwFlags: LONGINT; lpMem: ADDRESS): ADDRESS;
  600. (** The InitializeCriticalSection function initializes a critical section object. *)
  601. InitializeCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  602. (** The InterlockedDecrement function both decrements (decreases by one) the value of the specified 32-bit
  603. variable and checks the resulting value. *)
  604. InterlockedDecrement-: PROCEDURE {WINAPI} ( VAR lpAddend: LONGINT ): LONGINT;
  605. (** The InterlockedIncrement function both increments (increases by one) the value of the specified 32-bit variable
  606. and checks the resulting value. *)
  607. InterlockedIncrement-: PROCEDURE {WINAPI} ( VAR lpAddend: LONGINT ): LONGINT;
  608. (** The LeaveCriticalSection function releases ownership of the specified critical section object. *)
  609. LeaveCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection );
  610. (** The LocalFileTimeToFileTime function converts a local file time to a file time based on the Coordinated
  611. Universal Time (UTC). *)
  612. LocalFileTimeToFileTime-: PROCEDURE {WINAPI} ( VAR lpLocalFileTime: FileTime;
  613. VAR lpFileTime: FileTime ): BOOL;
  614. (** The MoveFileEx function renames an existing file or directory. *)
  615. MoveFileEx-: PROCEDURE {WINAPI} ( VAR lpExistingFileName, lpNewFileName: ARRAY OF CHAR;
  616. dwFlags: WORDSET ): BOOL;
  617. (** The OutputDebugString function sends a string to the debugger for the current application. *)
  618. outputDebugString-: PROCEDURE {WINAPI} ( CONST lpOutputString: ARRAY OF CHAR );
  619. (* The IsDebuggerPresent Function determines whether the calling process is being debugged by a user-mode debugger. *)
  620. IsDebuggerPresent-: PROCEDURE {WINAPI}(): BOOL;
  621. (** The PurgeComm function discards all characters from the output or input buffer of a specified communications resource. *)
  622. PurgeComm-: PROCEDURE {WINAPI} ( hFile: HANDLE; dwFlags: WORDSET ): BOOL;
  623. (** The QueryDosDevice function retrieves information about MS-DOS device names. *)
  624. QueryDosDevice-: PROCEDURE {WINAPI} ( CONST lpDeviceName: ARRAY OF CHAR;
  625. VAR lpTargetPath: ARRAY OF CHAR;
  626. ucchMax: LONGINT ): LONGINT;
  627. (** The QueryPerformanceCounter function retrieves the current value of the high-resolution
  628. performance counter, if one exists. *)
  629. QueryPerformanceCounter-: PROCEDURE {WINAPI} ( VAR lpPerformaceCount: LargeInteger ): BOOL;
  630. (** The QueryPerformanceFrequency function retrieves the frequency of the high-resolution
  631. performance counter, if one exists. *)
  632. QueryPerformanceFrequency-: PROCEDURE {WINAPI} ( VAR lpFrequency: LargeInteger ): BOOL;
  633. (** Retrieves the cycle time for the specified thread (both user and kernel mode, Windows Vista and newer) *)
  634. QueryThreadCycleTime- : PROCEDURE {WINAPI} (hThread : HANDLE; VAR cycleTime : HUGEINT) : BOOL;
  635. (** The ReadFile function reads data from a file, starting at the position indicated by the file pointer. *)
  636. ReadFile-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  637. VAR lpBuffer: ARRAY OF SYSTEM.BYTE;
  638. nNumberOfBytesToRead: LONGINT;
  639. VAR lpNumberOfBytesRead: LONGINT;
  640. VAR lpOverlapped: Overlapped ): BOOL;
  641. (** The ReadProcessMemory function reads data from an area of memory in a specified process. *)
  642. ReadProcessMemory-: PROCEDURE {WINAPI} ( hProcess: HANDLE;
  643. lpBaseAddress: ADDRESS;
  644. VAR lpBuffer: ARRAY OF SYSTEM.BYTE;
  645. nSize: LONGINT;
  646. VAR lpNumberOfBytesRead: LONGINT ): BOOL;
  647. (** The ReleaseSemaphore function increases the count of the specified semaphore object by a specified amount. *)
  648. ReleaseSemaphore-: PROCEDURE {WINAPI} ( hSemaphore: HANDLE; lReleaseCount: LONGINT; lpPreviousCount: ADDRESS): BOOL;
  649. (** The RemoveDirectory function deletes an existing empty directory. *)
  650. RemoveDirectory-: PROCEDURE {WINAPI} ( VAR lpPathName: ARRAY OF CHAR ): BOOL;
  651. (** unregisters a vectored continue handler. **)
  652. RemoveVectoredContinueHandler-: PROCEDURE {WINAPI} (vectoredHandler: VectoredExceptionHandler): ULONG;
  653. (** unregisters a vectored exception handler. **)
  654. RemoveVectoredExceptionHandler-: PROCEDURE {WINAPI} (vectoredHandler: VectoredExceptionHandler): ULONG;
  655. (** The ResetEvent function sets the state of the specified event object to nonsignaled. *)
  656. ResetEvent-: PROCEDURE {WINAPI} ( hEvent: HANDLE ): BOOL;
  657. (** The ResumeThread function decrements a thread's suspend count. *)
  658. ResumeThread-: PROCEDURE {WINAPI} ( hThread: HANDLE ): LONGINT;
  659. (** The SearchPath function searches for the specified file. *)
  660. SearchPath-: PROCEDURE {WINAPI} ( CONST lpPath, lpFileName, lpExtension: ARRAY OF CHAR;
  661. nBufferLength: LONGINT;
  662. VAR lpBuffer: ARRAY OF CHAR;
  663. VAR lpFilePart: LPSTR ): LONGINT;
  664. (** 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. *)
  665. SetCommBreak-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  666. (** The SetCommMask function specifies a set of events to be monitored for a communications device. *)
  667. SetCommMask-: PROCEDURE {WINAPI} ( hFile: HANDLE; dwEvtMask: DWORD ): BOOL;
  668. (** The SetCommState function configures a communications device according to the specifications in a device-control block (a DCB structure)*)
  669. SetCommState-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  670. VAR lpDCB: DCB ): BOOL;
  671. (** The SetCommTimeouts function sets the time-out parameters for all read and write operations on a specified communications device. *)
  672. SetCommTimeouts-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  673. VAR lpCommTimeouts: CommTimeouts ): BOOL;
  674. (** the SetConsoleCursorPosition sets the cursor position in the specified console screen buffer. *)
  675. SetConsoleCursorPosition-: PROCEDURE {WINAPI} ( hConsoleOutput: HANDLE; dwCursorPosition: (* imitate Coord=RECORD x,y: INTEGER END; *) LONGINT ): BOOL;
  676. (** The SetConsoleScreenBufferSize function changes the size of the specified console screen buffer. *)
  677. SetConsoleScreenBufferSize-: PROCEDURE {WINAPI} ( hConsoleOuput: HANDLE;
  678. dwSize: LONGINT ): BOOL;
  679. (** 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. *)
  680. SetConsoleTextAttribute-: PROCEDURE {WINAPI} (hConsoleOutput: HANDLE; wAttributes: LONGINT): BOOL;
  681. (** The SetConsoleTitle function sets the title bar string for the current console window. *)
  682. SetConsoleTitle-: PROCEDURE {WINAPI} ( VAR lpConsoleTitle: ARRAY OF CHAR ): BOOL;
  683. (** The SetConsoleWindowInfo function sets the current size and position of a console screen buffer's window. *)
  684. SetConsoleWindowInfo-: PROCEDURE {WINAPI} ( hConsoleOuput: HANDLE;
  685. bAbsolute: BOOL;
  686. VAR lpConsoleWindow: SmallRect ): BOOL;
  687. (** The SetCurrentDirectory function changes the current directory for the current process. *)
  688. SetCurrentDirectory-: PROCEDURE {WINAPI} ( VAR lpPathName: ARRAY OF CHAR ): BOOL;
  689. (** The SetErrorMode function controls whether the system will handle the specified types of serious errors,
  690. or whether the process will handle them. *)
  691. SetErrorMode-: PROCEDURE {WINAPI} ( uMode: DWORD ): DWORD;
  692. (** The SetEndOfFile function moves the end-of-file (EOF) position for the specified file to the current position of the file pointer. *)
  693. SetEndOfFile-: PROCEDURE {WINAPI} ( hFile: HANDLE ): BOOL;
  694. (** The SetEvent function sets the state of the specified event object to signaled. *)
  695. SetEvent-: PROCEDURE {WINAPI} ( hEvent: HANDLE ): BOOL;
  696. (** The SetFileAttributes function sets a file's attributes. *)
  697. SetFileAttributes-: PROCEDURE {WINAPI} ( VAR lpFileName: ARRAY OF CHAR;
  698. dwFileAttributes: WORDSET ): BOOL;
  699. (** The SetFilePointer function moves the file pointer of an open file. *)
  700. SetFilePointer-: PROCEDURE {WINAPI} ( hFile: HANDLE; lDistanceToMove: LONGINT;
  701. VAR lpDistanceToMoveHigh: LONGINT;
  702. dwMoveMethod: LONGINT ): LONGINT;
  703. SetFilePointerEx-: PROCEDURE {WINAPI} ( hFile: HANDLE; lDistanceToMove: HUGEINT;
  704. VAR lpNewFilePointer: HUGEINT;
  705. dwMoveMethod: LONGINT ): BOOL;
  706. (** The SetFileTime function sets the date and time that a file was created, last accessed, or last modified. *)
  707. SetFileTime-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  708. VAR lpCreationTime, lpLastAccessTime, lpLastWriteTime: FileTime ): BOOL;
  709. (** The SetLocalTime function sets the current local time and date. *)
  710. SetLocalTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime ): BOOL;
  711. (** The SetThreadAffinityMask function sets a processor affinity mask for the specified thread. *)
  712. SetThreadAffinityMask-: PROCEDURE {WINAPI} ( hThread: HANDLE; dwThreadAffinityMask: DWORD): DWORD;
  713. (** The SetThreadContext function sets the context in the specified thread. *)
  714. SetThreadContext-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  715. VAR lpContext: Context ): BOOL;
  716. (** The SetThreadPriority function sets the priority value for the specified thread. *)
  717. SetThreadPriority-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  718. nPriority: LONGINT ): BOOL;
  719. (** The SetupComm function initializes the communications parameters for a specified communications device. *)
  720. SetupComm-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  721. dwInQueue, dwOutQueue: LONGINT ): BOOL;
  722. (** The Sleep function suspends the execution of the current thread for a specified interval. *)
  723. Sleep-: PROCEDURE {WINAPI} ( dwMilliseconds: LONGINT );
  724. (** The SuspendThread function suspends the specified thread. *)
  725. SuspendThread-: PROCEDURE {WINAPI} ( hThread: HANDLE ): LONGINT;
  726. (** The SystemTimeToFileTime function converts a system time to a file time. *)
  727. SystemTimeToFileTime-: PROCEDURE {WINAPI} ( VAR lpSystemTime: SystemTime;
  728. VAR lpFileTime: FileTime ): BOOL;
  729. (** The TerminateThread function terminates a thread. *)
  730. TerminateThread-: PROCEDURE {WINAPI} ( hThread: HANDLE;
  731. dwExitCode: LONGINT ): BOOL;
  732. TlsAlloc-: PROCEDURE {WINAPI} ( ): LONGINT;
  733. TlsFree-: PROCEDURE {WINAPI} ( dwTlsIndex: LONGINT ): BOOL;
  734. TlsGetValue-: PROCEDURE {WINAPI} ( dwTlsIndex: LONGINT ): LONGINT;
  735. TlsSetValue-: PROCEDURE {WINAPI} ( dwTlsIndex, lpTlsValue: LONGINT ): BOOL;
  736. (** The TryEnterCriticalSection function attempts to enter a critical section without blocking. *)
  737. TryEnterCriticalSection-: PROCEDURE {WINAPI} ( VAR lpCriticalSection: CriticalSection ): BOOL;
  738. (** The VirtualAlloc function reserves or commits a region of pages in the virtual address space of the calling process. *)
  739. VirtualAlloc-: PROCEDURE {WINAPI} ( lpAddress: ADDRESS; dwSize: SIZE;
  740. flAllocationType, flProtect: WORDSET ): ADDRESS;
  741. (** The VirtualFree function releases or decommits (or both) a region of pages within the virtual address space of the
  742. calling process. *)
  743. VirtualFree-: PROCEDURE {WINAPI} ( lpAddress: ADDRESS; dwSize: SIZE;
  744. dwFreeType: WORDSET ): BOOL;
  745. (** The WaitForSingleObject function returns when one of the following occurs:
  746. The specified object is in the signaled state.
  747. The time-out interval elapses. *)
  748. WaitForSingleObject-: PROCEDURE {WINAPI} ( hHandle: HANDLE;
  749. dwMilliseconds: LONGINT ): LONGINT;
  750. (** The WriteFile function writes data to a file and is designed for both synchronous and asynchronous operation. *)
  751. WriteFile-: PROCEDURE {WINAPI} ( hFile: HANDLE;
  752. CONST lpBuffer: ARRAY OF SYSTEM.BYTE;
  753. nNumberOfBytesToWrite: LONGINT;
  754. VAR lpNumberOfBytesWritten: LONGINT;
  755. VAR lpOverlapped: Overlapped ): BOOL;
  756. (** Thread abort notifier, parameter is the threads id. Note this should only be used in modules which
  757. can't use the exception handling mechanism provided by module Exceptions. *)
  758. (** Method used to write text to the Console. *)
  759. OutputString*: PROCEDURE ( CONST a: ARRAY OF CHAR );
  760. (* OutputString*: OutputStringProc; *)
  761. Shutdown*: PROCEDURE ( code: LONGINT );
  762. (** Wrapper for getProcAddress. *)
  763. PROCEDURE GetProcAddress*( hModule: HMODULE; CONST procName: ARRAY OF CHAR; VAR adr: ADDRESS );
  764. BEGIN
  765. adr := getProcAddress( hModule, procName )
  766. END GetProcAddress;
  767. (** Copy a zero-terminated string from address lpString. *)
  768. PROCEDURE CopyString*( lpString: LPSTR; VAR str: ARRAY OF CHAR );
  769. VAR i: LONGINT; ch: CHAR;
  770. BEGIN
  771. i := 0;
  772. IF lpString # NULL THEN
  773. SYSTEM.GET( lpString, ch );
  774. WHILE ch # 0X DO
  775. str[i] := ch; INC( i ); INC( lpString ); SYSTEM.GET( lpString, ch )
  776. END
  777. END;
  778. str[i] := 0X
  779. END CopyString;
  780. PROCEDURE OutputDebugString*( CONST str: ARRAY OF CHAR );
  781. BEGIN
  782. outputDebugString( str );
  783. END OutputDebugString;
  784. PROCEDURE NoOutputString(CONST str: ARRAY OF CHAR);
  785. BEGIN
  786. END NoOutputString;
  787. PROCEDURE ConsoleString(CONST str: ARRAY OF CHAR);
  788. VAR i: LONGINT;
  789. BEGIN
  790. i := 0;
  791. WHILE (i<LEN(str)) & (str[i] # 0X) DO
  792. TraceChar(str[i]);INC(i);
  793. END;
  794. END ConsoleString;
  795. PROCEDURE TraceChar(c: CHAR);
  796. VAR len: LONGINT; b: BOOL;
  797. BEGIN
  798. len := 1;
  799. b := WriteFile(hout,c,len,len,NIL);
  800. END TraceChar;
  801. PROCEDURE SendToDebugger*(CONST str: ARRAY OF CHAR; x: ADDRESS );
  802. VAR s: ARRAY 16 OF CHAR;
  803. d: ADDRESS; i: SIZE;
  804. pad: ARRAY 256 OF CHAR;
  805. BEGIN
  806. IF IsDebuggerPresent() = True THEN
  807. OutputDebugString( str );
  808. s[8] := 0X;
  809. FOR i := 7 TO 0 BY -1 DO
  810. d := x MOD 16;
  811. IF d < 10 THEN s[i] := CHR( d + ORD( "0" ) ) ELSE s[i] := CHR( d - 10 + ORD( "A" ) ) END;
  812. x := x DIV 16
  813. END;
  814. OutputDebugString( s ); s[0] := 0AX; s[1] := 0X; OutputDebugString( s )
  815. END;
  816. END SendToDebugger;
  817. PROCEDURE ShutdownP(l: LONGINT);
  818. VAR i: LONGINT;
  819. BEGIN
  820. OutputString("Kernel32.Shutdown");
  821. ExitProcess(l);
  822. END ShutdownP;
  823. PROCEDURE Init*;
  824. VAR mod: HMODULE;
  825. BEGIN
  826. Shutdown := ShutdownP;
  827. mod := LoadLibrary("Kernel32.DLL");
  828. GetProcAddress(mod, "AllocConsole",SYSTEM.VAL(ADDRESS,AllocConsole));
  829. GetProcAddress(mod, "AddVectoredExceptionHandler",SYSTEM.VAL(ADDRESS,AddVectoredExceptionHandler));
  830. GetProcAddress(mod, "AddVectoredContinueHandler",SYSTEM.VAL(ADDRESS,AddVectoredContinueHandler));
  831. GetProcAddress(mod, "AttachConsole",SYSTEM.VAL(ADDRESS,AttachConsole));
  832. GetProcAddress(mod, "Beep",SYSTEM.VAL(ADDRESS,Beep));
  833. GetProcAddress(mod, "CancelIoEx",SYSTEM.VAL(ADDRESS,CancelIoEx));
  834. GetProcAddress(mod, "ClearCommBreak",SYSTEM.VAL(ADDRESS,ClearCommBreak));
  835. GetProcAddress(mod, "ClearCommError",SYSTEM.VAL(ADDRESS,ClearCommError));
  836. GetProcAddress(mod, "CloseHandle",SYSTEM.VAL(ADDRESS,CloseHandle));
  837. GetProcAddress(mod, "CopyFileA",SYSTEM.VAL(ADDRESS,CopyFile));
  838. GetProcAddress(mod, "CreateDirectoryA",SYSTEM.VAL(ADDRESS,CreateDirectory));
  839. GetProcAddress(mod, "CreateEventA",SYSTEM.VAL(ADDRESS,CreateEvent));
  840. GetProcAddress(mod, "CreateFileA",SYSTEM.VAL(ADDRESS,CreateFile));
  841. GetProcAddress(mod, "CreateProcessA",SYSTEM.VAL(ADDRESS,CreateProcess));
  842. GetProcAddress(mod, "CreateSemaphoreA",SYSTEM.VAL(ADDRESS,CreateSemaphore));
  843. GetProcAddress(mod, "CreateThread",SYSTEM.VAL(ADDRESS,CreateThread));
  844. GetProcAddress(mod, "DeleteCriticalSection",SYSTEM.VAL(ADDRESS,DeleteCriticalSection));
  845. GetProcAddress(mod, "DeleteFileA",SYSTEM.VAL(ADDRESS,DeleteFile));
  846. GetProcAddress(mod, "DisableThreadLibraryCalls",SYSTEM.VAL(ADDRESS,DisableThreadLibraryCalls));
  847. GetProcAddress(mod, "DuplicateHandle",SYSTEM.VAL(ADDRESS,DuplicateHandle));
  848. GetProcAddress(mod, "EnterCriticalSection",SYSTEM.VAL(ADDRESS,EnterCriticalSection));
  849. GetProcAddress(mod, "EscapeCommFunction",SYSTEM.VAL(ADDRESS,EscapeCommFunction));
  850. GetProcAddress(mod, "ExitProcess",SYSTEM.VAL(ADDRESS,ExitProcess));
  851. GetProcAddress(mod, "ExitThread",SYSTEM.VAL(ADDRESS,ExitThread));
  852. GetProcAddress(mod, "FindClose",SYSTEM.VAL(ADDRESS,FindClose));
  853. GetProcAddress(mod, "FileTimeToLocalFileTime",SYSTEM.VAL(ADDRESS,FileTimeToLocalFileTime));
  854. GetProcAddress(mod, "FileTimeToSystemTime",SYSTEM.VAL(ADDRESS,FileTimeToSystemTime));
  855. GetProcAddress(mod, "FindFirstFileA",SYSTEM.VAL(ADDRESS,FindFirstFile));
  856. GetProcAddress(mod, "FindNextFileA",SYSTEM.VAL(ADDRESS,FindNextFile));
  857. GetProcAddress(mod, "FlushFileBuffers",SYSTEM.VAL(ADDRESS,FlushFileBuffers));
  858. GetProcAddress(mod, "FreeConsole",SYSTEM.VAL(ADDRESS,FreeConsole));
  859. GetProcAddress(mod, "FreeLibrary",SYSTEM.VAL(ADDRESS,FreeLibrary));
  860. GetProcAddress(mod, "GetCommandLineA",SYSTEM.VAL(ADDRESS,GetCommandLine));
  861. GetProcAddress(mod, "GetCommModemStatus",SYSTEM.VAL(ADDRESS,GetCommModemStatus));
  862. GetProcAddress(mod, "GetCommState",SYSTEM.VAL(ADDRESS,GetCommState));
  863. GetProcAddress(mod, "GetComputerNameA",SYSTEM.VAL(ADDRESS,GetComputerName));
  864. GetProcAddress(mod, "GetCurrentDirectoryA",SYSTEM.VAL(ADDRESS,GetCurrentDirectory));
  865. GetProcAddress(mod, "GetCurrentProcess",SYSTEM.VAL(ADDRESS,GetCurrentProcess));
  866. GetProcAddress(mod, "GetCurrentProcessId",SYSTEM.VAL(ADDRESS,GetCurrentProcessId));
  867. GetProcAddress(mod, "GetCurrentThread",SYSTEM.VAL(ADDRESS,GetCurrentThread));
  868. GetProcAddress(mod, "GetCurrentThreadId",SYSTEM.VAL(ADDRESS,GetCurrentThreadId));
  869. GetProcAddress(mod, "GetDiskFreeSpaceA",SYSTEM.VAL(ADDRESS,GetDiskFreeSpace));
  870. GetProcAddress(mod, "GetDriveTypeA",SYSTEM.VAL(ADDRESS,GetDriveType));
  871. GetProcAddress(mod, "GetExitCodeProcess",SYSTEM.VAL(ADDRESS,GetExitCodeProcess));
  872. GetProcAddress(mod, "GetFileAttributesA",SYSTEM.VAL(ADDRESS,GetFileAttributes));
  873. GetProcAddress(mod, "GetFileSize",SYSTEM.VAL(ADDRESS,GetFileSize));
  874. GetProcAddress(mod, "GetFileSizeEx",SYSTEM.VAL(ADDRESS,GetFileSizeEx));
  875. GetProcAddress(mod, "GetFileTime",SYSTEM.VAL(ADDRESS,GetFileTime));
  876. GetProcAddress(mod, "GetFullPathNameA",SYSTEM.VAL(ADDRESS,GetFullPathName));
  877. GetProcAddress(mod, "GetLastError",SYSTEM.VAL(ADDRESS,GetLastError));
  878. GetProcAddress(mod, "GetLocalTime",SYSTEM.VAL(ADDRESS,GetLocalTime));
  879. GetProcAddress(mod, "GetLogicalDriveStringsA",SYSTEM.VAL(ADDRESS,GetLogicalDriveStrings));
  880. GetProcAddress(mod, "GetLogicalDrives",SYSTEM.VAL(ADDRESS,GetLogicalDrives));
  881. GetProcAddress(mod, "GetModuleFileNameA",SYSTEM.VAL(ADDRESS,GetModuleFileName));
  882. GetProcAddress(mod, "GetModuleHandleA",SYSTEM.VAL(ADDRESS,GetModuleHandle));
  883. GetProcAddress(mod, "GetOverlappedResult",SYSTEM.VAL(ADDRESS,GetOverlappedResult));
  884. GetProcAddress(mod, "GetPrivateProfileStringA",SYSTEM.VAL(ADDRESS,GetPrivateProfileString));
  885. (* must be done by linker: GetProcAddress(mod, "GetProcAddress",SYSTEM.VAL(ADDRESS,getProcAddress)); *)
  886. GetProcAddress(mod, "GetProcessAffinityMask",SYSTEM.VAL(ADDRESS,GetProcessAffinityMask));
  887. GetProcAddress(mod, "GetProcessHeap",SYSTEM.VAL(ADDRESS,GetProcessHeap));
  888. GetProcAddress(mod, "GetProcessTimes", SYSTEM.VAL(ADDRESS, GetProcessTimes));
  889. GetProcAddress(mod, "GetStartupInfoA",SYSTEM.VAL(ADDRESS,GetStartupInfo));
  890. GetProcAddress(mod, "GetStdHandle",SYSTEM.VAL(ADDRESS,GetStdHandle));
  891. GetProcAddress(mod, "GetSystemInfo",SYSTEM.VAL(ADDRESS,GetSystemInfo));
  892. GetProcAddress(mod, "GetSystemTime",SYSTEM.VAL(ADDRESS,GetSystemTime));
  893. GetProcAddress(mod, "GetTempFileNameA",SYSTEM.VAL(ADDRESS,GetTempFileName));
  894. GetProcAddress(mod, "GetTempPathA",SYSTEM.VAL(ADDRESS,GetTempPath));
  895. GetProcAddress(mod, "GetThreadContext",SYSTEM.VAL(ADDRESS,GetThreadContext));
  896. GetProcAddress(mod, "GetThreadPriority",SYSTEM.VAL(ADDRESS,GetThreadPriority));
  897. GetProcAddress(mod, "GetThreadTimes",SYSTEM.VAL(ADDRESS,GetThreadTimes));
  898. GetProcAddress(mod, "GetTickCount",SYSTEM.VAL(ADDRESS,GetTickCount));
  899. GetProcAddress(mod, "GetWindowsDirectoryA",SYSTEM.VAL(ADDRESS,GetWindowsDirectory));
  900. GetProcAddress(mod, "GetTimeZoneInformation",SYSTEM.VAL(ADDRESS,GetTimeZoneInformation));
  901. GetProcAddress(mod, "GetVersion",SYSTEM.VAL(ADDRESS,GetVersion));
  902. GetProcAddress(mod, "GetVersionExA",SYSTEM.VAL(ADDRESS,GetVersionEx));
  903. GetProcAddress(mod, "GetVolumeInformationA",SYSTEM.VAL(ADDRESS,GetVolumeInformation));
  904. GetProcAddress(mod, "GlobalAddAtomA",SYSTEM.VAL(ADDRESS,GlobalAddAtom));
  905. GetProcAddress(mod, "GlobalAlloc",SYSTEM.VAL(ADDRESS,GlobalAlloc));
  906. GetProcAddress(mod, "GlobalDeleteAtom",SYSTEM.VAL(ADDRESS,GlobalDeleteAtom));
  907. GetProcAddress(mod, "GlobalLock",SYSTEM.VAL(ADDRESS,GlobalLock));
  908. GetProcAddress(mod, "GlobalReAlloc",SYSTEM.VAL(ADDRESS,GlobalReAlloc));
  909. GetProcAddress(mod, "GlobalSize",SYSTEM.VAL(ADDRESS,GlobalSize));
  910. GetProcAddress(mod, "GlobalUnlock",SYSTEM.VAL(ADDRESS,GlobalUnlock));
  911. GetProcAddress(mod, "HeapAlloc",SYSTEM.VAL(ADDRESS,HeapAlloc));
  912. GetProcAddress(mod, "HeapFree",SYSTEM.VAL(ADDRESS,HeapFree));
  913. GetProcAddress(mod, "InitializeCriticalSection",SYSTEM.VAL(ADDRESS,InitializeCriticalSection));
  914. GetProcAddress(mod, "InterlockedDecrement",SYSTEM.VAL(ADDRESS,InterlockedDecrement));
  915. GetProcAddress(mod, "InterlockedIncrement",SYSTEM.VAL(ADDRESS,InterlockedIncrement));
  916. GetProcAddress(mod, "IsDebuggerPresent",SYSTEM.VAL(ADDRESS,IsDebuggerPresent));
  917. GetProcAddress(mod, "LeaveCriticalSection",SYSTEM.VAL(ADDRESS,LeaveCriticalSection));
  918. (* must be done by linker: GetProcAddress(mod, "LoadLibraryA",SYSTEM.VAL(ADDRESS,LoadLibrary)); *)
  919. GetProcAddress(mod, "LocalFileTimeToFileTime",SYSTEM.VAL(ADDRESS,LocalFileTimeToFileTime));
  920. GetProcAddress(mod, "MoveFileExA",SYSTEM.VAL(ADDRESS,MoveFileEx));
  921. GetProcAddress(mod, "OutputDebugStringA",SYSTEM.VAL(ADDRESS,outputDebugString));
  922. GetProcAddress(mod, "PurgeComm",SYSTEM.VAL(ADDRESS,PurgeComm));
  923. GetProcAddress(mod, "QueryDosDeviceA",SYSTEM.VAL(ADDRESS,QueryDosDevice));
  924. GetProcAddress(mod, "QueryPerformanceCounter",SYSTEM.VAL(ADDRESS,QueryPerformanceCounter));
  925. GetProcAddress(mod, "QueryPerformanceFrequency",SYSTEM.VAL(ADDRESS,QueryPerformanceFrequency));
  926. GetProcAddress(mod, "QueryThreadCycleTime", SYSTEM.VAL(ADDRESS, QueryThreadCycleTime));
  927. GetProcAddress(mod, "ReadFile",SYSTEM.VAL(ADDRESS,ReadFile));
  928. GetProcAddress(mod, "ReadProcessMemory",SYSTEM.VAL(ADDRESS,ReadProcessMemory));
  929. GetProcAddress(mod, "ReleaseSemaphore",SYSTEM.VAL(ADDRESS,ReleaseSemaphore));
  930. GetProcAddress(mod, "RemoveDirectoryA",SYSTEM.VAL(ADDRESS,RemoveDirectory));
  931. GetProcAddress(mod, "RemoveVectoredExceptionHandler",SYSTEM.VAL(ADDRESS,RemoveVectoredExceptionHandler));
  932. GetProcAddress(mod, "RemoveVectoredExceptionHandler",SYSTEM.VAL(ADDRESS,RemoveVectoredContinueHandler));
  933. GetProcAddress(mod, "ResetEvent",SYSTEM.VAL(ADDRESS,ResetEvent));
  934. GetProcAddress(mod, "ResumeThread",SYSTEM.VAL(ADDRESS,ResumeThread));
  935. GetProcAddress(mod, "SearchPathA",SYSTEM.VAL(ADDRESS,SearchPath));
  936. GetProcAddress(mod, "SetCommBreak",SYSTEM.VAL(ADDRESS,SetCommBreak));
  937. GetProcAddress(mod, "SetCommMask",SYSTEM.VAL(ADDRESS,SetCommMask));
  938. GetProcAddress(mod, "SetCommState",SYSTEM.VAL(ADDRESS,SetCommState));
  939. GetProcAddress(mod, "SetCommTimeouts",SYSTEM.VAL(ADDRESS,SetCommTimeouts));
  940. GetProcAddress(mod, "SetConsoleCursorPosition",SYSTEM.VAL(ADDRESS,SetConsoleCursorPosition));
  941. GetProcAddress(mod, "SetConsoleScreenBufferSize",SYSTEM.VAL(ADDRESS,SetConsoleScreenBufferSize));
  942. GetProcAddress(mod, "SetConsoleTextAttribute",SYSTEM.VAL(ADDRESS,SetConsoleTextAttribute));
  943. GetProcAddress(mod, "SetConsoleTitleA",SYSTEM.VAL(ADDRESS,SetConsoleTitle));
  944. GetProcAddress(mod, "SetConsoleWindowInfo",SYSTEM.VAL(ADDRESS,SetConsoleWindowInfo));
  945. GetProcAddress(mod, "SetCurrentDirectoryA",SYSTEM.VAL(ADDRESS,SetCurrentDirectory));
  946. GetProcAddress(mod, "SetEndOfFile",SYSTEM.VAL(ADDRESS,SetEndOfFile));
  947. GetProcAddress(mod, "SetErrorMode",SYSTEM.VAL(ADDRESS,SetErrorMode));
  948. GetProcAddress(mod, "SetEvent",SYSTEM.VAL(ADDRESS,SetEvent));
  949. GetProcAddress(mod, "SetFileAttributesA",SYSTEM.VAL(ADDRESS,SetFileAttributes));
  950. GetProcAddress(mod, "SetFilePointer",SYSTEM.VAL(ADDRESS,SetFilePointer));
  951. GetProcAddress(mod, "SetFilePointerEx",SYSTEM.VAL(ADDRESS,SetFilePointerEx));
  952. GetProcAddress(mod, "SetFileTime",SYSTEM.VAL(ADDRESS,SetFileTime));
  953. GetProcAddress(mod, "SetLocalTime",SYSTEM.VAL(ADDRESS,SetLocalTime));
  954. GetProcAddress(mod, "SetThreadAffinityMask",SYSTEM.VAL(ADDRESS,SetThreadAffinityMask));
  955. GetProcAddress(mod, "SetThreadContext",SYSTEM.VAL(ADDRESS,SetThreadContext));
  956. GetProcAddress(mod, "SetThreadPriority",SYSTEM.VAL(ADDRESS,SetThreadPriority));
  957. GetProcAddress(mod, "SetupComm",SYSTEM.VAL(ADDRESS,SetupComm));
  958. GetProcAddress(mod, "Sleep",SYSTEM.VAL(ADDRESS,Sleep));
  959. GetProcAddress(mod, "SuspendThread",SYSTEM.VAL(ADDRESS,SuspendThread));
  960. GetProcAddress(mod, "SystemTimeToFileTime",SYSTEM.VAL(ADDRESS,SystemTimeToFileTime));
  961. GetProcAddress(mod, "TerminateThread",SYSTEM.VAL(ADDRESS,TerminateThread));
  962. GetProcAddress(mod, "TlsAlloc",SYSTEM.VAL(ADDRESS,TlsAlloc));
  963. GetProcAddress(mod, "TlsFree",SYSTEM.VAL(ADDRESS,TlsFree));
  964. GetProcAddress(mod, "TlsGetValue",SYSTEM.VAL(ADDRESS,TlsGetValue));
  965. GetProcAddress(mod, "TlsSetValue",SYSTEM.VAL(ADDRESS,TlsSetValue));
  966. GetProcAddress(mod, "TryEnterCriticalSection", SYSTEM.VAL(ADDRESS, TryEnterCriticalSection));
  967. GetProcAddress(mod, "VirtualAlloc",SYSTEM.VAL(ADDRESS,VirtualAlloc));
  968. GetProcAddress(mod, "VirtualFree",SYSTEM.VAL(ADDRESS,VirtualFree));
  969. GetProcAddress(mod, "WaitForSingleObject",SYSTEM.VAL(ADDRESS,WaitForSingleObject));
  970. GetProcAddress(mod, "WriteFile",SYSTEM.VAL(ADDRESS,WriteFile));
  971. GetProcAddress(mod, "GlobalMemoryStatusEx",SYSTEM.VAL(ADDRESS,GlobalMemoryStatusEx));
  972. isEXE := hInstance = NULL;
  973. IF isEXE THEN hInstance := GetModuleHandle( NIL ) END;
  974. SetTraceConsole;
  975. IF IsDebuggerPresent()=True THEN
  976. OutputString := OutputDebugString
  977. ELSE
  978. OutputString := ConsoleString
  979. END;
  980. END Init;
  981. VAR g: BOOLEAN;
  982. VAR hout: HANDLE;
  983. PROCEDURE SetTraceConsole;
  984. VAR res: WORD;
  985. BEGIN
  986. hout := GetStdHandle (STDOutput);
  987. Trace.Char := TraceChar;
  988. END SetTraceConsole;
  989. #IF I386 THEN
  990. (* The following procedure is linked as the first block in the code section of a PE32 executable file
  991. It contains the import table for the two procedures Kernel32.GetProcAddress and Kernel32.LoadLibrary that
  992. are patched by the PE linker.
  993. [CF. Microsoft Portable Executable and Common Object File Format Specification]
  994. *)
  995. PROCEDURE {NOPAF, FIXED(401000H)} EntryPoint;
  996. CODE{SYSTEM.i386}
  997. JMP DWORD end;
  998. DB 0
  999. DB 0
  1000. DB 0
  1001. ImportTable:
  1002. DD Kernel32Import + 1000H
  1003. DD 0
  1004. DD -1
  1005. DD Kernel32Name + 1000H
  1006. DD Kernel32Import + 1000H
  1007. DD 0, 0, 0, 0, 0
  1008. Kernel32Import:
  1009. adrLoadLibrary:
  1010. DD LoadLibraryA + 1000H
  1011. adrGetProcAddress:
  1012. DD GetProcAddress + 1000H
  1013. DD 0
  1014. Kernel32Name:
  1015. DB 'KERNEL32.DLL' , 0
  1016. LoadLibraryA:
  1017. DW 0
  1018. DB 'LoadLibraryA',0,0
  1019. GetProcAddress:
  1020. DW 0
  1021. DB 'GetProcAddress',0
  1022. end:
  1023. MOV EAX,[401000H+adrLoadLibrary]
  1024. MOV LoadLibrary, EAX
  1025. MOV EAX,[401000H+adrGetProcAddress]
  1026. MOV getProcAddress, EAX
  1027. END EntryPoint;
  1028. #ELSIF AMD64 THEN
  1029. (* The following procedure is linked as the first block in the code section of a PE32 executable file
  1030. It contains the import table for the two procedures Kernel32.GetProcAddress and Kernel32.LoadLibrary that
  1031. are patched by the PE linker.
  1032. [CF. Microsoft Portable Executable and Common Object File Format Specification]
  1033. *)
  1034. PROCEDURE {NOPAF, FIXED(401000H)} EntryPoint;
  1035. CODE{SYSTEM.AMD64}
  1036. JMP DWORD end;
  1037. DB 0
  1038. DB 0
  1039. DB 0
  1040. ImportTable:
  1041. DD Kernel32Import + 1000H
  1042. DD 0
  1043. DD -1
  1044. DD Kernel32Name + 1000H
  1045. DD Kernel32Import + 1000H
  1046. DD 0, 0, 0, 0, 0
  1047. Kernel32Import:
  1048. adrLoadLibrary:
  1049. DD LoadLibraryA + 1000H
  1050. DD 0
  1051. adrGetProcAddress:
  1052. DD GetProcAddress + 1000H
  1053. DD 0
  1054. DD 0
  1055. DD 0
  1056. Kernel32Name:
  1057. DB 'KERNEL32.DLL' , 0
  1058. LoadLibraryA:
  1059. DW 0
  1060. DB 'LoadLibraryA',0,0
  1061. GetProcAddress:
  1062. DW 0
  1063. DB 'GetProcAddress',0
  1064. end:
  1065. MOV RAX,[401000H+adrLoadLibrary]
  1066. MOV LoadLibrary, RAX
  1067. MOV RAX,[401000H+adrGetProcAddress]
  1068. MOV getProcAddress, RAX
  1069. END EntryPoint;
  1070. #ELSE
  1071. UNIMPLEMENTED
  1072. #END
  1073. END Kernel32.