source: branches/branch-1-0/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: 37.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-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 /* ******************************************************************
588 *
589 * XFILEs
590 *
591 ********************************************************************/
592
593 /*
594 *@@ XFILE:
595 *
596 *@@added V0.9.16 (2001-10-19) [umoeller]
597 */
598
599 typedef struct _XFILE
600 {
601 HFILE hf;
602
603 PSZ pszFilename; // as given to doshOpen
604 ULONG flOpenMode; // as given to doshOpen
605
606 ULONG cbInitial, // intial file size on open (can be 0 if new)
607 cbCurrent; // current file size (raised with each write)
608
609 PBYTE pbCache; // if != NULL, cached data from doshReadAt
610 ULONG cbCache, // size of data in cbCache
611 ulReadFrom; // file offset where pbCache was read from
612 } XFILE, *PXFILE;
613
614 #define XOPEN_READ_EXISTING 0x0001
615 #define XOPEN_READWRITE_EXISTING 0x0002
616 #define XOPEN_READWRITE_APPEND 0x0003
617 #define XOPEN_READWRITE_NEW 0x0004
618 #define XOPEN_ACCESS_MASK 0xffff
619
620 #define XOPEN_BINARY 0x10000000
621
622 APIRET doshOpen(PCSZ pcszFilename,
623 ULONG flOpenMode,
624 PULONG pcbFile,
625 PXFILE *ppFile);
626
627 #define DRFL_NOCACHE 0x0001
628 #define DRFL_FAILIFLESS 0x0002
629
630 APIRET doshReadAt(PXFILE pFile,
631 ULONG ulOffset,
632 PULONG pcb,
633 PBYTE pbData,
634 ULONG fl);
635
636 APIRET doshWrite(PXFILE pFile,
637 ULONG cb,
638 PCSZ pbData);
639
640 APIRET doshWriteAt(PXFILE pFile,
641 ULONG ulOffset,
642 ULONG cb,
643 PCSZ pbData);
644
645 APIRET doshWriteLogEntry(PXFILE pFile,
646 const char* pcszFormat,
647 ...);
648
649 APIRET doshClose(PXFILE *ppFile);
650
651 APIRET doshReadText(PXFILE pFile,
652 PSZ* ppszContent,
653 PULONG pcbRead);
654
655 APIRET doshLoadTextFile(PCSZ pcszFile,
656 PSZ* ppszContent,
657 PULONG pcbRead);
658
659 PSZ doshCreateBackupFileName(const char* pszExisting);
660
661 APIRET doshCreateTempFileName(PSZ pszTempFileName,
662 PCSZ pcszDir,
663 PCSZ pcszPrefix,
664 PCSZ pcszExt);
665
666 APIRET doshWriteTextFile(const char* pszFile,
667 const char* pszContent,
668 PULONG pulWritten,
669 PSZ pszBackup);
670
671
672 /* ******************************************************************
673 *
674 * Directory helpers
675 *
676 ********************************************************************/
677
678 BOOL doshQueryDirExist(PCSZ pcszDir);
679
680 APIRET doshCreatePath(PCSZ pcszPath,
681 BOOL fHidden);
682
683 APIRET doshQueryCurrentDir(PSZ pszBuf);
684
685 APIRET doshSetCurrentDir(PCSZ pcszDir);
686
687 #define DOSHDELDIR_RECURSE 0x0001
688 #define DOSHDELDIR_DELETEFILES 0x0002
689
690 APIRET doshDeleteDir(PCSZ pcszDir,
691 ULONG flFlags,
692 PULONG pulDirs,
693 PULONG pulFiles);
694
695 APIRET doshCanonicalize(PCSZ pcszFileIn,
696 PSZ pszFileOut,
697 ULONG cbFileOut);
698
699 /* ******************************************************************
700 *
701 * Process helpers
702 *
703 ********************************************************************/
704
705 ULONG XWPENTRY doshMyPID(VOID);
706 typedef ULONG XWPENTRY DOSHMYPID(VOID);
707 typedef DOSHMYPID *PDOSHMYPID;
708
709 ULONG XWPENTRY doshMyTID(VOID);
710 typedef ULONG XWPENTRY DOSHMYTID(VOID);
711 typedef DOSHMYTID *PDOSHMYTID;
712
713 APIRET doshExecVIO(PCSZ pcszExecWithArgs,
714 PLONG plExitCode);
715
716 APIRET doshQuickStartSession(PCSZ pcszPath,
717 PCSZ pcszParams,
718 PCSZ pcszTitle,
719 USHORT usSessionType,
720 BOOL fForeground,
721 USHORT usPgmCtl,
722 BOOL fWait,
723 PULONG pulSID,
724 PPID ppid,
725 PUSHORT pusReturn);
726
727 APIRET doshSearchPath(PCSZ pcszPath,
728 PCSZ pcszFile,
729 PSZ pszExecutable,
730 ULONG cbExecutable);
731
732 // added V1.0.4 (2005-06-16) [chennecke]
733 APIRET doshSearchDirs(PCSZ pcszDirList,
734 PCSZ pcszFile,
735 PSZ pszExecutable,
736 ULONG cbExecutable);
737
738 APIRET doshFindExecutable(PCSZ pcszCommand,
739 PSZ pszExecutable,
740 ULONG cbExecutable,
741 PCSZ *papcszExtensions,
742 ULONG cExtensions);
743
744 /********************************************************************
745 *
746 * Partition functions
747 *
748 ********************************************************************/
749
750 /*
751 *@@ LVMINFO:
752 * informational structure created by
753 * doshQueryLVMInfo.
754 *
755 *@@added V0.9.9 (2001-04-07) [umoeller]
756 */
757
758 typedef struct _LVMINFO
759 {
760 HMODULE hmodLVM;
761
762 } LVMINFO, *PLVMINFO;
763
764 /* #define DOSH_PARTITIONS_LIMIT 10
765
766 #define PAR_UNUSED 0x00 // Unused
767 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
768 #define PAR_XENIXROOT 0x02 // XENIX root
769 #define PAR_XENIXUSER 0x03 // XENIX user
770 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
771 #define PAR_EXTENDED 0x05 // Extended partition
772 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
773 #define PAR_HPFS 0x07 // OS/2 HPFS
774 #define PAR_AIXBOOT 0x08 // AIX bootable partition
775 #define PAR_AIXDATA 0x09 // AIX bootable partition
776 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
777 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
778 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
779 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
780 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
781 #define PAR_OPUS 0x10 // OPUS
782 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
783 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
784 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
785 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
786 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
787 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
788 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
789 #define PAR_THEOS 0x38 // THEOS
790 #define PAR_VENIX 0x40 // VENIX
791 #define PAR_RISCBOOT 0x41 // Personal RISC boot
792 #define PAR_SFS 0x42 // SFS
793 #define PAR_ONTRACK 0x50 // Ontrack
794 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
795 #define PAR_CPM 0x52 // CP/M
796 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
797 #define PAR_NOVELL_64 0x64 // Novell
798 #define PAR_NOVELL_65 0x65 // Novell
799 #define PAR_NOVELL_67 0x67 // Novell
800 #define PAR_NOVELL_68 0x68 // Novell
801 #define PAR_NOVELL_69 0x69 // Novell
802 #define PAR_PCIX 0x75 // PCIX
803 #define PAR_MINIX 0x80 // MINIX
804 #define PAR_LINUX 0x81 // Linux
805 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
806 #define PAR_LINUXFILE 0x83 // Linux File System
807 #define PAR_FREEBSD 0xA5 // FreeBSD
808 #define PAR_BBT 0xFF // BBT
809 */
810
811 // one-byte alignment
812 #pragma pack(1)
813
814 /*
815 *@@ PAR_INFO:
816 * partition table
817 */
818
819 typedef struct _PAR_INFO
820 {
821 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
822 BYTE bBeginHead; // partition begins at this head...
823 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
824 BYTE bFileSysCode; // file system type
825 BYTE bEndHead; // partition ends at this head...
826 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
827 ULONG lBeginAbsSec; // partition begins at this absolute sector #
828 ULONG lTotalSects; // total sectors in this partition
829 } PAR_INFO, *PPAR_INFO;
830
831 /*
832 *@@ MBR_INFO:
833 * master boot record table.
834 * This has the four primary partitions.
835 */
836
837 typedef struct _MBR_INFO // MBR
838 {
839 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
840 PAR_INFO sPrtnInfo[4]; // primary partition entries
841 USHORT wPrtnTblSig; // partition table signature (aa55H)
842 } MBR_INFO, *PMBR_INFO;
843
844 /*
845 *@@ SYS_INFO:
846 *
847 */
848
849 typedef struct _SYS_INFO
850 {
851 BYTE startable;
852 BYTE unknown[3];
853 BYTE bootable;
854 BYTE name[8];
855 BYTE reservd[3];
856 } SYS_INFO, *PSYS_INFO;
857
858 /*
859 *@@ SYE_INFO:
860 *
861 */
862
863 typedef struct _SYE_INFO
864 {
865 BYTE bootable;
866 BYTE name[8];
867 } SYE_INFO, *PSYE_INFO;
868
869 /*
870 *@@ EXT_INFO:
871 *
872 */
873
874 typedef struct _EXT_INFO
875 {
876 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
877 SYE_INFO sBmNames[4]; // System Names
878 BYTE bReserved[16]; // reserved
879 PAR_INFO sPrtnInfo[4]; // partitioms entrys
880 USHORT wPrtnTblSig; // partition table signature (aa55H)
881 } EXT_INFO, *PEXT_INFO;
882
883 typedef struct _PARTITIONINFO *PPARTITIONINFO;
884
885 /*
886 *@@ PARTITIONINFO:
887 * informational structure returned
888 * by doshGetPartitionsList. One of
889 * these items is created for each
890 * bootable partition.
891 */
892
893 typedef struct _PARTITIONINFO
894 {
895 BYTE bDisk; // drive number
896 CHAR cLetter; // probable drive letter or ' ' if none
897 BYTE bFSType; // file system type
898 PCSZ pcszFSType; // file system name (as returned by
899 // doshType2FSName, can be NULL!)
900 BOOL fPrimary; // primary partition?
901 BOOL fBootable; // bootable by Boot Manager?
902 CHAR szBootName[21]; // Boot Manager name, if (fBootable)
903 // extended for LVM names V0.9.20 (2002-08-10) [umoeller]
904 ULONG ulSize; // size MBytes
905 PPARTITIONINFO pNext; // next info or NULL if last
906 } PARTITIONINFO;
907
908 UINT doshQueryDiskCount(VOID);
909
910 APIRET doshReadSector(USHORT disk,
911 void *buff,
912 USHORT head,
913 USHORT cylinder,
914 USHORT sector);
915
916 // restore original alignment
917 #pragma pack()
918
919 const char* doshType2FSName(unsigned char bFSType);
920
921 APIRET doshGetBootManager(USHORT *pusDisk,
922 USHORT *pusPart,
923 PAR_INFO *BmInfo);
924
925 typedef struct _PARTITIONSLIST
926 {
927 PLVMINFO pLVMInfo; // != NULL if LVM is installed
928
929 // partitions array
930 PPARTITIONINFO pPartitionInfo;
931 USHORT cPartitions;
932 } PARTITIONSLIST, *PPARTITIONSLIST;
933
934 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
935 PUSHORT pusContext);
936
937 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
938
939 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
940
941 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
942 PPARTITIONINFO *ppPartitionInfo,
943 PUSHORT pcPartitions);
944
945 VOID doshFreeLVMInfo(PLVMINFO pInfo);
946
947 /* ******************************************************************
948 *
949 * Wildcard matching
950 *
951 ********************************************************************/
952
953 BOOL doshMatchCase(PCSZ pcszMask,
954 PCSZ pcszName);
955
956 BOOL doshMatchCaseNoPath(const char *pcszMask,
957 const char *pcszName);
958
959 BOOL doshMatch(PCSZ pcszMask,
960 PCSZ pcszName);
961
962#endif
963
964#if __cplusplus
965}
966#endif
967
Note: See TracBrowser for help on using the repository browser.