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

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

Coupla bugfixes.

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