doscall2.pas 96 KB

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