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

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