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

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

Major updates; timers, LVM, miscellaneous.

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