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

Last change on this file since 155 was 153, checked in by umoeller, 23 years ago

Lots of changes from the last three weeks.

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