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

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