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

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

misc changes

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