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

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

Misc fixes.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 52.5 KB
Line 
1
2/*
3 *@@sourcefile dosh.h:
4 * header file for dosh.c. See remarks there.
5 *
6 * Note: Version numbering in this file relates to XWorkplace version
7 * numbering.
8 *
9 *@@include #define INCL_DOSPROCESS
10 *@@include #define INCL_DOSDEVIOCTL // for doshQueryDiskParams only
11 *@@include #include <os2.h>
12 *@@include #include "helpers\dosh.h"
13 */
14
15/* This file Copyright (C) 1997-2001 Ulrich M”ller,
16 * Dmitry A. Steklenev.
17 * This file is part of the "XWorkplace helpers" source package.
18 * This is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published
20 * by the Free Software Foundation, in version 2 as it comes in the
21 * "COPYING" file of the XWorkplace main distribution.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 */
27
28#if __cplusplus
29extern "C" {
30#endif
31
32#ifndef DOSH_HEADER_INCLUDED
33 #define DOSH_HEADER_INCLUDED
34
35 /* ******************************************************************
36 *
37 * Miscellaneous
38 *
39 ********************************************************************/
40
41 CHAR doshGetChar(VOID);
42
43 BOOL doshQueryShiftState(VOID);
44
45 ULONG doshIsWarp4(VOID);
46
47 PSZ doshQuerySysErrorMsg(APIRET arc);
48
49 ULONG doshQuerySysUptime(VOID);
50
51 /* ******************************************************************
52 *
53 * Memory helpers
54 *
55 ********************************************************************/
56
57 PVOID doshMalloc(ULONG cb,
58 APIRET *parc);
59
60 APIRET doshAllocArray(ULONG c,
61 ULONG cbArrayItem,
62 PBYTE *ppv,
63 PULONG pcbAllocated);
64
65 PVOID doshAllocSharedMem(ULONG ulSize,
66 const char* pcszName);
67
68 PVOID doshRequestSharedMem(PCSZ pcszName);
69
70 /* ******************************************************************
71 *
72 * Drive helpers
73 *
74 ********************************************************************/
75
76 APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
77 PBOOL pfFixed);
78
79 #ifdef INCL_DOSDEVIOCTL
80
81 // flags for DRIVEPARMS.usDeviceAttrs (see DSK_GETDEVICEPARAMS in CPREF):
82 #define DEVATTR_REMOVEABLE 0x0001 // drive is removeable
83 #define DEVATTR_CHANGELINE 0x0002 // media has been removed since last I/O operation
84 #define DEVATTR_GREATER16MB 0x0004 // physical device driver supports physical addresses > 16 MB
85
86 // #pragma pack(1)
87
88 /*
89 * DRIVEPARAMS:
90 * structure used for doshQueryDiskParams.
91 * removed this, we can directly use BIOSPARAMETERBLOCK
92 * V0.9.13 (2001-06-14) [umoeller]
93 */
94
95 /* typedef struct _DRIVEPARAMS
96 {
97 BIOSPARAMETERBLOCK bpb;
98 // BIOS parameter block. This is the first sector
99 // (at byte 0) in each partition. This is defined
100 // in the OS2 headers as follows:
101
102 typedef struct _BIOSPARAMETERBLOCK {
103 0 USHORT usBytesPerSector;
104 // Number of bytes per sector.
105 2 BYTE bSectorsPerCluster;
106 // Number of sectors per cluster.
107 3 USHORT usReservedSectors;
108 // Number of reserved sectors.
109 5 BYTE cFATs;
110 // Number of FATs.
111 6 USHORT cRootEntries;
112 // Number of root directory entries.
113 8 USHORT cSectors;
114 // Number of sectors.
115 10 BYTE bMedia;
116 // Media descriptor.
117 11 USHORT usSectorsPerFAT;
118 // Number of secctors per FAT.
119 13 USHORT usSectorsPerTrack;
120 // Number of sectors per track.
121 15 USHORT cHeads;
122 // Number of heads.
123 17 ULONG cHiddenSectors;
124 // Number of hidden sectors.
125 21 ULONG cLargeSectors;
126 // Number of large sectors.
127 25 BYTE abReserved[6];
128 // Reserved.
129 31 USHORT cCylinders;
130 // Number of cylinders defined for the physical
131 // device.
132 33 BYTE bDeviceType;
133 // Physical layout of the specified device.
134 34 USHORT fsDeviceAttr;
135 // A bit field that returns flag information
136 // about the specified drive.
137 } BIOSPARAMETERBLOCK;
138
139 // removed the following fields... these are already
140 // in the extended BPB structure, as defined in the
141 // Toolkit's BIOSPARAMETERBLOCK struct. Checked this,
142 // the definition is the same for the Toolkit 3 and 4.5.
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 // and CD-ROMs)
159 // -- 8: R/W optical disk
160 // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
161 USHORT usDeviceAttrs;
162 // DEVATTR_* flags
163 } DRIVEPARAMS, *PDRIVEPARAMS;
164 #pragma pack() */
165
166 APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
167 PBIOSPARAMETERBLOCK pdp);
168
169 BOOL XWPENTRY doshIsCDROM(PBIOSPARAMETERBLOCK pdp);
170
171 #endif
172
173 APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive,
174 HFILE hfDrive,
175 BOOL fMixedModeCD,
176 PBOOL pfAudio);
177
178 VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
179 PCSZ pcszFileSystem,
180 BOOL fSkipRemoveables);
181 typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
182 PCSZ pcszFileSystem,
183 BOOL fSkipRemoveables);
184 typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
185
186 CHAR doshQueryBootDrive(VOID);
187
188 #define ERROR_AUDIO_CD_ROM 10000
189
190 #define ASSERTFL_MIXEDMODECD 0x0001
191
192 APIRET doshAssertDrive(ULONG ulLogicalDrive,
193 ULONG fl);
194
195 APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
196
197 APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
198 typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
199 typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
200
201 APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
202 typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
203 typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
204
205 APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
206 typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
207 typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
208
209 APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
210 PSZ pszVolumeLabel);
211
212 APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
213 PSZ pszNewLabel);
214
215 /* ******************************************************************
216 *
217 * Module handling helpers
218 *
219 ********************************************************************/
220
221 /*
222 *@@ RESOLVEFUNCTION:
223 * one of these structures each define
224 * a single function import to doshResolveImports.
225 *
226 *@@added V0.9.3 (2000-04-25) [umoeller]
227 */
228
229 typedef struct _RESOLVEFUNCTION
230 {
231 const char *pcszFunctionName;
232 PFN *ppFuncAddress;
233 } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
234
235 APIRET doshResolveImports(PSZ pszModuleName,
236 HMODULE *phmod,
237 PRESOLVEFUNCTION paResolves,
238 ULONG cResolves);
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 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
279 */
280
281 typedef struct _DOSHPERFSYS
282 {
283 // output: no. of processors on the system
284 ULONG cProcessors;
285 // output: one CPU load for each CPU
286 PLONG palLoads;
287
288 // output: one CPU interrupt load for each CPU
289 PLONG palIntrs;
290
291 // each of the following ptrs points to an array of cProcessors items
292 PCPUUTIL paCPUUtils; // CPUUTIL structures
293 double *padBusyPrev; // previous "busy" calculations
294 double *padTimePrev; // previous "time" calculations
295 double *padIntrPrev; // previous "intr" calculations
296
297 // private stuff
298 HMODULE hmod;
299 BOOL fInitialized;
300 PFNDOSPERFSYSCALL pDosPerfSysCall;
301 } DOSHPERFSYS, *PDOSHPERFSYS;
302
303 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
304
305 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
306
307 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
308
309 /* ******************************************************************
310 *
311 * File name parsing
312 *
313 ********************************************************************/
314
315 APIRET doshGetDriveSpec(PCSZ pcszFullFile,
316 PSZ pszDrive,
317 PULONG pulDriveLen,
318 PBOOL pfIsUNC);
319
320 PSZ doshGetExtension(PCSZ pcszFilename);
321
322 /* ******************************************************************
323 *
324 * File helpers
325 *
326 ********************************************************************/
327
328 BOOL doshIsFileOnFAT(const char* pcszFileName);
329
330 APIRET doshIsValidFileName(const char* pcszFile,
331 BOOL fFullyQualified);
332
333 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
334
335 APIRET doshQueryFileSize(HFILE hFile,
336 PULONG pulSize);
337
338 APIRET doshQueryPathSize(PCSZ pcszFile,
339 PULONG pulSize);
340
341 APIRET doshQueryPathAttr(const char* pcszFile,
342 PULONG pulAttr);
343
344 APIRET doshSetPathAttr(const char* pcszFile,
345 ULONG ulAttr);
346
347 APIRET doshOpenExisting(PCSZ pcszFilename,
348 ULONG ulOpenFlags,
349 HFILE *phf);
350
351 APIRET doshWriteAt(HFILE hf,
352 LONG lOffset,
353 ULONG ulMethod,
354 ULONG cb,
355 PBYTE pbData);
356
357 APIRET doshReadAt(HFILE hf,
358 LONG lOffset,
359 ULONG ulMethod,
360 PULONG pcb,
361 PBYTE pbData);
362
363 /*
364 *@@ XFILE:
365 *
366 *@@added V0.9.16 (2001-10-19) [umoeller]
367 */
368
369 typedef struct _XFILE
370 {
371 HFILE hf;
372 ULONG hmtx; // a HMTX really
373 ULONG flOpenMode; // as given to doshOpen
374 ULONG cbInitial, // intial file size on open (can be 0 if new)
375 cbCurrent; // current file size (raised with each write)
376 } XFILE, *PXFILE;
377
378 #define XOPEN_READ_EXISTING 0x0001
379 #define XOPEN_READWRITE_APPEND 0x0002
380 #define XOPEN_READWRITE_NEW 0x0003
381 #define XOPEN_ACCESS_MASK 0xffff
382
383 #define XOPEN_BINARY 0x10000000
384
385 APIRET doshOpen(PCSZ pcszFilename,
386 ULONG flOpenMode,
387 PULONG pcbFile,
388 PXFILE *ppFile);
389
390 APIRET doshWrite(PXFILE pFile,
391 PCSZ pcsz,
392 ULONG cb);
393
394 APIRET doshWriteLogEntry(PXFILE pFile,
395 const char* pcszFormat,
396 ...);
397
398 APIRET doshClose(PXFILE *ppFile);
399
400 APIRET doshLoadTextFile(PCSZ pcszFile,
401 PSZ* ppszContent);
402
403 PSZ doshCreateBackupFileName(const char* pszExisting);
404
405 APIRET doshCreateTempFileName(PSZ pszTempFileName,
406 PCSZ pcszDir,
407 PCSZ pcszPrefix,
408 PCSZ pcszExt);
409
410 APIRET doshWriteTextFile(const char* pszFile,
411 const char* pszContent,
412 PULONG pulWritten,
413 PSZ pszBackup);
414
415
416 /* ******************************************************************
417 *
418 * Directory helpers
419 *
420 ********************************************************************/
421
422 BOOL doshQueryDirExist(PCSZ pcszDir);
423
424 APIRET doshCreatePath(PCSZ pcszPath,
425 BOOL fHidden);
426
427 APIRET doshQueryCurrentDir(PSZ pszBuf);
428
429 APIRET doshSetCurrentDir(PCSZ pcszDir);
430
431 #define DOSHDELDIR_RECURSE 0x0001
432 #define DOSHDELDIR_DELETEFILES 0x0002
433
434 APIRET doshDeleteDir(PCSZ pcszDir,
435 ULONG flFlags,
436 PULONG pulDirs,
437 PULONG pulFiles);
438
439 /* ******************************************************************
440 *
441 * Process helpers
442 *
443 ********************************************************************/
444
445 ULONG XWPENTRY doshMyPID(VOID);
446 typedef ULONG XWPENTRY DOSHMYPID(VOID);
447 typedef DOSHMYPID *PDOSHMYPID;
448
449 ULONG XWPENTRY doshMyTID(VOID);
450 typedef ULONG XWPENTRY DOSHMYTID(VOID);
451 typedef DOSHMYTID *PDOSHMYTID;
452
453 APIRET doshExecVIO(PCSZ pcszExecWithArgs,
454 PLONG plExitCode);
455
456 APIRET doshQuickStartSession(PCSZ pcszPath,
457 PCSZ pcszParams,
458 BOOL fForeground,
459 USHORT usPgmCtl,
460 BOOL fWait,
461 PULONG pulSID,
462 PPID ppid,
463 PUSHORT pusReturn);
464
465 /********************************************************************
466 *
467 * Executable helpers
468 *
469 ********************************************************************/
470
471 #pragma pack(1)
472
473 /*
474 *@@ DOSEXEHEADER:
475 * old DOS EXE header at offset 0
476 * in any EXE file.
477 *
478 *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
479 *@@changed V0.9.9 (2001-04-06) [lafaix]: additional fields defined
480 */
481
482 typedef struct _DOSEXEHEADER
483 {
484 USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
485 USHORT usFileLenMod512; // 02: filelen mod 512
486 USHORT usFileLenDiv512; // 04: filelen div 512
487 USHORT usSegFix; // 06: count of segment adds to fix
488 USHORT usHdrPargCnt; // 08: size of header in paragrphs
489 USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
490 USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
491 USHORT usSSStartup; // 0e: SS at startup
492 USHORT usSPStartup; // 10: SP at startup
493 USHORT usHdrChecksum; // 12: header checksum
494 USHORT usIPStartup; // 14: IP at startup
495 USHORT usCodeSegOfs; // 16: code segment offset from EXE start
496 USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40)
497 USHORT usOverlayNo; // 1a: overlay no.
498 USHORT usLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
499 USHORT usUnused1; // 1e: unused
500 USHORT usBehaviorBits; // 20: exe.h says this field contains
501 // 'behavior bits'
502 USHORT usUnused2; // 22: unused
503 USHORT usOEMIdentifier; // 24: OEM identifier
504 USHORT usOEMInformation; // 26: OEM information
505 ULONG ulUnused3; // 28:
506 ULONG ulUnused4; // 2c:
507 ULONG ulUnused5; // 30:
508 ULONG ulUnused6; // 34:
509 ULONG ulUnused7; // 38:
510 ULONG ulNewHeaderOfs; // 3c: new header ofs (if 0x18 > 0x40)
511 // fixed this from USHORT, thanks Martin Lafaix
512 // V0.9.7 (2000-12-20) [umoeller]
513 } DOSEXEHEADER, *PDOSEXEHEADER;
514
515 // NE and LX OS types
516 #define NEOS_UNKNOWN 0
517 #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
518 #define NEOS_WIN16 2
519 #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
520 #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
521
522 /*
523 *@@ NEHEADER:
524 * linear executable (LX) header format,
525 * which comes after the DOS header in the
526 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
527 *
528 *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed typo in usMoveableEntries
529 */
530
531 typedef struct _NEHEADER
532 {
533 CHAR achNE[2]; // 00: "NE" magic ne_magic
534 BYTE bLinkerVersion; // 02: linker version ne_ver
535 BYTE bLinkerRevision; // 03: linker revision ne_rev
536 USHORT usEntryTblOfs; // 04: ofs from this to entrytable ne_enttab
537 USHORT usEntryTblLen; // 06: length of entrytable ne_cbenttab
538 ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum ne_crc
539 USHORT usFlags; // 0c: flags ne_flags
540 /*
541 #define NENOTP 0x8000 // Not a process == library
542 #define NENOTMPSAFE 0x4000 // Process is not multi-processor safe
543 // (Win3.1 SDK: "reserved")
544 #define NEIERR 0x2000 // Errors in image
545 #define NEBOUND 0x0800 // Bound Family/API
546 // (Win3.1 SDK: "first segment contains code
547 // that loads the application")
548 #define NEAPPTYP 0x0700 // Application type mask
549 // (Win3.1 SDK: "reserved")
550 #define NENOTWINCOMPAT 0x0100 // Not compatible with P.M. Windowing
551 // (Win3.1 SDK: "reserved")
552 #define NEWINCOMPAT 0x0200 // Compatible with P.M. Windowing
553 // (Win3.1 SDK: "reserved")
554 #define NEWINAPI 0x0300 // Uses P.M. Windowing API
555 // (Win3.1 SDK: "reserved")
556 #define NEFLTP 0x0080 // Floating-point instructions
557 #define NEI386 0x0040 // 386 instructions
558 #define NEI286 0x0020 // 286 instructions
559 #define NEI086 0x0010 // 8086 instructions
560 #define NEPROT 0x0008 // Runs in protected mode only
561 // (Win3.1 SDK: "reserved")
562 #define NEPPLI 0x0004 // Per-Process Library Initialization
563 // (Win3.1 SDK: "reserved")
564 #define NEINST 0x0002 // Instance data
565 #define NESOLO 0x0001 // Solo data (single data)
566 */
567 USHORT usAutoDataSegNo; // 0e: auto-data seg no. ne_autodata
568 // (Win3.1 SDK: "0 if both NEINST and NESOLO are cleared")
569 USHORT usInitlHeapSize; // 10: initl. heap size ne_heap
570 // (Win3.1 SDK: "0 if no local allocation")
571 USHORT usInitlStackSize; // 12: initl. stack size ne_stack
572 // (Win3.1 SDK: "0 if SS != DS")
573 ULONG ulCSIP; // 14: CS:IP ne_csip
574 ULONG ulSSSP; // 18: SS:SP ne_sssp
575 USHORT usSegTblEntries; // 1c: segment tbl entry count ne_cseg
576 USHORT usModuleTblEntries; // 1e: module ref. table entry count ne_cmod
577 USHORT usNonResdTblLen; // 20: non-resd. name tbl length ne_cbnrestab
578 USHORT usSegTblOfs; // 22: segment tbl ofs ne_segtab
579 // (from start of NEHEADER)
580 USHORT usResTblOfs; // 24: resource tbl ofs ne_rsrctab
581 // (from start of NEHEADER)
582 USHORT usResdNameTblOfs; // 26: resd. name tbl ofs ne_restab
583 // (from start of NEHEADER)
584 USHORT usModRefTblOfs; // 28: module ref. table ofs ne_modtab
585 // (from start of NEHEADER)
586 USHORT usImportTblOfs; // 2a: import name tbl ofs ne_imptab
587 // (from start of NEHEADER)
588 ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs ne_nrestab
589 // (from start of EXE!)
590 USHORT usMoveableEntries; // 30: moveable entry points count ne_cmovent
591 USHORT usLogicalSectShift; // 32: logcl. sector shift ne_align
592 // (Win3.1 SDK: "typically 4, but default is 9")
593 USHORT usResSegmCount; // 34: resource segm. count ne_cres
594 BYTE bTargetOS; // 36: target OS (NEOS_* flags) ne_exetyp
595 BYTE bFlags2; // 37: addtl. flags ne_flagsothers
596 // Win3.1 SDK:
597 // bit 1 --> Win2.x, but runs in Win3.x protected mode
598 // bit 2 --> Win2.x that supports prop. fonts
599 // bit 3 --> exec contains fastload area
600 /*
601 #define NELONGNAMES 0x01
602 #define NEWINISPROT 0x02
603 #define NEWINGETPROPFON 0x04
604 #define NEWLOAPPL 0x80
605 */
606 // the following are not listed in newexe.h, but are documented for Win3.x
607 USHORT usFastLoadOfs; // 38: fast-load area ofs
608 USHORT usFastLoadLen; // 3a: fast-load area length
609 USHORT usReserved; // 3c: MS: 'reserved'
610 USHORT usReqWinVersion; // 3e: Win-only: min. Win version
611 } NEHEADER, *PNEHEADER;
612
613 /*
614 *@@ LXHEADER:
615 * linear executable (LX) header format,
616 * which comes after the DOS header in the
617 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
618 *
619 *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed auto data object and ulinstanceDemdCnt
620 */
621
622 typedef struct _LXHEADER
623 {
624 CHAR achLX[2]; // 00: "LX" or "LE" magic
625 // this is "LX" for 32-bit OS/2 programs, but
626 // "LE" for MS-DOS progs which use this format
627 // (e.g. WINDOWS\SMARTDRV.EXE). IBM says the
628 // LE format was never released and superceded
629 // by LX... I am unsure what the differences are.
630 BYTE fByteBigEndian; // 02: byte ordering (1 = big endian)
631 BYTE fWordBigEndian; // 03: word ordering (1 = big endian)
632 ULONG ulFormatLevel; // 04: format level
633 USHORT usCPU; // 08: CPU type
634 USHORT usTargetOS; // 0a: OS type (NEOS_* flags)
635 ULONG ulModuleVersion; // 0c: module version
636 ULONG ulFlags; // 10: module flags
637 /* #define E32NOTP 0x8000L // Library Module - used as NENOTP
638 #define E32NOLOAD 0x2000L // Module not Loadable
639 #define E32PMAPI 0x0300L // Uses PM Windowing API
640 #define E32PMW 0x0200L // Compatible with PM Windowing
641 #define E32NOPMW 0x0100L // Incompatible with PM Windowing
642 #define E32NOEXTFIX 0x0020L // NO External Fixups in .EXE
643 #define E32NOINTFIX 0x0010L // NO Internal Fixups in .EXE
644 #define E32SYSDLL 0x0008L // System DLL, Internal Fixups discarded
645 #define E32LIBINIT 0x0004L // Per-Process Library Initialization
646 #define E32LIBTERM 0x40000000L // Per-Process Library Termination
647 #define E32APPMASK 0x0300L // Application Type Mask
648 */
649 ULONG ulPageCount; // 14: no. of pages in module
650 ULONG ulEIPRelObj; // 18: object to which EIP is relative
651 ULONG ulEIPEntryAddr; // 1c: EIP entry addr
652 ULONG ulESPObj; // 20: ESP object
653 ULONG ulESP; // 24: ESP
654 ULONG ulPageSize; // 28: page size (4K)
655 ULONG ulPageLeftShift; // 2c: page left-shift
656 ULONG ulFixupTblLen; // 30: fixup section total size
657 ULONG ulFixupTblChecksum; // 34: fixup section checksum
658 ULONG ulLoaderLen; // 38: size req. for loader section
659 ULONG ulLoaderChecksum; // 3c: loader section checksum
660 ULONG ulObjTblOfs; // 40: object table offset
661 ULONG ulObjCount; // 44: object count
662 ULONG ulObjPageTblOfs; // 48: object page table ofs
663 ULONG ulObjIterPagesOfs; // 4c: object iter pages ofs
664 ULONG ulResTblOfs; // 50: resource table ofs
665 ULONG ulResTblCnt; // 54: resource entry count
666 ULONG ulResdNameTblOfs; // 58: resident name tbl ofs
667 ULONG ulEntryTblOfs; // 5c: entry tbl ofs
668 ULONG ulModDirectivesOfs; // 60: module directives ofs
669 ULONG ulModDirectivesCnt; // 64: module directives count
670 ULONG ulFixupPagePageTblOfs;// 68: fixup page tbl ofs
671 ULONG ulFixupRecTblOfs; // 6c: fixup record tbl ofs
672 ULONG ulImportModTblOfs; // 70: import modl tbl ofs
673 ULONG ulImportModTblCnt; // 74: import modl tbl count
674 ULONG ulImportProcTblOfs; // 78: import proc tbl ofs
675 ULONG ulPerPageCSOfs; // 7c: per page checksum ofs
676 ULONG ulDataPagesOfs; // 80: data pages ofs
677 ULONG ulPreloadPagesCnt; // 84: preload pages count
678 ULONG ulNonResdNameTblOfs; // 88: non-resdnt name tbl ofs
679 ULONG ulNonResdNameTblLen; // 8c: non-resdnt name tbl length
680 ULONG ulNonResdNameTblCS; // 90: non-res name tbl checksum
681 ULONG ulAutoDataSegObj; // 94: auto dataseg object
682 ULONG ulDebugOfs; // 98: debug info ofs
683 ULONG ulDebugLen; // 9c: debug info length
684 ULONG ulInstancePrelCnt; // a0: instance preload count
685 ULONG ulInstanceDemdCnt; // a0: instance demand count
686 ULONG ulHeapSize16; // a8: heap size (16-bit)
687 ULONG ulStackSize; // ac: stack size
688 } LXHEADER, *PLXHEADER;
689
690 /*
691 *@@ PEHEADER:
692 * portable executable (PE) header format,
693 * which comes after the DOS header in the
694 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
695 *
696 *@@added V0.9.10 (2001-04-08) [lafaix]
697 */
698
699 typedef struct _PEHEADER
700 {
701 // standard header
702 ULONG ulSignature; // 00: 'P', 'E', 0, 0
703 USHORT usCPU; // 04: CPU type
704 USHORT usObjCount; // 06: number of object entries
705 ULONG ulTimeDateStamp; // 08: store the time and date the
706 // file was created or modified
707 // by the linker
708 ULONG ulReserved1; // 0c: reserved
709 ULONG ulReserved2; // 10: reserved
710 USHORT usHeaderSize; // 14: number of remaining bytes after
711 // usImageFlags
712 USHORT usImageFlags; // 16: flags bits for the image
713
714 // optional header (always present in valid Win32 files)
715 USHORT usReserved3; // 18: reserved
716 USHORT usLinkerMajor; // 1a: linker major version number
717 USHORT usLinkerMinor; // 1c: linker minor version number
718 USHORT usReserved4; // 1e: reserved
719 ULONG ulReserved5; // 20: reserved
720 ULONG ulReserved6; // 24: reserved
721 ULONG ulEntryPointRVA; // 28: entry point relative virtual address
722 ULONG ulReserved7; // 2c: reserved
723 ULONG ulReserved8; // 30: reserved
724 ULONG ulImageBase; // 34:
725 ULONG ulObjectAlign; // 38:
726 ULONG ulFileAlign; // 3c:
727 USHORT usOSMajor; // 40:
728 USHORT usOSMinor; // 42:
729 USHORT usUserMajor; // 44:
730 USHORT usUserMinor; // 46:
731 USHORT usSubSystemMajor; // 48:
732 USHORT usSubSystemMinor; // 4a:
733 ULONG ulReserved9; // 4c: reserved
734 ULONG ulImageSize; // 50:
735 ULONG ulHeaderSize; // 54:
736 ULONG ulFileChecksum; // 58:
737 USHORT usSubSystem; // 5c:
738 USHORT usDLLFlags; // 5e:
739 ULONG ulStackReserveSize; // 60:
740 ULONG ulStackCommitSize; // 64:
741 ULONG ulHeapReserveSize; // 68:
742 ULONG ulHeapCommitSize; // 6c:
743 ULONG ulReserved10; // 70: reserved
744 ULONG ulInterestingRVACount;// 74:
745 ULONG aulRVASize[1]; // 78: array of RVA/Size entries
746 } PEHEADER, *PPEHEADER;
747
748 // additional LX structures
749
750 /*
751 *@@ RESOURCETABLEENTRY:
752 * LX resource table entry.
753 *
754 *@@added V0.9.16 (2001-12-08) [umoeller]
755 */
756
757 typedef struct _RESOURCETABLEENTRY // rsrc32
758 {
759 unsigned short type; // Resource type
760 unsigned short name; // Resource name
761 unsigned long cb; // Resource size
762 unsigned short obj; // Object number
763 unsigned long offset; // Offset within object
764 } RESOURCETABLEENTRY;
765
766 /*
767 *@@ OBJECTTABLEENTRY:
768 * LX object table entry.
769 *
770 *@@added V0.9.16 (2001-12-08) [umoeller]
771 */
772
773 typedef struct _OBJECTTABLEENTRY // o32_obj
774 {
775 unsigned long o32_size; // Object virtual size
776 unsigned long o32_base; // Object base virtual address
777 unsigned long o32_flags; // Attribute flags
778 unsigned long o32_pagemap; // Object page map index
779 unsigned long o32_mapsize; // Number of entries in object page map
780 unsigned long o32_reserved; // Reserved
781 } OBJECTTABLEENTRY;
782
783 /*
784 *@@ OBJECTPAGETABLEENTRY:
785 * LX object _page_ table entry, sometimes
786 * referred to as map entry.
787 *
788 *@@added V0.9.16 (2001-12-08) [umoeller]
789 */
790
791 typedef struct _OBJECTPAGETABLEENTRY // o32_map
792 {
793 unsigned long o32_pagedataoffset; // file offset of page
794 unsigned short o32_pagesize; // # of real bytes of page data
795 unsigned short o32_pageflags; // Per-Page attributes
796 } OBJECTPAGETABLEENTRY;
797
798 /*
799 *@@ LXITER:
800 * iteration Record format for 'EXEPACK'ed pages.
801 *
802 *@@added V0.9.16 (2001-12-08) [umoeller]
803 */
804
805 typedef struct _LXITER
806 {
807 unsigned short LX_nIter; // number of iterations
808 unsigned short LX_nBytes; // number of bytes
809 unsigned char LX_Iterdata; // iterated data byte(s)
810 } LXITER, *PLXITER;
811
812 /*
813 *@@ OS2NERESTBLENTRY:
814 * OS/2 NE resource table entry.
815 *
816 *@@added V0.9.16 (2001-12-08) [umoeller]
817 */
818
819 typedef struct _OS2NERESTBLENTRY
820 {
821 USHORT usType;
822 USHORT usID;
823 } OS2NERESTBLENTRY, *POS2NERESTBLENTRY;
824
825 /*
826 *@@ OS2NESEGMENT:
827 * OS/2 NE segment definition.
828 *
829 *@@added V0.9.16 (2001-12-08) [umoeller]
830 */
831
832 typedef struct _OS2NESEGMENT // New .EXE segment table entry
833 {
834 unsigned short ns_sector; // File sector of start of segment
835 unsigned short ns_cbseg; // Number of bytes in file
836 unsigned short ns_flags; // Attribute flags
837 unsigned short ns_minalloc; // Minimum allocation in bytes
838 } OS2NESEGMENT, *POS2NESEGMENT;
839
840 #pragma pack()
841
842 // object/segment flags (in NE and LX)
843 #define OBJWRITE 0x0002L // Writeable Object
844 #define OBJDISCARD 0x0010L // Object is Discardable
845 #define OBJSHARED 0x0020L // Object is Shared
846 #define OBJPRELOAD 0x0040L // Object has preload pages
847
848 // resource flags
849 #define RNMOVE 0x0010 // Moveable resource
850 #define RNPURE 0x0020 // Pure (read-only) resource
851 #define RNPRELOAD 0x0040 // Preloaded resource
852 #define RNDISCARD 0xF000 // Discard priority level for resource
853
854 // EXE format
855 #define EXEFORMAT_OLDDOS 1
856 #define EXEFORMAT_NE 2
857 #define EXEFORMAT_PE 3
858 #define EXEFORMAT_LX 4
859 #define EXEFORMAT_TEXT_BATCH 5
860 #define EXEFORMAT_TEXT_REXX 6
861
862 // target OS (in NE and LX)
863 #define EXEOS_DOS3 1
864 #define EXEOS_DOS4 2 // there is a flag for this in NE
865 #define EXEOS_OS2 3
866 #define EXEOS_WIN16 4
867 #define EXEOS_WIN386 5 // according to IBM, there are flags
868 // for this both in NE and LX
869 #define EXEOS_WIN32 6
870
871 /*
872 *@@ EXECUTABLE:
873 * structure used with all the doshExec*
874 * functions.
875 */
876
877 typedef struct _EXECUTABLE
878 {
879 HFILE hfExe;
880
881 /* All the following fields are set by
882 doshExecOpen if NO_ERROR is returned. */
883
884 // old DOS EXE header;
885 // note: before 0.9.12, this was ALWAYS valid,
886 // but since we support NOSTUB executables now,
887 // there may be situations where this is NULL,
888 // but the other fields are valid! V0.9.12 (2001-05-03) [umoeller]
889 PDOSEXEHEADER pDosExeHeader;
890 ULONG cbDosExeHeader;
891
892 // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
893#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
894 PNEHEADER pNEHeader;
895 ULONG cbNEHeader;
896#endif
897
898 // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
899 PLXHEADER pLXHeader;
900 ULONG cbLXHeader;
901
902 // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
903#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
904 PPEHEADER pPEHeader;
905 ULONG cbPEHeader;
906#endif
907 // module analysis (always set):
908 ULONG ulExeFormat;
909 // one of:
910 // EXEFORMAT_OLDDOS 1
911 // EXEFORMAT_NE 2
912 // EXEFORMAT_PE 3
913 // EXEFORMAT_LX 4
914 // EXEFORMAT_TEXT_BATCH 5
915 // EXEFORMAT_TEXT_REXX 6
916
917 BOOL fLibrary, // TRUE if this is a DLL
918 f32Bits; // TRUE if this a 32-bits module
919
920 ULONG ulOS;
921 // target operating system as flagged in one of
922 // the EXE headers; one of:
923 // EXEOS_DOS3 1
924 // EXEOS_DOS4 2 // there is a flag for this in NE
925 // EXEOS_OS2 3
926 // EXEOS_WIN16 4
927 // EXEOS_WIN386 5 // according to IBM, there are flags
928 // for this both in NE and LX
929 // EXEOS_WIN32 6
930
931 /* The following fields are only set after
932 an extra call to doshExecQueryBldLevel. */
933
934 PSZ pszDescription;
935 // whole string (first non-res name tbl entry)
936 PSZ pszVendor;
937 // vendor substring (if IBM BLDLEVEL format)
938 PSZ pszVersion;
939 // version substring (if IBM BLDLEVEL format)
940
941 PSZ pszInfo;
942 // module info substring (if IBM BLDLEVEL format)
943
944#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
945 // if pszInfo is extended DESCRIPTION field, the following
946 // are set as well:
947 PSZ pszBuildDateTime,
948 pszBuildMachine,
949 pszASD,
950 pszLanguage,
951 pszCountry,
952 pszRevision,
953 pszUnknown,
954 pszFixpak;
955
956 // the following fields are set after doshLoadLXMaps
957 BOOL fLXMapsLoaded; // TRUE after doshLoadLXMaps
958 RESOURCETABLEENTRY *pRsTbl; // pLXHeader->ulResTblCnt
959 OBJECTTABLEENTRY *pObjTbl; // pLXHeader->ulObjCount
960 OBJECTPAGETABLEENTRY *pObjPageTbl; // pLXHeader->ulPageCount
961
962 // the following fields are set after doshLoadOS2NEMaps
963 BOOL fOS2NEMapsLoaded;
964 POS2NERESTBLENTRY paOS2NEResTblEntry;
965 POS2NESEGMENT paOS2NESegments;
966
967#endif
968 } EXECUTABLE, *PEXECUTABLE;
969
970 APIRET doshExecOpen(const char* pcszExecutable,
971 PEXECUTABLE* ppExec);
972
973 APIRET doshExecQueryBldLevel(PEXECUTABLE pExec);
974
975 /*
976 *@@ FSYSMODULE:
977 *
978 *@@added V0.9.9 (2001-03-11) [lafaix]
979 */
980
981 typedef struct _FSYSMODULE
982 {
983 CHAR achModuleName[256];
984 } FSYSMODULE, *PFSYSMODULE;
985
986 APIRET doshExecQueryImportedModules(PEXECUTABLE pExec,
987 PFSYSMODULE *ppaModules,
988 PULONG pcModules);
989
990 APIRET doshExecFreeImportedModules(PFSYSMODULE paModules);
991
992 /*
993 *@@ FSYSFUNCTION:
994 *
995 *@@added V0.9.9 (2001-03-11) [lafaix]
996 */
997
998 typedef struct _FSYSFUNCTION
999 {
1000 ULONG ulOrdinal;
1001 ULONG ulType;
1002 CHAR achFunctionName[256];
1003 } FSYSFUNCTION, *PFSYSFUNCTION;
1004
1005 APIRET doshExecQueryExportedFunctions(PEXECUTABLE pExec,
1006 PFSYSFUNCTION *ppaFunctions,
1007 PULONG pcFunctions);
1008
1009 APIRET doshExecFreeExportedFunctions(PFSYSFUNCTION paFunctions);
1010
1011 #define WINRT_ACCELERATOR 9
1012 #define WINRT_BITMAP 2
1013 #define WINRT_CURSOR 1
1014 #define WINRT_DIALOG 5
1015 #define WINRT_FONT 8
1016 #define WINRT_FONTDIR 7
1017 #define WINRT_ICON 3
1018 #define WINRT_MENU 4
1019 #define WINRT_RCDATA 10
1020 #define WINRT_STRING 6
1021
1022 /*
1023 *@@ FSYSRESOURCE:
1024 *
1025 *@@added V0.9.7 (2000-12-18) [lafaix]
1026 */
1027
1028 typedef struct _FSYSRESOURCE
1029 {
1030 ULONG ulID; // resource ID
1031 ULONG ulType; // resource type
1032 ULONG ulSize; // resource size in bytes
1033 ULONG ulFlag; // resource flags
1034
1035 } FSYSRESOURCE, *PFSYSRESOURCE;
1036
1037 APIRET doshExecQueryResources(PEXECUTABLE pExec,
1038 PFSYSRESOURCE *ppaResources,
1039 PULONG pcResources);
1040
1041 APIRET doshExecFreeResources(PFSYSRESOURCE paResources);
1042
1043 APIRET doshLoadLXMaps(PEXECUTABLE pExec);
1044
1045 VOID doshFreeLXMaps(PEXECUTABLE pExec);
1046
1047 APIRET doshLoadOS2NEMaps(PEXECUTABLE pExec);
1048
1049 VOID doshFreeNEMaps(PEXECUTABLE pExec);
1050
1051 APIRET doshExecClose(PEXECUTABLE *ppExec);
1052
1053 APIRET doshSearchPath(PCSZ pcszPath,
1054 PCSZ pcszFile,
1055 PSZ pszExecutable,
1056 ULONG cbExecutable);
1057
1058 APIRET doshFindExecutable(PCSZ pcszCommand,
1059 PSZ pszExecutable,
1060 ULONG cbExecutable,
1061 PCSZ *papcszExtensions,
1062 ULONG cExtensions);
1063
1064 /********************************************************************
1065 *
1066 * Partition functions
1067 *
1068 ********************************************************************/
1069
1070 /*
1071 *@@ LVMINFO:
1072 * informational structure created by
1073 * doshQueryLVMInfo.
1074 *
1075 *@@added V0.9.9 (2001-04-07) [umoeller]
1076 */
1077
1078 typedef struct _LVMINFO
1079 {
1080 HMODULE hmodLVM;
1081
1082 } LVMINFO, *PLVMINFO;
1083
1084 /* #define DOSH_PARTITIONS_LIMIT 10
1085
1086 #define PAR_UNUSED 0x00 // Unused
1087 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
1088 #define PAR_XENIXROOT 0x02 // XENIX root
1089 #define PAR_XENIXUSER 0x03 // XENIX user
1090 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
1091 #define PAR_EXTENDED 0x05 // Extended partition
1092 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
1093 #define PAR_HPFS 0x07 // OS/2 HPFS
1094 #define PAR_AIXBOOT 0x08 // AIX bootable partition
1095 #define PAR_AIXDATA 0x09 // AIX bootable partition
1096 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
1097 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
1098 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
1099 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
1100 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
1101 #define PAR_OPUS 0x10 // OPUS
1102 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
1103 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
1104 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
1105 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
1106 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
1107 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
1108 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
1109 #define PAR_THEOS 0x38 // THEOS
1110 #define PAR_VENIX 0x40 // VENIX
1111 #define PAR_RISCBOOT 0x41 // Personal RISC boot
1112 #define PAR_SFS 0x42 // SFS
1113 #define PAR_ONTRACK 0x50 // Ontrack
1114 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
1115 #define PAR_CPM 0x52 // CP/M
1116 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
1117 #define PAR_NOVELL_64 0x64 // Novell
1118 #define PAR_NOVELL_65 0x65 // Novell
1119 #define PAR_NOVELL_67 0x67 // Novell
1120 #define PAR_NOVELL_68 0x68 // Novell
1121 #define PAR_NOVELL_69 0x69 // Novell
1122 #define PAR_PCIX 0x75 // PCIX
1123 #define PAR_MINIX 0x80 // MINIX
1124 #define PAR_LINUX 0x81 // Linux
1125 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
1126 #define PAR_LINUXFILE 0x83 // Linux File System
1127 #define PAR_FREEBSD 0xA5 // FreeBSD
1128 #define PAR_BBT 0xFF // BBT
1129 */
1130
1131 // one-byte alignment
1132 #pragma pack(1)
1133
1134 /*
1135 *@@ PAR_INFO:
1136 * partition table
1137 */
1138
1139 typedef struct _PAR_INFO
1140 {
1141 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
1142 BYTE bBeginHead; // partition begins at this head...
1143 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
1144 BYTE bFileSysCode; // file system type
1145 BYTE bEndHead; // partition ends at this head...
1146 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
1147 ULONG lBeginAbsSec; // partition begins at this absolute sector #
1148 ULONG lTotalSects; // total sectors in this partition
1149 } PAR_INFO, *PPAR_INFO;
1150
1151 /*
1152 *@@ MBR_INFO:
1153 * master boot record table.
1154 * This has the four primary partitions.
1155 */
1156
1157 typedef struct _MBR_INFO // MBR
1158 {
1159 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
1160 PAR_INFO sPrtnInfo[4]; // primary partition entries
1161 USHORT wPrtnTblSig; // partition table signature (aa55H)
1162 } MBR_INFO, *PMBR_INFO;
1163
1164 /*
1165 *@@ SYS_INFO:
1166 *
1167 */
1168
1169 typedef struct _SYS_INFO
1170 {
1171 BYTE startable;
1172 BYTE unknown[3];
1173 BYTE bootable;
1174 BYTE name[8];
1175 BYTE reservd[3];
1176 } SYS_INFO, *PSYS_INFO;
1177
1178 /*
1179 *@@ SYE_INFO:
1180 *
1181 */
1182
1183 typedef struct _SYE_INFO
1184 {
1185 BYTE bootable;
1186 BYTE name[8];
1187 } SYE_INFO, *PSYE_INFO;
1188
1189 /*
1190 *@@ EXT_INFO:
1191 *
1192 */
1193
1194 typedef struct _EXT_INFO
1195 {
1196 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
1197 SYE_INFO sBmNames[4]; // System Names
1198 BYTE bReserved[16]; // reserved
1199 PAR_INFO sPrtnInfo[4]; // partitioms entrys
1200 USHORT wPrtnTblSig; // partition table signature (aa55H)
1201 } EXT_INFO, *PEXT_INFO;
1202
1203 typedef struct _PARTITIONINFO *PPARTITIONINFO;
1204
1205 /*
1206 *@@ PARTITIONINFO:
1207 * informational structure returned
1208 * by doshGetPartitionsList. One of
1209 * these items is created for each
1210 * bootable partition.
1211 */
1212
1213 typedef struct _PARTITIONINFO
1214 {
1215 BYTE bDisk; // drive number
1216 CHAR cLetter; // probable drive letter or ' ' if none
1217 BYTE bFSType; // file system type
1218 PCSZ pcszFSType; // file system name (as returned by
1219 // doshType2FSName, can be NULL!)
1220 BOOL fPrimary; // primary partition?
1221 BOOL fBootable; // bootable by Boot Manager?
1222 CHAR szBootName[9]; // Boot Manager name, if (fBootable)
1223 ULONG ulSize; // size MBytes
1224 PPARTITIONINFO pNext; // next info or NULL if last
1225 } PARTITIONINFO;
1226
1227 UINT doshQueryDiskCount(VOID);
1228
1229 APIRET doshReadSector(USHORT disk,
1230 void *buff,
1231 USHORT head,
1232 USHORT cylinder,
1233 USHORT sector);
1234
1235 // restore original alignment
1236 #pragma pack()
1237
1238 const char* doshType2FSName(unsigned char bFSType);
1239
1240 APIRET doshGetBootManager(USHORT *pusDisk,
1241 USHORT *pusPart,
1242 PAR_INFO *BmInfo);
1243
1244 typedef struct _PARTITIONSLIST
1245 {
1246 PLVMINFO pLVMInfo; // != NULL if LVM is installed
1247
1248 // partitions array
1249 PPARTITIONINFO pPartitionInfo;
1250 USHORT cPartitions;
1251 } PARTITIONSLIST, *PPARTITIONSLIST;
1252
1253 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
1254 PUSHORT pusContext);
1255
1256 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
1257
1258 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
1259
1260 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
1261 PPARTITIONINFO *ppPartitionInfo,
1262 PUSHORT pcPartitions);
1263
1264 VOID doshFreeLVMInfo(PLVMINFO pInfo);
1265
1266#endif
1267
1268#if __cplusplus
1269}
1270#endif
1271
Note: See TracBrowser for help on using the repository browser.