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

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

Initial checkin of helpers code, which used to be in WarpIN.

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