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

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

Misc updates.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 40.9 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 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
161 BOOL XWPENTRY doshIsCDROM(PBIOSPARAMETERBLOCK pdp);
162
163 #endif
164
165 APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive,
166 HFILE hfDrive,
167 BOOL fMixedModeCD,
168 PBOOL pfAudio);
169
170 VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
171 const char *pcszFileSystem,
172 BOOL fSkipRemoveables);
173 typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
174 const char *pcszFileSystem,
175 BOOL fSkipRemoveables);
176 typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
177
178 CHAR doshQueryBootDrive(VOID);
179
180 #define ERROR_AUDIO_CD_ROM 10000
181
182 #define ASSERTFL_MIXEDMODECD 0x0001
183
184 APIRET doshAssertDrive(ULONG ulLogicalDrive,
185 ULONG fl);
186
187 APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
188
189 APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
190 typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
191 typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
192
193 APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
194 typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
195 typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
196
197 APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
198 typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
199 typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
200
201 APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
202 PSZ pszVolumeLabel);
203
204 APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
205 PSZ pszNewLabel);
206
207 /* ******************************************************************
208 *
209 * Module handling helpers
210 *
211 ********************************************************************/
212
213 /*
214 *@@ RESOLVEFUNCTION:
215 * one of these structures each define
216 * a single function import to doshResolveImports.
217 *
218 *@@added V0.9.3 (2000-04-25) [umoeller]
219 */
220
221 typedef struct _RESOLVEFUNCTION
222 {
223 const char *pcszFunctionName;
224 PFN *ppFuncAddress;
225 } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
226
227 APIRET doshResolveImports(PSZ pszModuleName,
228 HMODULE *phmod,
229 PRESOLVEFUNCTION paResolves,
230 ULONG cResolves);
231
232 /* ******************************************************************
233 *
234 * Performance Counters (CPU Load)
235 *
236 ********************************************************************/
237
238 #define CMD_PERF_INFO 0x41
239 #define CMD_KI_ENABLE 0x60
240 #define CMD_KI_DISABLE 0x61
241 #ifndef CMD_KI_RDCNT
242 #define CMD_KI_RDCNT 0x63
243 typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
244 ULONG ulParm1,
245 ULONG ulParm2,
246 ULONG ulParm3);
247 typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
248 #endif
249
250 typedef struct _CPUUTIL
251 {
252 ULONG ulTimeLow; // low 32 bits of time stamp
253 ULONG ulTimeHigh; // high 32 bits of time stamp
254 ULONG ulIdleLow; // low 32 bits of idle time
255 ULONG ulIdleHigh; // high 32 bits of idle time
256 ULONG ulBusyLow; // low 32 bits of busy time
257 ULONG ulBusyHigh; // high 32 bits of busy time
258 ULONG ulIntrLow; // low 32 bits of interrupt time
259 ULONG ulIntrHigh; // high 32 bits of interrupt time
260 } CPUUTIL, *PCPUUTIL;
261
262 // macro to convert 8-byte (low, high) time value to double
263 #define LL2F(high, low) (4294967296.0*(high)+(low))
264
265 /*
266 *@@ DOSHPERFSYS:
267 * structure used with doshPerfOpen.
268 *
269 *@@added V0.9.7 (2000-12-02) [umoeller]
270 *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
271 */
272
273 typedef struct _DOSHPERFSYS
274 {
275 // output: no. of processors on the system
276 ULONG cProcessors;
277 // output: one CPU load for each CPU
278 PLONG palLoads;
279
280 // output: one CPU interrupt load for each CPU
281 PLONG palIntrs;
282
283 // each of the following ptrs points to an array of cProcessors items
284 PCPUUTIL paCPUUtils; // CPUUTIL structures
285 double *padBusyPrev; // previous "busy" calculations
286 double *padTimePrev; // previous "time" calculations
287 double *padIntrPrev; // previous "intr" calculations
288
289 // private stuff
290 HMODULE hmod;
291 BOOL fInitialized;
292 PFNDOSPERFSYSCALL pDosPerfSysCall;
293 } DOSHPERFSYS, *PDOSHPERFSYS;
294
295 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
296
297 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
298
299 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
300
301 /* ******************************************************************
302 *
303 * File helpers
304 *
305 ********************************************************************/
306
307 PSZ doshGetExtension(const char *pcszFilename);
308
309 BOOL doshIsFileOnFAT(const char* pcszFileName);
310
311 APIRET doshIsValidFileName(const char* pcszFile,
312 BOOL fFullyQualified);
313
314 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
315
316 ULONG doshQueryFileSize(HFILE hFile);
317
318 ULONG doshQueryPathSize(PSZ pszFile);
319
320 APIRET doshQueryPathAttr(const char* pcszFile,
321 PULONG pulAttr);
322
323 APIRET doshSetPathAttr(const char* pcszFile,
324 ULONG ulAttr);
325
326 APIRET doshOpenExisting(const char *pcszFilename,
327 ULONG ulOpenFlags,
328 HFILE *phf);
329
330 APIRET doshWriteAt(HFILE hf,
331 LONG lOffset,
332 ULONG ulMethod,
333 ULONG cb,
334 PBYTE pbData);
335
336 APIRET doshReadAt(HFILE hf,
337 LONG lOffset,
338 ULONG ulMethod,
339 ULONG cb,
340 PBYTE pbData);
341
342 APIRET doshLoadTextFile(const char *pcszFile,
343 PSZ* ppszContent);
344
345 PSZ doshCreateBackupFileName(const char* pszExisting);
346
347 APIRET doshCreateTempFileName(PSZ pszTempFileName,
348 const char *pcszDir,
349 const char *pcszPrefix,
350 const char *pcszExt);
351
352 APIRET doshWriteTextFile(const char* pszFile,
353 const char* pszContent,
354 PULONG pulWritten,
355 PSZ pszBackup);
356
357 HFILE doshOpenLogFile(const char* pcszFilename);
358
359 APIRET doshWriteToLogFile(HFILE hfLog, const char* pcsz);
360
361 /* ******************************************************************
362 *
363 * Directory helpers
364 *
365 ********************************************************************/
366
367 BOOL doshQueryDirExist(const char *pcszDir);
368
369 APIRET doshCreatePath(const char *pcszPath,
370 BOOL fHidden);
371
372 APIRET doshQueryCurrentDir(PSZ pszBuf);
373
374 APIRET doshSetCurrentDir(const char *pcszDir);
375
376 #define DOSHDELDIR_RECURSE 0x0001
377 #define DOSHDELDIR_DELETEFILES 0x0002
378
379 APIRET doshDeleteDir(const char *pcszDir,
380 ULONG flFlags,
381 PULONG pulDirs,
382 PULONG pulFiles);
383
384 /* ******************************************************************
385 *
386 * Process helpers
387 *
388 ********************************************************************/
389
390 ULONG XWPENTRY doshMyPID(VOID);
391 typedef ULONG XWPENTRY DOSHMYPID(VOID);
392 typedef DOSHMYPID *PDOSHMYPID;
393
394 ULONG XWPENTRY doshMyTID(VOID);
395 typedef ULONG XWPENTRY DOSHMYTID(VOID);
396 typedef DOSHMYTID *PDOSHMYTID;
397
398 APIRET doshFindExecutable(const char *pcszCommand,
399 PSZ pszExecutable,
400 ULONG cbExecutable,
401 const char **papcszExtensions,
402 ULONG cExtensions);
403
404 APIRET doshExecVIO(const char *pcszExecWithArgs,
405 PLONG plExitCode);
406
407 APIRET doshQuickStartSession(const char *pcszPath,
408 const char *pcszParams,
409 BOOL fForeground,
410 USHORT usPgmCtl,
411 BOOL fWait,
412 PULONG pulSID,
413 PPID ppid,
414 PUSHORT pusReturn);
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" magic
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" magic
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). IBM says the
530 // LE format was never released and superceded
531 // by LX... I am unsure what the differences are.
532 BYTE fByteBigEndian; // 02: byte ordering (1 = big endian)
533 BYTE fWordBigEndian; // 03: word ordering (1 = big endian)
534 ULONG ulFormatLevel; // 04: format level
535 USHORT usCPU; // 08: CPU type
536 USHORT usTargetOS; // 0a: OS type (NEOS_* flags)
537 ULONG ulModuleVersion; // 0c: module version
538 ULONG ulFlags; // 10: module flags
539 ULONG ulPageCount; // 14: no. of pages in module
540 ULONG ulEIPRelObj; // 18: object to which EIP is relative
541 ULONG ulEIPEntryAddr; // 1c: EIP entry addr
542 ULONG ulESPObj; // 20: ESP object
543 ULONG ulESP; // 24: ESP
544 ULONG ulPageSize; // 28: page size (4K)
545 ULONG ulPageLeftShift; // 2c: page left-shift
546 ULONG ulFixupTblLen; // 30: fixup section total size
547 ULONG ulFixupTblChecksum; // 34: fixup section checksum
548 ULONG ulLoaderLen; // 38: size req. for loader section
549 ULONG ulLoaderChecksum; // 3c: loader section checksum
550 ULONG ulObjTblOfs; // 40: object table offset
551 ULONG ulObjCount; // 44: object count
552 ULONG ulObjPageTblOfs; // 48: object page table ofs
553 ULONG ulObjIterPagesOfs; // 4c: object iter pages ofs
554 ULONG ulResTblOfs; // 50: resource table ofs
555 ULONG ulResTblCnt; // 54: resource entry count
556 ULONG ulResdNameTblOfs; // 58: resident name tbl ofs
557 ULONG ulEntryTblOfs; // 5c: entry tbl ofs
558 ULONG ulModDirectivesOfs; // 60: module directives ofs
559 ULONG ulModDirectivesCnt; // 64: module directives count
560 ULONG ulFixupPagePageTblOfs;// 68: fixup page tbl ofs
561 ULONG ulFixupRecTblOfs; // 6c: fixup record tbl ofs
562 ULONG ulImportModTblOfs; // 70: import modl tbl ofs
563 ULONG ulImportModTblCnt; // 74: import modl tbl count
564 ULONG ulImportProcTblOfs; // 78: import proc tbl ofs
565 ULONG ulPerPageCSOfs; // 7c: per page checksum ofs
566 ULONG ulDataPagesOfs; // 80: data pages ofs
567 ULONG ulPreloadPagesCnt; // 84: preload pages count
568 ULONG ulNonResdNameTblOfs; // 88: non-resdnt name tbl ofs
569 ULONG ulNonResdNameTblLen; // 8c: non-resdnt name tbl length
570 ULONG ulNonResdNameTblCS; // 90: non-res name tbl checksum
571 ULONG ulAutoDataSegObj; // 94: auto dataseg object
572 ULONG ulDebugOfs; // 98: debug info ofs
573 ULONG ulDebugLen; // 9c: debug info length
574 ULONG ulInstancePrelCnt; // a0: instance preload count
575 ULONG ulInstanceDemdCnt; // a0: instance demand count
576 ULONG ulHeapSize16; // a8: heap size (16-bit)
577 ULONG ulStackSize; // ac: stack size
578 } LXHEADER, *PLXHEADER;
579
580 /*
581 *@@ PEHEADER:
582 * portable executable (PE) header format,
583 * which comes after the DOS header in the
584 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
585 *
586 *@@added V0.9.10 (2001-04-08) [lafaix]
587 */
588
589 typedef struct _PEHEADER
590 {
591 // standard header
592 ULONG ulSignature; // 00: 'P', 'E', 0, 0
593 USHORT usCPU; // 04: CPU type
594 USHORT usObjCount; // 06: number of object entries
595 ULONG ulTimeDateStamp; // 08: store the time and date the
596 // file was created or modified
597 // by the linker
598 ULONG ulReserved1; // 0c: reserved
599 ULONG ulReserved2; // 10: reserved
600 USHORT usHeaderSize; // 14: number of remaining bytes after
601 // usImageFlags
602 USHORT usImageFlags; // 16: flags bits for the image
603
604 // optional header (always present in valid Win32 files)
605 USHORT usReserved3; // 18: reserved
606 USHORT usLinkerMajor; // 1a: linker major version number
607 USHORT usLinkerMinor; // 1c: linker minor version number
608 USHORT usReserved4; // 1e: reserved
609 ULONG ulReserved5; // 20: reserved
610 ULONG ulReserved6; // 24: reserved
611 ULONG ulEntryPointRVA; // 28: entry point relative virtual address
612 ULONG ulReserved7; // 2c: reserved
613 ULONG ulReserved8; // 30: reserved
614 ULONG ulImageBase; // 34:
615 ULONG ulObjectAlign; // 38:
616 ULONG ulFileAlign; // 3c:
617 USHORT usOSMajor; // 40:
618 USHORT usOSMinor; // 42:
619 USHORT usUserMajor; // 44:
620 USHORT usUserMinor; // 46:
621 USHORT usSubSystemMajor; // 48:
622 USHORT usSubSystemMinor; // 4a:
623 ULONG ulReserved9; // 4c: reserved
624 ULONG ulImageSize; // 50:
625 ULONG ulHeaderSize; // 54:
626 ULONG ulFileChecksum; // 58:
627 USHORT usSubSystem; // 5c:
628 USHORT usDLLFlags; // 5e:
629 ULONG ulStackReserveSize; // 60:
630 ULONG ulStackCommitSize; // 64:
631 ULONG ulHeapReserveSize; // 68:
632 ULONG ulHeapCommitSize; // 6c:
633 ULONG ulReserved10; // 70: reserved
634 ULONG ulInterestingRVACount;// 74:
635 ULONG aulRVASize[1]; // 78: array of RVA/Size entries
636 } PEHEADER, *PPEHEADER;
637
638 #pragma pack()
639
640 /*
641 *@@ FSYSMODULE:
642 *
643 *@@added V0.9.9 (2001-03-11) [lafaix]
644 */
645
646 typedef struct _FSYSMODULE
647 {
648 CHAR achModuleName[256];
649 } FSYSMODULE, *PFSYSMODULE;
650
651 /*
652 *@@ FSYSFUNCTION:
653 *
654 *@@added V0.9.9 (2001-03-11) [lafaix]
655 */
656
657 typedef struct _FSYSFUNCTION
658 {
659 ULONG ulOrdinal;
660 ULONG ulType;
661 CHAR achFunctionName[256];
662 } FSYSFUNCTION, *PFSYSFUNCTION;
663
664 /*
665 *@@ FSYSRESOURCE:
666 *
667 *@@added V0.9.7 (2000-12-18) [lafaix]
668 */
669
670 typedef struct _FSYSRESOURCE
671 {
672 ULONG ulID; // resource ID
673 ULONG ulType; // resource type
674 ULONG ulSize; // resource size in bytes
675 ULONG ulFlag; // resource flags
676 } FSYSRESOURCE, *PFSYSRESOURCE;
677
678 // object/segment flags (in NE and LX)
679 #define OBJWRITE 0x0002L // Writeable Object
680 #define OBJDISCARD 0x0010L // Object is Discardable
681 #define OBJSHARED 0x0020L // Object is Shared
682 #define OBJPRELOAD 0x0040L // Object has preload pages
683
684 // resource flags
685 #define RNMOVE 0x0010 // Moveable resource
686 #define RNPURE 0x0020 // Pure (read-only) resource
687 #define RNPRELOAD 0x0040 // Preloaded resource
688 #define RNDISCARD 0xF000 // Discard priority level for resource
689
690 // EXE format
691 #define EXEFORMAT_OLDDOS 1
692 #define EXEFORMAT_NE 2
693 #define EXEFORMAT_PE 3
694 #define EXEFORMAT_LX 4
695 #define EXEFORMAT_TEXT_BATCH 5
696 #define EXEFORMAT_TEXT_REXX 6
697
698 // target OS (in NE and LX)
699 #define EXEOS_DOS3 1
700 #define EXEOS_DOS4 2 // there is a flag for this in NE
701 #define EXEOS_OS2 3
702 #define EXEOS_WIN16 4
703 #define EXEOS_WIN386 5 // according to IBM, there are flags
704 // for this both in NE and LX
705 #define EXEOS_WIN32 6
706
707 /*
708 *@@ EXECUTABLE:
709 * structure used with all the doshExec*
710 * functions.
711 */
712
713 typedef struct _EXECUTABLE
714 {
715 HFILE hfExe;
716
717 /* All the following fields are set by
718 doshExecOpen if NO_ERROR is returned. */
719
720 // old DOS EXE header;
721 // note: before 0.9.12, this was ALWAYS valid,
722 // but since we support NOSTUB executables now,
723 // there may be situations where this is NULL,
724 // but the other fields are valid! V0.9.12 (2001-05-03) [umoeller]
725 PDOSEXEHEADER pDosExeHeader;
726 ULONG cbDosExeHeader;
727
728 // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
729#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
730 PNEHEADER pNEHeader;
731 ULONG cbNEHeader;
732#endif
733
734 // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
735 PLXHEADER pLXHeader;
736 ULONG cbLXHeader;
737
738 // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
739#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
740 PPEHEADER pPEHeader;
741 ULONG cbPEHeader;
742#endif
743 // module analysis (always set):
744 ULONG ulExeFormat;
745 // one of:
746 // EXEFORMAT_OLDDOS 1
747 // EXEFORMAT_NE 2
748 // EXEFORMAT_PE 3
749 // EXEFORMAT_LX 4
750 // EXEFORMAT_TEXT_BATCH 5
751 // EXEFORMAT_TEXT_REXX 6
752
753 BOOL fLibrary, // TRUE if this is a DLL
754 f32Bits; // TRUE if this a 32-bits module
755
756 ULONG ulOS;
757 // target operating system as flagged in one of
758 // the EXE headers; one of:
759 // EXEOS_DOS3 1
760 // EXEOS_DOS4 2 // there is a flag for this in NE
761 // EXEOS_OS2 3
762 // EXEOS_WIN16 4
763 // EXEOS_WIN386 5 // according to IBM, there are flags
764 // for this both in NE and LX
765 // EXEOS_WIN32 6
766
767 /* The following fields are only set after
768 an extra call to doshExecQueryBldLevel. */
769
770 PSZ pszDescription;
771 // whole string (first non-res name tbl entry)
772 PSZ pszVendor;
773 // vendor substring (if IBM BLDLEVEL format)
774 PSZ pszVersion;
775 // version substring (if IBM BLDLEVEL format)
776
777 PSZ pszInfo;
778 // module info substring (if IBM BLDLEVEL format)
779
780 // if pszInfo is extended DESCRIPTION field, the following
781 // are set as well:
782 PSZ pszBuildDateTime,
783 pszBuildMachine,
784 pszASD,
785 pszLanguage,
786 pszCountry,
787 pszRevision,
788 pszUnknown,
789 pszFixpak;
790
791 } EXECUTABLE, *PEXECUTABLE;
792
793 APIRET doshExecOpen(const char* pcszExecutable,
794 PEXECUTABLE* ppExec);
795
796 APIRET doshExecClose(PEXECUTABLE pExec);
797
798 APIRET doshExecQueryBldLevel(PEXECUTABLE pExec);
799
800 APIRET doshExecQueryImportedModules(PEXECUTABLE pExec,
801 PFSYSMODULE *ppaModules,
802 PULONG pcModules);
803
804 APIRET doshExecFreeImportedModules(PFSYSMODULE paModules);
805
806 APIRET doshExecQueryExportedFunctions(PEXECUTABLE pExec,
807 PFSYSFUNCTION *ppaFunctions,
808 PULONG pcFunctions);
809
810 APIRET doshExecFreeExportedFunctions(PFSYSFUNCTION paFunctions);
811
812 APIRET doshExecQueryResources(PEXECUTABLE pExec,
813 PFSYSRESOURCE *ppaResources,
814 PULONG pcResources);
815
816 APIRET doshExecFreeResources(PFSYSRESOURCE paResources);
817
818 /********************************************************************
819 *
820 * Partition functions
821 *
822 ********************************************************************/
823
824 /*
825 *@@ LVMINFO:
826 * informational structure created by
827 * doshQueryLVMInfo.
828 *
829 *@@added V0.9.9 (2001-04-07) [umoeller]
830 */
831
832 typedef struct _LVMINFO
833 {
834 HMODULE hmodLVM;
835
836 } LVMINFO, *PLVMINFO;
837
838 #define DOSH_PARTITIONS_LIMIT 10
839
840 #define PAR_UNUSED 0x00 // Unused
841 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
842 #define PAR_XENIXROOT 0x02 // XENIX root
843 #define PAR_XENIXUSER 0x03 // XENIX user
844 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
845 #define PAR_EXTENDED 0x05 // Extended partition
846 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
847 #define PAR_HPFS 0x07 // OS/2 HPFS
848 #define PAR_AIXBOOT 0x08 // AIX bootable partition
849 #define PAR_AIXDATA 0x09 // AIX bootable partition
850 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
851 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
852 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
853 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
854 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
855 #define PAR_OPUS 0x10 // OPUS
856 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
857 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
858 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
859 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
860 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
861 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
862 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
863 #define PAR_THEOS 0x38 // THEOS
864 #define PAR_VENIX 0x40 // VENIX
865 #define PAR_RISCBOOT 0x41 // Personal RISC boot
866 #define PAR_SFS 0x42 // SFS
867 #define PAR_ONTRACK 0x50 // Ontrack
868 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
869 #define PAR_CPM 0x52 // CP/M
870 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
871 #define PAR_NOVELL_64 0x64 // Novell
872 #define PAR_NOVELL_65 0x65 // Novell
873 #define PAR_NOVELL_67 0x67 // Novell
874 #define PAR_NOVELL_68 0x68 // Novell
875 #define PAR_NOVELL_69 0x69 // Novell
876 #define PAR_PCIX 0x75 // PCIX
877 #define PAR_MINIX 0x80 // MINIX
878 #define PAR_LINUX 0x81 // Linux
879 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
880 #define PAR_LINUXFILE 0x83 // Linux File System
881 #define PAR_FREEBSD 0xA5 // FreeBSD
882 #define PAR_BBT 0xFF // BBT
883
884 // one-byte alignment
885 #pragma pack(1)
886
887 /*
888 *@@ PAR_INFO:
889 * partition table
890 */
891
892 typedef struct _PAR_INFO
893 {
894 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
895 BYTE bBeginHead; // partition begins at this head...
896 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
897 BYTE bFileSysCode; // file system type
898 BYTE bEndHead; // partition ends at this head...
899 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
900 ULONG lBeginAbsSec; // partition begins at this absolute sector #
901 ULONG lTotalSects; // total sectors in this partition
902 } PAR_INFO, *PPAR_INFO;
903
904 /*
905 *@@ MBR_INFO:
906 * master boot record table.
907 * This has the four primary partitions.
908 */
909
910 typedef struct _MBR_INFO // MBR
911 {
912 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
913 PAR_INFO sPrtnInfo[4]; // primary partition entries
914 USHORT wPrtnTblSig; // partition table signature (aa55H)
915 } MBR_INFO, *PMBR_INFO;
916
917 /*
918 *@@ SYS_INFO:
919 *
920 */
921
922 typedef struct _SYS_INFO
923 {
924 BYTE startable;
925 BYTE unknown[3];
926 BYTE bootable;
927 BYTE name[8];
928 BYTE reservd[3];
929 } SYS_INFO, *PSYS_INFO;
930
931 /*
932 *@@ SYE_INFO:
933 *
934 */
935
936 typedef struct _SYE_INFO
937 {
938 BYTE bootable;
939 BYTE name[8];
940 } SYE_INFO, *PSYE_INFO;
941
942 /*
943 *@@ EXT_INFO:
944 *
945 */
946
947 typedef struct _EXT_INFO
948 {
949 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
950 SYE_INFO sBmNames[4]; // System Names
951 BYTE bReserved[16]; // reserved
952 PAR_INFO sPrtnInfo[4]; // partitioms entrys
953 USHORT wPrtnTblSig; // partition table signature (aa55H)
954 } EXT_INFO, *PEXT_INFO;
955
956 typedef struct _PARTITIONINFO *PPARTITIONINFO;
957
958 /*
959 *@@ PARTITIONINFO:
960 * informational structure returned
961 * by doshGetPartitionsList. One of
962 * these items is created for each
963 * bootable partition.
964 */
965
966 typedef struct _PARTITIONINFO
967 {
968 BYTE bDisk; // drive number
969 CHAR cLetter; // probable drive letter or ' ' if none
970 BYTE bFSType; // file system type
971 CHAR szFSType[10]; // file system name (created by us)
972 BOOL fPrimary; // primary partition?
973 BOOL fBootable; // bootable by Boot Manager?
974 CHAR szBootName[9]; // Boot Manager name, if (fBootable)
975 ULONG ulSize; // size MBytes
976 PPARTITIONINFO pNext; // next info or NULL if last
977 } PARTITIONINFO;
978
979 UINT doshQueryDiskCount(VOID);
980
981 APIRET doshReadSector(USHORT disk,
982 void *buff,
983 USHORT head,
984 USHORT cylinder,
985 USHORT sector);
986
987 // restore original alignment
988 #pragma pack()
989
990 const char* doshType2FSName(unsigned char bFSType);
991
992 APIRET doshGetBootManager(USHORT *pusDisk,
993 USHORT *pusPart,
994 PAR_INFO *BmInfo);
995
996 typedef struct _PARTITIONSLIST
997 {
998 PLVMINFO pLVMInfo; // != NULL if LVM is installed
999
1000 // partitions array
1001 PPARTITIONINFO pPartitionInfo;
1002 USHORT cPartitions;
1003 } PARTITIONSLIST, *PPARTITIONSLIST;
1004
1005 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
1006 PUSHORT pusContext);
1007
1008 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
1009
1010 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
1011
1012 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
1013 PPARTITIONINFO *ppPartitionInfo,
1014 PUSHORT pcPartitions);
1015
1016 VOID doshFreeLVMInfo(PLVMINFO pInfo);
1017
1018#endif
1019
1020#if __cplusplus
1021}
1022#endif
1023
Note: See TracBrowser for help on using the repository browser.