source: trunk/include/helpers/dosh.h@ 390

Last change on this file since 390 was 364, checked in by pr, 17 years ago

Add doshIsFixpak for bug 1067.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 38.4 KB
Line 
1
2/*
3 *@@sourcefile dosh.h:
4 * header file for dosh.c. See remarks there.
5 *
6 * Note: Version numbering in this file relates to XWorkplace version
7 * numbering.
8 *
9 *@@include #define INCL_DOSPROCESS
10 *@@include #define INCL_DOSDEVIOCTL // for doshQueryDiskParams only
11 *@@include #include <os2.h>
12 *@@include #include "helpers\dosh.h"
13 */
14
15/* This file Copyright (C) 1997-2006 Ulrich M”ller,
16 * Dmitry A. Steklenev.
17 * This file is part of the "XWorkplace helpers" source package.
18 * This is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published
20 * by the Free Software Foundation, in version 2 as it comes in the
21 * "COPYING" file of the XWorkplace main distribution.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 */
27
28#if __cplusplus
29extern "C" {
30#endif
31
32#ifndef DOSH_HEADER_INCLUDED
33 #define DOSH_HEADER_INCLUDED
34
35 /* ******************************************************************
36 *
37 * Wrappers
38 *
39 ********************************************************************/
40
41 // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h,
42 // all the following Dos* API calls are redirected to the dosh*
43 // counterparts
44
45 #ifdef DOSH_STANDARDWRAPPERS
46
47 #ifdef INCL_DOSPROCESS
48
49 APIRET XWPENTRY doshSleep(ULONG msec);
50 #define DosSleep(a) doshSleep((a))
51
52 #endif
53
54 #ifdef INCL_DOSSEMAPHORES
55
56 APIRET XWPENTRY doshCreateMutexSem(PSZ pszName,
57 PHMTX phmtx,
58 ULONG flAttr,
59 BOOL32 fState);
60 #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d))
61
62 APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
63 #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t))
64
65 APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx);
66 #define DosReleaseMutexSem(h) doshReleaseMutexSem((h))
67
68 #endif
69
70 #ifdef INCL_DOSEXCEPTIONS
71
72 APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
73 #define DosSetExceptionHandler(a) doshSetExceptionHandler((a))
74
75 APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
76 #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a))
77
78 #endif
79
80 #endif
81
82 /* ******************************************************************
83 *
84 * Miscellaneous
85 *
86 ********************************************************************/
87
88 CHAR doshGetChar(VOID);
89
90 BOOL doshQueryShiftState(VOID);
91
92 ULONG doshIsWarp4(VOID);
93
94 BOOL doshIsFixpak(BOOL fIsMcp,
95 ULONG ulFixpakLevel);
96
97 PSZ doshQuerySysErrorMsg(APIRET arc);
98
99 ULONG doshQuerySysUptime(VOID);
100
101 APIRET doshDevIOCtl(HFILE hf,
102 ULONG ulCategory,
103 ULONG ulFunction,
104 PVOID pvParams,
105 ULONG cbParams,
106 PVOID pvData,
107 ULONG cbData);
108
109 /* ******************************************************************
110 *
111 * Memory helpers
112 *
113 ********************************************************************/
114
115 PVOID doshMalloc(ULONG cb,
116 APIRET *parc);
117
118 APIRET doshAllocArray(ULONG c,
119 ULONG cbArrayItem,
120 PBYTE *ppv,
121 PULONG pcbAllocated);
122
123 PVOID doshAllocSharedMem(ULONG ulSize,
124 const char* pcszName);
125
126 PVOID doshRequestSharedMem(PCSZ pcszName);
127
128 /* ******************************************************************
129 *
130 * Drive helpers
131 *
132 ********************************************************************/
133
134 APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
135 PBOOL pfFixed);
136
137 #ifdef INCL_DOSDEVIOCTL
138
139 // #pragma pack(1)
140
141 /*
142 * DRIVEPARAMS:
143 * structure used for doshQueryDiskParams.
144 * removed this, we can directly use BIOSPARAMETERBLOCK
145 * V0.9.13 (2001-06-14) [umoeller]
146 */
147
148 /* typedef struct _DRIVEPARAMS
149 {
150 BIOSPARAMETERBLOCK bpb;
151 // BIOS parameter block. This is the first sector
152 // (at byte 0) in each partition. This is defined
153 // in the OS2 headers as follows:
154
155 typedef struct _BIOSPARAMETERBLOCK {
156 0 USHORT usBytesPerSector;
157 // Number of bytes per sector.
158 2 BYTE bSectorsPerCluster;
159 // Number of sectors per cluster.
160 3 USHORT usReservedSectors;
161 // Number of reserved sectors.
162 5 BYTE cFATs;
163 // Number of FATs.
164 6 USHORT cRootEntries;
165 // Number of root directory entries.
166 8 USHORT cSectors;
167 // Number of sectors.
168 10 BYTE bMedia;
169 // Media descriptor.
170 11 USHORT usSectorsPerFAT;
171 // Number of secctors per FAT.
172 13 USHORT usSectorsPerTrack;
173 // Number of sectors per track.
174 15 USHORT cHeads;
175 // Number of heads.
176 17 ULONG cHiddenSectors;
177 // Number of hidden sectors.
178 21 ULONG cLargeSectors;
179 // Number of large sectors.
180 25 BYTE abReserved[6];
181 // Reserved.
182 31 USHORT cCylinders;
183 // Number of cylinders defined for the physical
184 // device.
185 33 BYTE bDeviceType;
186 // Physical layout of the specified device.
187 34 USHORT fsDeviceAttr;
188 // A bit field that returns flag information
189 // about the specified drive.
190 } BIOSPARAMETERBLOCK;
191
192 // removed the following fields... these are already
193 // in the extended BPB structure, as defined in the
194 // Toolkit's BIOSPARAMETERBLOCK struct. Checked this,
195 // the definition is the same for the Toolkit 3 and 4.5.
196
197 USHORT usCylinders;
198 // no. of cylinders
199 UCHAR ucDeviceType;
200 // device type; according to the IBM Control
201 // Program Reference (see DSK_GETDEVICEPARAMS),
202 // this value can be:
203 // -- 0: 48 TPI low-density diskette drive
204 // -- 1: 96 TPI high-density diskette drive
205 // -- 2: 3.5-inch 720KB diskette drive
206 // -- 3: 8-Inch single-density diskette drive
207 // -- 4: 8-Inch double-density diskette drive
208 // -- 5: Fixed disk
209 // -- 6: Tape drive
210 // -- 7: Other (includes 1.44MB 3.5-inch diskette drive
211 // and CD-ROMs)
212 // -- 8: R/W optical disk
213 // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
214 USHORT usDeviceAttrs;
215 // DEVATTR_* flags
216 } DRIVEPARAMS, *PDRIVEPARAMS;
217 #pragma pack() */
218
219 APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
220 PBIOSPARAMETERBLOCK pdp);
221
222 BYTE doshQueryDriveType(ULONG ulLogicalDrive,
223 PBIOSPARAMETERBLOCK pdp,
224 BOOL fFixed);
225 #endif
226
227 APIRET doshQueryCDDrives(PBYTE pcCDs,
228 PBYTE pbFirstCD);
229
230 APIRET XWPENTRY doshOpenDrive(ULONG ulLogicalDrive,
231 HFILE *phf);
232
233 APIRET XWPENTRY doshHasAudioCD(HFILE hfDrive,
234 BOOL fMixedModeCD,
235 PBOOL pfAudio);
236
237 #define CDFL_DOOROPEN 0x00000001 // bit 0
238 #define CDFL_DOORLOCKED 0x00000002 // bit 1
239 #define CDFL_COOKEDANDRAW 0x00000004 // bit 2
240 #define CDFL_READWRITE 0x00000008 // bit 3
241 #define CDFL_DATAANDAUDIO 0x00000010 // bit 4
242 #define CDFL_ISO9660INTERLEAVE 0x00000020 // bit 5
243 #define CDFL_PREFETCHSUPPORT 0x00000080 // bit 7
244 #define CDFL_AUDIOCHANNELMANIP 0x00000100 // bit 8
245 #define CDFL_MINUTESECONDADDR 0x00000200 // bit 9
246 #define CDFL_MODE2SUPPORT 0x00000400 // bit 10
247 #define CDFL_DISKPRESENT 0x00000800 // bit 11
248 #define CDFL_PLAYINGAUDIO 0x00001000 // bit 12
249 #define CDFL_CDDA 0x40000000 // bit 30
250
251 APIRET XWPENTRY doshQueryCDStatus(HFILE hfDrive,
252 PULONG pflStatus);
253
254 VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
255 PCSZ pcszFileSystem,
256 BOOL fSkipRemoveables);
257 typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
258 PCSZ pcszFileSystem,
259 BOOL fSkipRemoveables);
260 typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
261
262 CHAR doshQueryBootDrive(VOID);
263
264 #define ERROR_AUDIO_CD_ROM 10000
265
266 #define DRVFL_MIXEDMODECD 0x0001
267 #define DRVFL_TOUCHFLOPPIES 0x0002
268 #define DRVFL_CHECKEAS 0x0004
269 #define DRVFL_CHECKLONGNAMES 0x0008
270
271 APIRET doshAssertDrive(ULONG ulLogicalDrive,
272 ULONG fl);
273
274 #ifdef INCL_DOSDEVIOCTL
275
276 /*
277 *@@ XDISKINFO:
278 *
279 *@@added V0.9.16 (2002-01-13) [umoeller]
280 */
281
282 typedef struct _XDISKINFO
283 {
284 CHAR cDriveLetter; // drive letter
285 CHAR cLogicalDrive; // logical drive no.
286
287 BOOL fPresent; // if FALSE, drive does not exist
288
289 // the following are only valid if fPresent == TRUE
290
291 BIOSPARAMETERBLOCK bpb;
292 // 0x00 USHORT usBytesPerSector;
293 // 0x02 BYTE bSectorsPerCluster;
294 // 0x03 USHORT usReservedSectors;
295 // 0x05 BYTE cFATs;
296 // 0x06 USHORT cRootEntries;
297 // 0x08 USHORT cSectors;
298 // 0x0a BYTE bMedia;
299 // 0x0b USHORT usSectorsPerFAT;
300 // 0x0d USHORT usSectorsPerTrack;
301 // 0x0f USHORT cHeads;
302 // 0x11 ULONG cHiddenSectors;
303 // 0x15 ULONG cLargeSectors;
304 // 0x19 BYTE abReserved[6];
305 // 0x1a USHORT cCylinders;
306 // 0x1c BYTE bDeviceType;
307 #ifndef DEVTYPE_48TPI
308 #define DEVTYPE_48TPI 0x0000
309 #define DEVTYPE_96TPI 0x0001
310 #define DEVTYPE_35 0x0002
311 #define DEVTYPE_8SD 0x0003
312 #define DEVTYPE_8DD 0x0004
313 #define DEVTYPE_FIXED 0x0005
314 #define DEVTYPE_TAPE 0x0006
315 #endif
316 #define DEVTYPE_OTHER 0x0007
317 // includes 1.44 3.5" floppy
318 #define DEVTYPE_RWOPTICAL 0x0008
319 #define DEVTYPE_35_288MB 0x0009
320 // 0x1d USHORT fsDeviceAttr;
321 #define DEVATTR_REMOVEABLE 0x0001
322 // drive is removeable
323 #define DEVATTR_CHANGELINE 0x0002
324 // device can determine whether media has
325 // been removed since last I/O operation
326 #define DEVATTR_GREATER16MB 0x0004
327 // physical device driver supports physical
328 // addresses > 16 MB
329 #define DEVATTR_PARTITIONALREMOVEABLE 0x0008
330 // undocumented flag; set for ZIP drives
331
332 BYTE bType;
333 // do not change these codes, XWorkplace relies
334 // on them too to parse WPDisk data
335 #define DRVTYPE_HARDDISK 0
336 #define DRVTYPE_FLOPPY 1
337 #define DRVTYPE_TAPE 2
338 #define DRVTYPE_VDISK 3
339 #define DRVTYPE_CDROM 4
340 #define DRVTYPE_LAN 5
341 #define DRVTYPE_PRT 6
342 // partitionable removeable (ZIP drive)
343 #define DRVTYPE_UNKNOWN 255
344
345 ULONG flDevice;
346 // any combination of the following:
347 #define DFL_REMOTE 0x0001
348 // drive is remote (not local)
349 #define DFL_FIXED 0x0002
350 // drive is fixed; otherwise it is removeable!
351 // always set for harddisks and zip drives
352 #define DFL_PARTITIONABLEREMOVEABLE 0x0004
353 // set for zip drives;
354 // in that case, DFL_FIXED is set also
355 #define DFL_BOOTDRIVE 0x0008
356 // drive was booted from
357
358 // media flags: all changed V1.0.0 (2002-08-31) [umoeller]
359
360 #define DFL_MEDIA_PRESENT 0x0100
361 // media is present in drive;
362 // -- always set for harddisks,
363 // unless the file system is not
364 // understood
365 // -- always set for remove drives
366 // -- always set for A: and B:
367 // -- set for CD-ROMS only if data
368 // CD-ROM is inserted
369 #define DFL_AUDIO_CD 0x0200
370 // set for CD-ROMs only, if an audio CD
371 // is currently inserted; in that case,
372 // DFL_MEDIA_PRESENT is _not_ set
373 #define DFL_DOOR_OPEN 0x0400
374 // set for CD-ROMs only if the CD-ROM
375 // door is currently open
376 // V1.0.0 (2002-08-31) [umoeller]
377
378 #define DFL_SUPPORTS_EAS 0x0800
379 // drive supports extended attributes
380 // (assumption based on DosFSCtl,
381 // might not be correct for remote drives;
382 // reports correctly for FAT32 though)
383 #define DFL_SUPPORTS_LONGNAMES 0x1000
384 // drive supports long names; this does not
385 // necessarily mean that we support all IFS
386 // characters also
387
388
389 // the following are only valid if DFL_MEDIA_PRESENT is set;
390 // they are always set for drives A: and B:
391
392 CHAR szFileSystem[30];
393 // e.g. "FAT" or "HPFS" or "JFS" or "CDFS"
394
395 LONG lFileSystem;
396 // do not change these codes, XWorkplace relies
397 // on them too to parse WPDisk data
398 #define FSYS_UNKNOWN 0
399 // drive not formatted, or unknown file system
400 #define FSYS_FAT 1
401 #define FSYS_HPFS_JFS 2
402 #define FSYS_CDFS 3
403 #define FSYS_CDWFS 6 // not used by WPS!
404 // added V0.9.19 (2002-04-25) [umoeller]
405 #define FSYS_TVFS 7 // not used by WPS!
406 #define FSYS_FAT32_EXT2 8 // not used by WPS!
407 #define FSYS_RAMFS 9 // not used by WPS!
408 #define FSYS_REMOTE 10
409 // NOTE: if this has a negative value, this is
410 // the APIRET code from DosQueryFSAttach
411
412 // error codes for various operations
413 APIRET arcIsFixedDisk,
414 arcQueryDiskParams,
415 arcQueryMedia,
416 arcOpenLongnames;
417
418 } XDISKINFO, *PXDISKINFO;
419
420 APIRET doshGetDriveInfo(ULONG ulLogicalDrive,
421 ULONG fl,
422 PXDISKINFO pdi);
423
424 #endif
425
426 APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
427
428 APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
429 typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
430 typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
431
432 APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
433 typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
434 typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
435
436 APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
437 typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
438 typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
439
440 APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
441 PSZ pszVolumeLabel);
442
443 APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
444 PSZ pszNewLabel);
445
446 /* ******************************************************************
447 *
448 * Module handling helpers
449 *
450 ********************************************************************/
451
452 APIRET doshQueryProcAddr(PCSZ pcszModuleName,
453 ULONG ulOrdinal,
454 PFN *ppfn);
455
456 /*
457 *@@ RESOLVEFUNCTION:
458 * one of these structures each define
459 * a single function import to doshResolveImports.
460 *
461 *@@added V0.9.3 (2000-04-25) [umoeller]
462 */
463
464 typedef struct _RESOLVEFUNCTION
465 {
466 const char *pcszFunctionName;
467 PFN *ppFuncAddress;
468 } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
469
470 typedef const struct _RESOLVEFUNCTION *PCRESOLVEFUNCTION;
471
472 APIRET doshResolveImports(PCSZ pcszModuleName,
473 HMODULE *phmod,
474 PCRESOLVEFUNCTION paResolves,
475 ULONG cResolves);
476 // V1.0.5 (2006-05-28) [pr]
477 typedef APIRET DOSHRESOLVEIMPORTS(PCSZ pcszModuleName,
478 HMODULE *phmod,
479 PCRESOLVEFUNCTION paResolves,
480 ULONG cResolves);
481 typedef DOSHRESOLVEIMPORTS *PDOSHRESOLVEIMPORTS;
482
483 /* ******************************************************************
484 *
485 * Performance Counters (CPU Load)
486 *
487 ********************************************************************/
488
489 #define CMD_PERF_INFO 0x41
490 #define CMD_KI_ENABLE 0x60
491 #define CMD_KI_DISABLE 0x61
492 #ifndef CMD_KI_RDCNT
493 #define CMD_KI_RDCNT 0x63
494 typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
495 ULONG ulParm1,
496 ULONG ulParm2,
497 ULONG ulParm3);
498 typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
499 #endif
500
501 typedef struct _CPUUTIL
502 {
503 ULONG ulTimeLow; // low 32 bits of time stamp
504 ULONG ulTimeHigh; // high 32 bits of time stamp
505 ULONG ulIdleLow; // low 32 bits of idle time
506 ULONG ulIdleHigh; // high 32 bits of idle time
507 ULONG ulBusyLow; // low 32 bits of busy time
508 ULONG ulBusyHigh; // high 32 bits of busy time
509 ULONG ulIntrLow; // low 32 bits of interrupt time
510 ULONG ulIntrHigh; // high 32 bits of interrupt time
511 } CPUUTIL, *PCPUUTIL;
512
513 // macro to convert 8-byte (low, high) time value to double
514 #define LL2F(high, low) (4294967296.0*(high)+(low))
515
516 /*
517 *@@ DOSHPERFSYS:
518 * structure used with doshPerfOpen.
519 *
520 *@@added V0.9.7 (2000-12-02) [umoeller]
521 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
522 */
523
524 typedef struct _DOSHPERFSYS
525 {
526 // output: no. of processors on the system
527 ULONG cProcessors;
528 // output: one CPU load for each CPU
529 PLONG palLoads;
530
531 // output: one CPU interrupt load for each CPU
532 PLONG palIntrs;
533
534 // each of the following ptrs points to an array of cProcessors items
535 PCPUUTIL paCPUUtils; // CPUUTIL structures
536 double *padBusyPrev; // previous "busy" calculations
537 double *padTimePrev; // previous "time" calculations
538 double *padIntrPrev; // previous "intr" calculations
539
540 // private stuff
541 HMODULE hmod;
542 BOOL fInitialized;
543 PFNDOSPERFSYSCALL pDosPerfSysCall;
544 } DOSHPERFSYS, *PDOSHPERFSYS;
545
546 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
547
548 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
549
550 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
551
552 /* ******************************************************************
553 *
554 * File name parsing
555 *
556 ********************************************************************/
557
558 APIRET doshGetDriveSpec(PCSZ pcszFullFile,
559 PSZ pszDrive,
560 PULONG pulDriveLen,
561 PBOOL pfIsUNC);
562
563 PSZ doshGetExtension(PCSZ pcszFilename);
564
565 /* ******************************************************************
566 *
567 * File helpers
568 *
569 ********************************************************************/
570
571 BOOL doshIsFileOnFAT(const char* pcszFileName);
572
573 APIRET doshIsValidFileName(const char* pcszFile,
574 BOOL fFullyQualified);
575
576 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
577
578 APIRET doshQueryFileSize(HFILE hFile,
579 PULONG pulSize);
580
581 APIRET doshQueryPathSize(PCSZ pcszFile,
582 PULONG pulSize);
583
584 APIRET doshQueryPathAttr(const char* pcszFile,
585 PULONG pulAttr);
586
587 APIRET doshSetPathAttr(const char* pcszFile,
588 ULONG ulAttr);
589
590 PBYTE doshFindEAValue(PFEA2LIST pFEA2List2,
591 PCSZ pcszEAName,
592 PUSHORT pcbValue);
593
594 BOOL doshQueryLongname(PFEA2LIST pFEA2List2,
595 PSZ pszLongname,
596 PULONG pulNameLen);
597
598 /* ******************************************************************
599 *
600 * XFILEs
601 *
602 ********************************************************************/
603
604 /*
605 *@@ XFILE:
606 *
607 *@@added V0.9.16 (2001-10-19) [umoeller]
608 */
609
610 typedef struct _XFILE
611 {
612 HFILE hf;
613
614 PSZ pszFilename; // as given to doshOpen
615 ULONG flOpenMode; // as given to doshOpen
616
617 ULONG cbInitial, // intial file size on open (can be 0 if new)
618 cbCurrent; // current file size (raised with each write)
619
620 PBYTE pbCache; // if != NULL, cached data from doshReadAt
621 ULONG cbCache, // size of data in cbCache
622 ulReadFrom; // file offset where pbCache was read from
623 } XFILE, *PXFILE;
624
625 #define XOPEN_READ_EXISTING 0x0001
626 #define XOPEN_READWRITE_EXISTING 0x0002
627 #define XOPEN_READWRITE_APPEND 0x0003
628 #define XOPEN_READWRITE_NEW 0x0004
629 #define XOPEN_ACCESS_MASK 0xffff
630
631 #define XOPEN_BINARY 0x10000000
632 #define XOPEN_WRITETHRU 0x20000000
633
634 APIRET doshOpen(PCSZ pcszFilename,
635 ULONG flOpenMode,
636 PULONG pcbFile,
637 PXFILE *ppFile);
638
639 #define DRFL_NOCACHE 0x0001
640 #define DRFL_FAILIFLESS 0x0002
641
642 APIRET doshReadAt(PXFILE pFile,
643 ULONG ulOffset,
644 PULONG pcb,
645 PBYTE pbData,
646 ULONG fl);
647
648 APIRET doshWrite(PXFILE pFile,
649 ULONG cb,
650 PCSZ pbData);
651
652 APIRET doshWriteAt(PXFILE pFile,
653 ULONG ulOffset,
654 ULONG cb,
655 PCSZ pbData);
656
657 APIRET doshWriteLogEntry(PXFILE pFile,
658 const char* pcszFormat,
659 ...);
660
661 APIRET doshClose(PXFILE *ppFile);
662
663 APIRET doshReadText(PXFILE pFile,
664 PSZ* ppszContent,
665 PULONG pcbRead);
666
667 APIRET doshLoadTextFile(PCSZ pcszFile,
668 PSZ* ppszContent,
669 PULONG pcbRead);
670
671 BOOL doshCreateLogFilename(PSZ pszBuf,
672 PCSZ pcszFilename,
673 BOOL fAllowBootDrive);
674
675 PSZ doshCreateBackupFileName(const char* pszExisting);
676
677 APIRET doshCreateTempFileName(PSZ pszTempFileName,
678 PCSZ pcszDir,
679 PCSZ pcszPrefix,
680 PCSZ pcszExt);
681
682 APIRET doshWriteTextFile(const char* pszFile,
683 const char* pszContent,
684 PULONG pulWritten,
685 PSZ pszBackup);
686
687
688 /* ******************************************************************
689 *
690 * Directory helpers
691 *
692 ********************************************************************/
693
694 BOOL doshQueryDirExist(PCSZ pcszDir);
695
696 APIRET doshCreatePath(PCSZ pcszPath,
697 BOOL fHidden);
698
699 APIRET doshQueryCurrentDir(PSZ pszBuf);
700
701 APIRET doshSetCurrentDir(PCSZ pcszDir);
702
703 #define DOSHDELDIR_RECURSE 0x0001
704 #define DOSHDELDIR_DELETEFILES 0x0002
705
706 APIRET doshDeleteDir(PCSZ pcszDir,
707 ULONG flFlags,
708 PULONG pulDirs,
709 PULONG pulFiles);
710
711 APIRET doshCanonicalize(PCSZ pcszFileIn,
712 PSZ pszFileOut,
713 ULONG cbFileOut);
714
715 typedef APIRET XWPENTRY FNCBFORALLFILES(const FILEFINDBUF3 *pfb3,
716 PVOID pvCallback);
717
718 APIRET doshForAllFiles(PCSZ pcszSearchMask,
719 ULONG flFile,
720 FNCBFORALLFILES *pfncb,
721 PVOID pvCallback);
722
723 /* ******************************************************************
724 *
725 * Process helpers
726 *
727 ********************************************************************/
728
729 ULONG XWPENTRY doshMyPID(VOID);
730 typedef ULONG XWPENTRY DOSHMYPID(VOID);
731 typedef DOSHMYPID *PDOSHMYPID;
732
733 ULONG doshMyParentPID(VOID);
734
735 ULONG XWPENTRY doshMyTID(VOID);
736 typedef ULONG XWPENTRY DOSHMYTID(VOID);
737 typedef DOSHMYTID *PDOSHMYTID;
738
739 APIRET doshExecVIO(PCSZ pcszExecWithArgs,
740 PLONG plExitCode);
741
742 APIRET doshQuickStartSession(PCSZ pcszPath,
743 PCSZ pcszParams,
744 PCSZ pcszTitle,
745 USHORT usSessionType,
746 BOOL fForeground,
747 USHORT usPgmCtl,
748 BOOL fWait,
749 PULONG pulSID,
750 PPID ppid,
751 PUSHORT pusReturn);
752
753 APIRET doshSearchPath(PCSZ pcszPath,
754 PCSZ pcszFile,
755 PSZ pszExecutable,
756 ULONG cbExecutable);
757
758 // added V1.0.4 (2005-06-16) [chennecke]
759 APIRET doshSearchDirs(PCSZ pcszDirList,
760 PCSZ pcszFile,
761 PSZ pszExecutable,
762 ULONG cbExecutable);
763
764 APIRET doshFindExecutable(PCSZ pcszCommand,
765 PSZ pszExecutable,
766 ULONG cbExecutable,
767 PCSZ *papcszExtensions,
768 ULONG cExtensions);
769
770 /********************************************************************
771 *
772 * Partition functions
773 *
774 ********************************************************************/
775
776 /*
777 *@@ LVMINFO:
778 * informational structure created by
779 * doshQueryLVMInfo.
780 *
781 *@@added V0.9.9 (2001-04-07) [umoeller]
782 */
783
784 typedef struct _LVMINFO
785 {
786 HMODULE hmodLVM;
787
788 } LVMINFO, *PLVMINFO;
789
790 /* #define DOSH_PARTITIONS_LIMIT 10
791
792 #define PAR_UNUSED 0x00 // Unused
793 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
794 #define PAR_XENIXROOT 0x02 // XENIX root
795 #define PAR_XENIXUSER 0x03 // XENIX user
796 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
797 #define PAR_EXTENDED 0x05 // Extended partition
798 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
799 #define PAR_HPFS 0x07 // OS/2 HPFS
800 #define PAR_AIXBOOT 0x08 // AIX bootable partition
801 #define PAR_AIXDATA 0x09 // AIX bootable partition
802 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
803 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
804 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
805 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
806 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
807 #define PAR_OPUS 0x10 // OPUS
808 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
809 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
810 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
811 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
812 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
813 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
814 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
815 #define PAR_THEOS 0x38 // THEOS
816 #define PAR_VENIX 0x40 // VENIX
817 #define PAR_RISCBOOT 0x41 // Personal RISC boot
818 #define PAR_SFS 0x42 // SFS
819 #define PAR_ONTRACK 0x50 // Ontrack
820 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
821 #define PAR_CPM 0x52 // CP/M
822 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
823 #define PAR_NOVELL_64 0x64 // Novell
824 #define PAR_NOVELL_65 0x65 // Novell
825 #define PAR_NOVELL_67 0x67 // Novell
826 #define PAR_NOVELL_68 0x68 // Novell
827 #define PAR_NOVELL_69 0x69 // Novell
828 #define PAR_PCIX 0x75 // PCIX
829 #define PAR_MINIX 0x80 // MINIX
830 #define PAR_LINUX 0x81 // Linux
831 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
832 #define PAR_LINUXFILE 0x83 // Linux File System
833 #define PAR_FREEBSD 0xA5 // FreeBSD
834 #define PAR_BBT 0xFF // BBT
835 */
836
837 // one-byte alignment
838 #pragma pack(1)
839
840 /*
841 *@@ PAR_INFO:
842 * partition table
843 */
844
845 typedef struct _PAR_INFO
846 {
847 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
848 BYTE bBeginHead; // partition begins at this head...
849 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
850 BYTE bFileSysCode; // file system type
851 BYTE bEndHead; // partition ends at this head...
852 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
853 ULONG lBeginAbsSec; // partition begins at this absolute sector #
854 ULONG lTotalSects; // total sectors in this partition
855 } PAR_INFO, *PPAR_INFO;
856
857 /*
858 *@@ MBR_INFO:
859 * master boot record table.
860 * This has the four primary partitions.
861 */
862
863 typedef struct _MBR_INFO // MBR
864 {
865 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
866 PAR_INFO sPrtnInfo[4]; // primary partition entries
867 USHORT wPrtnTblSig; // partition table signature (aa55H)
868 } MBR_INFO, *PMBR_INFO;
869
870 /*
871 *@@ SYS_INFO:
872 *
873 */
874
875 typedef struct _SYS_INFO
876 {
877 BYTE startable;
878 BYTE unknown[3];
879 BYTE bootable;
880 BYTE name[8];
881 BYTE reservd[3];
882 } SYS_INFO, *PSYS_INFO;
883
884 /*
885 *@@ SYE_INFO:
886 *
887 */
888
889 typedef struct _SYE_INFO
890 {
891 BYTE bootable;
892 BYTE name[8];
893 } SYE_INFO, *PSYE_INFO;
894
895 /*
896 *@@ EXT_INFO:
897 *
898 */
899
900 typedef struct _EXT_INFO
901 {
902 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
903 SYE_INFO sBmNames[4]; // System Names
904 BYTE bReserved[16]; // reserved
905 PAR_INFO sPrtnInfo[4]; // partitioms entrys
906 USHORT wPrtnTblSig; // partition table signature (aa55H)
907 } EXT_INFO, *PEXT_INFO;
908
909 typedef struct _PARTITIONINFO *PPARTITIONINFO;
910
911 /*
912 *@@ PARTITIONINFO:
913 * informational structure returned
914 * by doshGetPartitionsList. One of
915 * these items is created for each
916 * bootable partition.
917 */
918
919 typedef struct _PARTITIONINFO
920 {
921 BYTE bDisk; // drive number
922 CHAR cLetter; // probable drive letter or ' ' if none
923 BYTE bFSType; // file system type
924 PCSZ pcszFSType; // file system name (as returned by
925 // doshType2FSName, can be NULL!)
926 BOOL fPrimary; // primary partition?
927 BOOL fBootable; // bootable by Boot Manager?
928 CHAR szBootName[21]; // Boot Manager name, if (fBootable)
929 // extended for LVM names V0.9.20 (2002-08-10) [umoeller]
930 ULONG ulSize; // size MBytes
931 PPARTITIONINFO pNext; // next info or NULL if last
932 } PARTITIONINFO;
933
934 UINT doshQueryDiskCount(VOID);
935
936 APIRET doshReadSector(USHORT disk,
937 void *buff,
938 USHORT head,
939 USHORT cylinder,
940 USHORT sector);
941
942 // restore original alignment
943 #pragma pack()
944
945 const char* doshType2FSName(unsigned char bFSType);
946
947 APIRET doshGetBootManager(USHORT *pusDisk,
948 USHORT *pusPart,
949 PAR_INFO *BmInfo);
950
951 typedef struct _PARTITIONSLIST
952 {
953 PLVMINFO pLVMInfo; // != NULL if LVM is installed
954
955 // partitions array
956 PPARTITIONINFO pPartitionInfo;
957 USHORT cPartitions;
958 } PARTITIONSLIST, *PPARTITIONSLIST;
959
960 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
961 PUSHORT pusContext);
962
963 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
964
965 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
966
967 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
968 PPARTITIONINFO *ppPartitionInfo,
969 PUSHORT pcPartitions);
970
971 VOID doshFreeLVMInfo(PLVMINFO pInfo);
972
973 /* ******************************************************************
974 *
975 * Wildcard matching
976 *
977 ********************************************************************/
978
979 BOOL doshMatchCase(PCSZ pcszMask,
980 PCSZ pcszName);
981
982 BOOL doshMatchCaseNoPath(const char *pcszMask,
983 const char *pcszName);
984
985 BOOL doshMatch(PCSZ pcszMask,
986 PCSZ pcszName);
987
988#endif
989
990#if __cplusplus
991}
992#endif
993
Note: See TracBrowser for help on using the repository browser.