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

Last change on this file since 37 was 23, checked in by umoeller, 25 years ago

Fixes for V0.9.7.

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