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 "dosh.h"
|
---|
13 | */
|
---|
14 |
|
---|
15 | /* This file Copyright (C) 1997-2001 Ulrich Mller,
|
---|
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
|
---|
29 | extern "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 doshAllocSharedMem(ULONG ulSize,
|
---|
58 | const char* pcszName);
|
---|
59 |
|
---|
60 | PVOID doshRequestSharedMem(const char *pcszName);
|
---|
61 |
|
---|
62 | /* ******************************************************************
|
---|
63 | *
|
---|
64 | * Drive helpers
|
---|
65 | *
|
---|
66 | ********************************************************************/
|
---|
67 |
|
---|
68 | APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
|
---|
69 | PBOOL pfFixed);
|
---|
70 |
|
---|
71 | #ifdef INCL_DOSDEVIOCTL
|
---|
72 |
|
---|
73 | // flags for DRIVEPARMS.usDeviceAttrs (see DSK_GETDEVICEPARAMS in CPREF):
|
---|
74 | #define DEVATTR_REMOVEABLE 0x0001 // drive is removeable
|
---|
75 | #define DEVATTR_CHANGELINE 0x0002 // media has been removed since last I/O operation
|
---|
76 | #define DEVATTR_GREATER16MB 0x0004 // physical device driver supports physical addresses > 16 MB
|
---|
77 |
|
---|
78 | // #pragma pack(1)
|
---|
79 |
|
---|
80 | /*
|
---|
81 | * DRIVEPARAMS:
|
---|
82 | * structure used for doshQueryDiskParams.
|
---|
83 | * removed this, we can directly use BIOSPARAMETERBLOCK
|
---|
84 | * V0.9.13 (2001-06-14) [umoeller]
|
---|
85 | */
|
---|
86 |
|
---|
87 | /* typedef struct _DRIVEPARAMS
|
---|
88 | {
|
---|
89 | BIOSPARAMETERBLOCK bpb;
|
---|
90 | // BIOS parameter block. This is the first sector
|
---|
91 | // (at byte 0) in each partition. This is defined
|
---|
92 | // in the OS2 headers as follows:
|
---|
93 |
|
---|
94 | typedef struct _BIOSPARAMETERBLOCK {
|
---|
95 | 0 USHORT usBytesPerSector;
|
---|
96 | // Number of bytes per sector.
|
---|
97 | 2 BYTE bSectorsPerCluster;
|
---|
98 | // Number of sectors per cluster.
|
---|
99 | 3 USHORT usReservedSectors;
|
---|
100 | // Number of reserved sectors.
|
---|
101 | 5 BYTE cFATs;
|
---|
102 | // Number of FATs.
|
---|
103 | 6 USHORT cRootEntries;
|
---|
104 | // Number of root directory entries.
|
---|
105 | 8 USHORT cSectors;
|
---|
106 | // Number of sectors.
|
---|
107 | 10 BYTE bMedia;
|
---|
108 | // Media descriptor.
|
---|
109 | 11 USHORT usSectorsPerFAT;
|
---|
110 | // Number of secctors per FAT.
|
---|
111 | 13 USHORT usSectorsPerTrack;
|
---|
112 | // Number of sectors per track.
|
---|
113 | 15 USHORT cHeads;
|
---|
114 | // Number of heads.
|
---|
115 | 17 ULONG cHiddenSectors;
|
---|
116 | // Number of hidden sectors.
|
---|
117 | 21 ULONG cLargeSectors;
|
---|
118 | // Number of large sectors.
|
---|
119 | 25 BYTE abReserved[6];
|
---|
120 | // Reserved.
|
---|
121 | 31 USHORT cCylinders;
|
---|
122 | // Number of cylinders defined for the physical
|
---|
123 | // device.
|
---|
124 | 33 BYTE bDeviceType;
|
---|
125 | // Physical layout of the specified device.
|
---|
126 | 34 USHORT fsDeviceAttr;
|
---|
127 | // A bit field that returns flag information
|
---|
128 | // about the specified drive.
|
---|
129 | } BIOSPARAMETERBLOCK;
|
---|
130 |
|
---|
131 | // removed the following fields... these are already
|
---|
132 | // in the extended BPB structure, as defined in the
|
---|
133 | // Toolkit's BIOSPARAMETERBLOCK struct. Checked this,
|
---|
134 | // the definition is the same for the Toolkit 3 and 4.5.
|
---|
135 |
|
---|
136 | USHORT usCylinders;
|
---|
137 | // no. of cylinders
|
---|
138 | UCHAR ucDeviceType;
|
---|
139 | // device type; according to the IBM Control
|
---|
140 | // Program Reference (see DSK_GETDEVICEPARAMS),
|
---|
141 | // this value can be:
|
---|
142 | // -- 0: 48 TPI low-density diskette drive
|
---|
143 | // -- 1: 96 TPI high-density diskette drive
|
---|
144 | // -- 2: 3.5-inch 720KB diskette drive
|
---|
145 | // -- 3: 8-Inch single-density diskette drive
|
---|
146 | // -- 4: 8-Inch double-density diskette drive
|
---|
147 | // -- 5: Fixed disk
|
---|
148 | // -- 6: Tape drive
|
---|
149 | // -- 7: Other (includes 1.44MB 3.5-inch diskette drive
|
---|
150 | // and CD-ROMs)
|
---|
151 | // -- 8: R/W optical disk
|
---|
152 | // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
|
---|
153 | USHORT usDeviceAttrs;
|
---|
154 | // DEVATTR_* flags
|
---|
155 | } DRIVEPARAMS, *PDRIVEPARAMS;
|
---|
156 | #pragma pack() */
|
---|
157 |
|
---|
158 | APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
|
---|
159 | PBIOSPARAMETERBLOCK pdp);
|
---|
160 | #endif
|
---|
161 |
|
---|
162 | VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
|
---|
163 | const char *pcszFileSystem,
|
---|
164 | BOOL fSkipRemoveables);
|
---|
165 | typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
|
---|
166 | const char *pcszFileSystem,
|
---|
167 | BOOL fSkipRemoveables);
|
---|
168 | typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
|
---|
169 |
|
---|
170 | CHAR doshQueryBootDrive(VOID);
|
---|
171 |
|
---|
172 | #define ERROR_AUDIO_CD_ROM 10000
|
---|
173 |
|
---|
174 | #define ASSERTFL_MIXEDMODECD 0x0001
|
---|
175 |
|
---|
176 | APIRET doshAssertDrive(ULONG ulLogicalDrive,
|
---|
177 | ULONG fl);
|
---|
178 |
|
---|
179 | APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
|
---|
180 |
|
---|
181 | APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
|
---|
182 | typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
|
---|
183 | typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
|
---|
184 |
|
---|
185 | APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
|
---|
186 | typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
|
---|
187 | typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
|
---|
188 |
|
---|
189 | APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
|
---|
190 | typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
|
---|
191 | typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
|
---|
192 |
|
---|
193 | APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
|
---|
194 | PSZ pszVolumeLabel);
|
---|
195 |
|
---|
196 | APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
|
---|
197 | PSZ pszNewLabel);
|
---|
198 |
|
---|
199 | /* ******************************************************************
|
---|
200 | *
|
---|
201 | * Module handling helpers
|
---|
202 | *
|
---|
203 | ********************************************************************/
|
---|
204 |
|
---|
205 | /*
|
---|
206 | *@@ RESOLVEFUNCTION:
|
---|
207 | * one of these structures each define
|
---|
208 | * a single function import to doshResolveImports.
|
---|
209 | *
|
---|
210 | *@@added V0.9.3 (2000-04-25) [umoeller]
|
---|
211 | */
|
---|
212 |
|
---|
213 | typedef struct _RESOLVEFUNCTION
|
---|
214 | {
|
---|
215 | const char *pcszFunctionName;
|
---|
216 | PFN *ppFuncAddress;
|
---|
217 | } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
|
---|
218 |
|
---|
219 | APIRET doshResolveImports(PSZ pszModuleName,
|
---|
220 | HMODULE *phmod,
|
---|
221 | PRESOLVEFUNCTION paResolves,
|
---|
222 | ULONG cResolves);
|
---|
223 |
|
---|
224 | /* ******************************************************************
|
---|
225 | *
|
---|
226 | * Performance Counters (CPU Load)
|
---|
227 | *
|
---|
228 | ********************************************************************/
|
---|
229 |
|
---|
230 | #define CMD_PERF_INFO 0x41
|
---|
231 | #define CMD_KI_ENABLE 0x60
|
---|
232 | #define CMD_KI_DISABLE 0x61
|
---|
233 | #ifndef CMD_KI_RDCNT
|
---|
234 | #define CMD_KI_RDCNT 0x63
|
---|
235 | typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
|
---|
236 | ULONG ulParm1,
|
---|
237 | ULONG ulParm2,
|
---|
238 | ULONG ulParm3);
|
---|
239 | typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
|
---|
240 | #endif
|
---|
241 |
|
---|
242 | typedef struct _CPUUTIL
|
---|
243 | {
|
---|
244 | ULONG ulTimeLow; // low 32 bits of time stamp
|
---|
245 | ULONG ulTimeHigh; // high 32 bits of time stamp
|
---|
246 | ULONG ulIdleLow; // low 32 bits of idle time
|
---|
247 | ULONG ulIdleHigh; // high 32 bits of idle time
|
---|
248 | ULONG ulBusyLow; // low 32 bits of busy time
|
---|
249 | ULONG ulBusyHigh; // high 32 bits of busy time
|
---|
250 | ULONG ulIntrLow; // low 32 bits of interrupt time
|
---|
251 | ULONG ulIntrHigh; // high 32 bits of interrupt time
|
---|
252 | } CPUUTIL, *PCPUUTIL;
|
---|
253 |
|
---|
254 | // macro to convert 8-byte (low, high) time value to double
|
---|
255 | #define LL2F(high, low) (4294967296.0*(high)+(low))
|
---|
256 |
|
---|
257 | /*
|
---|
258 | *@@ DOSHPERFSYS:
|
---|
259 | * structure used with doshPerfOpen.
|
---|
260 | *
|
---|
261 | *@@added V0.9.7 (2000-12-02) [umoeller]
|
---|
262 | *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
|
---|
263 | */
|
---|
264 |
|
---|
265 | typedef struct _DOSHPERFSYS
|
---|
266 | {
|
---|
267 | // output: no. of processors on the system
|
---|
268 | ULONG cProcessors;
|
---|
269 | // output: one CPU load for each CPU
|
---|
270 | PLONG palLoads;
|
---|
271 |
|
---|
272 | // output: one CPU interrupt load for each CPU
|
---|
273 | PLONG palIntrs;
|
---|
274 |
|
---|
275 | // each of the following ptrs points to an array of cProcessors items
|
---|
276 | PCPUUTIL paCPUUtils; // CPUUTIL structures
|
---|
277 | double *padBusyPrev; // previous "busy" calculations
|
---|
278 | double *padTimePrev; // previous "time" calculations
|
---|
279 | double *padIntrPrev; // previous "intr" calculations
|
---|
280 |
|
---|
281 | // private stuff
|
---|
282 | HMODULE hmod;
|
---|
283 | BOOL fInitialized;
|
---|
284 | PFNDOSPERFSYSCALL pDosPerfSysCall;
|
---|
285 | } DOSHPERFSYS, *PDOSHPERFSYS;
|
---|
286 |
|
---|
287 | APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
|
---|
288 |
|
---|
289 | APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
|
---|
290 |
|
---|
291 | APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
|
---|
292 |
|
---|
293 | /* ******************************************************************
|
---|
294 | *
|
---|
295 | * File helpers
|
---|
296 | *
|
---|
297 | ********************************************************************/
|
---|
298 |
|
---|
299 | PSZ doshGetExtension(const char *pcszFilename);
|
---|
300 |
|
---|
301 | BOOL doshIsFileOnFAT(const char* pcszFileName);
|
---|
302 |
|
---|
303 | APIRET doshIsValidFileName(const char* pcszFile,
|
---|
304 | BOOL fFullyQualified);
|
---|
305 |
|
---|
306 | BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
|
---|
307 |
|
---|
308 | ULONG doshQueryFileSize(HFILE hFile);
|
---|
309 |
|
---|
310 | ULONG doshQueryPathSize(PSZ pszFile);
|
---|
311 |
|
---|
312 | APIRET doshQueryPathAttr(const char* pcszFile,
|
---|
313 | PULONG pulAttr);
|
---|
314 |
|
---|
315 | APIRET doshSetPathAttr(const char* pcszFile,
|
---|
316 | ULONG ulAttr);
|
---|
317 |
|
---|
318 | APIRET doshOpenExisting(const char *pcszFilename,
|
---|
319 | ULONG ulOpenFlags,
|
---|
320 | HFILE *phf);
|
---|
321 |
|
---|
322 | APIRET doshWriteAt(HFILE hf,
|
---|
323 | LONG lOffset,
|
---|
324 | ULONG ulMethod,
|
---|
325 | ULONG cb,
|
---|
326 | PBYTE pbData);
|
---|
327 |
|
---|
328 | APIRET doshReadAt(HFILE hf,
|
---|
329 | LONG lOffset,
|
---|
330 | ULONG ulMethod,
|
---|
331 | ULONG cb,
|
---|
332 | PBYTE pbData);
|
---|
333 |
|
---|
334 | APIRET doshLoadTextFile(const char *pcszFile,
|
---|
335 | PSZ* ppszContent);
|
---|
336 |
|
---|
337 | PSZ doshCreateBackupFileName(const char* pszExisting);
|
---|
338 |
|
---|
339 | APIRET doshCreateTempFileName(PSZ pszTempFileName,
|
---|
340 | const char *pcszDir,
|
---|
341 | const char *pcszPrefix,
|
---|
342 | const char *pcszExt);
|
---|
343 |
|
---|
344 | APIRET doshWriteTextFile(const char* pszFile,
|
---|
345 | const char* pszContent,
|
---|
346 | PULONG pulWritten,
|
---|
347 | PSZ pszBackup);
|
---|
348 |
|
---|
349 | HFILE doshOpenLogFile(const char* pcszFilename);
|
---|
350 |
|
---|
351 | APIRET doshWriteToLogFile(HFILE hfLog, const char* pcsz);
|
---|
352 |
|
---|
353 | /* ******************************************************************
|
---|
354 | *
|
---|
355 | * Directory helpers
|
---|
356 | *
|
---|
357 | ********************************************************************/
|
---|
358 |
|
---|
359 | BOOL doshQueryDirExist(const char *pcszDir);
|
---|
360 |
|
---|
361 | APIRET doshCreatePath(const char *pcszPath,
|
---|
362 | BOOL fHidden);
|
---|
363 |
|
---|
364 | APIRET doshQueryCurrentDir(PSZ pszBuf);
|
---|
365 |
|
---|
366 | APIRET doshSetCurrentDir(const char *pcszDir);
|
---|
367 |
|
---|
368 | #define DOSHDELDIR_RECURSE 0x0001
|
---|
369 | #define DOSHDELDIR_DELETEFILES 0x0002
|
---|
370 |
|
---|
371 | APIRET doshDeleteDir(const char *pcszDir,
|
---|
372 | ULONG flFlags,
|
---|
373 | PULONG pulDirs,
|
---|
374 | PULONG pulFiles);
|
---|
375 |
|
---|
376 | /* ******************************************************************
|
---|
377 | *
|
---|
378 | * Process helpers
|
---|
379 | *
|
---|
380 | ********************************************************************/
|
---|
381 |
|
---|
382 | ULONG XWPENTRY doshMyPID(VOID);
|
---|
383 | typedef ULONG XWPENTRY DOSHMYPID(VOID);
|
---|
384 | typedef DOSHMYPID *PDOSHMYPID;
|
---|
385 |
|
---|
386 | ULONG XWPENTRY doshMyTID(VOID);
|
---|
387 | typedef ULONG XWPENTRY DOSHMYTID(VOID);
|
---|
388 | typedef DOSHMYTID *PDOSHMYTID;
|
---|
389 |
|
---|
390 | APIRET doshFindExecutable(const char *pcszCommand,
|
---|
391 | PSZ pszExecutable,
|
---|
392 | ULONG cbExecutable,
|
---|
393 | const char **papcszExtensions,
|
---|
394 | ULONG cExtensions);
|
---|
395 |
|
---|
396 | APIRET doshExecVIO(const char *pcszExecWithArgs,
|
---|
397 | PLONG plExitCode);
|
---|
398 |
|
---|
399 | APIRET doshQuickStartSession(const char *pcszPath,
|
---|
400 | const char *pcszParams,
|
---|
401 | BOOL fForeground,
|
---|
402 | USHORT usPgmCtl,
|
---|
403 | BOOL fWait,
|
---|
404 | PULONG pulSID,
|
---|
405 | PPID ppid);
|
---|
406 |
|
---|
407 | /********************************************************************
|
---|
408 | *
|
---|
409 | * Executable helpers
|
---|
410 | *
|
---|
411 | ********************************************************************/
|
---|
412 |
|
---|
413 | /*
|
---|
414 | *@@ DOSEXEHEADER:
|
---|
415 | * old DOS EXE header at offset 0
|
---|
416 | * in any EXE file.
|
---|
417 | *
|
---|
418 | *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
|
---|
419 | *@@changed V0.9.9 (2001-04-06) [lafaix]: additional fields defined
|
---|
420 | */
|
---|
421 |
|
---|
422 | #pragma pack(1)
|
---|
423 | typedef struct _DOSEXEHEADER
|
---|
424 | {
|
---|
425 | USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
|
---|
426 | USHORT usFileLenMod512; // 02: filelen mod 512
|
---|
427 | USHORT usFileLenDiv512; // 04: filelen div 512
|
---|
428 | USHORT usSegFix; // 06: count of segment adds to fix
|
---|
429 | USHORT usHdrPargCnt; // 08: size of header in paragrphs
|
---|
430 | USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
|
---|
431 | USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
|
---|
432 | USHORT usSSStartup; // 0e: SS at startup
|
---|
433 | USHORT usSPStartup; // 10: SP at startup
|
---|
434 | USHORT usHdrChecksum; // 12: header checksum
|
---|
435 | USHORT usIPStartup; // 14: IP at startup
|
---|
436 | USHORT usCodeSegOfs; // 16: code segment offset from EXE start
|
---|
437 | USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40)
|
---|
438 | USHORT usOverlayNo; // 1a: overlay no.
|
---|
439 | USHORT usLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
|
---|
440 | USHORT usUnused1; // 1e: unused
|
---|
441 | USHORT usBehaviorBits; // 20: exe.h says this field contains
|
---|
442 | // 'behavior bits'
|
---|
443 | USHORT usUnused2; // 22: unused
|
---|
444 | USHORT usOEMIdentifier; // 24: OEM identifier
|
---|
445 | USHORT usOEMInformation; // 26: OEM information
|
---|
446 | ULONG ulUnused3; // 28:
|
---|
447 | ULONG ulUnused4; // 2c:
|
---|
448 | ULONG ulUnused5; // 30:
|
---|
449 | ULONG ulUnused6; // 34:
|
---|
450 | ULONG ulUnused7; // 38:
|
---|
451 | ULONG ulNewHeaderOfs; // 3c: new header ofs (if 0x18 > 0x40)
|
---|
452 | // fixed this from USHORT, thanks Martin Lafaix
|
---|
453 | // V0.9.7 (2000-12-20) [umoeller]
|
---|
454 | } DOSEXEHEADER, *PDOSEXEHEADER;
|
---|
455 |
|
---|
456 | // NE and LX OS types
|
---|
457 | #define NEOS_UNKNOWN 0
|
---|
458 | #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
|
---|
459 | #define NEOS_WIN16 2
|
---|
460 | #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
|
---|
461 | #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
|
---|
462 |
|
---|
463 | /*
|
---|
464 | *@@ NEHEADER:
|
---|
465 | * linear executable (LX) header format,
|
---|
466 | * which comes after the DOS header in the
|
---|
467 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
468 | *
|
---|
469 | *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed typo in usMoveableEntries
|
---|
470 | */
|
---|
471 |
|
---|
472 | typedef struct _NEHEADER
|
---|
473 | {
|
---|
474 | CHAR achNE[2]; // 00: "NE" magic
|
---|
475 | BYTE bLinkerVersion; // 02: linker version
|
---|
476 | BYTE bLinkerRevision; // 03: linker revision
|
---|
477 | USHORT usEntryTblOfs; // 04: ofs from this to entrytable
|
---|
478 | USHORT usEntryTblLen; // 06: length of entrytable
|
---|
479 | ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum
|
---|
480 | USHORT usFlags; // 0c: flags
|
---|
481 | USHORT usAutoDataSegNo; // 0e: auto-data seg no.
|
---|
482 | USHORT usInitlHeapSize; // 10: initl. heap size
|
---|
483 | USHORT usInitlStackSize; // 12: initl. stack size
|
---|
484 | ULONG ulCSIP; // 14: CS:IP
|
---|
485 | ULONG ulSSSP; // 18: SS:SP
|
---|
486 | USHORT usSegTblEntries; // 1c: segment tbl entry count
|
---|
487 | USHORT usModuleTblEntries; // 1e: module ref. table entry count
|
---|
488 | USHORT usNonResdTblLen; // 20: non-resd. name tbl length
|
---|
489 | USHORT usSegTblOfs; // 22: segment tbl ofs
|
---|
490 | USHORT usResTblOfs; // 24: resource tbl ofs
|
---|
491 | USHORT usResdNameTblOfs; // 26: resd. name tbl ofs
|
---|
492 | USHORT usModRefTblOfs; // 28: module ref. table ofs
|
---|
493 | USHORT usImportTblOfs; // 2a: import tbl ofs
|
---|
494 | ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs
|
---|
495 | USHORT usMoveableEntries; // 30: moveable entry pts. count
|
---|
496 | USHORT usLogicalSectShift; // 32: logcl. sector shift
|
---|
497 | USHORT usResSegmCount; // 34: resource segm. count
|
---|
498 | BYTE bTargetOS; // 36: target OS (NEOS_* flags)
|
---|
499 | BYTE bFlags2; // 37: addtl. flags
|
---|
500 | USHORT usFastLoadOfs; // 38: fast-load area ofs
|
---|
501 | USHORT usFastLoadLen; // 3a: fast-load area length
|
---|
502 | USHORT usReserved; // 3c: MS: 'reserved'
|
---|
503 | USHORT usReqWinVersion; // 3e: Win-only: min. Win version
|
---|
504 | } NEHEADER, *PNEHEADER;
|
---|
505 |
|
---|
506 | /*
|
---|
507 | *@@ LXHEADER:
|
---|
508 | * linear executable (LX) header format,
|
---|
509 | * which comes after the DOS header in the
|
---|
510 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
511 | *
|
---|
512 | *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed auto data object and ulinstanceDemdCnt
|
---|
513 | */
|
---|
514 |
|
---|
515 | typedef struct _LXHEADER
|
---|
516 | {
|
---|
517 | CHAR achLX[2]; // 00: "LX" or "LE" magic
|
---|
518 | // this is "LX" for 32-bit OS/2 programs, but
|
---|
519 | // "LE" for MS-DOS progs which use this format
|
---|
520 | // (e.g. WINDOWS\SMARTDRV.EXE). IBM says the
|
---|
521 | // LE format was never released and superceded
|
---|
522 | // by LX... I am unsure what the differences are.
|
---|
523 | BYTE fByteBigEndian; // 02: byte ordering (1 = big endian)
|
---|
524 | BYTE fWordBigEndian; // 03: word ordering (1 = big endian)
|
---|
525 | ULONG ulFormatLevel; // 04: format level
|
---|
526 | USHORT usCPU; // 08: CPU type
|
---|
527 | USHORT usTargetOS; // 0a: OS type (NEOS_* flags)
|
---|
528 | ULONG ulModuleVersion; // 0c: module version
|
---|
529 | ULONG ulFlags; // 10: module flags
|
---|
530 | ULONG ulPageCount; // 14: no. of pages in module
|
---|
531 | ULONG ulEIPRelObj; // 18: object to which EIP is relative
|
---|
532 | ULONG ulEIPEntryAddr; // 1c: EIP entry addr
|
---|
533 | ULONG ulESPObj; // 20: ESP object
|
---|
534 | ULONG ulESP; // 24: ESP
|
---|
535 | ULONG ulPageSize; // 28: page size (4K)
|
---|
536 | ULONG ulPageLeftShift; // 2c: page left-shift
|
---|
537 | ULONG ulFixupTblLen; // 30: fixup section total size
|
---|
538 | ULONG ulFixupTblChecksum; // 34: fixup section checksum
|
---|
539 | ULONG ulLoaderLen; // 38: size req. for loader section
|
---|
540 | ULONG ulLoaderChecksum; // 3c: loader section checksum
|
---|
541 | ULONG ulObjTblOfs; // 40: object table offset
|
---|
542 | ULONG ulObjCount; // 44: object count
|
---|
543 | ULONG ulObjPageTblOfs; // 48: object page table ofs
|
---|
544 | ULONG ulObjIterPagesOfs; // 4c: object iter pages ofs
|
---|
545 | ULONG ulResTblOfs; // 50: resource table ofs
|
---|
546 | ULONG ulResTblCnt; // 54: resource entry count
|
---|
547 | ULONG ulResdNameTblOfs; // 58: resident name tbl ofs
|
---|
548 | ULONG ulEntryTblOfs; // 5c: entry tbl ofs
|
---|
549 | ULONG ulModDirectivesOfs; // 60: module directives ofs
|
---|
550 | ULONG ulModDirectivesCnt; // 64: module directives count
|
---|
551 | ULONG ulFixupPagePageTblOfs;// 68: fixup page tbl ofs
|
---|
552 | ULONG ulFixupRecTblOfs; // 6c: fixup record tbl ofs
|
---|
553 | ULONG ulImportModTblOfs; // 70: import modl tbl ofs
|
---|
554 | ULONG ulImportModTblCnt; // 74: import modl tbl count
|
---|
555 | ULONG ulImportProcTblOfs; // 78: import proc tbl ofs
|
---|
556 | ULONG ulPerPageCSOfs; // 7c: per page checksum ofs
|
---|
557 | ULONG ulDataPagesOfs; // 80: data pages ofs
|
---|
558 | ULONG ulPreloadPagesCnt; // 84: preload pages count
|
---|
559 | ULONG ulNonResdNameTblOfs; // 88: non-resdnt name tbl ofs
|
---|
560 | ULONG ulNonResdNameTblLen; // 8c: non-resdnt name tbl length
|
---|
561 | ULONG ulNonResdNameTblCS; // 90: non-res name tbl checksum
|
---|
562 | ULONG ulAutoDataSegObj; // 94: auto dataseg object
|
---|
563 | ULONG ulDebugOfs; // 98: debug info ofs
|
---|
564 | ULONG ulDebugLen; // 9c: debug info length
|
---|
565 | ULONG ulInstancePrelCnt; // a0: instance preload count
|
---|
566 | ULONG ulInstanceDemdCnt; // a0: instance demand count
|
---|
567 | ULONG ulHeapSize16; // a8: heap size (16-bit)
|
---|
568 | ULONG ulStackSize; // ac: stack size
|
---|
569 | } LXHEADER, *PLXHEADER;
|
---|
570 |
|
---|
571 | /*
|
---|
572 | *@@ PEHEADER:
|
---|
573 | * portable executable (PE) header format,
|
---|
574 | * which comes after the DOS header in the
|
---|
575 | * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
|
---|
576 | *
|
---|
577 | *@@added V0.9.10 (2001-04-08) [lafaix]
|
---|
578 | */
|
---|
579 |
|
---|
580 | typedef struct _PEHEADER
|
---|
581 | {
|
---|
582 | // standard header
|
---|
583 | ULONG ulSignature; // 00: 'P', 'E', 0, 0
|
---|
584 | USHORT usCPU; // 04: CPU type
|
---|
585 | USHORT usObjCount; // 06: number of object entries
|
---|
586 | ULONG ulTimeDateStamp; // 08: store the time and date the
|
---|
587 | // file was created or modified
|
---|
588 | // by the linker
|
---|
589 | ULONG ulReserved1; // 0c: reserved
|
---|
590 | ULONG ulReserved2; // 10: reserved
|
---|
591 | USHORT usHeaderSize; // 14: number of remaining bytes after
|
---|
592 | // usImageFlags
|
---|
593 | USHORT usImageFlags; // 16: flags bits for the image
|
---|
594 |
|
---|
595 | // optional header (always present in valid Win32 files)
|
---|
596 | USHORT usReserved3; // 18: reserved
|
---|
597 | USHORT usLinkerMajor; // 1a: linker major version number
|
---|
598 | USHORT usLinkerMinor; // 1c: linker minor version number
|
---|
599 | USHORT usReserved4; // 1e: reserved
|
---|
600 | ULONG ulReserved5; // 20: reserved
|
---|
601 | ULONG ulReserved6; // 24: reserved
|
---|
602 | ULONG ulEntryPointRVA; // 28: entry point relative virtual address
|
---|
603 | ULONG ulReserved7; // 2c: reserved
|
---|
604 | ULONG ulReserved8; // 30: reserved
|
---|
605 | ULONG ulImageBase; // 34:
|
---|
606 | ULONG ulObjectAlign; // 38:
|
---|
607 | ULONG ulFileAlign; // 3c:
|
---|
608 | USHORT usOSMajor; // 40:
|
---|
609 | USHORT usOSMinor; // 42:
|
---|
610 | USHORT usUserMajor; // 44:
|
---|
611 | USHORT usUserMinor; // 46:
|
---|
612 | USHORT usSubSystemMajor; // 48:
|
---|
613 | USHORT usSubSystemMinor; // 4a:
|
---|
614 | ULONG ulReserved9; // 4c: reserved
|
---|
615 | ULONG ulImageSize; // 50:
|
---|
616 | ULONG ulHeaderSize; // 54:
|
---|
617 | ULONG ulFileChecksum; // 58:
|
---|
618 | USHORT usSubSystem; // 5c:
|
---|
619 | USHORT usDLLFlags; // 5e:
|
---|
620 | ULONG ulStackReserveSize; // 60:
|
---|
621 | ULONG ulStackCommitSize; // 64:
|
---|
622 | ULONG ulHeapReserveSize; // 68:
|
---|
623 | ULONG ulHeapCommitSize; // 6c:
|
---|
624 | ULONG ulReserved10; // 70: reserved
|
---|
625 | ULONG ulInterestingRVACount;// 74:
|
---|
626 | ULONG aulRVASize[1]; // 78: array of RVA/Size entries
|
---|
627 | } PEHEADER, *PPEHEADER;
|
---|
628 |
|
---|
629 | #pragma pack()
|
---|
630 |
|
---|
631 | /*
|
---|
632 | *@@ FSYSMODULE:
|
---|
633 | *
|
---|
634 | *@@added V0.9.9 (2001-03-11) [lafaix]
|
---|
635 | */
|
---|
636 |
|
---|
637 | typedef struct _FSYSMODULE
|
---|
638 | {
|
---|
639 | CHAR achModuleName[256];
|
---|
640 | } FSYSMODULE, *PFSYSMODULE;
|
---|
641 |
|
---|
642 | /*
|
---|
643 | *@@ FSYSFUNCTION:
|
---|
644 | *
|
---|
645 | *@@added V0.9.9 (2001-03-11) [lafaix]
|
---|
646 | */
|
---|
647 |
|
---|
648 | typedef struct _FSYSFUNCTION
|
---|
649 | {
|
---|
650 | ULONG ulOrdinal;
|
---|
651 | ULONG ulType;
|
---|
652 | CHAR achFunctionName[256];
|
---|
653 | } FSYSFUNCTION, *PFSYSFUNCTION;
|
---|
654 |
|
---|
655 | /*
|
---|
656 | *@@ FSYSRESOURCE:
|
---|
657 | *
|
---|
658 | *@@added V0.9.7 (2000-12-18) [lafaix]
|
---|
659 | */
|
---|
660 |
|
---|
661 | typedef struct _FSYSRESOURCE
|
---|
662 | {
|
---|
663 | ULONG ulID; // resource ID
|
---|
664 | ULONG ulType; // resource type
|
---|
665 | ULONG ulSize; // resource size in bytes
|
---|
666 | ULONG ulFlag; // resource flags
|
---|
667 | } FSYSRESOURCE, *PFSYSRESOURCE;
|
---|
668 |
|
---|
669 | // object/segment flags (in NE and LX)
|
---|
670 | #define OBJWRITE 0x0002L // Writeable Object
|
---|
671 | #define OBJDISCARD 0x0010L // Object is Discardable
|
---|
672 | #define OBJSHARED 0x0020L // Object is Shared
|
---|
673 | #define OBJPRELOAD 0x0040L // Object has preload pages
|
---|
674 |
|
---|
675 | // resource flags
|
---|
676 | #define RNMOVE 0x0010 // Moveable resource
|
---|
677 | #define RNPURE 0x0020 // Pure (read-only) resource
|
---|
678 | #define RNPRELOAD 0x0040 // Preloaded resource
|
---|
679 | #define RNDISCARD 0xF000 // Discard priority level for resource
|
---|
680 |
|
---|
681 | // EXE format
|
---|
682 | #define EXEFORMAT_OLDDOS 1
|
---|
683 | #define EXEFORMAT_NE 2
|
---|
684 | #define EXEFORMAT_PE 3
|
---|
685 | #define EXEFORMAT_LX 4
|
---|
686 | #define EXEFORMAT_TEXT_BATCH 5
|
---|
687 | #define EXEFORMAT_TEXT_REXX 6
|
---|
688 |
|
---|
689 | // target OS (in NE and LX)
|
---|
690 | #define EXEOS_DOS3 1
|
---|
691 | #define EXEOS_DOS4 2 // there is a flag for this in NE
|
---|
692 | #define EXEOS_OS2 3
|
---|
693 | #define EXEOS_WIN16 4
|
---|
694 | #define EXEOS_WIN386 5 // according to IBM, there are flags
|
---|
695 | // for this both in NE and LX
|
---|
696 | #define EXEOS_WIN32 6
|
---|
697 |
|
---|
698 | /*
|
---|
699 | *@@ EXECUTABLE:
|
---|
700 | * structure used with all the doshExec*
|
---|
701 | * functions.
|
---|
702 | */
|
---|
703 |
|
---|
704 | typedef struct _EXECUTABLE
|
---|
705 | {
|
---|
706 | HFILE hfExe;
|
---|
707 |
|
---|
708 | /* All the following fields are set by
|
---|
709 | doshExecOpen if NO_ERROR is returned. */
|
---|
710 |
|
---|
711 | // old DOS EXE header;
|
---|
712 | // note: before 0.9.12, this was ALWAYS valid,
|
---|
713 | // but since we support NOSTUB executables now,
|
---|
714 | // there may be situations where this is NULL,
|
---|
715 | // but the other fields are valid! V0.9.12 (2001-05-03) [umoeller]
|
---|
716 | PDOSEXEHEADER pDosExeHeader;
|
---|
717 | ULONG cbDosExeHeader;
|
---|
718 |
|
---|
719 | // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
|
---|
720 | PNEHEADER pNEHeader;
|
---|
721 | ULONG cbNEHeader;
|
---|
722 |
|
---|
723 | // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
|
---|
724 | PLXHEADER pLXHeader;
|
---|
725 | ULONG cbLXHeader;
|
---|
726 |
|
---|
727 | // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
|
---|
728 | PPEHEADER pPEHeader;
|
---|
729 | ULONG cbPEHeader;
|
---|
730 |
|
---|
731 | // module analysis (always set):
|
---|
732 | ULONG ulExeFormat;
|
---|
733 | // one of:
|
---|
734 | // EXEFORMAT_OLDDOS 1
|
---|
735 | // EXEFORMAT_NE 2
|
---|
736 | // EXEFORMAT_PE 3
|
---|
737 | // EXEFORMAT_LX 4
|
---|
738 | // EXEFORMAT_TEXT_BATCH 5
|
---|
739 | // EXEFORMAT_TEXT_REXX 6
|
---|
740 |
|
---|
741 | BOOL fLibrary, // TRUE if this is a DLL
|
---|
742 | f32Bits; // TRUE if this a 32-bits module
|
---|
743 |
|
---|
744 | ULONG ulOS;
|
---|
745 | // target operating system as flagged in one of
|
---|
746 | // the EXE headers; one of:
|
---|
747 | // EXEOS_DOS3 1
|
---|
748 | // EXEOS_DOS4 2 // there is a flag for this in NE
|
---|
749 | // EXEOS_OS2 3
|
---|
750 | // EXEOS_WIN16 4
|
---|
751 | // EXEOS_WIN386 5 // according to IBM, there are flags
|
---|
752 | // for this both in NE and LX
|
---|
753 | // EXEOS_WIN32 6
|
---|
754 |
|
---|
755 | /* The following fields are only set after
|
---|
756 | an extra call to doshExecQueryBldLevel. */
|
---|
757 |
|
---|
758 | PSZ pszDescription;
|
---|
759 | // whole string (first non-res name tbl entry)
|
---|
760 | PSZ pszVendor;
|
---|
761 | // vendor substring (if IBM BLDLEVEL format)
|
---|
762 | PSZ pszVersion;
|
---|
763 | // version substring (if IBM BLDLEVEL format)
|
---|
764 |
|
---|
765 | PSZ pszInfo;
|
---|
766 | // module info substring (if IBM BLDLEVEL format)
|
---|
767 |
|
---|
768 | // if pszInfo is extended DESCRIPTION field, the following
|
---|
769 | // are set as well:
|
---|
770 | PSZ pszBuildDateTime,
|
---|
771 | pszBuildMachine,
|
---|
772 | pszASD,
|
---|
773 | pszLanguage,
|
---|
774 | pszCountry,
|
---|
775 | pszRevision,
|
---|
776 | pszUnknown,
|
---|
777 | pszFixpak;
|
---|
778 |
|
---|
779 | } EXECUTABLE, *PEXECUTABLE;
|
---|
780 |
|
---|
781 | APIRET doshExecOpen(const char* pcszExecutable,
|
---|
782 | PEXECUTABLE* ppExec);
|
---|
783 |
|
---|
784 | APIRET doshExecClose(PEXECUTABLE pExec);
|
---|
785 |
|
---|
786 | APIRET doshExecQueryBldLevel(PEXECUTABLE pExec);
|
---|
787 |
|
---|
788 | APIRET doshExecQueryImportedModules(PEXECUTABLE pExec,
|
---|
789 | PFSYSMODULE *ppaModules,
|
---|
790 | PULONG pcModules);
|
---|
791 |
|
---|
792 | APIRET doshExecFreeImportedModules(PFSYSMODULE paModules);
|
---|
793 |
|
---|
794 | APIRET doshExecQueryExportedFunctions(PEXECUTABLE pExec,
|
---|
795 | PFSYSFUNCTION *ppaFunctions,
|
---|
796 | PULONG pcFunctions);
|
---|
797 |
|
---|
798 | APIRET doshExecFreeExportedFunctions(PFSYSFUNCTION paFunctions);
|
---|
799 |
|
---|
800 | APIRET doshExecQueryResources(PEXECUTABLE pExec,
|
---|
801 | PFSYSRESOURCE *ppaResources,
|
---|
802 | PULONG pcResources);
|
---|
803 |
|
---|
804 | APIRET doshExecFreeResources(PFSYSRESOURCE paResources);
|
---|
805 |
|
---|
806 | /********************************************************************
|
---|
807 | *
|
---|
808 | * Partition functions
|
---|
809 | *
|
---|
810 | ********************************************************************/
|
---|
811 |
|
---|
812 | /*
|
---|
813 | *@@ LVMINFO:
|
---|
814 | * informational structure created by
|
---|
815 | * doshQueryLVMInfo.
|
---|
816 | *
|
---|
817 | *@@added V0.9.9 (2001-04-07) [umoeller]
|
---|
818 | */
|
---|
819 |
|
---|
820 | typedef struct _LVMINFO
|
---|
821 | {
|
---|
822 | HMODULE hmodLVM;
|
---|
823 |
|
---|
824 | } LVMINFO, *PLVMINFO;
|
---|
825 |
|
---|
826 | #define DOSH_PARTITIONS_LIMIT 10
|
---|
827 |
|
---|
828 | #define PAR_UNUSED 0x00 // Unused
|
---|
829 | #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
|
---|
830 | #define PAR_XENIXROOT 0x02 // XENIX root
|
---|
831 | #define PAR_XENIXUSER 0x03 // XENIX user
|
---|
832 | #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
|
---|
833 | #define PAR_EXTENDED 0x05 // Extended partition
|
---|
834 | #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
|
---|
835 | #define PAR_HPFS 0x07 // OS/2 HPFS
|
---|
836 | #define PAR_AIXBOOT 0x08 // AIX bootable partition
|
---|
837 | #define PAR_AIXDATA 0x09 // AIX bootable partition
|
---|
838 | #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
|
---|
839 | #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
|
---|
840 | #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
|
---|
841 | #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
|
---|
842 | #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
|
---|
843 | #define PAR_OPUS 0x10 // OPUS
|
---|
844 | #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
|
---|
845 | #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
|
---|
846 | #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
|
---|
847 | #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
|
---|
848 | #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
|
---|
849 | #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
|
---|
850 | #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
|
---|
851 | #define PAR_THEOS 0x38 // THEOS
|
---|
852 | #define PAR_VENIX 0x40 // VENIX
|
---|
853 | #define PAR_RISCBOOT 0x41 // Personal RISC boot
|
---|
854 | #define PAR_SFS 0x42 // SFS
|
---|
855 | #define PAR_ONTRACK 0x50 // Ontrack
|
---|
856 | #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
|
---|
857 | #define PAR_CPM 0x52 // CP/M
|
---|
858 | #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
|
---|
859 | #define PAR_NOVELL_64 0x64 // Novell
|
---|
860 | #define PAR_NOVELL_65 0x65 // Novell
|
---|
861 | #define PAR_NOVELL_67 0x67 // Novell
|
---|
862 | #define PAR_NOVELL_68 0x68 // Novell
|
---|
863 | #define PAR_NOVELL_69 0x69 // Novell
|
---|
864 | #define PAR_PCIX 0x75 // PCIX
|
---|
865 | #define PAR_MINIX 0x80 // MINIX
|
---|
866 | #define PAR_LINUX 0x81 // Linux
|
---|
867 | #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
|
---|
868 | #define PAR_LINUXFILE 0x83 // Linux File System
|
---|
869 | #define PAR_FREEBSD 0xA5 // FreeBSD
|
---|
870 | #define PAR_BBT 0xFF // BBT
|
---|
871 |
|
---|
872 | // one-byte alignment
|
---|
873 | #pragma pack(1)
|
---|
874 |
|
---|
875 | /*
|
---|
876 | *@@ PAR_INFO:
|
---|
877 | * partition table
|
---|
878 | */
|
---|
879 |
|
---|
880 | typedef struct _PAR_INFO
|
---|
881 | {
|
---|
882 | BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
|
---|
883 | BYTE bBeginHead; // partition begins at this head...
|
---|
884 | USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
|
---|
885 | BYTE bFileSysCode; // file system type
|
---|
886 | BYTE bEndHead; // partition ends at this head...
|
---|
887 | USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
|
---|
888 | ULONG lBeginAbsSec; // partition begins at this absolute sector #
|
---|
889 | ULONG lTotalSects; // total sectors in this partition
|
---|
890 | } PAR_INFO, *PPAR_INFO;
|
---|
891 |
|
---|
892 | /*
|
---|
893 | *@@ MBR_INFO:
|
---|
894 | * master boot record table.
|
---|
895 | * This has the four primary partitions.
|
---|
896 | */
|
---|
897 |
|
---|
898 | typedef struct _MBR_INFO // MBR
|
---|
899 | {
|
---|
900 | BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
|
---|
901 | PAR_INFO sPrtnInfo[4]; // primary partition entries
|
---|
902 | USHORT wPrtnTblSig; // partition table signature (aa55H)
|
---|
903 | } MBR_INFO, *PMBR_INFO;
|
---|
904 |
|
---|
905 | /*
|
---|
906 | *@@ SYS_INFO:
|
---|
907 | *
|
---|
908 | */
|
---|
909 |
|
---|
910 | typedef struct _SYS_INFO
|
---|
911 | {
|
---|
912 | BYTE startable;
|
---|
913 | BYTE unknown[3];
|
---|
914 | BYTE bootable;
|
---|
915 | BYTE name[8];
|
---|
916 | BYTE reservd[3];
|
---|
917 | } SYS_INFO, *PSYS_INFO;
|
---|
918 |
|
---|
919 | /*
|
---|
920 | *@@ SYE_INFO:
|
---|
921 | *
|
---|
922 | */
|
---|
923 |
|
---|
924 | typedef struct _SYE_INFO
|
---|
925 | {
|
---|
926 | BYTE bootable;
|
---|
927 | BYTE name[8];
|
---|
928 | } SYE_INFO, *PSYE_INFO;
|
---|
929 |
|
---|
930 | /*
|
---|
931 | *@@ EXT_INFO:
|
---|
932 | *
|
---|
933 | */
|
---|
934 |
|
---|
935 | typedef struct _EXT_INFO
|
---|
936 | {
|
---|
937 | BYTE aBootCode[0x18A]; // abBootCode master boot executable code
|
---|
938 | SYE_INFO sBmNames[4]; // System Names
|
---|
939 | BYTE bReserved[16]; // reserved
|
---|
940 | PAR_INFO sPrtnInfo[4]; // partitioms entrys
|
---|
941 | USHORT wPrtnTblSig; // partition table signature (aa55H)
|
---|
942 | } EXT_INFO, *PEXT_INFO;
|
---|
943 |
|
---|
944 | typedef struct _PARTITIONINFO *PPARTITIONINFO;
|
---|
945 |
|
---|
946 | /*
|
---|
947 | *@@ PARTITIONINFO:
|
---|
948 | * informational structure returned
|
---|
949 | * by doshGetPartitionsList. One of
|
---|
950 | * these items is created for each
|
---|
951 | * bootable partition.
|
---|
952 | */
|
---|
953 |
|
---|
954 | typedef struct _PARTITIONINFO
|
---|
955 | {
|
---|
956 | BYTE bDisk; // drive number
|
---|
957 | CHAR cLetter; // probable drive letter or ' ' if none
|
---|
958 | BYTE bFSType; // file system type
|
---|
959 | CHAR szFSType[10]; // file system name (created by us)
|
---|
960 | BOOL fPrimary; // primary partition?
|
---|
961 | BOOL fBootable; // bootable by Boot Manager?
|
---|
962 | CHAR szBootName[9]; // Boot Manager name, if (fBootable)
|
---|
963 | ULONG ulSize; // size MBytes
|
---|
964 | PPARTITIONINFO pNext; // next info or NULL if last
|
---|
965 | } PARTITIONINFO;
|
---|
966 |
|
---|
967 | UINT doshQueryDiskCount(VOID);
|
---|
968 |
|
---|
969 | APIRET doshReadSector(USHORT disk,
|
---|
970 | void *buff,
|
---|
971 | USHORT head,
|
---|
972 | USHORT cylinder,
|
---|
973 | USHORT sector);
|
---|
974 |
|
---|
975 | // restore original alignment
|
---|
976 | #pragma pack()
|
---|
977 |
|
---|
978 | const char* doshType2FSName(unsigned char bFSType);
|
---|
979 |
|
---|
980 | APIRET doshGetBootManager(USHORT *pusDisk,
|
---|
981 | USHORT *pusPart,
|
---|
982 | PAR_INFO *BmInfo);
|
---|
983 |
|
---|
984 | typedef struct _PARTITIONSLIST
|
---|
985 | {
|
---|
986 | PLVMINFO pLVMInfo; // != NULL if LVM is installed
|
---|
987 |
|
---|
988 | // partitions array
|
---|
989 | PPARTITIONINFO pPartitionInfo;
|
---|
990 | USHORT cPartitions;
|
---|
991 | } PARTITIONSLIST, *PPARTITIONSLIST;
|
---|
992 |
|
---|
993 | APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
|
---|
994 | PUSHORT pusContext);
|
---|
995 |
|
---|
996 | APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
|
---|
997 |
|
---|
998 | APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
|
---|
999 |
|
---|
1000 | APIRET doshReadLVMPartitions(PLVMINFO pInfo,
|
---|
1001 | PPARTITIONINFO *ppPartitionInfo,
|
---|
1002 | PUSHORT pcPartitions);
|
---|
1003 |
|
---|
1004 | VOID doshFreeLVMInfo(PLVMINFO pInfo);
|
---|
1005 |
|
---|
1006 | #endif
|
---|
1007 |
|
---|
1008 | #if __cplusplus
|
---|
1009 | }
|
---|
1010 | #endif
|
---|
1011 |
|
---|