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

Last change on this file since 315 was 315, checked in by pr, 19 years ago

Add typedefs for doshResolveImports()

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