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