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

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

More updates.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 42.4 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 cbInitial, // intial file size on open (can be 0 if new)
369 cbCurrent; // current file size (raised with each write)
370 } XFILE, *PXFILE;
371
372 #define XOPEN_READ_EXISTING 1
373 #define XOPEN_READWRITE_APPEND 2
374 #define XOPEN_READWRITE_NEW 3
375
376 APIRET doshOpen(PCSZ pcszFilename,
377 ULONG ulOpenMode,
378 PULONG pcbFile,
379 PXFILE *ppFile);
380
381 APIRET doshWrite(PXFILE pFile,
382 PCSZ pcsz,
383 ULONG cb);
384
385 APIRET doshWriteLogEntry(PXFILE pFile,
386 const char* pcszFormat,
387 ...);
388
389 APIRET doshClose(PXFILE *ppFile);
390
391 APIRET doshLoadTextFile(PCSZ pcszFile,
392 PSZ* ppszContent);
393
394 PSZ doshCreateBackupFileName(const char* pszExisting);
395
396 APIRET doshCreateTempFileName(PSZ pszTempFileName,
397 PCSZ pcszDir,
398 PCSZ pcszPrefix,
399 PCSZ pcszExt);
400
401 APIRET doshWriteTextFile(const char* pszFile,
402 const char* pszContent,
403 PULONG pulWritten,
404 PSZ pszBackup);
405
406
407 /* ******************************************************************
408 *
409 * Directory helpers
410 *
411 ********************************************************************/
412
413 BOOL doshQueryDirExist(PCSZ pcszDir);
414
415 APIRET doshCreatePath(PCSZ pcszPath,
416 BOOL fHidden);
417
418 APIRET doshQueryCurrentDir(PSZ pszBuf);
419
420 APIRET doshSetCurrentDir(PCSZ pcszDir);
421
422 #define DOSHDELDIR_RECURSE 0x0001
423 #define DOSHDELDIR_DELETEFILES 0x0002
424
425 APIRET doshDeleteDir(PCSZ pcszDir,
426 ULONG flFlags,
427 PULONG pulDirs,
428 PULONG pulFiles);
429
430 /* ******************************************************************
431 *
432 * Process helpers
433 *
434 ********************************************************************/
435
436 ULONG XWPENTRY doshMyPID(VOID);
437 typedef ULONG XWPENTRY DOSHMYPID(VOID);
438 typedef DOSHMYPID *PDOSHMYPID;
439
440 ULONG XWPENTRY doshMyTID(VOID);
441 typedef ULONG XWPENTRY DOSHMYTID(VOID);
442 typedef DOSHMYTID *PDOSHMYTID;
443
444 APIRET doshExecVIO(PCSZ pcszExecWithArgs,
445 PLONG plExitCode);
446
447 APIRET doshQuickStartSession(PCSZ pcszPath,
448 PCSZ pcszParams,
449 BOOL fForeground,
450 USHORT usPgmCtl,
451 BOOL fWait,
452 PULONG pulSID,
453 PPID ppid,
454 PUSHORT pusReturn);
455
456 /********************************************************************
457 *
458 * Executable helpers
459 *
460 ********************************************************************/
461
462 /*
463 *@@ DOSEXEHEADER:
464 * old DOS EXE header at offset 0
465 * in any EXE file.
466 *
467 *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
468 *@@changed V0.9.9 (2001-04-06) [lafaix]: additional fields defined
469 */
470
471 #pragma pack(1)
472 typedef struct _DOSEXEHEADER
473 {
474 USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
475 USHORT usFileLenMod512; // 02: filelen mod 512
476 USHORT usFileLenDiv512; // 04: filelen div 512
477 USHORT usSegFix; // 06: count of segment adds to fix
478 USHORT usHdrPargCnt; // 08: size of header in paragrphs
479 USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
480 USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
481 USHORT usSSStartup; // 0e: SS at startup
482 USHORT usSPStartup; // 10: SP at startup
483 USHORT usHdrChecksum; // 12: header checksum
484 USHORT usIPStartup; // 14: IP at startup
485 USHORT usCodeSegOfs; // 16: code segment offset from EXE start
486 USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40)
487 USHORT usOverlayNo; // 1a: overlay no.
488 USHORT usLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
489 USHORT usUnused1; // 1e: unused
490 USHORT usBehaviorBits; // 20: exe.h says this field contains
491 // 'behavior bits'
492 USHORT usUnused2; // 22: unused
493 USHORT usOEMIdentifier; // 24: OEM identifier
494 USHORT usOEMInformation; // 26: OEM information
495 ULONG ulUnused3; // 28:
496 ULONG ulUnused4; // 2c:
497 ULONG ulUnused5; // 30:
498 ULONG ulUnused6; // 34:
499 ULONG ulUnused7; // 38:
500 ULONG ulNewHeaderOfs; // 3c: new header ofs (if 0x18 > 0x40)
501 // fixed this from USHORT, thanks Martin Lafaix
502 // V0.9.7 (2000-12-20) [umoeller]
503 } DOSEXEHEADER, *PDOSEXEHEADER;
504
505 // NE and LX OS types
506 #define NEOS_UNKNOWN 0
507 #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
508 #define NEOS_WIN16 2
509 #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
510 #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
511
512 /*
513 *@@ NEHEADER:
514 * linear executable (LX) header format,
515 * which comes after the DOS header in the
516 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
517 *
518 *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed typo in usMoveableEntries
519 */
520
521 typedef struct _NEHEADER
522 {
523 CHAR achNE[2]; // 00: "NE" magic
524 BYTE bLinkerVersion; // 02: linker version
525 BYTE bLinkerRevision; // 03: linker revision
526 USHORT usEntryTblOfs; // 04: ofs from this to entrytable
527 USHORT usEntryTblLen; // 06: length of entrytable
528 ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum
529 USHORT usFlags; // 0c: flags
530 USHORT usAutoDataSegNo; // 0e: auto-data seg no.
531 USHORT usInitlHeapSize; // 10: initl. heap size
532 USHORT usInitlStackSize; // 12: initl. stack size
533 ULONG ulCSIP; // 14: CS:IP
534 ULONG ulSSSP; // 18: SS:SP
535 USHORT usSegTblEntries; // 1c: segment tbl entry count
536 USHORT usModuleTblEntries; // 1e: module ref. table entry count
537 USHORT usNonResdTblLen; // 20: non-resd. name tbl length
538 USHORT usSegTblOfs; // 22: segment tbl ofs
539 USHORT usResTblOfs; // 24: resource tbl ofs
540 USHORT usResdNameTblOfs; // 26: resd. name tbl ofs
541 USHORT usModRefTblOfs; // 28: module ref. table ofs
542 USHORT usImportTblOfs; // 2a: import tbl ofs
543 ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs
544 USHORT usMoveableEntries; // 30: moveable entry pts. count
545 USHORT usLogicalSectShift; // 32: logcl. sector shift
546 USHORT usResSegmCount; // 34: resource segm. count
547 BYTE bTargetOS; // 36: target OS (NEOS_* flags)
548 BYTE bFlags2; // 37: addtl. flags
549 USHORT usFastLoadOfs; // 38: fast-load area ofs
550 USHORT usFastLoadLen; // 3a: fast-load area length
551 USHORT usReserved; // 3c: MS: 'reserved'
552 USHORT usReqWinVersion; // 3e: Win-only: min. Win version
553 } NEHEADER, *PNEHEADER;
554
555 /*
556 *@@ LXHEADER:
557 * linear executable (LX) header format,
558 * which comes after the DOS header in the
559 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
560 *
561 *@@changed V0.9.9 (2001-04-06) [lafaix]: fixed auto data object and ulinstanceDemdCnt
562 */
563
564 typedef struct _LXHEADER
565 {
566 CHAR achLX[2]; // 00: "LX" or "LE" magic
567 // this is "LX" for 32-bit OS/2 programs, but
568 // "LE" for MS-DOS progs which use this format
569 // (e.g. WINDOWS\SMARTDRV.EXE). IBM says the
570 // LE format was never released and superceded
571 // by LX... I am unsure what the differences are.
572 BYTE fByteBigEndian; // 02: byte ordering (1 = big endian)
573 BYTE fWordBigEndian; // 03: word ordering (1 = big endian)
574 ULONG ulFormatLevel; // 04: format level
575 USHORT usCPU; // 08: CPU type
576 USHORT usTargetOS; // 0a: OS type (NEOS_* flags)
577 ULONG ulModuleVersion; // 0c: module version
578 ULONG ulFlags; // 10: module flags
579 ULONG ulPageCount; // 14: no. of pages in module
580 ULONG ulEIPRelObj; // 18: object to which EIP is relative
581 ULONG ulEIPEntryAddr; // 1c: EIP entry addr
582 ULONG ulESPObj; // 20: ESP object
583 ULONG ulESP; // 24: ESP
584 ULONG ulPageSize; // 28: page size (4K)
585 ULONG ulPageLeftShift; // 2c: page left-shift
586 ULONG ulFixupTblLen; // 30: fixup section total size
587 ULONG ulFixupTblChecksum; // 34: fixup section checksum
588 ULONG ulLoaderLen; // 38: size req. for loader section
589 ULONG ulLoaderChecksum; // 3c: loader section checksum
590 ULONG ulObjTblOfs; // 40: object table offset
591 ULONG ulObjCount; // 44: object count
592 ULONG ulObjPageTblOfs; // 48: object page table ofs
593 ULONG ulObjIterPagesOfs; // 4c: object iter pages ofs
594 ULONG ulResTblOfs; // 50: resource table ofs
595 ULONG ulResTblCnt; // 54: resource entry count
596 ULONG ulResdNameTblOfs; // 58: resident name tbl ofs
597 ULONG ulEntryTblOfs; // 5c: entry tbl ofs
598 ULONG ulModDirectivesOfs; // 60: module directives ofs
599 ULONG ulModDirectivesCnt; // 64: module directives count
600 ULONG ulFixupPagePageTblOfs;// 68: fixup page tbl ofs
601 ULONG ulFixupRecTblOfs; // 6c: fixup record tbl ofs
602 ULONG ulImportModTblOfs; // 70: import modl tbl ofs
603 ULONG ulImportModTblCnt; // 74: import modl tbl count
604 ULONG ulImportProcTblOfs; // 78: import proc tbl ofs
605 ULONG ulPerPageCSOfs; // 7c: per page checksum ofs
606 ULONG ulDataPagesOfs; // 80: data pages ofs
607 ULONG ulPreloadPagesCnt; // 84: preload pages count
608 ULONG ulNonResdNameTblOfs; // 88: non-resdnt name tbl ofs
609 ULONG ulNonResdNameTblLen; // 8c: non-resdnt name tbl length
610 ULONG ulNonResdNameTblCS; // 90: non-res name tbl checksum
611 ULONG ulAutoDataSegObj; // 94: auto dataseg object
612 ULONG ulDebugOfs; // 98: debug info ofs
613 ULONG ulDebugLen; // 9c: debug info length
614 ULONG ulInstancePrelCnt; // a0: instance preload count
615 ULONG ulInstanceDemdCnt; // a0: instance demand count
616 ULONG ulHeapSize16; // a8: heap size (16-bit)
617 ULONG ulStackSize; // ac: stack size
618 } LXHEADER, *PLXHEADER;
619
620 /*
621 *@@ PEHEADER:
622 * portable executable (PE) header format,
623 * which comes after the DOS header in the
624 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
625 *
626 *@@added V0.9.10 (2001-04-08) [lafaix]
627 */
628
629 typedef struct _PEHEADER
630 {
631 // standard header
632 ULONG ulSignature; // 00: 'P', 'E', 0, 0
633 USHORT usCPU; // 04: CPU type
634 USHORT usObjCount; // 06: number of object entries
635 ULONG ulTimeDateStamp; // 08: store the time and date the
636 // file was created or modified
637 // by the linker
638 ULONG ulReserved1; // 0c: reserved
639 ULONG ulReserved2; // 10: reserved
640 USHORT usHeaderSize; // 14: number of remaining bytes after
641 // usImageFlags
642 USHORT usImageFlags; // 16: flags bits for the image
643
644 // optional header (always present in valid Win32 files)
645 USHORT usReserved3; // 18: reserved
646 USHORT usLinkerMajor; // 1a: linker major version number
647 USHORT usLinkerMinor; // 1c: linker minor version number
648 USHORT usReserved4; // 1e: reserved
649 ULONG ulReserved5; // 20: reserved
650 ULONG ulReserved6; // 24: reserved
651 ULONG ulEntryPointRVA; // 28: entry point relative virtual address
652 ULONG ulReserved7; // 2c: reserved
653 ULONG ulReserved8; // 30: reserved
654 ULONG ulImageBase; // 34:
655 ULONG ulObjectAlign; // 38:
656 ULONG ulFileAlign; // 3c:
657 USHORT usOSMajor; // 40:
658 USHORT usOSMinor; // 42:
659 USHORT usUserMajor; // 44:
660 USHORT usUserMinor; // 46:
661 USHORT usSubSystemMajor; // 48:
662 USHORT usSubSystemMinor; // 4a:
663 ULONG ulReserved9; // 4c: reserved
664 ULONG ulImageSize; // 50:
665 ULONG ulHeaderSize; // 54:
666 ULONG ulFileChecksum; // 58:
667 USHORT usSubSystem; // 5c:
668 USHORT usDLLFlags; // 5e:
669 ULONG ulStackReserveSize; // 60:
670 ULONG ulStackCommitSize; // 64:
671 ULONG ulHeapReserveSize; // 68:
672 ULONG ulHeapCommitSize; // 6c:
673 ULONG ulReserved10; // 70: reserved
674 ULONG ulInterestingRVACount;// 74:
675 ULONG aulRVASize[1]; // 78: array of RVA/Size entries
676 } PEHEADER, *PPEHEADER;
677
678 #pragma pack()
679
680 /*
681 *@@ FSYSMODULE:
682 *
683 *@@added V0.9.9 (2001-03-11) [lafaix]
684 */
685
686 typedef struct _FSYSMODULE
687 {
688 CHAR achModuleName[256];
689 } FSYSMODULE, *PFSYSMODULE;
690
691 /*
692 *@@ FSYSFUNCTION:
693 *
694 *@@added V0.9.9 (2001-03-11) [lafaix]
695 */
696
697 typedef struct _FSYSFUNCTION
698 {
699 ULONG ulOrdinal;
700 ULONG ulType;
701 CHAR achFunctionName[256];
702 } FSYSFUNCTION, *PFSYSFUNCTION;
703
704 /*
705 *@@ FSYSRESOURCE:
706 *
707 *@@added V0.9.7 (2000-12-18) [lafaix]
708 */
709
710 typedef struct _FSYSRESOURCE
711 {
712 ULONG ulID; // resource ID
713 ULONG ulType; // resource type
714 ULONG ulSize; // resource size in bytes
715 ULONG ulFlag; // resource flags
716 } FSYSRESOURCE, *PFSYSRESOURCE;
717
718 // object/segment flags (in NE and LX)
719 #define OBJWRITE 0x0002L // Writeable Object
720 #define OBJDISCARD 0x0010L // Object is Discardable
721 #define OBJSHARED 0x0020L // Object is Shared
722 #define OBJPRELOAD 0x0040L // Object has preload pages
723
724 // resource flags
725 #define RNMOVE 0x0010 // Moveable resource
726 #define RNPURE 0x0020 // Pure (read-only) resource
727 #define RNPRELOAD 0x0040 // Preloaded resource
728 #define RNDISCARD 0xF000 // Discard priority level for resource
729
730 // EXE format
731 #define EXEFORMAT_OLDDOS 1
732 #define EXEFORMAT_NE 2
733 #define EXEFORMAT_PE 3
734 #define EXEFORMAT_LX 4
735 #define EXEFORMAT_TEXT_BATCH 5
736 #define EXEFORMAT_TEXT_REXX 6
737
738 // target OS (in NE and LX)
739 #define EXEOS_DOS3 1
740 #define EXEOS_DOS4 2 // there is a flag for this in NE
741 #define EXEOS_OS2 3
742 #define EXEOS_WIN16 4
743 #define EXEOS_WIN386 5 // according to IBM, there are flags
744 // for this both in NE and LX
745 #define EXEOS_WIN32 6
746
747 /*
748 *@@ EXECUTABLE:
749 * structure used with all the doshExec*
750 * functions.
751 */
752
753 typedef struct _EXECUTABLE
754 {
755 HFILE hfExe;
756
757 /* All the following fields are set by
758 doshExecOpen if NO_ERROR is returned. */
759
760 // old DOS EXE header;
761 // note: before 0.9.12, this was ALWAYS valid,
762 // but since we support NOSTUB executables now,
763 // there may be situations where this is NULL,
764 // but the other fields are valid! V0.9.12 (2001-05-03) [umoeller]
765 PDOSEXEHEADER pDosExeHeader;
766 ULONG cbDosExeHeader;
767
768 // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
769#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
770 PNEHEADER pNEHeader;
771 ULONG cbNEHeader;
772#endif
773
774 // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
775 PLXHEADER pLXHeader;
776 ULONG cbLXHeader;
777
778 // Portable Executable (PE) header, if ulExeFormat == EXEFORMAT_PE
779#ifndef __STRIP_DOWN_EXECUTABLE__ // for mini stubs in warpin, to reduce code size
780 PPEHEADER pPEHeader;
781 ULONG cbPEHeader;
782#endif
783 // module analysis (always set):
784 ULONG ulExeFormat;
785 // one of:
786 // EXEFORMAT_OLDDOS 1
787 // EXEFORMAT_NE 2
788 // EXEFORMAT_PE 3
789 // EXEFORMAT_LX 4
790 // EXEFORMAT_TEXT_BATCH 5
791 // EXEFORMAT_TEXT_REXX 6
792
793 BOOL fLibrary, // TRUE if this is a DLL
794 f32Bits; // TRUE if this a 32-bits module
795
796 ULONG ulOS;
797 // target operating system as flagged in one of
798 // the EXE headers; one of:
799 // EXEOS_DOS3 1
800 // EXEOS_DOS4 2 // there is a flag for this in NE
801 // EXEOS_OS2 3
802 // EXEOS_WIN16 4
803 // EXEOS_WIN386 5 // according to IBM, there are flags
804 // for this both in NE and LX
805 // EXEOS_WIN32 6
806
807 /* The following fields are only set after
808 an extra call to doshExecQueryBldLevel. */
809
810 PSZ pszDescription;
811 // whole string (first non-res name tbl entry)
812 PSZ pszVendor;
813 // vendor substring (if IBM BLDLEVEL format)
814 PSZ pszVersion;
815 // version substring (if IBM BLDLEVEL format)
816
817 PSZ pszInfo;
818 // module info substring (if IBM BLDLEVEL format)
819
820 // if pszInfo is extended DESCRIPTION field, the following
821 // are set as well:
822 PSZ pszBuildDateTime,
823 pszBuildMachine,
824 pszASD,
825 pszLanguage,
826 pszCountry,
827 pszRevision,
828 pszUnknown,
829 pszFixpak;
830
831 } EXECUTABLE, *PEXECUTABLE;
832
833 APIRET doshExecOpen(const char* pcszExecutable,
834 PEXECUTABLE* ppExec);
835
836 APIRET doshExecClose(PEXECUTABLE pExec);
837
838 APIRET doshExecQueryBldLevel(PEXECUTABLE pExec);
839
840 APIRET doshExecQueryImportedModules(PEXECUTABLE pExec,
841 PFSYSMODULE *ppaModules,
842 PULONG pcModules);
843
844 APIRET doshExecFreeImportedModules(PFSYSMODULE paModules);
845
846 APIRET doshExecQueryExportedFunctions(PEXECUTABLE pExec,
847 PFSYSFUNCTION *ppaFunctions,
848 PULONG pcFunctions);
849
850 APIRET doshExecFreeExportedFunctions(PFSYSFUNCTION paFunctions);
851
852 APIRET doshExecQueryResources(PEXECUTABLE pExec,
853 PFSYSRESOURCE *ppaResources,
854 PULONG pcResources);
855
856 APIRET doshExecFreeResources(PFSYSRESOURCE paResources);
857
858 APIRET doshSearchPath(PCSZ pcszPath,
859 PCSZ pcszFile,
860 PSZ pszExecutable,
861 ULONG cbExecutable);
862
863 APIRET doshFindExecutable(PCSZ pcszCommand,
864 PSZ pszExecutable,
865 ULONG cbExecutable,
866 PCSZ *papcszExtensions,
867 ULONG cExtensions);
868
869 /********************************************************************
870 *
871 * Partition functions
872 *
873 ********************************************************************/
874
875 /*
876 *@@ LVMINFO:
877 * informational structure created by
878 * doshQueryLVMInfo.
879 *
880 *@@added V0.9.9 (2001-04-07) [umoeller]
881 */
882
883 typedef struct _LVMINFO
884 {
885 HMODULE hmodLVM;
886
887 } LVMINFO, *PLVMINFO;
888
889 /* #define DOSH_PARTITIONS_LIMIT 10
890
891 #define PAR_UNUSED 0x00 // Unused
892 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
893 #define PAR_XENIXROOT 0x02 // XENIX root
894 #define PAR_XENIXUSER 0x03 // XENIX user
895 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
896 #define PAR_EXTENDED 0x05 // Extended partition
897 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
898 #define PAR_HPFS 0x07 // OS/2 HPFS
899 #define PAR_AIXBOOT 0x08 // AIX bootable partition
900 #define PAR_AIXDATA 0x09 // AIX bootable partition
901 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
902 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
903 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
904 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
905 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
906 #define PAR_OPUS 0x10 // OPUS
907 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
908 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
909 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
910 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
911 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
912 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
913 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
914 #define PAR_THEOS 0x38 // THEOS
915 #define PAR_VENIX 0x40 // VENIX
916 #define PAR_RISCBOOT 0x41 // Personal RISC boot
917 #define PAR_SFS 0x42 // SFS
918 #define PAR_ONTRACK 0x50 // Ontrack
919 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
920 #define PAR_CPM 0x52 // CP/M
921 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
922 #define PAR_NOVELL_64 0x64 // Novell
923 #define PAR_NOVELL_65 0x65 // Novell
924 #define PAR_NOVELL_67 0x67 // Novell
925 #define PAR_NOVELL_68 0x68 // Novell
926 #define PAR_NOVELL_69 0x69 // Novell
927 #define PAR_PCIX 0x75 // PCIX
928 #define PAR_MINIX 0x80 // MINIX
929 #define PAR_LINUX 0x81 // Linux
930 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
931 #define PAR_LINUXFILE 0x83 // Linux File System
932 #define PAR_FREEBSD 0xA5 // FreeBSD
933 #define PAR_BBT 0xFF // BBT
934 */
935
936 // one-byte alignment
937 #pragma pack(1)
938
939 /*
940 *@@ PAR_INFO:
941 * partition table
942 */
943
944 typedef struct _PAR_INFO
945 {
946 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
947 BYTE bBeginHead; // partition begins at this head...
948 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
949 BYTE bFileSysCode; // file system type
950 BYTE bEndHead; // partition ends at this head...
951 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
952 ULONG lBeginAbsSec; // partition begins at this absolute sector #
953 ULONG lTotalSects; // total sectors in this partition
954 } PAR_INFO, *PPAR_INFO;
955
956 /*
957 *@@ MBR_INFO:
958 * master boot record table.
959 * This has the four primary partitions.
960 */
961
962 typedef struct _MBR_INFO // MBR
963 {
964 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
965 PAR_INFO sPrtnInfo[4]; // primary partition entries
966 USHORT wPrtnTblSig; // partition table signature (aa55H)
967 } MBR_INFO, *PMBR_INFO;
968
969 /*
970 *@@ SYS_INFO:
971 *
972 */
973
974 typedef struct _SYS_INFO
975 {
976 BYTE startable;
977 BYTE unknown[3];
978 BYTE bootable;
979 BYTE name[8];
980 BYTE reservd[3];
981 } SYS_INFO, *PSYS_INFO;
982
983 /*
984 *@@ SYE_INFO:
985 *
986 */
987
988 typedef struct _SYE_INFO
989 {
990 BYTE bootable;
991 BYTE name[8];
992 } SYE_INFO, *PSYE_INFO;
993
994 /*
995 *@@ EXT_INFO:
996 *
997 */
998
999 typedef struct _EXT_INFO
1000 {
1001 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
1002 SYE_INFO sBmNames[4]; // System Names
1003 BYTE bReserved[16]; // reserved
1004 PAR_INFO sPrtnInfo[4]; // partitioms entrys
1005 USHORT wPrtnTblSig; // partition table signature (aa55H)
1006 } EXT_INFO, *PEXT_INFO;
1007
1008 typedef struct _PARTITIONINFO *PPARTITIONINFO;
1009
1010 /*
1011 *@@ PARTITIONINFO:
1012 * informational structure returned
1013 * by doshGetPartitionsList. One of
1014 * these items is created for each
1015 * bootable partition.
1016 */
1017
1018 typedef struct _PARTITIONINFO
1019 {
1020 BYTE bDisk; // drive number
1021 CHAR cLetter; // probable drive letter or ' ' if none
1022 BYTE bFSType; // file system type
1023 PCSZ pcszFSType; // file system name (as returned by
1024 // doshType2FSName, can be NULL!)
1025 BOOL fPrimary; // primary partition?
1026 BOOL fBootable; // bootable by Boot Manager?
1027 CHAR szBootName[9]; // Boot Manager name, if (fBootable)
1028 ULONG ulSize; // size MBytes
1029 PPARTITIONINFO pNext; // next info or NULL if last
1030 } PARTITIONINFO;
1031
1032 UINT doshQueryDiskCount(VOID);
1033
1034 APIRET doshReadSector(USHORT disk,
1035 void *buff,
1036 USHORT head,
1037 USHORT cylinder,
1038 USHORT sector);
1039
1040 // restore original alignment
1041 #pragma pack()
1042
1043 const char* doshType2FSName(unsigned char bFSType);
1044
1045 APIRET doshGetBootManager(USHORT *pusDisk,
1046 USHORT *pusPart,
1047 PAR_INFO *BmInfo);
1048
1049 typedef struct _PARTITIONSLIST
1050 {
1051 PLVMINFO pLVMInfo; // != NULL if LVM is installed
1052
1053 // partitions array
1054 PPARTITIONINFO pPartitionInfo;
1055 USHORT cPartitions;
1056 } PARTITIONSLIST, *PPARTITIONSLIST;
1057
1058 APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
1059 PUSHORT pusContext);
1060
1061 APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
1062
1063 APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
1064
1065 APIRET doshReadLVMPartitions(PLVMINFO pInfo,
1066 PPARTITIONINFO *ppPartitionInfo,
1067 PUSHORT pcPartitions);
1068
1069 VOID doshFreeLVMInfo(PLVMINFO pInfo);
1070
1071#endif
1072
1073#if __cplusplus
1074}
1075#endif
1076
Note: See TracBrowser for help on using the repository browser.