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

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

New folder sorting. Updated folder refresh. Misc other changes.

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