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

Last change on this file since 45 was 43, checked in by umoeller, 24 years ago

Misc. changes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 32.2 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 "dosh.h"
13 */
14
15/* This file Copyright (C) 1997-2000 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 * Miscellaneous
38 *
39 ********************************************************************/
40
41 CHAR doshGetChar(VOID);
42
43 BOOL doshQueryShiftState(VOID);
44
45 BOOL doshIsWarp4(VOID);
46
47 PSZ doshQuerySysErrorMsg(APIRET arc);
48
49 /* ******************************************************************
50 *
51 * Memory helpers
52 *
53 ********************************************************************/
54
55 PVOID doshAllocSharedMem(ULONG ulSize,
56 const char* pcszName);
57
58 PVOID doshRequestSharedMem(const char *pcszName);
59
60 /* ******************************************************************
61 *
62 * Drive helpers
63 *
64 ********************************************************************/
65
66 VOID doshEnumDrives(PSZ pszBuffer,
67 const char *pcszFileSystem,
68 BOOL fSkipRemoveables);
69
70 CHAR doshQueryBootDrive(VOID);
71
72 APIRET doshAssertDrive(ULONG ulLogicalDrive);
73
74 APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
75
76 APIRET doshQueryDiskFree(ULONG ulLogicalDrive,
77 double *pdFree);
78
79 APIRET doshQueryDiskFSType(ULONG ulLogicalDrive,
80 PSZ pszBuf,
81 ULONG cbBuf);
82
83 APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
84 PBOOL pfFixed);
85
86 #ifdef INCL_DOSDEVIOCTL
87
88 // flags for DRIVEPARMS.usDeviceAttrs (see DSK_GETDEVICEPARAMS in CPREF):
89 #define DEVATTR_REMOVEABLE 0x0001 // drive is removeable
90 #define DEVATTR_CHANGELINE 0x0002 // media has been removed since last I/O operation
91 #define DEVATTR_GREATER16MB 0x0004 // physical device driver supports physical addresses > 16 MB
92
93 #pragma pack(1)
94
95 /*
96 *@@ DRIVEPARAMS:
97 * structure used for doshQueryDiskParams.
98 */
99
100 typedef struct _DRIVEPARAMS
101 {
102 BIOSPARAMETERBLOCK bpb;
103 // BIOS parameter block. This is the first sector
104 // (at byte 0) in each partition. This is defined
105 // in the OS2 headers as follows:
106
107 /*
108 typedef struct _BIOSPARAMETERBLOCK {
109 USHORT usBytesPerSector;
110 // Number of bytes per sector.
111 BYTE bSectorsPerCluster;
112 // Number of sectors per cluster.
113 USHORT usReservedSectors;
114 // Number of reserved sectors.
115 BYTE cFATs;
116 // Number of FATs.
117 USHORT cRootEntries;
118 // Number of root directory entries.
119 USHORT cSectors;
120 // Number of sectors.
121 BYTE bMedia;
122 // Media descriptor.
123 USHORT usSectorsPerFAT;
124 // Number of secctors per FAT.
125 USHORT usSectorsPerTrack;
126 // Number of sectors per track.
127 USHORT cHeads;
128 // Number of heads.
129 ULONG cHiddenSectors;
130 // Number of hidden sectors.
131 ULONG cLargeSectors;
132 // Number of large sectors.
133 BYTE abReserved[6];
134 // Reserved.
135 USHORT cCylinders;
136 // Number of cylinders defined for the physical
137 // device.
138 BYTE bDeviceType;
139 // Physical layout of the specified device.
140 USHORT fsDeviceAttr;
141 // A bit field that returns flag information
142 // about the specified drive.
143 } BIOSPARAMETERBLOCK; */
144
145 USHORT usCylinders;
146 // no. of cylinders
147 UCHAR ucDeviceType;
148 // device type; according to the IBM Control
149 // Program Reference (see DSK_GETDEVICEPARAMS),
150 // this value can be:
151 // -- 0: 48 TPI low-density diskette drive
152 // -- 1: 96 TPI high-density diskette drive
153 // -- 2: 3.5-inch 720KB diskette drive
154 // -- 3: 8-Inch single-density diskette drive
155 // -- 4: 8-Inch double-density diskette drive
156 // -- 5: Fixed disk
157 // -- 6: Tape drive
158 // -- 7: Other (includes 1.44MB 3.5-inch diskette drive)
159 // -- 8: R/W optical disk
160 // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
161 USHORT usDeviceAttrs;
162 // DEVATTR_* flags
163 } DRIVEPARAMS, *PDRIVEPARAMS;
164 #pragma pack()
165
166 APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
167 PDRIVEPARAMS pdp);
168 #endif
169
170 APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
171 PSZ pszVolumeLabel);
172
173 APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
174 PSZ pszNewLabel);
175
176 /* ******************************************************************
177 *
178 * Module handling helpers
179 *
180 ********************************************************************/
181
182 /*
183 *@@ RESOLVEFUNCTION:
184 * one of these structures each define
185 * a single function import to doshResolveImports.
186 *
187 *@@added V0.9.3 (2000-04-25) [umoeller]
188 */
189
190 typedef struct _RESOLVEFUNCTION
191 {
192 const char *pcszFunctionName;
193 PFN *ppFuncAddress;
194 } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
195
196 APIRET doshResolveImports(PSZ pszModuleName,
197 HMODULE *phmod,
198 PRESOLVEFUNCTION paResolves,
199 ULONG cResolves);
200
201 /* ******************************************************************
202 *
203 * Performance Counters (CPU Load)
204 *
205 ********************************************************************/
206
207 #define CMD_PERF_INFO 0x41
208 #define CMD_KI_ENABLE 0x60
209 #define CMD_KI_DISABLE 0x61
210 #ifndef CMD_KI_RDCNT
211 #define CMD_KI_RDCNT 0x63
212 typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
213 ULONG ulParm1,
214 ULONG ulParm2,
215 ULONG ulParm3);
216 typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
217 #endif
218
219 typedef struct _CPUUTIL
220 {
221 ULONG ulTimeLow; // low 32 bits of time stamp
222 ULONG ulTimeHigh; // high 32 bits of time stamp
223 ULONG ulIdleLow; // low 32 bits of idle time
224 ULONG ulIdleHigh; // high 32 bits of idle time
225 ULONG ulBusyLow; // low 32 bits of busy time
226 ULONG ulBusyHigh; // high 32 bits of busy time
227 ULONG ulIntrLow; // low 32 bits of interrupt time
228 ULONG ulIntrHigh; // high 32 bits of interrupt time
229 } CPUUTIL, *PCPUUTIL;
230
231 // macro to convert 8-byte (low, high) time value to double
232 #define LL2F(high, low) (4294967296.0*(high)+(low))
233
234 /*
235 *@@ DOSHPERFSYS:
236 * structure used with doshPerfOpen.
237 *
238 *@@added V0.9.7 (2000-12-02) [umoeller]
239 */
240
241 typedef struct _DOSHPERFSYS
242 {
243 // output: no. of processors on the system
244 ULONG cProcessors;
245 // output: one CPU load for each CPU
246 PLONG palLoads;
247
248 // each of the following ptrs points to an array of cProcessors items
249 PCPUUTIL paCPUUtils; // CPUUTIL structures
250 double *padBusyPrev; // previous "busy" calculations
251 double *padTimePrev; // previous "time" calculations
252
253 // private stuff
254 HMODULE hmod;
255 BOOL fInitialized;
256 PFNDOSPERFSYSCALL pDosPerfSysCall;
257 } DOSHPERFSYS, *PDOSHPERFSYS;
258
259 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
260
261 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
262
263 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
264
265 /* ******************************************************************
266 *
267 * File helpers
268 *
269 ********************************************************************/
270
271 PSZ doshGetExtension(const char *pcszFilename);
272
273 BOOL doshIsFileOnFAT(const char* pcszFileName);
274
275 APIRET doshIsValidFileName(const char* pcszFile,
276 BOOL fFullyQualified);
277
278 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
279
280 ULONG doshQueryFileSize(HFILE hFile);
281
282 ULONG doshQueryPathSize(PSZ pszFile);
283
284 APIRET doshQueryPathAttr(const char* pcszFile,
285 PULONG pulAttr);
286
287 APIRET doshSetPathAttr(const char* pcszFile,
288 ULONG ulAttr);
289
290 APIRET doshLoadTextFile(const char *pcszFile,
291 PSZ* ppszContent);
292
293 PSZ doshCreateBackupFileName(const char* pszExisting);
294
295 APIRET doshWriteTextFile(const char* pszFile,
296 const char* pszContent,
297 PULONG pulWritten,
298 PSZ pszBackup);
299
300 HFILE doshOpenLogFile(const char* pcszFilename);
301
302 APIRET doshWriteToLogFile(HFILE hfLog, const char* pcsz);
303
304 /* ******************************************************************
305 *
306 * Directory helpers
307 *
308 ********************************************************************/
309
310 BOOL doshQueryDirExist(const char *pcszDir);
311
312 APIRET doshCreatePath(PSZ pszPath,
313 BOOL fHidden);
314
315 APIRET doshQueryCurrentDir(PSZ pszBuf);
316
317 APIRET doshSetCurrentDir(const char *pcszDir);
318
319 #define DOSHDELDIR_RECURSE 0x0001
320 #define DOSHDELDIR_DELETEFILES 0x0002
321
322 APIRET doshDeleteDir(const char *pcszDir,
323 ULONG flFlags,
324 PULONG pulDirs,
325 PULONG pulFiles);
326
327 /* ******************************************************************
328 *
329 * Process helpers
330 *
331 ********************************************************************/
332
333 APIRET doshFindExecutable(const char *pcszCommand,
334 PSZ pszExecutable,
335 ULONG cbExecutable,
336 const char **papcszExtensions,
337 ULONG cExtensions);
338
339 APIRET doshExecVIO(const char *pcszExecWithArgs,
340 PLONG plExitCode);
341
342 APIRET doshQuickStartSession(const char *pcszPath,
343 const char *pcszParams,
344 BOOL fForeground,
345 USHORT usPgmCtl,
346 BOOL fWait,
347 PULONG pulSID,
348 PPID ppid);
349
350 /* ******************************************************************
351 *
352 * Environment helpers
353 *
354 ********************************************************************/
355
356 /*
357 *@@ DOSENVIRONMENT:
358 * structure holding an array of environment
359 * variables (papszVars). This is initialized
360 * doshGetEnvironment,
361 *
362 *@@added V0.9.4 (2000-07-19) [umoeller]
363 */
364
365 typedef struct _DOSENVIRONMENT
366 {
367 ULONG cVars; // count of vars in papzVars
368 PSZ *papszVars; // array of PSZ's to environment strings (VAR=VALUE)
369 } DOSENVIRONMENT, *PDOSENVIRONMENT;
370
371 APIRET doshParseEnvironment(const char *pcszEnv,
372 PDOSENVIRONMENT pEnv);
373
374 APIRET doshGetEnvironment(PDOSENVIRONMENT pEnv);
375
376 PSZ* doshFindEnvironmentVar(PDOSENVIRONMENT pEnv,
377 PSZ pszVarName);
378
379 APIRET doshSetEnvironmentVar(PDOSENVIRONMENT pEnv,
380 PSZ pszNewEnv,
381 BOOL fAddFirst);
382
383 APIRET doshConvertEnvironment(PDOSENVIRONMENT pEnv,
384 PSZ *ppszEnv,
385 PULONG pulSize);
386
387 APIRET doshFreeEnvironment(PDOSENVIRONMENT pEnv);
388
389 /********************************************************************
390 *
391 * Executable helpers
392 *
393 ********************************************************************/
394
395 /*
396 *@@ DOSEXEHEADER:
397 * old DOS EXE header at offset 0
398 * in any EXE file.
399 *
400 *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
401 */
402
403 #pragma pack(1)
404 typedef struct _DOSEXEHEADER
405 {
406 USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
407 USHORT usFileLenMod512; // 02: filelen mod 512
408 USHORT usFileLenDiv512; // 04: filelen div 512
409 USHORT usSegFix; // 06: count of segment adds to fix
410 USHORT usHdrPargCnt; // 08: size of header in paragrphs
411 USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
412 USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
413 USHORT usSSStartup; // 0e: SS at startup
414 USHORT usSPStartup; // 10: SP at startup
415 USHORT usHdrChecksum; // 12: header checksum
416 USHORT usIPStartup; // 14: IP at startup
417 USHORT usCodeSegOfs; // 16: code segment offset from EXE start
418 USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40)
419 USHORT usOverlayNo; // 1a: overlay no.
420 ULONG ulLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
421 ULONG ulUnused1; // 20: unused
422 ULONG ulUnused2; // 24: exe.h says the following fields are
423 ULONG ulUnused3; // 28: 'behavior bits'
424 ULONG ulUnused4; // 3c:
425 ULONG ulUnused5; // 30:
426 ULONG ulUnused6; // 34:
427 ULONG ulUnused7; // 38:
428 ULONG ulNewHeaderOfs; // new header ofs (if 0x18 > 0x40)
429 // fixed this from USHORT, thanks Martin Lafaix
430 // V0.9.7 (2000-12-20) [umoeller]
431 } DOSEXEHEADER, *PDOSEXEHEADER;
432
433 // NE and LX OS types
434 #define NEOS_UNKNOWN 0
435 #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
436 #define NEOS_WIN16 2
437 #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
438 #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
439
440 /*
441 *@@ NEHEADER:
442 * linear executable (LX) header format,
443 * which comes after the DOS header in the
444 * EXE file (at DOSEXEHEADER.usNewHeaderOfs).
445 */
446
447 typedef struct _NEHEADER
448 {
449 CHAR achNE[2]; // 00: NE
450 BYTE bLinkerVersion; // 02: linker version
451 BYTE bLinkerRevision; // 03: linker revision
452 USHORT usEntryTblOfs; // 04: ofs from this to entrytable
453 USHORT usEntryTblLen; // 06: length of entrytable
454 ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum
455 USHORT usFlags; // 0c: flags
456 USHORT usAutoDataSegNo; // 0e: auto-data seg no.
457 USHORT usInitlHeapSize; // 10: initl. heap size
458 USHORT usInitlStackSize; // 12: initl. stack size
459 ULONG ulCSIP; // 14: CS:IP
460 ULONG ulSSSP; // 18: SS:SP
461 USHORT usSegTblEntries; // 1c: segment tbl entry count
462 USHORT usModuleTblEntries; // 1e: module ref. table entry count
463 USHORT usNonResdTblLen; // 20: non-resd. name tbl length
464 USHORT usSegTblOfs; // 22: segment tbl ofs
465 USHORT usResTblOfs; // 24: resource tbl ofs
466 USHORT usResdNameTblOfs; // 26: resd. name tbl ofs
467 USHORT usModRefTblOfs; // 28: module ref. table ofs
468 USHORT usImportTblOfs; // 2a: import tbl ofs
469 ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs
470 USHORT usMoveableEntires; // 30: moveable entry pts. count
471 USHORT usLogicalSectShift; // 32: logcl. sector shift
472 USHORT usResSegmCount; // 34: resource segm. count
473 BYTE bTargetOS; // 36: target OS (NEOS_* flags)
474 BYTE bFlags2; // 37: addtl. flags
475 USHORT usFastLoadOfs; // 38: fast-load area ofs
476 USHORT usFastLoadLen; // 3a: fast-load area length
477 USHORT usReserved; // 3c: MS: 'reserved'
478 USHORT usReqWinVersion; // 3e: Win-only: min. Win version
479 } NEHEADER, *PNEHEADER;
480
481 /*
482 *@@ LXHEADER:
483 * linear executable (LX) header format,
484 * which comes after the DOS header in the
485 * EXE file (at DOSEXEHEADER.usNewHeaderOfs).
486 */
487
488 typedef struct _LXHEADER
489 {
490 CHAR achLX[2]; // 00: LX or LE
491 /* this is "LX" for 32-bit OS/2 programs, but
492 "LE" for MS-DOS progs which use this format
493 (e.g. WINDOWS\SMARTDRV.EXE) */
494 BYTE fByteBigEndian; // 02: byte ordering (1 = big endian)
495 BYTE fWordBigEndian; // 03: word ordering (1 = big endian)
496 ULONG ulFormatLevel; // 04: format level
497 USHORT usCPU; // 08: CPU type
498 USHORT usTargetOS; // 0a: OS type (NEOS_* flags)
499 ULONG ulModuleVersion; // 0c: module version
500 ULONG ulFlags; // 10: module flags
501 ULONG ulPageCount; // 14: no. of pages in module
502 ULONG ulEIPRelObj; // 18: object to which EIP is relative
503 ULONG ulEIPEntryAddr; // 1c: EIP entry addr
504 ULONG ulESPObj; // 20: ESP object
505 ULONG ulESP; // 24: ESP
506 ULONG ulPageSize; // 28: page size (4K)
507 ULONG ulPageLeftShift; // 2c: page left-shift
508 ULONG ulFixupTblLen; // 30: fixup section total size
509 ULONG ulFixupTblChecksum; // 34: fixup section checksum
510 ULONG ulLoaderLen; // 38: size req. for loader section
511 ULONG ulLoaderChecksum; // 3c: loader section checksum
512 ULONG ulObjTblOfs; // 40: object table offset
513 ULONG ulObjCount; // 44: object count
514 ULONG ulObjPageTblOfs; // 48: object page table ofs
515 ULONG ulObjIterPagesOfs; // 4c: object iter pages ofs
516 ULONG ulResTblOfs; // 50: resource table ofs
517 ULONG ulResTblCnt; // 54: resource entry count
518 ULONG ulResdNameTblOfs; // 58: resident name tbl ofs
519 ULONG ulEntryTblOfs; // 5c: entry tbl ofs
520 ULONG ulModDirectivesOfs; // 60: module directives ofs
521 ULONG ulModDirectivesCnt; // 64: module directives count
522 ULONG ulFixupPagePageTblOfs;// 68: fixup page tbl ofs
523 ULONG ulFixupRecTblOfs; // 6c: fixup record tbl ofs
524 ULONG ulImportModTblOfs; // 70: import modl tbl ofs
525 ULONG ulImportModTblCnt; // 74: import modl tbl count
526 ULONG ulImportProcTblOfs; // 78: import proc tbl ofs
527 ULONG ulPerPageCSOfs; // 7c: per page checksum ofs
528 ULONG ulDataPagesOfs; // 80: data pages ofs
529 ULONG ulPreloadPagesCnt; // 84: preload pages count
530 ULONG ulNonResdNameTblOfs; // 88: non-resdnt name tbl ofs
531 ULONG ulNonResdNameTblLen; // 8c: non-resdnt name tbl length
532 ULONG ulNonResdNameTblCS; // 90: non-res name tbl checksum
533 ULONG ulAutoDataSegObjCnt; // 94: auto dataseg object count
534 ULONG ulDebugOfs; // 98: debug info ofs
535 ULONG ulDebugLen; // 9c: debug info length
536 ULONG ulInstancePrelCnt; // a0: instance preload count
537 ULONG ulinstanceDemdCnt; // a0: instance demand count
538 ULONG ulHeapSize16; // a8: heap size (16-bit)
539 ULONG ulStackSize; // ac: stack size
540 } LXHEADER, *PLXHEADER;
541
542 #pragma pack()
543
544 // EXE format
545 #define EXEFORMAT_OLDDOS 1
546 #define EXEFORMAT_NE 2
547 #define EXEFORMAT_PE 3
548 #define EXEFORMAT_LX 4
549 #define EXEFORMAT_TEXT_BATCH 5
550 #define EXEFORMAT_TEXT_REXX 6
551
552 // target OS (in NE and LX)
553 #define EXEOS_DOS3 1
554 #define EXEOS_DOS4 2 // there is a flag for this in NE
555 #define EXEOS_OS2 3
556 #define EXEOS_WIN16 4
557 #define EXEOS_WIN386 5 // according to IBM, there are flags
558 // for this both in NE and LX
559 #define EXEOS_WIN32 6
560
561 /*
562 *@@ EXECUTABLE:
563 * structure used with all the doshExec*
564 * functions.
565 */
566
567 typedef struct _EXECUTABLE
568 {
569 HFILE hfExe;
570
571 /* All the following fields are set by
572 doshExecOpen if NO_ERROR is returned. */
573
574 // old DOS EXE header (always valid)
575 PDOSEXEHEADER pDosExeHeader;
576 ULONG cbDosExeHeader;
577
578 // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
579 PNEHEADER pNEHeader;
580 ULONG cbNEHeader;
581
582 // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
583 PLXHEADER pLXHeader;
584 ULONG cbLXHeader;
585
586 // module analysis (always set):
587 ULONG ulExeFormat;
588 // one of:
589 // EXEFORMAT_OLDDOS 1
590 // EXEFORMAT_NE 2
591 // EXEFORMAT_PE 3
592 // EXEFORMAT_LX 4
593 // EXEFORMAT_TEXT_BATCH 5
594 // EXEFORMAT_TEXT_REXX 6
595
596 BOOL fLibrary,
597 f32Bits;
598 ULONG ulOS;
599 // one of:
600 // EXEOS_DOS3 1
601 // EXEOS_DOS4 2 // there is a flag for this in NE
602 // EXEOS_OS2 3
603 // EXEOS_WIN16 4
604 // EXEOS_WIN386 5 // according to IBM, there are flags
605 // // for this both in NE and LX
606 // EXEOS_WIN32 6
607
608 /* The following fields are only set after
609 an extra call to doshExecQueryBldLevel. */
610
611 PSZ pszDescription; // whole string (first non-res name tbl entry)
612 PSZ pszVendor; // vendor substring (if IBM BLDLEVEL format)
613 PSZ pszVersion; // version substring (if IBM BLDLEVEL format)
614 PSZ pszInfo; // module info substring (if IBM BLDLEVEL format)
615
616 } EXECUTABLE, *PEXECUTABLE;
617
618 APIRET doshExecOpen(const char* pcszExecutable,
619 PEXECUTABLE* ppExec);
620
621 APIRET doshExecClose(PEXECUTABLE pExec);
622
623 APIRET doshExecQueryBldLevel(PEXECUTABLE pExec);
624
625 /********************************************************************
626 *
627 * Partition functions
628 *
629 ********************************************************************/
630
631 #define DOSH_PARTITIONS_LIMIT 10
632
633 #define PAR_UNUSED 0x00 // Unused
634 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
635 #define PAR_XENIXROOT 0x02 // XENIX root
636 #define PAR_XENIXUSER 0x03 // XENIX user
637 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
638 #define PAR_EXTENDED 0x05 // Extended partition
639 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
640 #define PAR_HPFS 0x07 // OS/2 HPFS
641 #define PAR_AIXBOOT 0x08 // AIX bootable partition
642 #define PAR_AIXDATA 0x09 // AIX bootable partition
643 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
644 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
645 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
646 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
647 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
648 #define PAR_OPUS 0x10 // OPUS
649 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
650 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
651 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
652 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
653 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
654 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
655 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
656 #define PAR_THEOS 0x38 // THEOS
657 #define PAR_VENIX 0x40 // VENIX
658 #define PAR_RISCBOOT 0x41 // Personal RISC boot
659 #define PAR_SFS 0x42 // SFS
660 #define PAR_ONTRACK 0x50 // Ontrack
661 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
662 #define PAR_CPM 0x52 // CP/M
663 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
664 #define PAR_NOVELL_64 0x64 // Novell
665 #define PAR_NOVELL_65 0x65 // Novell
666 #define PAR_NOVELL_67 0x67 // Novell
667 #define PAR_NOVELL_68 0x68 // Novell
668 #define PAR_NOVELL_69 0x69 // Novell
669 #define PAR_PCIX 0x75 // PCIX
670 #define PAR_MINIX 0x80 // MINIX
671 #define PAR_LINUX 0x81 // Linux
672 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
673 #define PAR_LINUXFILE 0x83 // Linux File System
674 #define PAR_FREEBSD 0xA5 // FreeBSD
675 #define PAR_BBT 0xFF // BBT
676
677 // one-byte alignment
678 #pragma pack(1)
679
680 /*
681 *@@ PAR_INFO:
682 * partition table
683 */
684
685 typedef struct _PAR_INFO
686 {
687 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
688 BYTE bBeginHead; // partition begins at this head...
689 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
690 BYTE bFileSysCode; // file system type
691 BYTE bEndHead; // partition ends at this head...
692 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
693 ULONG lBeginAbsSec; // partition begins at this absolute sector #
694 ULONG lTotalSects; // total sectors in this partition
695 } PAR_INFO, *PPAR_INFO;
696
697 /*
698 *@@ MBR_INFO:
699 * master boot record table.
700 * This has the four primary partitions.
701 */
702
703 typedef struct _MBR_INFO // MBR
704 {
705 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
706 PAR_INFO sPrtnInfo[4]; // primary partition entries
707 USHORT wPrtnTblSig; // partition table signature (aa55H)
708 } MBR_INFO, *PMBR_INFO;
709
710 /*
711 *@@ SYS_INFO:
712 *
713 */
714
715 typedef struct _SYS_INFO // š­ä®à¬ æšï ® § £à㊠¥¬®© ášá⥬¥
716 {
717 BYTE startable; // & 0x80
718 BYTE unknown[3]; // unknown
719 BYTE bootable; // & 0x01
720 BYTE name[8]; // š¬ï à §€¥« 
721 BYTE reservd[3]; // unknown
722 } SYS_INFO, *PSYS_INFO;
723
724 /*
725 *@@ SYE_INFO:
726 *
727 */
728
729 typedef struct _SYE_INFO // š­ä®à¬ æšï ® § £à㊠¥¬®© ášá⥬¥ €«ï
730 { // à áèšà¥­­ëå à §€¥«®¢
731 BYTE bootable; // & 0x01
732 BYTE name[8]; // š¬ï à §€¥« 
733 } SYE_INFO, *PSYE_INFO;
734
735 /*
736 *@@ EXT_INFO:
737 *
738 */
739
740 typedef struct _EXT_INFO
741 {
742 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
743 SYE_INFO sBmNames[4]; // System Names
744 BYTE bReserved[16]; // reserved
745 PAR_INFO sPrtnInfo[4]; // partitioms entrys
746 USHORT wPrtnTblSig; // partition table signature (aa55H)
747 } EXT_INFO, *PEXT_INFO;
748
749 typedef struct _PARTITIONINFO *PPARTITIONINFO;
750
751 /*
752 *@@ PARTITIONINFO:
753 * informational structure returned
754 * by doshGetPartitionsList. One of
755 * these items is created for each
756 * bootable partition.
757 */
758
759 typedef struct _PARTITIONINFO
760 {
761 BYTE bDisk; // drive number
762 CHAR cLetter; // probable drive letter or ' ' if none
763 BYTE bFSType; // file system type
764 CHAR szFSType[10]; // file system name (created by us)
765 BOOL fPrimary; // primary partition?
766 BOOL fBootable; // bootable by Boot Manager?
767 CHAR szBootName[9]; // Boot Manager name, if (fBootable)
768 ULONG ulSize; // size MBytes
769 PPARTITIONINFO pNext; // next info or NULL if last
770 } PARTITIONINFO;
771
772 UINT doshQueryDiskCount(VOID);
773
774 APIRET doshReadSector(USHORT disk,
775 void *buff,
776 USHORT head,
777 USHORT cylinder,
778 USHORT sector);
779
780 // restore original alignment
781 #pragma pack()
782
783 char* doshType2FSName(unsigned char bFSType);
784
785 APIRET doshGetBootManager(USHORT *pusDisk,
786 USHORT *pusPart,
787 PAR_INFO *BmInfo);
788
789 APIRET doshGetPartitionsList(PPARTITIONINFO *ppPartitionInfo,
790 PUSHORT pusPartitionCount,
791 PUSHORT pusContext);
792
793 APIRET doshFreePartitionsList(PPARTITIONINFO pPartitionInfo);
794
795#endif
796
797#if __cplusplus
798}
799#endif
800
Note: See TracBrowser for help on using the repository browser.