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

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

Misc changes.

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