Windows.Kernel32.Mod 60 KB

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