2
0

doscall2.pas 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2014 by the Free Pascal development team.
  4. Additional OS/2 API functions implemented in DOSCALL1.DLL:
  5. - File handling (64-bit functions available in WSeB/MCP/eCS and
  6. protected access to file handles as available in OS/2 2.1+)
  7. - Certain SMP related functions for querying and setting status
  8. of processors and thread and system affinity (available
  9. in SMP-ready versions of OS/2 kernels)
  10. - Support for working with extended LIBPATH (available in
  11. OS/2 Warp 4.0 and higher).
  12. Availability of individual functions is checked dynamically during
  13. initialization and fake (simulated) functions are used if running
  14. under an OS/2 version not providing the respective functionality.
  15. See the file COPYING.FPC, included in this distribution,
  16. for details about the copyright.
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. **********************************************************************}
  21. {$IFNDEF FPC_DOTTEDUNITS}
  22. unit DosCall2;
  23. {$ENDIF FPC_DOTTEDUNITS}
  24. {***************************************************************************}
  25. interface
  26. {***************************************************************************}
  27. {$IFDEF FPC_DOTTEDUNITS}
  28. uses
  29. OS2Api.doscalls, System.Strings;
  30. {$ELSE FPC_DOTTEDUNITS}
  31. uses
  32. DosCalls, Strings;
  33. {$ENDIF FPC_DOTTEDUNITS}
  34. const
  35. (* Status in DosGet/SetProcessorStatus *)
  36. PROC_OFFLINE = 0; (* Processor is offline *)
  37. PROC_ONLINE = 1; (* Processor is online *)
  38. (* Scope in DosQueryThreadAffinity *)
  39. AFNTY_THREAD = 0; (* Return the current threads processor affinity mask. *)
  40. AFNTY_SYSTEM = 1; (* Return the system's current capable processor affinity
  41. mask. *)
  42. (* Flags in DosQuery/SetExtLibPath *)
  43. BEGIN_LIBPATH = 1; (* The new path is searched before the LIBPATH. *)
  44. END_LIBPATH = 2; (* The new path is searched after the LIBPATH. *)
  45. (* Constants for DosSuppressPopups *)
  46. SPU_DisableSuppression = 0;
  47. SPU_EnableSuppression = 1;
  48. (* Constants for DosDumpProcess *)
  49. DDP_DisableProcDump = 0;
  50. DDP_EnableProcDump = 1;
  51. DDP_PerformProcDump = 2;
  52. (* Constants for DosPerfSysCall *)
  53. Cmd_KI_Enable = $60;
  54. Cmd_KI_RdCnt = $63;
  55. Cmd_SoftTrace_Log = $14;
  56. (* Constants for DosQueryABIOSSupport *)
  57. HW_Cfg_MCA = 1;
  58. HW_Cfg_EISA = 2;
  59. HW_Cfg_ABIOS_Supported = 4;
  60. HW_Cfg_ABIOS_Present = 8;
  61. HW_Cfg_PCI = 16;
  62. HW_Cfg_OEM_ABIOS = 32;
  63. HW_Cfg_IBM_ABIOS = 0;
  64. HW_Cfg_Pentium_CPU = 64;
  65. (* Constants for DosQueryThreadContext - Level *)
  66. Context_Control = 1; { Control registers: SS:ESP, CS:EIP, EFLAGS and EBP }
  67. Context_Integer = 2; { EAX, EBX, ECX, EDX, ESI and EDI }
  68. Context_Segments = 4; { Segment registers: DS, ES, FS, and GS }
  69. Context_Floating_Point = 8; { Numeric coprocessor state }
  70. Context_Full = 15; { All of the above }
  71. type
  72. TFileLockL = record
  73. case boolean of
  74. false:
  75. (Offset: int64; (* Offset to beginning of the lock (or unlock) range. *)
  76. Range: int64); (* Length of the lock (or unlock) range in bytes. *)
  77. (* Length of 0 => locking (or unlocking) not required. *)
  78. true:
  79. (lOffset: int64;
  80. lRange: int64);
  81. end;
  82. PFileLockL = ^TFileLockL;
  83. TMPAffinity = record
  84. Mask: array [0..1] of cardinal;
  85. end;
  86. PMPAffinity = ^TMPAffinity;
  87. TCPUUtil = record
  88. TotalLow,
  89. TotalHigh,
  90. IdleLow,
  91. IdleHigh,
  92. BusyLow,
  93. BusyHigh,
  94. IntrLow,
  95. IntrHigh: cardinal;
  96. end;
  97. PCPUUtil = ^TCPUUtil;
  98. function DosOpenL (FileName: PAnsiChar; var Handle: THandle;
  99. var Action: cardinal; InitSize: int64;
  100. Attrib, OpenFlags, FileMode: cardinal;
  101. EA: pointer): cardinal; cdecl;
  102. function DosSetFilePtrL (Handle: THandle; Pos: int64; Method: cardinal;
  103. var PosActual: int64): cardinal; cdecl;
  104. function DosSetFileSizeL (Handle: THandle; Size: int64): cardinal; cdecl;
  105. function DosProtectOpen (FileName: PAnsiChar; var Handle: longint;
  106. var Action: longint; InitSize, Attrib,
  107. OpenFlags, OpenMode: longint; ea: PEAOp2;
  108. var FileHandleLockID: cardinal): cardinal; cdecl;
  109. function DosProtectOpen (const FileName: string; var Handle: longint;
  110. var Action: longint; InitSize, Attrib,
  111. OpenFlags, OpenMode: longint; ea: PEAOp2;
  112. var FileHandleLockID: cardinal): cardinal;
  113. function DosProtectOpen (const FileName: string; var Handle: THandle;
  114. var Action: cardinal; InitSize, Attrib,
  115. OpenFlags, OpenMode: cardinal; ea: PEAOp2;
  116. var FileHandleLockID: cardinal): cardinal;
  117. function DosProtectRead (Handle: longint; var Buffer; Count: longint;
  118. var ActCount: longint; FileHandleLockID: cardinal): cardinal; cdecl;
  119. function DosProtectWrite (Handle: longint; const Buffer; Count: longint;
  120. var ActCount: longint;
  121. FileHandleLockID: cardinal): cardinal; cdecl;
  122. function DosProtectSetFilePtr (Handle: longint; Pos, Method: longint;
  123. var PosActual: longint;
  124. FileHandleLockID: cardinal): cardinal; cdecl;
  125. function DosProtectSetFilePtr (Handle: THandle; Pos: longint;
  126. FileHandleLockID: cardinal): cardinal;
  127. function DosProtectGetFilePtr (Handle: longint;
  128. var PosActual: longint; FileHandleLockID: cardinal): cardinal;
  129. function DosProtectGetFilePtr (Handle: THandle;
  130. var PosActual: cardinal; FileHandleLockID: cardinal): cardinal;
  131. function DosProtectEnumAttribute (Handle: THandle; Entry: cardinal; var Buf;
  132. BufSize: cardinal; var Count: cardinal;
  133. InfoLevel: cardinal;
  134. FileHandleLockID: cardinal): cardinal;
  135. function DosProtectEnumAttribute (const FileName: string; Entry: cardinal;
  136. var Buf; BufSize: cardinal;
  137. var Count: cardinal; InfoLevel: cardinal;
  138. FileHandleLockID: cardinal): cardinal;
  139. function DosProtectOpen (FileName: PAnsiChar; var Handle: THandle;
  140. var Action: cardinal; InitSize, Attrib,
  141. OpenFlags, OpenMode: cardinal; ea: PEAOp2;
  142. var FileHandleLockID: cardinal): cardinal; cdecl;
  143. function DosProtectClose (Handle: THandle;
  144. FileHandleLockID: cardinal): cardinal; cdecl;
  145. function DosProtectRead (Handle: THandle; var Buffer; Count: cardinal;
  146. var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl;
  147. function DosProtectWrite (Handle: THandle; const Buffer; Count: cardinal;
  148. var ActCount: cardinal;
  149. FileHandleLockID: cardinal): cardinal; cdecl;
  150. function DosProtectSetFilePtr (Handle: THandle; Pos: longint;
  151. Method: cardinal; var PosActual: cardinal;
  152. FileHandleLockID: cardinal): cardinal; cdecl;
  153. function DosProtectSetFileSize (Handle: THandle; Size: cardinal;
  154. FileHandleLockID: cardinal): cardinal; cdecl;
  155. function DosProtectQueryFHState (Handle: THandle; var FileMode: cardinal;
  156. FileHandleLockID: cardinal): cardinal; cdecl;
  157. function DosProtectSetFHState (Handle: THandle; FileMode: cardinal;
  158. FileHandleLockID: cardinal): cardinal; cdecl;
  159. function DosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal;
  160. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  161. FileHandleLockID: cardinal): cardinal; cdecl;
  162. function DosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal;
  163. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  164. FileHandleLockID: cardinal): cardinal; cdecl;
  165. function DosProtectEnumAttribute (RefType: cardinal; AFile: pointer;
  166. Entry: cardinal; var Buf; BufSize: cardinal;
  167. var Count: cardinal; InfoLevel: cardinal;
  168. FileHandleLockID: cardinal): cardinal; cdecl;
  169. function DosProtectSetFileLocks (Handle: THandle;
  170. var Unlock, Lock: TFileLock;
  171. Timeout, Flags: cardinal;
  172. FileHandleLockID: cardinal): cardinal; cdecl;
  173. (*
  174. DosCancelLockRequestL cancels an outstanding DosSetFileLocksL request.
  175. If two threads in a process are waiting on a lock file range, and another
  176. thread issues DosCancelLockRequestL for that lock file range, then both
  177. waiting threads are released.
  178. Not all file-system drivers (FSDs) can cancel an outstanding lock request.
  179. Local Area Network (LAN) servers cannot cancel an outstanding lock request
  180. if they use a version of the operating system prior to OS/2 Version 2.00.
  181. Possible results:
  182. 0 No_Error
  183. 6 Error_Invalid_Handle
  184. 87 Error_Invalid_Parameter
  185. 173 Error_Cancel_Violation
  186. Handle = File handle used in the DosSetFileLocksL function
  187. that is to be cancelled.
  188. Lock = Specification of the lock request to be cancelled.
  189. *)
  190. function DosCancelLockRequestL (Handle: THandle;
  191. var Lock: TFileLockL): cardinal; cdecl;
  192. (*
  193. DosProtectSetFileLocksL locks and unlocks a range of an open file.
  194. Parameters:
  195. Handle = file handle
  196. Unlock = record containing the offset and length of a range to be unlocked
  197. Lock = record containing the offset and length of a range to be locked
  198. Timeout = the maximum time that the process is to wait for the requested locks
  199. (in milliseconds)
  200. Flags = bit mask specifying action to be taken.
  201. Bits 31..2 are reserved.
  202. Bit 1 (Atomic) means request for atomic locking - if the bit is set
  203. and the lock range is equal to the unlock range, an atomic lock occurs.
  204. If this bit is set to 1 and the lock range is not equal to the unlock
  205. range, an error is returned. If this bit is set to 0, then the lock
  206. may or may not occur atomically with the unlock.
  207. Bit 0 (Share) defines the type of access that other processes may have
  208. to the file range that is being locked. If this bit is set to 0
  209. (default), other processes have no access to the locked file range.
  210. The current process has exclusive access to the locked file range,
  211. which must not overlap any other locked file range. If this bit is set
  212. to 1, the current process and other processes have shared read only
  213. access to the locked file range. A file range with shared access may
  214. overlap any other file range with shared access, but must not overlap
  215. any other file range with exclusive access.
  216. FileHandleLockID = filehandle lockid returned by a previous DosProtectOpenL.
  217. Possible return codes:
  218. 0 NO_ERROR
  219. 6 ERROR_INVALID_HANDLE
  220. 33 ERROR_LOCK_VIOLATION
  221. 36 ERROR_SHARING_BUFFER_EXCEEDED
  222. 87 ERROR_INVALID_PARAMETER
  223. 95 ERROR_INTERRUPT
  224. 174 ERROR_ATOMIC_LOCK_NOT_SUPPORTED
  225. 175 ERROR_READ_LOCKS_NOT_SUPPORTED
  226. Remarks:
  227. DosProtectSetFileLocksL allows a process to lock and unlock a range in a file.
  228. The time during which a file range is locked should be short.
  229. If the lock and unlock ranges are both zero, ERROR_LOCK_VIOLATION is returned
  230. to the caller.
  231. If you only want to lock a file range, set the unlock file offset and the
  232. unlock range length to zero.
  233. If you only want to unlock a file range, set the lock file offset and the lock
  234. range length to zero.
  235. When the Atomic bit of flags is set to 0, and DosProtectSetFileLocksL specifies
  236. a lock operation and an unlock operation, the unlock operation occurs first,
  237. and then the lock operation is performed. If an error occurs during the unlock
  238. operation, an error code is returned and the lock operation is not performed.
  239. If an error occurs during the lock operation, an error code is returned and the
  240. unlock remains in effect if it was successful.
  241. The lock operation is atomic when all of these conditions are met:
  242. - The Atomic bit is set to 1 in flags
  243. - The unlock range is the same as the lock range
  244. - The process has shared access to the file range, and has requested exclusive
  245. access to it; or the process has exclusive access to the file range, and has
  246. requested shared access to it.
  247. Some file system drivers (FSDs) may not support atomic lock operations.
  248. Versions of the operating system prior to OS/2 Version 2.00 do not support
  249. atomic lock operations. If the application receives the error code
  250. ERROR_ATOMIC_LOCK_NOT_SUPPORTED, the application should unlock the file range
  251. and then lock it using a non-atomic operation (with the atomic bit set to 0
  252. in Flags). The application should also refresh its internal buffers before
  253. making any changes to the file.
  254. If you issue DosProtectClose to close a file with locks still in effect,
  255. the locks are released in no defined sequence.
  256. If you end a process with a file open, and you have locks in effect in that
  257. file, the file is closed and the locks are released in no defined sequence.
  258. The locked range can be anywhere in the logical file. Locking beyond the end
  259. of the file is not an error. A file range to be locked exclusively must first
  260. be cleared of any locked file sub-ranges or overlapping locked file ranges.
  261. If you repeat DosProtectSetFileLocksL for the same file handle and file range,
  262. then you duplicate access to the file range. Access to locked file ranges
  263. is not duplicated across DosExecPgm. The proper method of using locks is
  264. to attempt to lock the file range, and to examine the return value.
  265. The following table shows the level of access granted when the accessed file
  266. range is locked with an exclusive lock or a shared lock. Owner refers to
  267. a process that owns the lock. Non-owner refers to a process that does not own
  268. the lock.
  269. Action Exclusive Lock Shared Lock
  270. ===================================================================
  271. Owner read Success Success
  272. -------------------------------------------------------------------
  273. Non-owner Wait for unlock. Return Success
  274. read error code after time-out.
  275. -------------------------------------------------------------------
  276. Owner write Success Wait for unlock. Return
  277. error code after time-out.
  278. -------------------------------------------------------------------
  279. Non-owner Wait for unlock. Return Wait for unlock. Return
  280. write error code after time-out. error code after time-out.
  281. -------------------------------------------------------------------
  282. If only locking is specified, DosProtectSetFileLocksL locks the specified file
  283. range using Lock. If the lock operation cannot be accomplished, an error is
  284. returned, and the file range is not locked.
  285. After the lock request is processed, a file range can be unlocked using the
  286. Unlock parameter of another DosProtectSetFileLocksL request. If unlocking
  287. cannot be accomplished, an error is returned.
  288. Instead of denying read/write access to an entire file by specifying access
  289. and sharing modes with DosProtectOpenL requests, a process attempts to lock
  290. only the range needed for read/write access and examines the error code
  291. returned.
  292. Once a specified file range is locked exclusively, read and write access by
  293. another process is denied until the file range is unlocked. If both unlocking
  294. and locking are specified by DosProtectSetFileLocksL, the unlocking operation
  295. is performed first, then locking is done.
  296. *)
  297. function DosProtectSetFileLocksL (Handle: THandle; var Unlock: TFileLockL;
  298. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal;
  299. FileHandleLockID: cardinal): cardinal; cdecl;
  300. (*
  301. DosSetFileLocksL locks and unlocks a range of an open file.
  302. Parameters:
  303. Handle = file handle
  304. Unlock = record containing the offset and length of a range to be unlocked
  305. Lock = record containing the offset and length of a range to be locked
  306. Timeout = the maximum time that the process is to wait for the requested locks
  307. (in milliseconds)
  308. Flags = bit mask specifying action to be taken.
  309. Bits 31..2 are reserved.
  310. Bit 1 (Atomic) means request for atomic locking - if the bit is set
  311. and the lock range is equal to the unlock range, an atomic lock occurs.
  312. If this bit is set to 1 and the lock range is not equal to the unlock
  313. range, an error is returned. If this bit is set to 0, then the lock
  314. may or may not occur atomically with the unlock.
  315. Bit 0 (Share) defines the type of access that other processes may have
  316. to the file range that is being locked. If this bit is set to 0
  317. (default), other processes have no access to the locked file range.
  318. The current process has exclusive access to the locked file range,
  319. which must not overlap any other locked file range. If this bit is set
  320. to 1, the current process and other processes have shared read only
  321. access to the locked file range. A file range with shared access may
  322. overlap any other file range with shared access, but must not overlap
  323. any other file range with exclusive access.
  324. Possible return codes:
  325. 0 NO_ERROR
  326. 1 ERROR_INVALID_FUNCTION
  327. 6 ERROR_INVALID_HANDLE
  328. 33 ERROR_LOCK_VIOLATION
  329. 36 ERROR_SHARING_BUFFER_EXCEEDED
  330. 87 ERROR_INVALID_PARAMETER
  331. 95 ERROR_INTERRUPT
  332. 174 ERROR_ATOMIC_LOCK_NOT_SUPPORTED
  333. 175 ERROR_READ_LOCKS_NOT_SUPPORTED
  334. Remarks:
  335. DosSetFileLocksL allows a process to lock and unlock a range in a file. The
  336. time during which a file range is locked should be short.
  337. If the lock and unlock ranges are both zero, ERROR_LOCK_VIOLATION is returned
  338. to the caller.
  339. If you only want to lock a file range, set the unlock file offset and the
  340. unlock range length to zero.
  341. If you only want to unlock a file range, set the lock file offset and the lock
  342. range length to zero.
  343. When the Atomic bit of flags is set to 0, and DosSetFileLocksL specifies a lock
  344. operation and an unlock operation, the unlock operation occurs first, and then
  345. the lock operation is performed. If an error occurs during the unlock
  346. operation, an error code is returned and the lock operation is not performed.
  347. If an error occurs during the lock operation, an error code is returned and the
  348. unlock remains in effect if it was successful.
  349. The lock operation is atomic when all of these conditions are met:
  350. - The Atomic bit is set to 1 in flags
  351. - The unlock range is the same as the lock range
  352. - The process has shared access to the file range, and has requested exclusive
  353. access to it; or the process has exclusive access to the file range, and has
  354. requested shared access to it.
  355. Some file system drivers (FSDs) may not support atomic lock operations.
  356. Versions of the operating system prior to OS/2 Version 2.00 do not support
  357. atomic lock operations. If the application receives the error code
  358. ERROR_ATOMIC_LOCK_NOT_SUPPORTED, the application should unlock the file range
  359. and then lock it using a non-atomic operation (with the atomic bit set to 0 in
  360. flags). The application should also refresh its internal buffers before making
  361. any changes to the file.
  362. If you issue DosClose to close a file with locks still in effect, the locks are
  363. released in no defined sequence.
  364. If you end a process with a file open, and you have locks in effect in that
  365. file, the file is closed and the locks are released in no defined sequence.
  366. The locked range can be anywhere in the logical file. Locking beyond the end of
  367. the file is not an error. A file range to be locked exclusively must first be
  368. cleared of any locked file subranges or overlapping locked file ranges.
  369. If you repeat DosSetFileLocksL for the same file handle and file range, then
  370. you duplicate access to the file range. Access to locked file ranges is not
  371. duplicated across DosExecPgm. The proper method of using locks is to attempt to
  372. lock the file range, and to examine the return value.
  373. The following table shows the level of access granted when the accessed file
  374. range is locked with an exclusive lock or a shared lock. Owner refers to
  375. a process that owns the lock. Non-owner refers to a process that does not own
  376. the lock.
  377. Action Exclusive Lock Shared Lock
  378. ===================================================================
  379. Owner read Success Success
  380. -------------------------------------------------------------------
  381. Non-owner Wait for unlock. Return Success
  382. read error code after time-out.
  383. -------------------------------------------------------------------
  384. Owner write Success Wait for unlock. Return
  385. error code after time-out.
  386. -------------------------------------------------------------------
  387. Non-owner Wait for unlock. Return Wait for unlock. Return
  388. write error code after time-out. error code after time-out.
  389. -------------------------------------------------------------------
  390. If only locking is specified, DosSetFileLocksL locks the specified file range
  391. using Lock. If the lock operation cannot be accomplished, an error is
  392. returned, and the file range is not locked.
  393. After the lock request is processed, a file range can be unlocked using the
  394. Unlock parameter of another DosSetFileLocksL request. If unlocking cannot be
  395. accomplished, an error is returned.
  396. Instead of denying read/write access to an entire file by specifying access and
  397. sharing modes with DosOpenL requests, a process attempts to lock only the range
  398. needed for read/write access and examines the error code returned.
  399. Once a specified file range is locked exclusively, read and write access by
  400. another process is denied until the file range is unlocked. If both unlocking
  401. and locking are specified by DosSetFileLocksL, the unlocking operation is
  402. performed first, then locking is done.
  403. *)
  404. function DosSetFileLocksL (Handle: THandle; var Unlock: TFileLockL;
  405. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl;
  406. (*
  407. DosProtectOpenL opens a new file, an existing file, or a replacement for an
  408. existing file and returns a protected file handle. An open file can have
  409. extended attributes.
  410. Parameters:
  411. FileName = ASCIIZ path name of the file or device to be opened.
  412. Handle = handle for the file is returned here.
  413. Action = value that specifies the action taken by DosProtectOpenL is returned
  414. here; if DosProtectOpenL fails, this value has no meaning, otherwise,
  415. it is one of the following values:
  416. 1 FILE_EXISTED - file already existed.
  417. 2 FILE_CREATED - file was created.
  418. 3 FILE_TRUNCATED - file existed and was changed to a given size (file was
  419. replaced).
  420. InitSize = new logical size of the file (end of data, EOD), in bytes; this
  421. parameter is significant only when creating a new file or replacing
  422. an existing one. Otherwise, it is ignored. It is an error to create
  423. or replace a file with a nonzero length if the OpenMode
  424. Access-Mode flag is set to read-only.
  425. Attrib = file attributes; this parameter contains the following bit fields:
  426. Bits Description
  427. 31..6 - reserved, must be 0.
  428. 5 FILE_ARCHIVED (0x00000020) - file has been archived.
  429. 4 FILE_DIRECTORY (0x00000010) - file is a subdirectory.
  430. 3 - reserved, must be 0.
  431. 2 FILE_SYSTEM (0x00000004) - file is a system file.
  432. 1 FILE_HIDDEN (0x00000002) - file is hidden and does not appear in
  433. a directory listing.
  434. 0 FILE_READONLY (0x00000001) - file can be read from, but not written
  435. to.
  436. 0 FILE_NORMAL (0x00000000) - file can be read from or written to.
  437. File attributes apply only if the file is created. These bits may be set
  438. individually or in combination. For example, an attribute value of 0x00000021
  439. (bits 5 and 0 set to 1) indicates a read-only file that has been archived.
  440. OpenFlags = the action to be taken depending on whether the file exists or
  441. does not exist. This parameter contains the following bit fields:
  442. Bits Description
  443. 31..8 - reserved, must be 0.
  444. 7..4 - the following flags apply if the file does not exist:
  445. 0000 OPEN_ACTION_FAIL_IF_NEW
  446. Open an existing file; fail if the file does not exist.
  447. 0001 OPEN_ACTION_CREATE_IF_NEW
  448. Create the file if the file does not exist.
  449. 3..0 The following flags apply if the file does not exist:
  450. 0000 OPEN_ACTION_FAIL_IF_EXISTS
  451. Open the file; fail if the file already exists.
  452. 0001 OPEN_ACTION_OPEN_IF_EXISTS
  453. Open the file if it already exists.
  454. 0010 OPEN_ACTION_REPLACE_IF_EXISTS
  455. Replace the file if it already exists.
  456. OpenMode = the mode of the open function. This parameter contains the
  457. following bit fields:
  458. Bits Description
  459. 31 - reserved, must be zero.
  460. 30 OPEN_FLAGS_PROTECTED_HANDLE (0x40000000) - protected file handle flag.
  461. 0 - unprotected Handle
  462. 1 - protected Handle
  463. Protected handle requires the FileHandleLockID to be specified on subsequent
  464. DosProtectxxxx calls.
  465. Unprotected handle requires the FileHandleLockID value to be specified as
  466. zero on subsequent DosProtectxxxx calls. An unprotected handle may be used
  467. with the unprotected calls such as DosRead and DosWrite.
  468. 29 OPEN_SHARE_DENYLEGACY (0x10000000)
  469. Deny read/write access by the DosOpen command:
  470. 0 - allow read/write access by the DosOpen command.
  471. 1 - deny read/write access by the DosOpen command.
  472. A file opened by DosOpenL will not be allowed to grow larger than 2GB while
  473. that same file is open via a legacy DosOpen call. Setting this bit to 1 will
  474. prevent access by the obsolete DosOpen API and ensure that no error will
  475. occur when growing the file.
  476. 28..16 - reserved, must be zero.
  477. 15 OPEN_FLAGS_DASD (0x00008000)
  478. Direct Open flag:
  479. 0 - FileName represents a file to be opened normally.
  480. 1 - FileName is drive (such as C or A), and represents a mounted
  481. disk or diskette volume to be opened for direct access.
  482. 14 OPEN_FLAGS_WRITE_THROUGH (0x00004000)
  483. Write-Through flag:
  484. 0 - writes to the file may go through the file-system driver's
  485. cache; the file-system driver writes the sectors when the
  486. cache is full or the file is closed.
  487. 1 - writes to the file may go through the file-system driver's
  488. cache, but the sectors are written (the actual file I/O
  489. operation is completed) before a synchronous write call
  490. returns. This state of the file defines it as a synchronous
  491. file. For synchronous files, this bit must be set, because the
  492. data must be written to the medium for synchronous write
  493. operations.
  494. This bit flag is not inherited by child processes.
  495. 13 OPEN_FLAGS_FAIL_ON_ERROR (0x00002000)
  496. Fail-Errors flag. Media I/O errors are handled as follows:
  497. 0 - reported through the system critical-error handler.
  498. 1 - reported directly to the caller by way of a return code.
  499. Media I/O errors generated through Category 08h Logical Disk Control IOCtl
  500. Commands always get reported directly to the caller by way of return code.
  501. The Fail-Errors function applies only to non-IOCtl handle-based file I/O
  502. calls.
  503. This flag bit is not inherited by child processes.
  504. 12 OPEN_FLAGS_NO_CACHE (0x00001000)
  505. No-Cache/Cache flag:
  506. 0 - the file-system driver should place data from I/O operations
  507. into its cache.
  508. 1 - I/O operations to the file need not be done through the
  509. file-system driver's cache.
  510. The setting of this bit determines whether file-system drivers should place
  511. data into the cache. Like the write-through bit, this is a per-handle bit,
  512. and is not inherited by child processes.
  513. 11 - reserved; must be 0.
  514. 10..8 - the locality of reference flags contain information about how the
  515. application is to get access to the file. The values are as
  516. follows:
  517. 000 OPEN_FLAGS_NO_LOCALITY (0x00000000)
  518. No locality known.
  519. 001 OPEN_FLAGS_SEQUENTIAL (0x00000100)
  520. Mainly sequential access.
  521. 010 OPEN_FLAGS_RANDOM (0x00000200)
  522. Mainly random access.
  523. 011 OPEN_FLAGS_RANDOMSEQUENTIAL (0x00000300)
  524. Random with some locality.
  525. 7 OPEN_FLAGS_NOINHERIT (0x00000080)
  526. Inheritance flag:
  527. 0 - file handle is inherited by a process created from a call to
  528. DosExecPgm.
  529. 1 - file handle is private to the current process.
  530. This bit is not inherited by child processes.
  531. 6..4 Sharing Mode flags; this field defines any restrictions to file
  532. access placed by the caller on other processes. The values are as
  533. follows:
  534. 001 OPEN_SHARE_DENYREADWRITE (0x00000010)
  535. Deny read write access.
  536. 010 OPEN_SHARE_DENYWRITE (0x00000020)
  537. Deny write access.
  538. 011 OPEN_SHARE_DENYREAD (0x00000030)
  539. Deny read access.
  540. 100 OPEN_SHARE_DENYNONE (0x00000040)
  541. Deny neither read nor write access (deny none).
  542. Any other value is invalid.
  543. 3 Reserved; must be 0.
  544. 2..0 Access-Mode flags. This field defines the file access required by the
  545. caller. The values are as follows:
  546. 000 OPEN_ACCESS_READONLY (0x00000000)
  547. Read-only access
  548. 001 OPEN_ACCESS_WRITEONLY (0x00000001)
  549. Write-only access
  550. 010 OPEN_ACCESS_READWRITE (0x00000002)
  551. Read/write access.
  552. Any other value is invalid, as are any other combinations.
  553. File sharing requires the cooperation of sharing processes. This cooperation is
  554. communicated through sharing and access modes. Any sharing restrictions placed
  555. on a file opened by a process are removed when the process closes the file with
  556. a DosClose request.
  557. Sharing Mode:
  558. Specifies the type of file access that other processes may have. For example,
  559. if other processes can continue to read the file while your process is
  560. operating on it, specify Deny Write. The sharing mode prevents other processes
  561. from writing to the file but still allows them to read it.
  562. Access Mode:
  563. Specifies the type of file access (access mode) needed by your process. For
  564. example, if your process requires read/write access, and another process has
  565. already opened the file with a sharing mode of Deny None, your DosProtectOpenL
  566. request succeeds. However, if the file is open with a sharing mode of Deny
  567. Write, the process is denied access.
  568. If the file is inherited by a child process, all sharing and access
  569. restrictions also are inherited.
  570. If an open file handle is duplicated by a call to DosDupHandle, all sharing and
  571. access restrictions also are duplicated.
  572. EA = pointer to an extended attribute buffer. The address of the
  573. extended-attribute buffer, which contains an EAOP2 structure. The
  574. fpFEA2List field in the EAOP2 structure points to a data area where the
  575. relevant FEA2 list is to be found. The fpGEA2List and oError fields are
  576. ignored.
  577. Output fpGEA2List and fpFEA2List are unchanged. The area that fpFEA2List points
  578. to is unchanged. If an error occurred during the set, oError is the offset of
  579. the FEA2 entry where the error occurred. The return code from DosProtectOpenL
  580. is the error code for that error condition. If no error occurred, oError is
  581. undefined.
  582. EA is nil, then no extended attributes are defined for the file. If extended
  583. attributes are not to be defined or modified, the pointer EA must be set to
  584. nil.
  585. FileHandleLockID = 32-bit LockID for the file handle is returned here.
  586. Possible return codes:
  587. 0 NO_ERROR
  588. 2 ERROR_FILE_NOT_FOUND
  589. 3 ERROR_PATH_NOT_FOUND
  590. 4 ERROR_TOO_MANY_OPEN_FILES
  591. 5 ERROR_ACCESS_DENIED
  592. 12 ERROR_INVALID_ACCESS
  593. 26 ERROR_NOT_DOS_DISK
  594. 32 ERROR_SHARING_VIOLATION
  595. 36 ERROR_SHARING_BUFFER_EXCEEDED
  596. 82 ERROR_CANNOT_MAKE
  597. 87 ERROR_INVALID_PARAMETER
  598. 99 ERROR_DEVICE_IN_USE
  599. 108 ERROR_DRIVE_LOCKED
  600. 110 ERROR_OPEN_FAILED
  601. 112 ERROR_DISK_FULL
  602. 206 ERROR_FILENAME_EXCED_RANGE
  603. 231 ERROR_PIPE_BUSY
  604. Remarks:
  605. A successful DosProtectOpenL request returns a handle and a 32-bit LockID for
  606. accessing the file. The read/write pointer is set at the first byte of the
  607. file. The position of the pointer can be changed with DosProtectSetFilePtrL or
  608. by read and write operations on the file.
  609. The file s date and time can be queried with DosProtectQueryFileInfo. They are
  610. set with DosProtectSetFileInfo.
  611. The read-only attribute of a file can be set with the ATTRIB command.
  612. ulAttribute cannot be set to Volume Label. To set volume-label information,
  613. issue DosProtectSetFileInfo with a logical drive number. Volume labels cannot
  614. be opened.
  615. InitSize affects the size of the file only when the file is new or is
  616. a replacement. If an existing file is opened, cbFile is ignored. To change the
  617. size of the existing file, issue DosProtectSetFileSizeL.
  618. The value in InitSize is a recommended size. If the full size cannot be
  619. allocated, the open request may still succeed. The file system makes
  620. a reasonable attempt to allocate the new size in an area that is as nearly
  621. contiguous as possible on the medium. When the file size is extended, the
  622. values of the new bytes are undefined.
  623. The Direct Open bit provides direct access to an entire disk or diskette
  624. volume, independent of the file system. This mode of opening the volume that is
  625. currently on the drive returns a handle to the calling function; the handle
  626. represents the logical volume as a single file. The calling function specifies
  627. this handle with a DosDevIOCtl Category 8, DSK_LOCKDRIVE request to prevent
  628. other processes from accessing the logical volume. When you are finished using
  629. the logical volume, issue a DosDevIOCtl Category 8, DSK_UNLOCKDRIVE request to
  630. allow other processes to access the logical volume.
  631. The file-handle state bits can be set by DosProtectOpenL and
  632. DosProtectSetFHState. An application can query the file-handle state bits, as
  633. well as the rest of the Open Mode field, by issuing DosProtectQueryFHState.
  634. You can use an TEAOP2 structure to set extended attributes in EA when creating
  635. a file, replacing an existing file, or truncating an existing file. No extended
  636. attributes are set when an existing file is just opened.
  637. A replacement operation is logically equivalent to atomically deleting and
  638. re-creating the file. This means that any extended attributes associated with
  639. the file also are deleted before the file is re-created.
  640. The FileHandleLockID returned is required on each of the DosProtectxxx
  641. functions. An incorrect pfhFileHandleLockID on subsequent DosProtectxxx calls
  642. results in an ERROR_ACCESS_DENIED return code.
  643. The DosProtectxxx functions can be used with a NULL filehandle LockID, if the
  644. subject filehandle was obtained from DosOpen.
  645. *)
  646. function DosProtectOpenL (FileName: PAnsiChar; var Handle: THandle;
  647. var Action: cardinal; InitSize: int64; Attrib,
  648. OpenFlags, OpenMode: cardinal; EA: PEAOp2;
  649. var FileHandleLockID: cardinal): cardinal; cdecl;
  650. (*
  651. DosProtectSetFilePtrL moves the read or write pointer according to the type
  652. of move specified.
  653. Parameters:
  654. Handle = the handle returned by a previous DosOpenL function.
  655. Pos = The signed distance (offset) to move, in bytes.
  656. Method = The method of moving - location in the file at which the read/write
  657. pointer starts before adding the Pos offset. The values and their
  658. meanings are as shown in the following list:
  659. 0 FILE_BEGIN - move the pointer from the beginning of the file.
  660. 1 FILE_CURRENT - move the pointer from the current location of the
  661. read/write pointer.
  662. 2 FILE_END - move the pointer from the end of the file; use this method
  663. to determine a file's size.
  664. PosActual = address of the new pointer location.
  665. FileHandleLockID = The filehandle lockid returned by a previous
  666. DosProtectOpenL.
  667. Possible return codes:
  668. 0 NO_ERROR
  669. 1 ERROR_INVALID_FUNCTION
  670. 6 ERROR_INVALID_HANDLE
  671. 132 ERROR_SEEK_ON_DEVICE
  672. 131 ERROR_NEGATIVE_SEEK
  673. 130 ERROR_DIRECT_ACCESS_HANDLE
  674. Remarks:
  675. The read/write pointer in a file is a signed 64-bit number. A negative value
  676. for Pos moves the pointer backward in the file; a positive value moves it
  677. forward. DosProtectSetFilePtrL cannot be used to move to a negative position in
  678. the file.
  679. DosProtectSetFilePtrL cannot be used for a character device or pipe.
  680. *)
  681. function DosProtectSetFilePtrL (Handle: THandle; Pos: int64;
  682. Method: cardinal; var PosActual: int64;
  683. FileHandleLockID: cardinal): cardinal; cdecl;
  684. (*
  685. DosProtectSetFileSizeL changes the size of a file.
  686. Parameters:
  687. Handle = handle of the file whose size to be changed.
  688. Size = new size, in bytes, of the file.
  689. FileHandleLockID = the filehandle lockid obtained from DosProtectOpenL.
  690. Possible return codes:
  691. 0 NO_ERROR
  692. 5 ERROR_ACCESS_DENIED
  693. 6 ERROR_INVALID_HANDLE
  694. 26 ERROR_NOT_DOS_DISK
  695. 33 ERROR_LOCK_VIOLATION
  696. 87 ERROR_INVALID_PARAMETER
  697. 112 ERROR_DISK_FULL
  698. Remarks:
  699. When DosProtectSetFileSizeL is issued, the file must be open in a mode that
  700. allows write access.
  701. The size of the open file can be truncated or extended. If the file size is
  702. being extended, the file system tries to allocate additional bytes in
  703. a contiguous (or nearly contiguous) space on the medium. The values of the new
  704. bytes are undefined.
  705. *)
  706. function DosProtectSetFileSizeL (Handle: THandle; Size: int64;
  707. FileHandleLockID: cardinal): cardinal; cdecl;
  708. (*
  709. DosGetProcessorStatus allows checking status of individual processors
  710. in a SMP machine.
  711. Parameters:
  712. ProcID = Procesor ID numbered 1 through n, where there are n processors in
  713. total.
  714. Status = Returned processor status defined as follows:
  715. PROC_OFFLINE 0x00000000 Processor is offline
  716. PROC_ONLINE 0x00000001 Processor is online
  717. Possible return codes:
  718. 0 NO_ERROR
  719. 87 ERROR_INVALID_PARAMETER
  720. *)
  721. function DosGetProcessorStatus (ProcID: cardinal;
  722. var Status: cardinal): cardinal; cdecl;
  723. (*
  724. DosSetProcessorStatus sets the ONLINE or OFFLINE status of a processor on
  725. an SMP system. The processor status may be queried using DosGetProcessorStatus.
  726. ONLINE status implies the processor is available for running work. OFFLINE
  727. status implies the processor is not available for running work. The processor
  728. that executes DosSetProcessorStatus must be ONLINE.
  729. Parameters:
  730. ProcID = Processor ID numbered from 1 through n, where there are n processors
  731. in total.
  732. Status = Requested processor status defined as follows:
  733. PROC_OFFLINE 0x00000000 Processor is offline.
  734. PROC_ONLINE 0x00000001 Processor is online.
  735. Possible return codes:
  736. 0 NO_ERROR
  737. 87 ERROR_INVALID_PARAMETER
  738. *)
  739. function DosSetProcessorStatus (ProcID: cardinal;
  740. Status: cardinal): cardinal; cdecl;
  741. (*
  742. DosQueryThreadAffinity allows a thread to inquire for the current thread's
  743. processor affinity mask and the system's capable processor affinity mask.
  744. Parameters:
  745. Scope = Scope of the query defined by one of the following values:
  746. AFNTY_THREAD Return the current threads processor affinity mask.
  747. AFNTY_SYSTEM Return the system's current capable processor affinity mask.
  748. AffinityMask = Affinity mask is returned here; processors 0..31 are in Mask [0]
  749. and processors 32..63 are in Mask [1].
  750. Possible return codes:
  751. 13 ERROR_INVALID_DATA
  752. 87 ERROR_INVALID_PARAMETER
  753. *)
  754. function DosQueryThreadAffinity (Scope: cardinal;
  755. var AffinityMask: TMPAffinity): cardinal; cdecl;
  756. (*
  757. DosQueryExtLibPath returns the current path to be searched before or after the
  758. system LIBPATH when locating DLLs.
  759. Parameters:
  760. ExtLIBPATH = Buffer for receiving the extended LIBPATH string.
  761. ???
  762. If the buffer pointed to by this parameter is not large enough to hold
  763. the extended LIBPATH or an extended LIBPATH is not currently defined, this
  764. parameter returns a pointer to a NULL string.
  765. ??? How is it detected if the size is not passed???
  766. Flags - flag indicating when the new path is searched - possible values:
  767. BEGIN_LIBPATH - The new path is searched before the LIBPATH.
  768. END_LIBPATH - The new path is searched after the LIBPATH.
  769. Possible return codes:
  770. 0 NO_ERROR
  771. 87 ERROR_INVALID_PARAMETER
  772. 122 ERROR_INSUFFICIENT_BUFER
  773. *)
  774. function DosQueryExtLibPath (ExtLibPath: PAnsiChar; Flags: cardinal): cardinal;
  775. cdecl;
  776. (*
  777. DosSetExtLibPath defines the current path to be searched before or after the
  778. system LIBPATH when locating DLLs.
  779. Parameters:
  780. ExtLIBPATH = New extended LIBPATH string. Maximum size is 1024 bytes.
  781. A pointer to a NULL string removes the extended LIBPATH.
  782. Flags = When the new path is searched - possible values:
  783. BEGIN_LIBPATH (1) - the new path is searched before the LIBPATH.
  784. END_LIBPATH (2) - the new path is searched after the LIBPATH.
  785. The LIBPATH string is an environment variable found in the CONFIG.SYS file
  786. consisting of a set of paths. If a fully-qualified path is not specified when
  787. a module is loaded, the system searches these paths to find the DLL.
  788. There are two extended LIBPATH strings, BeginLIBPATH and EndLIBPATH.
  789. BeginLIBPATH is searched before the system LIBPATH, and EndLIBPATH is searched
  790. after both BeginLIBPATH and the system LIBPATH. These extended LIBPATHs can be
  791. set either from the command line using the "SET" command, or by calling
  792. DosSetExtLIBPATH. When DosSetExtLIBPATH is called, all modifications become
  793. specific to that process. Initial settings can be set for all processes in the
  794. system by setting the values in CONFIG.SYS using the "set" command.
  795. Note: The extended LIBPATHs are not true environment variables, and do not
  796. appear when querying the environment.
  797. Every process inherits the settings of BeginLIBPATH and EndLIBPATH from the
  798. process that starts it. If the extended library paths are initialized in
  799. CONFIG.SYS, those extended library paths become the initial settings for new
  800. processes. If a process changes BeginLIBPATH or EndLIBPATH and starts a new
  801. process, the new child process inherits the changed contents. Child processes
  802. that inherit their parent's extended LIBPATHs maintain their own copy.
  803. Modifications made by the parent after the child has been created have no
  804. effect on the children.
  805. This function permits the use of two symbols within the path string:
  806. %BeginLIBPATH% and %EndLIBPATH%. These symbols are replaced with the current
  807. string settings for the extended library paths.
  808. The LIBPATHs strings are only searched when the specified DLL is not currently
  809. loaded. The only way to guarantee that the DLL being used is the correct
  810. version is to set the fully-qualified path in DosLoadModule. When a request is
  811. made to load a module and a path is not specified, the system searches the
  812. paths in the LIBPATH string and uses the first instance of the specified DLL it
  813. finds. If the new paths are added to the search strings, the system does not
  814. check those directories to see if a different version exists. Consequently, if
  815. two processes started from different directories use the same DLL, but
  816. different versions of that DLL exist in both directories, the version of the
  817. DLL loaded by the first process is the one used by both processes. The only way
  818. to prevent this from occurring is to specify the path to the DLL when
  819. DosLoadModule is called.
  820. Consequently, if one process sets its BeginLIBPATH to C:\PROCESS1\DLL and loads
  821. the DLL MYAPP.DLL from that directory, and then a second process sets its
  822. BeginLIBPATH to C:\PROCESS2\DLL and there is for a different version of
  823. MYAPP.DLL in C:\PROCESS2\DLL, the second process will link to the DLL from
  824. C:\PROCESS1\DLL since it was already loaded.
  825. Both BeginLIBPATH and EndLIBPATH can be set from the command line using the SET
  826. command.
  827. Possible return codes:
  828. 0 NO_ERROR
  829. 8 ERROR_NOT_ENOUGH_MEMORY
  830. 87 ERROR_INVALID_PARAMETER
  831. 161 ERROR_BAD_PATHNAME
  832. *)
  833. function DosSetExtLibPath (ExtLibPath: PAnsiChar; Flags: cardinal): cardinal;
  834. cdecl;
  835. (*
  836. DosQueryModFromEIP queries a module handle and name from a given flat address.
  837. It takes a flat 32 bit address as a parameter and returns information about the
  838. module (a protected mode application currently executing) owning the storage.
  839. Parameters:
  840. HMod = Address of a location in which the module handle is returned.
  841. ObjNum = Address of a cardinal where the module object number corresponding to
  842. the Address is returned. The object number is zero based.
  843. BuffLen = Length of the user supplied buffer pointed to by Buff.
  844. Buff = Address of a user supplied buffer in which the module name is returned.
  845. Offset = Address where the offset to the object corresponding to the Address is
  846. returned. The offset is zero based.
  847. Address = Input address to be queried.
  848. Possible return codes:
  849. 0 NO_ERROR
  850. 87 ERROR_INVALID_PARAMETER
  851. 487 ERROR_INVALID_ADDRESS
  852. *)
  853. function DosQueryModFromEIP (var HMod: THandle; var ObjNum: cardinal;
  854. BuffLen: cardinal; Buff: PAnsiChar; var Offset: cardinal;
  855. Address: PtrUInt): cardinal; cdecl;
  856. (*
  857. DosDumpProcess initiates a process dump from a specified process. This may be used as part of an error handling routine to gather information about an error that may be analyzed later using the OS/2 System Dump Formatter. Configuration of Process Dump may be done using the PDUMPSYS, PDUMPUSR, and PROCDUMP commands.
  858. Parameters:
  859. Flag = Function to be performed (one of DDP_* constants).
  860. DDP_DISABLEPROCDUMP (0) - disable process dumps
  861. DDP_ENABLEPROCDUMP (1) - enable process dumps
  862. DDP_PERFORMPROCDUMP (2) - perform process dump (if the user enabled it using
  863. the PROCDUMP command; ERROR_INVALID_PARAMETER is
  864. returned otherwise)
  865. Drive = The ASCII character for the drive on which process dump files are
  866. to be created, or 0 to use the drive originally specified by the user
  867. using the PROCDUMP command. This is required only with the
  868. DDP_ENABLEPROCDUMP (PROCDUMP command allows customizing fully the drive
  869. and path).
  870. PID = The process to be dumped. 0 specifies the current process; otherwise
  871. a valid process ID must be specified. This parameter is actioned only
  872. with DDP_PERFORMPROCDUMP.
  873. Possible return Codes.
  874. 0 NO_ERROR
  875. 87 ERROR_INVALID PARAMETER
  876. Remarks:
  877. Use the PDUMPUSR command to specify what information will be dumped.
  878. Use the PROCDUMP command to customize options per process and in particular
  879. to specify whether child or parent process will be dumped.
  880. For maximum flexibility the use of DosDumpProcess should be limited
  881. to the DDP_PERFORMPROCDUMP function. This allows you to specify whether
  882. Process Dump should be enabled through the use of the PROCDUMP command.
  883. You may customize Process Dump completely through use of the PDUMPUSR,
  884. PDUMPSYS, AND PROCDUMP commands. For further information, see PROCDUMP.DOC
  885. in the OS2\SYSTEM\RAS directory. DDP_ENABLEPROCDUMP and DDP_DISABLEPROCDUMP
  886. are provided for backwards compatibility only.
  887. *)
  888. function DosDumpProcess (Flag: cardinal; Drive: AnsiChar;
  889. PID: cardinal): cardinal; cdecl;
  890. (*
  891. Suppress application trap popups and log them to the file POPUPLOG.OS2.
  892. Parameters:
  893. Flag = Flag indicating whether pop-up suppression should be enabled
  894. or disabled (one of SPU_* constants - 0 or 1).
  895. Drive = The drive letter for the log file (used only when pop-up suppression is
  896. enabled).
  897. Remarks:
  898. When pop-ups are suppressed through DosSuppressPopUps, the system does not
  899. display trap screens on the user's terminal. The user will not be required
  900. to respond to the abort, retry, continue message. Instead, the system displays
  901. message SYS3571 and logs the name of the process to the POPUPLOG.OS2 log file
  902. in the root directory of the specified drive. The system will also log
  903. the message inserts in the log file.
  904. If the log file does not exist, the system will create it. If the log file
  905. exists, the system appends to it. If the system cannot open the file (for
  906. example, because the drive does not exist), the system will not log the pop-up
  907. information.
  908. When pop-up suppression is enabled, the system overrides any settings
  909. established by DosError on a per-process basis.
  910. This API overrides the potential initial setting (e.g. 'SUPPRESSPOPUPS=c')
  911. in CONFIG.SYS.
  912. The drive letter for the log file may also be specified on the
  913. DosSuppressPopUps API.
  914. If an invalid flag (a flag other than SPU_ENABLESUPPRESSION
  915. or SPU_DISABLESUPPRESSION) or an invalid drive (a drive other than an upper- or
  916. lowercase letter) is specified on DosSuppressPopUps, the system returns error
  917. code ERROR_INVALID_PARAMETER. Otherwise, the system returns NO_ERROR.
  918. Possible error codes:
  919. 0 NO_ERROR
  920. 87 ERROR_INVALID_PARAMETER
  921. *)
  922. function DosSuppressPopups (Flag: cardinal; Drive: AnsiChar): cardinal; cdecl;
  923. (*
  924. DosPerfSysCall retrieves system performance information and performs software
  925. tracing.
  926. Parameters:
  927. Command = Command to be performed; the following commands are accepted:
  928. CMD_KI_RDCNT ($63) - reads CPU utilization information in both uniprocessor
  929. and symmetric multi-processor (SMP) environments by
  930. taking a snapshot of the time stamp counters. To
  931. determine CPU utilization, the application must compute
  932. the difference between two time stamp snapshots using 64
  933. bit aritimetic.
  934. CMD_SOFTTRACE_LOG ($14) - records software trace information.
  935. Parm1 (CPUUtil) = Command-specific. In case of CMD_KI_RDCNT, pointer to
  936. TCPUUtil record. In case of CMD_SOFTTRACE_LOG, major code for
  937. the trace entry in the range of 0 to 255. Major codes 184
  938. ($B8) and 185 ($B9) have been reserved for IBM customer use.
  939. Major code 1 is reserved for exclusive use by IBM.
  940. Parm2 = Command-specific. In case of CMD_KI_RdCnt, it must be 0. In case of
  941. CMD_SOFTTRACE_LOG, minor code for the trace entry in the range of
  942. 0 to 255.
  943. Parm3 (HookData) = Command-specific. In case of CMD_KI_RdCnt, it must be 0. In
  944. case of CMD_SOFTTRACE_LOG, pointer to a HOOKDATA data
  945. structure (see example code).
  946. Possible return codes:
  947. 0 NO_ERROR
  948. 1 ERROR_INVALID_FUNCTION
  949. Remarks:
  950. DosPerfSysCall is a general purpose performance function. This function accepts
  951. four parameters. The first parameter is the command requested. The other three
  952. parameters are command specific.
  953. Some functions of DosPerfSysCall may have a dependency on Intel Pentium or
  954. Pentium-Pro (or higher) support. If a function cannot be provided because OS/2
  955. is not running on a processor with the required features, a return code will
  956. indicate an attempt to use an unsupported function.
  957. Example code (C):
  958. int main (int argc, AnsiChar *argv[])
  959. {
  960. APIRET rc;
  961. BYTE HookBuffer [256];
  962. HOOKDATA Hookdata = {0,HookBuffer};
  963. ULONG ulMajor, ulMinor;
  964. *((PULONG) HookBuffer[0]) = 1;
  965. *((PULONG) HookBuffer[4]) = 2;
  966. *((PULONG) HookBuffer[8]) = 3;
  967. strcpy((PSZ HookBuffer[12], "Test of 3 ULONG values and a string.")
  968. HookData.ulLength = 12 + strlen((PSZ HookBuffer[12]) + 1;
  969. ulMajor = 0x00b8
  970. ulMinor = 0x0001
  971. rc = DosPerfSystCall(CMD_SOFTTRACE_LOG, ulMajor, ulMinor, (ULONG) HookData);
  972. if (rc != NO_ERROR) {
  973. fprintf (stderr, "CMD_SOFTTRACE_LOG failed rc = %u\n", rc);
  974. return 1;
  975. }
  976. return NO_ERROR;
  977. }
  978. *)
  979. function DosPerfSysCall (Command, Parm1, Parm2,
  980. Parm3: cardinal): cardinal; cdecl;
  981. function DosPerfSysCall (Command, Parm1, Parm2: cardinal;
  982. var HookData): cardinal; cdecl;
  983. function DosPerfSysCall (Command: cardinal; var CpuUtil: TCPUUtil; Parm2,
  984. Parm3: cardinal): cardinal; cdecl;
  985. (*
  986. Query context of a suspended thread.
  987. Parameters:
  988. TID = Thread ID
  989. Level = Desired level of information
  990. Context = Thread context record
  991. DosQueryThreadContext returns the context record of a suspended thread.
  992. A thread may be suspended by using DosSuspendThread or DosEnterCritSec.
  993. If DosSuspendThread is used, the caller must allow some time for OS/2 to
  994. suspend the thread before querying its context.
  995. Note: Values from the thread context should be used only when the state
  996. of the target thread is known.
  997. Possible return codes:
  998. 0 NO_ERROR
  999. 87 ERROR_INVALID_PARAMETER
  1000. 90 ERROR_NOT_FROZEN
  1001. 115 ERROR_PROTECTION_VIOLATION
  1002. 309 ERROR_INVALID_THREADID
  1003. *)
  1004. function DosQueryThreadContext (TID: cardinal; Level: cardinal;
  1005. var Context: TContextRecord): cardinal; cdecl;
  1006. (*
  1007. DosQueryABIOSSupport returns flags that indicate various basic hardware
  1008. configurations.
  1009. Parameters:
  1010. Reserved = Must be set to 0, no other value is defined.
  1011. The result of this function contains combination of flags (HW_Cfg_* constants)
  1012. signalizing the underlying hardware configuration.
  1013. *)
  1014. function DosQueryABIOSSupport (Reserved: cardinal): cardinal; cdecl;
  1015. {***************************************************************************}
  1016. implementation
  1017. {***************************************************************************}
  1018. {$IFDEF FPC_DOTTEDUNITS}
  1019. uses
  1020. OS2Api.os2def;
  1021. {$ELSE FPC_DOTTEDUNITS}
  1022. uses
  1023. OS2Def;
  1024. {$ENDIF FPC_DOTTEDUNITS}
  1025. function DummyDosCancelLockRequestL (Handle: THandle; var Lock: TFileLockL): cardinal; cdecl;
  1026. var
  1027. Lock0: TFileLock;
  1028. begin
  1029. if (Lock.Offset > high (longint)) or (Lock.Range > high (longint)) or
  1030. (Lock.Offset < 0) or (Lock.Range < 0) then
  1031. DummyDosCancelLockRequestL := Error_Invalid_Parameter
  1032. else
  1033. begin
  1034. Lock0.Offset := longint (Lock.Offset);
  1035. Lock0.Range := longint (Lock.Range);
  1036. DummyDosCancelLockRequestL := DosCancelLockRequest (Handle, Lock0);
  1037. end;
  1038. end;
  1039. function DummyDosProtectSetFileLocksL (Handle: THandle; var Unlock: TFileLockL;
  1040. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal;
  1041. FileHandleLockID: cardinal): cardinal; cdecl;
  1042. var
  1043. Lock0: TFileLock;
  1044. UnLock0: TFileLock;
  1045. begin
  1046. if (Lock.Offset > high (longint)) or (Lock.Range > high (longint)) or
  1047. (Unlock.Offset > high (longint)) or (Unlock.Range > high (longint)) then
  1048. DummyDosProtectSetFileLocksL := Error_Invalid_Parameter
  1049. else
  1050. begin
  1051. Lock0.Offset := longint (Lock.Offset);
  1052. Lock0.Range := longint (Lock.Range);
  1053. Unlock0.Offset := longint (Unlock.Offset);
  1054. Unlock0.Range := longint (Lock.Range);
  1055. DummyDosProtectSetFileLocksL := DosProtectSetFileLocks (Handle, Unlock0,
  1056. Lock0, Timeout, Flags, FileHandleLockID);
  1057. end;
  1058. end;
  1059. function DummyDosSetFileLocksL (Handle: THandle; var Unlock: TFileLockL;
  1060. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl;
  1061. var
  1062. Lock0: TFileLock;
  1063. UnLock0: TFileLock;
  1064. begin
  1065. if (Lock.Offset > high (longint)) or (Lock.Range > high (longint)) or
  1066. (Lock.Offset < 0) or (Lock.Range < 0) or
  1067. (Unlock.Offset < 0) or (Unlock.Range < 0) or
  1068. (Unlock.Offset > high (longint)) or (Unlock.Range > high (longint)) then
  1069. DummyDosSetFileLocksL := Error_Invalid_Parameter
  1070. else
  1071. begin
  1072. Lock0.Offset := longint (Lock.Offset);
  1073. Lock0.Range := longint (Lock.Range);
  1074. Unlock0.Offset := longint (Unlock.Offset);
  1075. Unlock0.Range := longint (Lock.Range);
  1076. DummyDosSetFileLocksL := DosSetFileLocks (Handle, Unlock0, Lock0, Timeout,
  1077. Flags);
  1078. end;
  1079. end;
  1080. function DummyDosProtectOpenL (FileName: PAnsiChar; var Handle: THandle;
  1081. var Action: cardinal; InitSize: int64; Attrib,
  1082. OpenFlags, OpenMode: cardinal; EA: PEAOp2;
  1083. var FileHandleLockID: cardinal): cardinal; cdecl;
  1084. begin
  1085. if InitSize > high (longint) then
  1086. DummyDosProtectOpenL := Error_Invalid_Parameter
  1087. else
  1088. DummyDosProtectOpenL := DosProtectOpen (FileName, Handle, Action,
  1089. longint (InitSize), Attrib, OpenFlags, OpenMode, EA, FileHandleLockID);
  1090. end;
  1091. function DummyDosProtectSetFilePtrL (Handle: THandle; Pos: int64;
  1092. Method: cardinal; var PosActual: int64;
  1093. FileHandleLockID: cardinal): cardinal; cdecl;
  1094. var
  1095. PosActual0: cardinal;
  1096. begin
  1097. if (Pos < low (longint)) or (Pos > high (longint)) then
  1098. DummyDosProtectSetFilePtrL := Error_Invalid_Parameter
  1099. else
  1100. begin
  1101. DummyDosProtectSetFilePtrL := DosProtectSetFilePtr (Handle, longint (Pos),
  1102. Method, PosActual0, FileHandleLockID);
  1103. PosActual := PosActual0;
  1104. end;
  1105. end;
  1106. function DummyDosProtectSetFileSizeL (Handle: THandle; Size: int64;
  1107. FileHandleLockID: cardinal): cardinal; cdecl;
  1108. begin
  1109. if (Size > high (cardinal)) then
  1110. DummyDosProtectSetFileSizeL := Error_Invalid_Parameter
  1111. else
  1112. DummyDosProtectSetFileSizeL := DosProtectSetFileSize (Handle,
  1113. cardinal (Size), FileHandleLockID);
  1114. end;
  1115. function DummyDosProtectSetFileLocks (Handle: THandle;
  1116. var Unlock, Lock: TFileLock;
  1117. Timeout, Flags: cardinal;
  1118. FileHandleLockID: cardinal): cardinal; cdecl;
  1119. begin
  1120. if FileHandleLockID <> 0 then
  1121. DummyDosProtectSetFileLocks := Error_Invalid_Parameter
  1122. else
  1123. DummyDosProtectSetFileLocks := DosSetFileLocks (Handle, Unlock, Lock,
  1124. Timeout, Flags);
  1125. end;
  1126. function DummyDosProtectOpen (FileName: PAnsiChar; var Handle: THandle;
  1127. var Action: cardinal; InitSize, Attrib,
  1128. OpenFlags, OpenMode: cardinal; ea: PEAOp2;
  1129. var FileHandleLockID: cardinal): cardinal; cdecl;
  1130. begin
  1131. DummyDosProtectOpen := DosOpen (FileName, Handle, Action, InitSize, Attrib,
  1132. OpenFlags, OpenMode, EA);
  1133. FileHandleLockID := 0;
  1134. end;
  1135. function DummyDosProtectClose (Handle: THandle;
  1136. FileHandleLockID: cardinal): cardinal; cdecl;
  1137. begin
  1138. DummyDosProtectClose := DosClose (Handle);
  1139. end;
  1140. function DummyDosProtectRead (Handle: THandle; var Buffer; Count: cardinal;
  1141. var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl;
  1142. begin
  1143. DummyDosProtectRead := DosRead (Handle, Buffer, Count, ActCount);
  1144. end;
  1145. function DummyDosProtectWrite (Handle: THandle; const Buffer; Count: cardinal;
  1146. var ActCount: cardinal;
  1147. FileHandleLockID: cardinal): cardinal; cdecl;
  1148. begin
  1149. DummyDosProtectWrite := DosWrite (Handle, Buffer, Count, ActCount);
  1150. end;
  1151. function DummyDosProtectSetFilePtr (Handle: THandle; Pos: longint;
  1152. Method: cardinal; var PosActual: cardinal;
  1153. FileHandleLockID: cardinal): cardinal; cdecl;
  1154. begin
  1155. DummyDosProtectSetFilePtr := DosSetFilePtr (Handle, Pos, Method, PosActual);
  1156. end;
  1157. function DummyDosProtectSetFileSize (Handle: THandle; Size: cardinal;
  1158. FileHandleLockID: cardinal): cardinal; cdecl;
  1159. begin
  1160. DummyDosProtectSetFileSize := DosSetFileSize (Handle, Size);
  1161. end;
  1162. function DummyDosProtectQueryFHState (Handle: THandle; var FileMode: cardinal;
  1163. FileHandleLockID: cardinal): cardinal; cdecl;
  1164. begin
  1165. DummyDosProtectQueryFHState := DosQueryFHState (Handle, FileMode);
  1166. end;
  1167. function DummyDosProtectSetFHState (Handle: THandle; FileMode: cardinal;
  1168. FileHandleLockID: cardinal): cardinal; cdecl;
  1169. begin
  1170. DummyDosProtectSetFHState := DosSetFHState (Handle, FileMode);
  1171. end;
  1172. function DummyDosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal;
  1173. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1174. FileHandleLockID: cardinal): cardinal; cdecl;
  1175. begin
  1176. DummyDosProtectQueryFileInfo := DosQueryFileInfo (Handle, InfoLevel,
  1177. AFileStatus, FileStatusLen);
  1178. end;
  1179. function DummyDosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal;
  1180. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1181. FileHandleLockID: cardinal): cardinal; cdecl;
  1182. begin
  1183. DummyDosProtectSetFileInfo := DosSetFileInfo (Handle, InfoLevel,
  1184. AFileStatus, FileStatusLen);
  1185. end;
  1186. function DummyDosProtectEnumAttribute (RefType: cardinal; AFile: pointer;
  1187. Entry: cardinal; var Buf; BufSize: cardinal;
  1188. var Count: cardinal; InfoLevel: cardinal;
  1189. FileHandleLockID: cardinal): cardinal; cdecl;
  1190. begin
  1191. DummyDosProtectEnumAttribute := DosEnumAttribute (RefType, AFile, Entry,
  1192. Buf, BufSize, Count, InfoLevel);
  1193. end;
  1194. function DummyDosGetProcessorStatus (ProcID: cardinal;
  1195. var Status: cardinal): cardinal; cdecl;
  1196. begin
  1197. if ProcID = 1 then
  1198. begin
  1199. Status := 1;
  1200. DummyDosGetProcessorStatus := No_Error;
  1201. end
  1202. else
  1203. DummyDosGetProcessorStatus := Error_Invalid_Parameter;
  1204. end;
  1205. function DummyDosSetProcessorStatus (ProcID: cardinal;
  1206. Status: cardinal): cardinal; cdecl;
  1207. begin
  1208. DummyDosSetProcessorStatus := Error_Invalid_Parameter;
  1209. end;
  1210. function DummyDosQueryThreadAffinity (Scope: cardinal;
  1211. var AffinityMask: TMPAffinity): cardinal; cdecl;
  1212. begin
  1213. DummyDosQueryThreadAffinity := Error_Invalid_Function;
  1214. end;
  1215. function DummyDosSetThreadAffinity (var AffinityMask: TMPAffinity): cardinal;
  1216. cdecl;
  1217. begin
  1218. DummyDosSetThreadAffinity := Error_Invalid_Function;
  1219. end;
  1220. function DummyDosQueryExtLibPath (ExtLibPath: PAnsiChar;
  1221. Flags: cardinal): cardinal; cdecl;
  1222. begin
  1223. if ExtLibPath <> nil then
  1224. begin
  1225. ExtLibPath := #0;
  1226. DummyDosQueryExtLibPath := No_Error;
  1227. end
  1228. else
  1229. DummyDosQueryExtLibPath := Error_Invalid_Parameter;
  1230. end;
  1231. function DummyDosSetExtLibPath (ExtLibPath: PAnsiChar; Flags: cardinal): cardinal;
  1232. cdecl;
  1233. begin
  1234. DummyDosSetExtLibPath := Error_Not_Enough_Memory;
  1235. end;
  1236. function DummyDosQueryModFromEIP (var HMod: THandle; var ObjNum: cardinal;
  1237. BuffLen: cardinal; Buff: PAnsiChar; var Offset: cardinal;
  1238. Address: PtrUInt): cardinal; cdecl;
  1239. begin
  1240. DummyDosQueryModFromEIP := Error_Invalid_Parameter;
  1241. HMod := THandle (-1);
  1242. ObjNum := 0;
  1243. if Buff <> nil then
  1244. Buff^ := #0;
  1245. Offset := 0;
  1246. end;
  1247. function DummyDosDumpProcess (Flag: cardinal; Drive: cardinal;
  1248. PID: cardinal): cardinal; cdecl;
  1249. begin
  1250. DummyDosDumpProcess := Error_Invalid_Function;
  1251. end;
  1252. function DummyDosSuppressPopups (Flag: cardinal; Drive: AnsiChar): cardinal; cdecl;
  1253. begin
  1254. DummyDosSuppressPopups := Error_Invalid_Function;
  1255. end;
  1256. function DummyDosPerfSysCall (Command, Parm1, Parm2,
  1257. Parm3: cardinal): cardinal; cdecl;
  1258. begin
  1259. DummyDosPerfSysCall := Error_Invalid_Function;
  1260. end;
  1261. function DummyDosQueryThreadContext (TID: cardinal; Level: cardinal;
  1262. var Context: TContextRecord): cardinal; cdecl;
  1263. begin
  1264. DummyDosQueryThreadContext := Error_Invalid_Function;
  1265. end;
  1266. function DummyDosQueryABIOSSupport (Reserved: cardinal): cardinal; cdecl;
  1267. begin
  1268. DummyDosQueryABIOSSupport := 0;
  1269. end;
  1270. type
  1271. TDosProtectOpen = function (FileName: PAnsiChar; var Handle: THandle;
  1272. var Action: cardinal; InitSize, Attrib,
  1273. OpenFlags, OpenMode: cardinal; ea: PEAOp2;
  1274. var FileHandleLockID: cardinal): cardinal; cdecl;
  1275. TDosProtectClose = function (Handle: THandle;
  1276. FileHandleLockID: cardinal): cardinal; cdecl;
  1277. TDosProtectRead = function (Handle: THandle; var Buffer; Count: cardinal;
  1278. var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl;
  1279. TDosProtectWrite = function (Handle: THandle; const Buffer; Count: cardinal;
  1280. var ActCount: cardinal;
  1281. FileHandleLockID: cardinal): cardinal; cdecl;
  1282. TDosProtectSetFilePtr = function (Handle: THandle; Pos: longint;
  1283. Method: cardinal; var PosActual: cardinal;
  1284. FileHandleLockID: cardinal): cardinal; cdecl;
  1285. TDosProtectSetFileSize = function (Handle: THandle; Size: cardinal;
  1286. FileHandleLockID: cardinal): cardinal; cdecl;
  1287. TDosProtectQueryFHState = function (Handle: THandle; var FileMode: cardinal;
  1288. FileHandleLockID: cardinal): cardinal; cdecl;
  1289. TDosProtectSetFHState = function (Handle: THandle; FileMode: cardinal;
  1290. FileHandleLockID: cardinal): cardinal; cdecl;
  1291. TDosProtectQueryFileInfo = function (Handle: THandle; InfoLevel: cardinal;
  1292. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1293. FileHandleLockID: cardinal): cardinal; cdecl;
  1294. TDosProtectSetFileInfo = function (Handle: THandle; InfoLevel: cardinal;
  1295. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1296. FileHandleLockID: cardinal): cardinal; cdecl;
  1297. TDosProtectEnumAttribute = function (RefType: cardinal; AFile: pointer;
  1298. Entry: cardinal; var Buf; BufSize: cardinal;
  1299. var Count: cardinal; InfoLevel: cardinal;
  1300. FileHandleLockID: cardinal): cardinal; cdecl;
  1301. TDosProtectSetFileLocks = function (Handle: THandle;
  1302. var Unlock, Lock: TFileLock;
  1303. Timeout, Flags: cardinal;
  1304. FileHandleLockID: cardinal): cardinal; cdecl;
  1305. TDosCancelLockRequestL = function (Handle: THandle; var Lock: TFileLockL):
  1306. cardinal; cdecl;
  1307. TDosProtectSetFileLocksL = function (Handle: THandle; var Unlock: TFileLockL;
  1308. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal;
  1309. FileHandleLockID: cardinal): cardinal; cdecl;
  1310. TDosSetFileLocksL = function (Handle: THandle; var Unlock: TFileLockL;
  1311. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl;
  1312. TDosProtectOpenL = function (FileName: PAnsiChar; var Handle: THandle;
  1313. var Action: cardinal; InitSize: int64; Attrib,
  1314. OpenFlags, OpenMode: cardinal; EA: PEAOp2;
  1315. var FileHandleLockID: cardinal): cardinal; cdecl;
  1316. TDosProtectSetFilePtrL = function (Handle: THandle; Pos: int64;
  1317. Method: cardinal;
  1318. var PosActual: int64; FileHandleLockID: cardinal): cardinal; cdecl;
  1319. TDosProtectSetFileSizeL = function (Handle: THandle; Size: int64;
  1320. FileHandleLockID: cardinal): cardinal; cdecl;
  1321. TDosGetProcessorStatus = function (ProcID: cardinal;
  1322. var Status: cardinal): cardinal; cdecl;
  1323. TDosSetProcessorStatus = function (ProcID: cardinal;
  1324. Status: cardinal): cardinal; cdecl;
  1325. TDosQueryThreadAffinity = function (Scope: cardinal;
  1326. var AffinityMask: TMPAffinity): cardinal; cdecl;
  1327. TDosSetThreadAffinity = function (var AffinityMask: TMPAffinity): cardinal;
  1328. cdecl;
  1329. TDosQueryExtLibPath = function (ExtLibPath: PAnsiChar;
  1330. Flags: cardinal): cardinal; cdecl;
  1331. TDosSetExtLibPath = function (ExtLibPath: PAnsiChar; Flags: cardinal): cardinal;
  1332. cdecl;
  1333. TDosQueryModFromEIP = function (var HMod: THandle; var ObjNum: cardinal;
  1334. BuffLen: cardinal; Buff: PAnsiChar; var Offset: cardinal;
  1335. Address: PtrUInt): cardinal; cdecl;
  1336. TDosDumpProcess = function (Flag: cardinal; Drive: cardinal;
  1337. PID: cardinal): cardinal; cdecl;
  1338. TDosSuppressPopups = function (Flag: cardinal; Drive: AnsiChar): cardinal; cdecl;
  1339. TDosPerfSysCall = function (Command, Parm1, Parm2,
  1340. Parm3: cardinal): cardinal; cdecl;
  1341. TDosQueryThreadContext = function (TID: cardinal; Level: cardinal;
  1342. var Context: TContextRecord): cardinal; cdecl;
  1343. TDosQueryABIOSSupport = function (Reserved: cardinal): cardinal; cdecl;
  1344. const
  1345. Sys_DosCancelLockRequestL: TDosCancelLockRequestL =
  1346. @DummyDosCancelLockRequestL;
  1347. Sys_DosSetFileLocksL: TDosSetFileLocksL = @DummyDosSetFileLocksL;
  1348. Sys_DosProtectSetFileLocksL: TDosProtectSetFileLocksL =
  1349. @DummyDosProtectSetFileLocksL;
  1350. Sys_DosProtectOpenL: TDosProtectOpenL = @DummyDosProtectOpenL;
  1351. Sys_DosProtectSetFilePtrL: TDosProtectSetFilePtrL =
  1352. @DummyDosProtectSetFilePtrL;
  1353. Sys_DosProtectSetFileSizeL: TDosProtectSetFileSizeL =
  1354. @DummyDosProtectSetFileSizeL;
  1355. Sys_DosProtectOpen: TDosProtectOpen = @DummyDosProtectOpen;
  1356. Sys_DosProtectClose: TDosProtectClose = @DummyDosProtectClose;
  1357. Sys_DosProtectRead: TDosProtectRead = @DummyDosProtectRead;
  1358. Sys_DosProtectWrite: TDosProtectWrite = @DummyDosProtectWrite;
  1359. Sys_DosProtectSetFilePtr: TDosProtectSetFilePtr = @DummyDosProtectSetFilePtr;
  1360. Sys_DosProtectSetFileSize: TDosProtectSetFileSize =
  1361. @DummyDosProtectSetFileSize;
  1362. Sys_DosProtectQueryFHState: TDosProtectQueryFHState =
  1363. @DummyDosProtectQueryFHState;
  1364. Sys_DosProtectSetFHState: TDosProtectSetFHState = @DummyDosProtectSetFHState;
  1365. Sys_DosProtectQueryFileInfo: TDosProtectQueryFileInfo =
  1366. @DummyDosProtectQueryFileInfo;
  1367. Sys_DosProtectSetFileInfo: TDosProtectSetFileInfo =
  1368. @DummyDosProtectSetFileInfo;
  1369. Sys_DosProtectEnumAttribute: TDosProtectEnumAttribute =
  1370. @DummyDosProtectEnumAttribute;
  1371. Sys_DosProtectSetFileLocks: TDosProtectSetFileLocks =
  1372. @DummyDosProtectSetFileLocks;
  1373. Sys_DosGetProcessorStatus: TDosGetProcessorStatus =
  1374. @DummyDosGetProcessorStatus;
  1375. Sys_DosSetProcessorStatus: TDosSetProcessorStatus =
  1376. @DummyDosSetProcessorStatus;
  1377. Sys_DosQueryThreadAffinity: TDosQueryThreadAffinity =
  1378. @DummyDosQueryThreadAffinity;
  1379. Sys_DosSetThreadAffinity: TDosSetThreadAffinity = @DummyDosSetThreadAffinity;
  1380. Sys_DosQueryExtLibPath: TDosQueryExtLibPath = @DummyDosQueryExtLibPath;
  1381. Sys_DosSetExtLibPath: TDosSetExtLibPath = @DummyDosSetExtLibPath;
  1382. Sys_DosQueryModFromEIP: TDosQueryModFromEIP = @DummyDosQueryModFromEIP;
  1383. Sys_DosDumpProcess: TDosDumpProcess = @DummyDosDumpProcess;
  1384. Sys_DosSuppressPopups: TDosSuppressPopups = @DummyDosSuppressPopups;
  1385. Sys_DosPerfSysCall: TDosPerfSysCall = @DummyDosPerfSysCall;
  1386. Sys_DosQueryThreadContext: TDosQueryThreadContext =
  1387. @DummyDosQueryThreadContext;
  1388. Sys_DosQueryABIOSSupport: TDosQueryABIOSSupport = @DummyDosQueryABIOSSupport;
  1389. function DosOpenL (FileName: PAnsiChar; var Handle: THandle;
  1390. var Action: cardinal; InitSize: int64;
  1391. Attrib, OpenFlags, FileMode: cardinal;
  1392. EA: pointer): cardinal; cdecl; inline;
  1393. begin
  1394. DosOpenL := Sys_DosOpenL (FileName, Handle, Action, InitSize, Attrib,
  1395. OpenFlags, FileMode, EA);
  1396. end;
  1397. function DosSetFilePtrL (Handle: THandle; Pos: int64; Method: cardinal;
  1398. var PosActual: int64): cardinal; cdecl; inline;
  1399. begin
  1400. DosSetFilePtrL := Sys_DosSetFilePtrL (Handle, Pos, Method, PosActual);
  1401. end;
  1402. function DosSetFileSizeL (Handle: THandle; Size: int64): cardinal; cdecl;
  1403. inline;
  1404. begin
  1405. DosSetFileSizeL := Sys_DosSetFileSizeL (Handle, Size);
  1406. end;
  1407. function DosProtectOpen (FileName: PAnsiChar; var Handle: THandle;
  1408. var Action: cardinal; InitSize, Attrib,
  1409. OpenFlags, OpenMode: cardinal; EA: PEAOp2;
  1410. var FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1411. begin
  1412. DosProtectOpen := Sys_DosProtectOpen (FileName, Handle, Action, InitSize,
  1413. Attrib, OpenFlags, OpenMode, EA, FileHandleLockID);
  1414. end;
  1415. function DosProtectClose (Handle: THandle;
  1416. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1417. begin
  1418. DosProtectClose := Sys_DosProtectClose (Handle, FileHandleLockID);
  1419. end;
  1420. function DosProtectRead (Handle: THandle; var Buffer; Count: cardinal;
  1421. var ActCount: cardinal; FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1422. begin
  1423. DosProtectRead := Sys_DosProtectRead (Handle, Buffer, Count, ActCount,
  1424. FileHandleLockID);
  1425. end;
  1426. function DosProtectWrite (Handle: THandle; const Buffer; Count: cardinal;
  1427. var ActCount: cardinal;
  1428. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1429. begin
  1430. DosProtectWrite := Sys_DosProtectWrite (Handle, Buffer, Count, ActCount,
  1431. FileHandleLockID);
  1432. end;
  1433. function DosProtectSetFilePtr (Handle: THandle; Pos: longint;
  1434. Method: cardinal; var PosActual: cardinal;
  1435. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1436. begin
  1437. DosProtectSetFilePtr := Sys_DosProtectSetFilePtr (Handle, Pos, Method,
  1438. PosActual, FileHandleLockID);
  1439. end;
  1440. function DosProtectSetFileSize (Handle: THandle; Size: cardinal;
  1441. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1442. begin
  1443. DosProtectSetFileSize := Sys_DosProtectSetFileSize (Handle, Size,
  1444. FileHandleLockID);
  1445. end;
  1446. function DosProtectQueryFHState (Handle: THandle; var FileMode: cardinal;
  1447. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1448. begin
  1449. DosProtectQueryFHState := Sys_DosProtectQueryFHState (Handle, FileMode,
  1450. FileHandleLockID);
  1451. end;
  1452. function DosProtectSetFHState (Handle: THandle; FileMode: cardinal;
  1453. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1454. begin
  1455. DosProtectSetFHState := Sys_DosProtectSetFHState (Handle, FileMode,
  1456. FileHandleLockID);
  1457. end;
  1458. function DosProtectQueryFileInfo (Handle: THandle; InfoLevel: cardinal;
  1459. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1460. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1461. begin
  1462. DosProtectQueryFileInfo := Sys_DosProtectQueryFileInfo (Handle, InfoLevel,
  1463. AFileStatus, FileStatusLen, FileHandleLockID);
  1464. end;
  1465. function DosProtectSetFileInfo (Handle: THandle; InfoLevel: cardinal;
  1466. AFileStatus: PFileStatus; FileStatusLen: cardinal;
  1467. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1468. begin
  1469. DosProtectSetFileInfo := Sys_DosProtectSetFileInfo (Handle, InfoLevel,
  1470. AFileStatus, FileStatusLen, FileHandleLockID);
  1471. end;
  1472. function DosProtectEnumAttribute (RefType: cardinal; AFile: pointer;
  1473. Entry: cardinal; var Buf; BufSize: cardinal;
  1474. var Count: cardinal; InfoLevel: cardinal;
  1475. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1476. begin
  1477. DosProtectEnumAttribute := Sys_DosProtectEnumAttribute (RefType, AFile,
  1478. Entry, Buf, BufSize, Count, InfoLevel, FileHandleLockID);
  1479. end;
  1480. function DosProtectSetFileLocks (Handle: THandle;
  1481. var Unlock, Lock: TFileLock;
  1482. Timeout, Flags: cardinal;
  1483. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1484. begin
  1485. DosProtectSetFileLocks := Sys_DosProtectSetFileLocks (Handle, Unlock, Lock,
  1486. Timeout, Flags, FileHandleLockID);
  1487. end;
  1488. function DosProtectOpen (FileName: PAnsiChar; var Handle: longint;
  1489. var Action: longint; InitSize, Attrib,
  1490. OpenFlags, OpenMode: longint; ea: PEAOp2;
  1491. var FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1492. begin
  1493. DosProtectOpen := Sys_DosProtectOpen (FileName, THandle (Handle),
  1494. cardinal (Action), cardinal (InitSize), cardinal (Attrib),
  1495. cardinal (OpenFlags), cardinal (OpenMode), EA, FileHandleLockID);
  1496. end;
  1497. function DosProtectOpen (const FileName: string; var Handle: longint;
  1498. var Action: longint; InitSize, Attrib,
  1499. OpenFlags, OpenMode: longint; ea: PEAOp2;
  1500. var FileHandleLockID: cardinal): cardinal;
  1501. var
  1502. T: array [0..255] of AnsiChar;
  1503. begin
  1504. StrPCopy (@T, FileName);
  1505. DosProtectOpen := Sys_DosProtectOpen (@T, THandle (Handle),
  1506. cardinal (Action), cardinal (InitSize), cardinal (Attrib),
  1507. cardinal (OpenFlags), cardinal (OpenMode), EA, FileHandleLockID);
  1508. end;
  1509. function DosProtectOpen (const FileName: string; var Handle: THandle;
  1510. var Action: cardinal; InitSize, Attrib,
  1511. OpenFlags, OpenMode: cardinal; ea: PEAOp2;
  1512. var FileHandleLockID: cardinal): cardinal;
  1513. var
  1514. T: array [0..255] of AnsiChar;
  1515. begin
  1516. StrPCopy (@T, FileName);
  1517. DosProtectOpen := Sys_DosProtectOpen (@T, Handle, Action, InitSize, Attrib,
  1518. OpenFlags, OpenMode, EA, FileHandleLockID);
  1519. end;
  1520. function DosProtectRead (Handle: longint; var Buffer; Count: longint;
  1521. var ActCount: longint; FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1522. begin
  1523. DosProtectRead := Sys_DosProtectRead (THandle (Handle), Buffer,
  1524. cardinal (Count), cardinal (ActCount), FileHandleLockID);
  1525. end;
  1526. function DosProtectWrite (Handle: longint; const Buffer; Count: longint;
  1527. var ActCount: longint;
  1528. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1529. begin
  1530. DosProtectWrite := Sys_DosProtectWrite (THandle (Handle), Buffer,
  1531. cardinal (Count), cardinal (ActCount), FileHandleLockID);
  1532. end;
  1533. function DosProtectSetFilePtr (Handle: longint; Pos, Method: longint;
  1534. var PosActual: longint;
  1535. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1536. begin
  1537. DosProtectSetFilePtr := Sys_DosProtectSetFilePtr (THandle (Handle),
  1538. cardinal (Pos), cardinal (Method), cardinal (PosActual), FileHandleLockID);
  1539. end;
  1540. function DosProtectSetFilePtr (Handle: THandle; Pos: longint;
  1541. FileHandleLockID: cardinal): cardinal;
  1542. var
  1543. PosActual: cardinal;
  1544. begin
  1545. DosProtectSetFilePtr := DosProtectSetFilePtr (Handle, Pos, 0, PosActual,
  1546. FileHandleLockID);
  1547. end;
  1548. function DosProtectGetFilePtr (Handle: longint;
  1549. var PosActual: longint; FileHandleLockID: cardinal): cardinal;
  1550. begin
  1551. DosProtectGetFilePtr := DosProtectSetFilePtr (THandle (Handle), 0, 1,
  1552. cardinal (PosActual), FileHandleLockID);
  1553. end;
  1554. function DosProtectGetFilePtr (Handle: THandle;
  1555. var PosActual: cardinal; FileHandleLockID: cardinal): cardinal;
  1556. begin
  1557. DosProtectGetFilePtr := DosProtectSetFilePtr (Handle, 0, 1, PosActual,
  1558. FileHandleLockID);
  1559. end;
  1560. function DosProtectEnumAttribute (Handle: THandle; Entry: cardinal; var Buf;
  1561. BufSize: cardinal; var Count: cardinal;
  1562. InfoLevel: cardinal;
  1563. FileHandleLockID: cardinal): cardinal;
  1564. begin
  1565. DosProtectEnumAttribute := DosProtectEnumAttribute (0, @Handle, Entry, Buf,
  1566. BufSize, Count, InfoLevel, FileHandleLockID);
  1567. end;
  1568. function DosProtectEnumAttribute (const FileName: string; Entry: cardinal;
  1569. var Buf; BufSize: cardinal;
  1570. var Count: cardinal; InfoLevel: cardinal;
  1571. FileHandleLockID: cardinal): cardinal;
  1572. var
  1573. T: array [0..255] of AnsiChar;
  1574. begin
  1575. StrPCopy (@T, FileName);
  1576. DosProtectEnumAttribute := DosProtectEnumAttribute (1, @T, Entry, Buf,
  1577. BufSize, Count, InfoLevel, FileHandleLockID);
  1578. end;
  1579. function DosCancelLockRequestL (Handle: THandle;
  1580. var Lock: TFileLockL): cardinal; cdecl; inline;
  1581. begin
  1582. DosCancelLockRequestL := Sys_DosCancelLockRequestL (Handle, Lock);
  1583. end;
  1584. function DosProtectSetFileLocksL (Handle: THandle; var Unlock: TFileLockL;
  1585. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal;
  1586. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1587. begin
  1588. DosProtectSetFileLocksL := Sys_DosProtectSetFileLocksL (Handle, Unlock, Lock,
  1589. Timeout, Flags, FileHandleLockID);
  1590. end;
  1591. function DosSetFileLocksL (Handle: THandle; var Unlock: TFileLockL;
  1592. var Lock: TFileLockL; Timeout: cardinal; Flags: cardinal): cardinal; cdecl;
  1593. inline;
  1594. begin
  1595. DosSetFileLocksL := Sys_DosSetFileLocksL (Handle, Unlock, Lock, Timeout,
  1596. Flags);
  1597. end;
  1598. function DosProtectOpenL (FileName: PAnsiChar; var Handle: THandle;
  1599. var Action: cardinal; InitSize: int64; Attrib,
  1600. OpenFlags, OpenMode: cardinal; EA: PEAOp2;
  1601. var FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1602. begin
  1603. DosProtectOpenL := Sys_DosProtectOpenL (FileName, Handle, Action, InitSize,
  1604. Attrib, OpenFlags, OpenMode, EA, FileHandleLockID);
  1605. end;
  1606. function DosProtectSetFilePtrL (Handle: THandle; Pos: int64;
  1607. Method: cardinal; var PosActual: int64;
  1608. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1609. begin
  1610. DosProtectSetFilePtrL := Sys_DosProtectSetFilePtrL (Handle, Pos, Method,
  1611. PosActual, FileHandleLockID);
  1612. end;
  1613. function DosProtectSetFileSizeL (Handle: THandle; Size: int64;
  1614. FileHandleLockID: cardinal): cardinal; cdecl; inline;
  1615. begin
  1616. DosProtectSetFileSizeL := Sys_DosProtectSetFileSizeL (Handle, Size,
  1617. FileHandleLockID);
  1618. end;
  1619. function DosGetProcessorStatus (ProcID: cardinal;
  1620. var Status: cardinal): cardinal; cdecl; inline;
  1621. begin
  1622. DosGetProcessorStatus := Sys_DosGetProcessorStatus (ProcID, Status);
  1623. end;
  1624. function DosSetProcessorStatus (ProcID: cardinal;
  1625. Status: cardinal): cardinal; cdecl; inline;
  1626. begin
  1627. DosSetProcessorStatus := Sys_DosSetProcessorStatus (ProcID, Status);
  1628. end;
  1629. function DosQueryThreadAffinity (Scope: cardinal;
  1630. var AffinityMask: TMPAffinity): cardinal; cdecl; inline;
  1631. begin
  1632. DosQueryThreadAffinity := Sys_DosQueryThreadAffinity (Scope, AffinityMask);
  1633. end;
  1634. function DosSetThreadAffinity (var AffinityMask: TMPAffinity): cardinal; cdecl;
  1635. inline;
  1636. begin
  1637. DosSetThreadAffinity := Sys_DosSetThreadAffinity (AffinityMask);
  1638. end;
  1639. function DosQueryExtLibPath (ExtLibPath: PAnsiChar; Flags: cardinal): cardinal;
  1640. cdecl; inline;
  1641. begin
  1642. DosQueryExtLibPath := Sys_DosQueryExtLibPath (ExtLibPath, Flags);
  1643. end;
  1644. function DosSetExtLibPath (ExtLibPath: PAnsiChar; Flags: cardinal): cardinal;
  1645. cdecl; inline;
  1646. begin
  1647. DosSetExtLibPath := Sys_DosSetExtLibPath (ExtLibPath, Flags);
  1648. end;
  1649. function DosQueryModFromEIP (var HMod: THandle; var ObjNum: cardinal;
  1650. BuffLen: cardinal; Buff: PAnsiChar; var Offset: cardinal;
  1651. Address: PtrUInt): cardinal; cdecl; inline;
  1652. begin
  1653. DosQueryModFromEIP := Sys_DosQueryModFromEIP (HMod, ObjNum, BuffLen, Buff,
  1654. Offset, Address);
  1655. end;
  1656. function DosDumpProcess (Flag: cardinal; Drive: AnsiChar;
  1657. PID: cardinal): cardinal; cdecl; inline;
  1658. begin
  1659. DosDumpProcess := Sys_DosDumpProcess (Flag, cardinal (Drive), PID);
  1660. end;
  1661. function DosSuppressPopups (Flag: cardinal;
  1662. Drive: AnsiChar): cardinal; cdecl; inline;
  1663. begin
  1664. DosSuppressPopups := Sys_DosSuppressPopups (Flag, Drive);
  1665. end;
  1666. function DosPerfSysCall (Command, Parm1, Parm2,
  1667. Parm3: cardinal): cardinal; cdecl; inline;
  1668. begin
  1669. DosPerfSysCall := Sys_DosPerfSysCall (Command, Parm1, Parm2, Parm3);
  1670. end;
  1671. function DosPerfSysCall (Command, Parm1, Parm2: cardinal;
  1672. var HookData): cardinal; cdecl;
  1673. begin
  1674. DosPerfSysCall := Sys_DosPerfSysCall (Command, Parm1, Parm2,
  1675. PtrUInt (HookData));
  1676. end;
  1677. function DosPerfSysCall (Command: cardinal; var CpuUtil: TCPUUtil; Parm2,
  1678. Parm3: cardinal): cardinal; cdecl;
  1679. begin
  1680. DosPerfSysCall := Sys_DosPerfSysCall (Command, PtrUInt (@CPUUtil), Parm2,
  1681. Parm3);
  1682. end;
  1683. function DosQueryThreadContext (TID: cardinal; Level: cardinal;
  1684. var Context: TContextRecord): cardinal; cdecl; inline;
  1685. begin
  1686. DosQueryThreadContext := Sys_DosQueryThreadContext (TID, Level, Context);
  1687. end;
  1688. function DosQueryABIOSSupport (Reserved: cardinal): cardinal; cdecl; inline;
  1689. begin
  1690. DosQueryABIOSSupport := Sys_DosQueryABIOSSupport (Reserved);
  1691. end;
  1692. var
  1693. P: pointer;
  1694. begin
  1695. if FSApi64 then
  1696. (* DosCallsHandle successfully initialized during initialization of unit *)
  1697. (* System and basic 64-bit functions were loaded successfully. *)
  1698. begin
  1699. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32CancelLockRequestL, nil, P)
  1700. = 0 then
  1701. Sys_DosCancelLockRequestL := TDosCancelLockRequestL (P);
  1702. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileLocksL, nil, P)
  1703. = 0 then
  1704. Sys_DosProtectSetFileLocksL := TDosProtectSetFileLocksL (P);
  1705. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetFileLocksL, nil, P)
  1706. = 0 then
  1707. Sys_DosSetFileLocksL := TDosSetFileLocksL (P);
  1708. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectOpenL, nil, P) = 0
  1709. then
  1710. Sys_DosProtectOpenL := TDosProtectOpenL (P);
  1711. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFilePtrL, nil, P)
  1712. = 0 then
  1713. Sys_DosProtectSetFilePtrL := TDosProtectSetFilePtrL (P);
  1714. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileSizeL, nil, P)
  1715. = 0 then
  1716. Sys_DosProtectSetFileSizeL := TDosProtectSetFileSizeL (P);
  1717. end;
  1718. if DosCallsHandle = THandle (-1) then
  1719. Exit;
  1720. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectOpen, nil, P) = 0 then
  1721. begin
  1722. Sys_DosProtectOpen := TDosProtectOpen (P);
  1723. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectClose, nil, P) = 0
  1724. then
  1725. Sys_DosProtectClose := TDosProtectClose (P);
  1726. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectRead, nil, P) = 0 then
  1727. Sys_DosProtectRead := TDosProtectRead (P);
  1728. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectWrite, nil, P) = 0
  1729. then
  1730. Sys_DosProtectWrite := TDosProtectWrite (P);
  1731. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFilePtr, nil,
  1732. P) = 0 then
  1733. Sys_DosProtectSetFilePtr := TDosProtectSetFilePtr (P);
  1734. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileSize, nil,
  1735. P) = 0 then
  1736. Sys_DosProtectSetFileSize := TDosProtectSetFileSize (P);
  1737. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectQueryFHState, nil,
  1738. P) = 0 then
  1739. Sys_DosProtectQueryFHState := TDosProtectQueryFHState (P);
  1740. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFHState, nil,
  1741. P) = 0 then
  1742. Sys_DosProtectSetFHState := TDosProtectSetFHState (P);
  1743. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectQueryFileInfo, nil,
  1744. P) = 0 then
  1745. Sys_DosProtectQueryFileInfo := TDosProtectQueryFileInfo (P);
  1746. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileInfo, nil,
  1747. P) = 0 then
  1748. Sys_DosProtectSetFileInfo := TDosProtectSetFileInfo (P);
  1749. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectEnumAttribute, nil,
  1750. P) = 0 then
  1751. Sys_DosProtectEnumAttribute := TDosProtectEnumAttribute (P);
  1752. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32ProtectSetFileLocks, nil,
  1753. P) = 0 then
  1754. Sys_DosProtectSetFileLocks := TDosProtectSetFileLocks (P);
  1755. end;
  1756. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32GetProcessorStatus, nil,
  1757. P) = 0 then
  1758. Sys_DosGetProcessorStatus := TDosGetProcessorStatus (P);
  1759. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetProcessorStatus, nil,
  1760. P) = 0 then
  1761. Sys_DosSetProcessorStatus := TDosSetProcessorStatus (P);
  1762. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryThreadAffinity, nil,
  1763. P) = 0 then
  1764. Sys_DosQueryThreadAffinity := TDosQueryThreadAffinity (P);
  1765. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetThreadAffinity, nil,
  1766. P) = 0 then
  1767. Sys_DosSetThreadAffinity := TDosSetThreadAffinity (P);
  1768. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryExtLibPath, nil,
  1769. P) = 0 then
  1770. Sys_DosQueryExtLibPath := TDosQueryExtLibPath (P);
  1771. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SetExtLibPath, nil,
  1772. P) = 0 then
  1773. Sys_DosSetExtLibPath := TDosSetExtLibPath (P);
  1774. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryModFromEIP, nil,
  1775. P) = 0 then
  1776. Sys_DosQueryModFromEIP := TDosQueryModFromEIP (P);
  1777. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32DumpProcess, nil, P) = 0 then
  1778. Sys_DosDumpProcess := TDosDumpProcess (P);
  1779. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32SuppressPopups, nil,
  1780. P) = 0 then
  1781. Sys_DosSuppressPopups := TDosSuppressPopups (P);
  1782. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32PerfSysCall, nil, P) = 0 then
  1783. Sys_DosPerfSysCall := TDosPerfSysCall (P);
  1784. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryThreadContext, nil,
  1785. P) = 0 then
  1786. Sys_DosQueryThreadContext := TDosQueryThreadContext (P);
  1787. if DosQueryProcAddr (DosCallsHandle, Ord_Dos32QueryABIOSSupport, nil,
  1788. P) = 0 then
  1789. Sys_DosQueryABIOSSupport := TDosQueryABIOSSupport (P);
  1790. end.
  1791. (*
  1792. Todo:
  1793. DosCreateSpinLock = DOSCALLS.449 - might be simulated using semaphores on non-SMP
  1794. DosAcquireSpinLock = DOSCALLS.450 - might be simulated using semaphores on non-SMP
  1795. DosReleaseSpinLock = DOSCALLS.451 - might be simulated using semaphores on non-SMP
  1796. DosFreeSpinLock = DOSCALLS.452 - might be simulated using semaphores on non-SMP
  1797. type
  1798. TSpinLock = cardinal;
  1799. HSpinLock = TSpinLock;
  1800. PSpinLock = ^TSpinLock;
  1801. PHSpinLock = PSpinLock;
  1802. function DosCreateSpinLock (var SpinLock: TSpinLock): cardinal; cdecl;
  1803. procedure DosAcquireSpinLock (SpinLock: TSpinLock); cdecl;
  1804. procedure DosReleaseSpinLock (SpinLock: TSpinLock); cdecl;
  1805. function DosFreeSpinLock (SpinLock: TSpinLock): cardinal; cdecl;
  1806. DosQueryModFromEIP - may be simulated by returning empty value if not available or possibly by using data returned by DosQuerySysState (if they are equal across different OS/2 versions?)
  1807. ___ function Dos16QueryModFromCS (...): ...
  1808. external 'DOSCALLS' index 359;
  1809. DosVerifyPidTid - may be implemented by analyzing information returned by DosQuerySysState
  1810. x DosQueryExtLibPath - may be simulated by providing empty result if not available
  1811. x DosSetExtLibPath - may be simulated by returning ERROR_NOT_ENOUGH_MEMORY if not available
  1812. Dos32AcquireSpinLock | DOSCALLS | SMP | SMP
  1813. Dos32FreeSpinLock | DOSCALLS | SMP | SMP
  1814. x Dos32GetProcessorStatus | DOSCALLS | SMP | SMP
  1815. Dos32ReleaseSpinLock | DOSCALLS | SMP | SMP
  1816. x Dos32SetProcessorStatus | DOSCALLS | SMP | SMP
  1817. Dos32TestPSD | DOSCALLS | SMP | SMP
  1818. x Dos32QueryThreadAffinity | DOSCALLS | PROC | 2.45
  1819. (x) Dos32QueryThreadContext | DOSCALLS | XCPT | 2.40
  1820. x Dos32SetThreadAffinity | DOSCALLS | PROC | 2.45
  1821. Dos32AllocThreadLocalMemory | DOSCALLS | PROC | 2.30
  1822. Dos32FreeThreadLocalMemory | DOSCALLS | PROC | 2.30
  1823. Dos32ListIO | DOSCALLS | FILE | 2.45
  1824. x Dos32ProtectClose | DOSCALLS | FILE | 2.10
  1825. x Dos32ProtectEnumAttribute | DOSCALLS | FILE | 2.10
  1826. x Dos32ProtectOpen | DOSCALLS | FILE | 2.10
  1827. x Dos32ProtectQueryFHState | DOSCALLS | FILE | 2.10
  1828. x Dos32ProtectQueryFileInfo | DOSCALLS | FILE | 2.10
  1829. x Dos32ProtectRead | DOSCALLS | FILE | 2.10
  1830. x Dos32ProtectSetFHState | DOSCALLS | FILE | 2.10
  1831. x Dos32ProtectSetFileInfo | DOSCALLS | FILE | 2.10
  1832. x Dos32ProtectSetFileLocks | DOSCALLS | FILE | 2.10
  1833. x Dos32ProtectSetFilePtr | DOSCALLS | FILE | 2.10
  1834. x Dos32ProtectSetFileSize | DOSCALLS | FILE | 2.10
  1835. x Dos32ProtectWrite | DOSCALLS | FILE | 2.10
  1836. Dos32QueryABIOSSupport | DOSCALLS | MOD | 2.10
  1837. (x) Dos32QueryModFromEIP | DOSCALLS | MOD | 2.10
  1838. (x) Dos32SuppressPopUps | DOSCALLS | MISC | 2.10
  1839. Dos32VerifyPidTid | DOSCALLS | MISC | 2.30
  1840. *)