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

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

Mistc. updates for WarpIN, new features.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 34.2 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 BOOL 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 */
240
241 typedef struct _DOSHPERFSYS
242 {
243 // output: no. of processors on the system
244 ULONG cProcessors;
245 // output: one CPU load for each CPU
246 PLONG palLoads;
247
248 // each of the following ptrs points to an array of cProcessors items
249 PCPUUTIL paCPUUtils; // CPUUTIL structures
250 double *padBusyPrev; // previous "busy" calculations
251 double *padTimePrev; // previous "time" calculations
252
253 // private stuff
254 HMODULE hmod;
255 BOOL fInitialized;
256 PFNDOSPERFSYSCALL pDosPerfSysCall;
257 } DOSHPERFSYS, *PDOSHPERFSYS;
258
259 APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
260
261 APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
262
263 APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
264
265 /* ******************************************************************
266 *
267 * File helpers
268 *
269 ********************************************************************/
270
271 PSZ doshGetExtension(const char *pcszFilename);
272
273 BOOL doshIsFileOnFAT(const char* pcszFileName);
274
275 APIRET doshIsValidFileName(const char* pcszFile,
276 BOOL fFullyQualified);
277
278 BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
279
280 ULONG doshQueryFileSize(HFILE hFile);
281
282 ULONG doshQueryPathSize(PSZ pszFile);
283
284 APIRET doshQueryPathAttr(const char* pcszFile,
285 PULONG pulAttr);
286
287 APIRET doshSetPathAttr(const char* pcszFile,
288 ULONG ulAttr);
289
290 APIRET doshLoadTextFile(const char *pcszFile,
291 PSZ* ppszContent);
292
293 PSZ doshCreateBackupFileName(const char* pszExisting);
294
295 APIRET doshWriteTextFile(const char* pszFile,
296 const char* pszContent,
297 PULONG pulWritten,
298 PSZ pszBackup);
299
300 HFILE doshOpenLogFile(const char* pcszFilename);
301
302 APIRET doshWriteToLogFile(HFILE hfLog, const char* pcsz);
303
304 /* ******************************************************************
305 *
306 * Directory helpers
307 *
308 ********************************************************************/
309
310 BOOL doshQueryDirExist(const char *pcszDir);
311
312 APIRET doshCreatePath(PSZ pszPath,
313 BOOL fHidden);
314
315 APIRET doshQueryCurrentDir(PSZ pszBuf);
316
317 APIRET doshSetCurrentDir(const char *pcszDir);
318
319 #define DOSHDELDIR_RECURSE 0x0001
320 #define DOSHDELDIR_DELETEFILES 0x0002
321
322 APIRET doshDeleteDir(const char *pcszDir,
323 ULONG flFlags,
324 PULONG pulDirs,
325 PULONG pulFiles);
326
327 /* ******************************************************************
328 *
329 * Process helpers
330 *
331 ********************************************************************/
332
333 APIRET doshFindExecutable(const char *pcszCommand,
334 PSZ pszExecutable,
335 ULONG cbExecutable,
336 const char **papcszExtensions,
337 ULONG cExtensions);
338
339 APIRET doshExecVIO(const char *pcszExecWithArgs,
340 PLONG plExitCode);
341
342 APIRET doshQuickStartSession(const char *pcszPath,
343 const char *pcszParams,
344 BOOL fForeground,
345 USHORT usPgmCtl,
346 BOOL fWait,
347 PULONG pulSID,
348 PPID ppid);
349
350 /* ******************************************************************
351 *
352 * Environment helpers
353 *
354 ********************************************************************/
355
356 /*
357 *@@ DOSENVIRONMENT:
358 * structure holding an array of environment
359 * variables (papszVars). This is initialized
360 * doshGetEnvironment,
361 *
362 *@@added V0.9.4 (2000-07-19) [umoeller]
363 */
364
365 typedef struct _DOSENVIRONMENT
366 {
367 ULONG cVars; // count of vars in papzVars
368 PSZ *papszVars; // array of PSZ's to environment strings (VAR=VALUE)
369 } DOSENVIRONMENT, *PDOSENVIRONMENT;
370
371 APIRET doshParseEnvironment(const char *pcszEnv,
372 PDOSENVIRONMENT pEnv);
373
374 APIRET doshGetEnvironment(PDOSENVIRONMENT pEnv);
375
376 PSZ* doshFindEnvironmentVar(PDOSENVIRONMENT pEnv,
377 PSZ pszVarName);
378
379 APIRET doshSetEnvironmentVar(PDOSENVIRONMENT pEnv,
380 PSZ pszNewEnv,
381 BOOL fAddFirst);
382
383 APIRET doshConvertEnvironment(PDOSENVIRONMENT pEnv,
384 PSZ *ppszEnv,
385 PULONG pulSize);
386
387 APIRET doshFreeEnvironment(PDOSENVIRONMENT pEnv);
388
389 /********************************************************************
390 *
391 * Executable helpers
392 *
393 ********************************************************************/
394
395 /*
396 *@@ DOSEXEHEADER:
397 * old DOS EXE header at offset 0
398 * in any EXE file.
399 *
400 *@@changed V0.9.7 (2000-12-20) [umoeller]: fixed NE offset
401 */
402
403 #pragma pack(1)
404 typedef struct _DOSEXEHEADER
405 {
406 USHORT usDosExeID; // 00: DOS exeid (0x5a4d)
407 USHORT usFileLenMod512; // 02: filelen mod 512
408 USHORT usFileLenDiv512; // 04: filelen div 512
409 USHORT usSegFix; // 06: count of segment adds to fix
410 USHORT usHdrPargCnt; // 08: size of header in paragrphs
411 USHORT usMinAddPargCnt; // 0a: minimum addtl paragraphs count
412 USHORT usMaxAddPargCnt; // 0c: max addtl paragraphs count
413 USHORT usSSStartup; // 0e: SS at startup
414 USHORT usSPStartup; // 10: SP at startup
415 USHORT usHdrChecksum; // 12: header checksum
416 USHORT usIPStartup; // 14: IP at startup
417 USHORT usCodeSegOfs; // 16: code segment offset from EXE start
418 USHORT usRelocTableOfs; // 18: reloc table ofs.header (Win: >= 0x40)
419 USHORT usOverlayNo; // 1a: overlay no.
420 ULONG ulLinkerVersion; // 1c: linker version (if 0x18 > 0x28)
421 ULONG ulUnused1; // 20: unused
422 ULONG ulUnused2; // 24: exe.h says the following fields are
423 ULONG ulUnused3; // 28: 'behavior bits'
424 ULONG ulUnused4; // 3c:
425 ULONG ulUnused5; // 30:
426 ULONG ulUnused6; // 34:
427 ULONG ulUnused7; // 38:
428 ULONG ulNewHeaderOfs; // new header ofs (if 0x18 > 0x40)
429 // fixed this from USHORT, thanks Martin Lafaix
430 // V0.9.7 (2000-12-20) [umoeller]
431 } DOSEXEHEADER, *PDOSEXEHEADER;
432
433 // NE and LX OS types
434 #define NEOS_UNKNOWN 0
435 #define NEOS_OS2 1 // Win16 SDK says: "reserved"...
436 #define NEOS_WIN16 2
437 #define NEOS_DOS4 3 // Win16 SDK says: "reserved"...
438 #define NEOS_WIN386 4 // Win16 SDK says: "reserved"...
439
440 /*
441 *@@ NEHEADER:
442 * linear executable (LX) header format,
443 * which comes after the DOS header in the
444 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
445 */
446
447 typedef struct _NEHEADER
448 {
449 CHAR achNE[2]; // 00: NE
450 BYTE bLinkerVersion; // 02: linker version
451 BYTE bLinkerRevision; // 03: linker revision
452 USHORT usEntryTblOfs; // 04: ofs from this to entrytable
453 USHORT usEntryTblLen; // 06: length of entrytable
454 ULONG ulChecksum; // 08: MS: reserved, OS/2: checksum
455 USHORT usFlags; // 0c: flags
456 USHORT usAutoDataSegNo; // 0e: auto-data seg no.
457 USHORT usInitlHeapSize; // 10: initl. heap size
458 USHORT usInitlStackSize; // 12: initl. stack size
459 ULONG ulCSIP; // 14: CS:IP
460 ULONG ulSSSP; // 18: SS:SP
461 USHORT usSegTblEntries; // 1c: segment tbl entry count
462 USHORT usModuleTblEntries; // 1e: module ref. table entry count
463 USHORT usNonResdTblLen; // 20: non-resd. name tbl length
464 USHORT usSegTblOfs; // 22: segment tbl ofs
465 USHORT usResTblOfs; // 24: resource tbl ofs
466 USHORT usResdNameTblOfs; // 26: resd. name tbl ofs
467 USHORT usModRefTblOfs; // 28: module ref. table ofs
468 USHORT usImportTblOfs; // 2a: import tbl ofs
469 ULONG ulNonResdTblOfs; // 2c: non-resd. name tbl ofs
470 USHORT usMoveableEntires; // 30: moveable entry pts. count
471 USHORT usLogicalSectShift; // 32: logcl. sector shift
472 USHORT usResSegmCount; // 34: resource segm. count
473 BYTE bTargetOS; // 36: target OS (NEOS_* flags)
474 BYTE bFlags2; // 37: addtl. flags
475 USHORT usFastLoadOfs; // 38: fast-load area ofs
476 USHORT usFastLoadLen; // 3a: fast-load area length
477 USHORT usReserved; // 3c: MS: 'reserved'
478 USHORT usReqWinVersion; // 3e: Win-only: min. Win version
479 } NEHEADER, *PNEHEADER;
480
481 /*
482 *@@ LXHEADER:
483 * linear executable (LX) header format,
484 * which comes after the DOS header in the
485 * EXE file (at DOSEXEHEADER.ulNewHeaderOfs).
486 */
487
488 typedef struct _LXHEADER
489 {
490 CHAR achLX[2]; // 00: LX or LE
491 /* this is "LX" for 32-bit OS/2 programs, but
492 "LE" for MS-DOS progs which use this format
493 (e.g. WINDOWS\SMARTDRV.EXE) */
494 BYTE fByteBigEndian; // 02: byte ordering (1 = big endian)
495 BYTE fWordBigEndian; // 03: word ordering (1 = big endian)
496 ULONG ulFormatLevel; // 04: format level
497 USHORT usCPU; // 08: CPU type
498 USHORT usTargetOS; // 0a: OS type (NEOS_* flags)
499 ULONG ulModuleVersion; // 0c: module version
500 ULONG ulFlags; // 10: module flags
501 ULONG ulPageCount; // 14: no. of pages in module
502 ULONG ulEIPRelObj; // 18: object to which EIP is relative
503 ULONG ulEIPEntryAddr; // 1c: EIP entry addr
504 ULONG ulESPObj; // 20: ESP object
505 ULONG ulESP; // 24: ESP
506 ULONG ulPageSize; // 28: page size (4K)
507 ULONG ulPageLeftShift; // 2c: page left-shift
508 ULONG ulFixupTblLen; // 30: fixup section total size
509 ULONG ulFixupTblChecksum; // 34: fixup section checksum
510 ULONG ulLoaderLen; // 38: size req. for loader section
511 ULONG ulLoaderChecksum; // 3c: loader section checksum
512 ULONG ulObjTblOfs; // 40: object table offset
513 ULONG ulObjCount; // 44: object count
514 ULONG ulObjPageTblOfs; // 48: object page table ofs
515 ULONG ulObjIterPagesOfs; // 4c: object iter pages ofs
516 ULONG ulResTblOfs; // 50: resource table ofs
517 ULONG ulResTblCnt; // 54: resource entry count
518 ULONG ulResdNameTblOfs; // 58: resident name tbl ofs
519 ULONG ulEntryTblOfs; // 5c: entry tbl ofs
520 ULONG ulModDirectivesOfs; // 60: module directives ofs
521 ULONG ulModDirectivesCnt; // 64: module directives count
522 ULONG ulFixupPagePageTblOfs;// 68: fixup page tbl ofs
523 ULONG ulFixupRecTblOfs; // 6c: fixup record tbl ofs
524 ULONG ulImportModTblOfs; // 70: import modl tbl ofs
525 ULONG ulImportModTblCnt; // 74: import modl tbl count
526 ULONG ulImportProcTblOfs; // 78: import proc tbl ofs
527 ULONG ulPerPageCSOfs; // 7c: per page checksum ofs
528 ULONG ulDataPagesOfs; // 80: data pages ofs
529 ULONG ulPreloadPagesCnt; // 84: preload pages count
530 ULONG ulNonResdNameTblOfs; // 88: non-resdnt name tbl ofs
531 ULONG ulNonResdNameTblLen; // 8c: non-resdnt name tbl length
532 ULONG ulNonResdNameTblCS; // 90: non-res name tbl checksum
533 ULONG ulAutoDataSegObjCnt; // 94: auto dataseg object count
534 ULONG ulDebugOfs; // 98: debug info ofs
535 ULONG ulDebugLen; // 9c: debug info length
536 ULONG ulInstancePrelCnt; // a0: instance preload count
537 ULONG ulinstanceDemdCnt; // a0: instance demand count
538 ULONG ulHeapSize16; // a8: heap size (16-bit)
539 ULONG ulStackSize; // ac: stack size
540 } LXHEADER, *PLXHEADER;
541
542 #pragma pack()
543
544 /*
545 *@@ FSYSMODULE:
546 *
547 *@@added V0.9.9 (2001-03-11) [lafaix]
548 */
549
550 typedef struct _FSYSMODULE
551 {
552 CHAR achModuleName[128];
553 } FSYSMODULE, *PFSYSMODULE;
554
555 /*
556 *@@ FSYSFUNCTION:
557 *
558 *@@added V0.9.9 (2001-03-11) [lafaix]
559 */
560
561 typedef struct _FSYSFUNCTION
562 {
563 ULONG ulOrdinal;
564 ULONG ulType;
565 CHAR achFunctionName[128];
566 } FSYSFUNCTION, *PFSYSFUNCTION;
567
568 /*
569 *@@ FSYSRESOURCE:
570 *
571 *@@added V0.9.7 (2000-12-18) [lafaix]
572 */
573
574 typedef struct _FSYSRESOURCE
575 {
576 ULONG ulID; // resource ID
577 ULONG ulType; // resource type
578 ULONG ulSize; // resource size in bytes
579 ULONG ulFlag; // resource flags
580 } FSYSRESOURCE, *PFSYSRESOURCE;
581
582 // object/segment flags (in NE and LX)
583 #define OBJWRITE 0x0002L // Writeable Object
584 #define OBJDISCARD 0x0010L // Object is Discardable
585 #define OBJSHARED 0x0020L // Object is Shared
586 #define OBJPRELOAD 0x0040L // Object has preload pages
587
588 // resource flags
589 #define RNMOVE 0x0010 // Moveable resource
590 #define RNPURE 0x0020 // Pure (read-only) resource
591 #define RNPRELOAD 0x0040 // Preloaded resource
592 #define RNDISCARD 0xF000 // Discard priority level for resource
593
594 // EXE format
595 #define EXEFORMAT_OLDDOS 1
596 #define EXEFORMAT_NE 2
597 #define EXEFORMAT_PE 3
598 #define EXEFORMAT_LX 4
599 #define EXEFORMAT_TEXT_BATCH 5
600 #define EXEFORMAT_TEXT_REXX 6
601
602 // target OS (in NE and LX)
603 #define EXEOS_DOS3 1
604 #define EXEOS_DOS4 2 // there is a flag for this in NE
605 #define EXEOS_OS2 3
606 #define EXEOS_WIN16 4
607 #define EXEOS_WIN386 5 // according to IBM, there are flags
608 // for this both in NE and LX
609 #define EXEOS_WIN32 6
610
611 /*
612 *@@ EXECUTABLE:
613 * structure used with all the doshExec*
614 * functions.
615 */
616
617 typedef struct _EXECUTABLE
618 {
619 HFILE hfExe;
620
621 /* All the following fields are set by
622 doshExecOpen if NO_ERROR is returned. */
623
624 // old DOS EXE header (always valid)
625 PDOSEXEHEADER pDosExeHeader;
626 ULONG cbDosExeHeader;
627
628 // New Executable (NE) header, if ulExeFormat == EXEFORMAT_NE
629 PNEHEADER pNEHeader;
630 ULONG cbNEHeader;
631
632 // Linear Executable (LX) header, if ulExeFormat == EXEFORMAT_LX
633 PLXHEADER pLXHeader;
634 ULONG cbLXHeader;
635
636 // module analysis (always set):
637 ULONG ulExeFormat;
638 // one of:
639 // EXEFORMAT_OLDDOS 1
640 // EXEFORMAT_NE 2
641 // EXEFORMAT_PE 3
642 // EXEFORMAT_LX 4
643 // EXEFORMAT_TEXT_BATCH 5
644 // EXEFORMAT_TEXT_REXX 6
645
646 BOOL fLibrary,
647 f32Bits;
648 ULONG ulOS;
649 // one of:
650 // EXEOS_DOS3 1
651 // EXEOS_DOS4 2 // there is a flag for this in NE
652 // EXEOS_OS2 3
653 // EXEOS_WIN16 4
654 // EXEOS_WIN386 5 // according to IBM, there are flags
655 // // for this both in NE and LX
656 // EXEOS_WIN32 6
657
658 /* The following fields are only set after
659 an extra call to doshExecQueryBldLevel. */
660
661 PSZ pszDescription; // whole string (first non-res name tbl entry)
662 PSZ pszVendor; // vendor substring (if IBM BLDLEVEL format)
663 PSZ pszVersion; // version substring (if IBM BLDLEVEL format)
664 PSZ pszInfo; // module info substring (if IBM BLDLEVEL format)
665
666 } EXECUTABLE, *PEXECUTABLE;
667
668 APIRET doshExecOpen(const char* pcszExecutable,
669 PEXECUTABLE* ppExec);
670
671 APIRET doshExecClose(PEXECUTABLE pExec);
672
673 APIRET doshExecQueryBldLevel(PEXECUTABLE pExec);
674
675 PFSYSRESOURCE doshExecQueryResources(PEXECUTABLE pExec,
676 PULONG pcResources);
677
678 APIRET doshExecFreeResources(PFSYSRESOURCE paResources);
679
680 PFSYSMODULE doshExecQueryImportedModules(PEXECUTABLE pExec,
681 PULONG pcModules);
682
683 APIRET doshExecFreeImportedModules(PFSYSMODULE paModules);
684
685 PFSYSFUNCTION doshExecQueryExportedFunctions(PEXECUTABLE pExec,
686 PULONG pcFunctions);
687
688 APIRET doshExecFreeExportedFunctions(PFSYSFUNCTION paFunctions);
689
690 /********************************************************************
691 *
692 * Partition functions
693 *
694 ********************************************************************/
695
696 #define DOSH_PARTITIONS_LIMIT 10
697
698 #define PAR_UNUSED 0x00 // Unused
699 #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
700 #define PAR_XENIXROOT 0x02 // XENIX root
701 #define PAR_XENIXUSER 0x03 // XENIX user
702 #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
703 #define PAR_EXTENDED 0x05 // Extended partition
704 #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
705 #define PAR_HPFS 0x07 // OS/2 HPFS
706 #define PAR_AIXBOOT 0x08 // AIX bootable partition
707 #define PAR_AIXDATA 0x09 // AIX bootable partition
708 #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
709 #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
710 #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
711 #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
712 #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
713 #define PAR_OPUS 0x10 // OPUS
714 #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
715 #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
716 #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
717 #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
718 #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
719 #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
720 #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
721 #define PAR_THEOS 0x38 // THEOS
722 #define PAR_VENIX 0x40 // VENIX
723 #define PAR_RISCBOOT 0x41 // Personal RISC boot
724 #define PAR_SFS 0x42 // SFS
725 #define PAR_ONTRACK 0x50 // Ontrack
726 #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
727 #define PAR_CPM 0x52 // CP/M
728 #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
729 #define PAR_NOVELL_64 0x64 // Novell
730 #define PAR_NOVELL_65 0x65 // Novell
731 #define PAR_NOVELL_67 0x67 // Novell
732 #define PAR_NOVELL_68 0x68 // Novell
733 #define PAR_NOVELL_69 0x69 // Novell
734 #define PAR_PCIX 0x75 // PCIX
735 #define PAR_MINIX 0x80 // MINIX
736 #define PAR_LINUX 0x81 // Linux
737 #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
738 #define PAR_LINUXFILE 0x83 // Linux File System
739 #define PAR_FREEBSD 0xA5 // FreeBSD
740 #define PAR_BBT 0xFF // BBT
741
742 // one-byte alignment
743 #pragma pack(1)
744
745 /*
746 *@@ PAR_INFO:
747 * partition table
748 */
749
750 typedef struct _PAR_INFO
751 {
752 BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
753 BYTE bBeginHead; // partition begins at this head...
754 USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
755 BYTE bFileSysCode; // file system type
756 BYTE bEndHead; // partition ends at this head...
757 USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
758 ULONG lBeginAbsSec; // partition begins at this absolute sector #
759 ULONG lTotalSects; // total sectors in this partition
760 } PAR_INFO, *PPAR_INFO;
761
762 /*
763 *@@ MBR_INFO:
764 * master boot record table.
765 * This has the four primary partitions.
766 */
767
768 typedef struct _MBR_INFO // MBR
769 {
770 BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
771 PAR_INFO sPrtnInfo[4]; // primary partition entries
772 USHORT wPrtnTblSig; // partition table signature (aa55H)
773 } MBR_INFO, *PMBR_INFO;
774
775 /*
776 *@@ SYS_INFO:
777 *
778 */
779
780 typedef struct _SYS_INFO // š­ä®à¬ æšï ® § £à㊠¥¬®© ášá⥬¥
781 {
782 BYTE startable; // & 0x80
783 BYTE unknown[3]; // unknown
784 BYTE bootable; // & 0x01
785 BYTE name[8]; // š¬ï à §€¥« 
786 BYTE reservd[3]; // unknown
787 } SYS_INFO, *PSYS_INFO;
788
789 /*
790 *@@ SYE_INFO:
791 *
792 */
793
794 typedef struct _SYE_INFO // š­ä®à¬ æšï ® § £à㊠¥¬®© ášá⥬¥ €«ï
795 { // à áèšà¥­­ëå à §€¥«®¢
796 BYTE bootable; // & 0x01
797 BYTE name[8]; // š¬ï à §€¥« 
798 } SYE_INFO, *PSYE_INFO;
799
800 /*
801 *@@ EXT_INFO:
802 *
803 */
804
805 typedef struct _EXT_INFO
806 {
807 BYTE aBootCode[0x18A]; // abBootCode master boot executable code
808 SYE_INFO sBmNames[4]; // System Names
809 BYTE bReserved[16]; // reserved
810 PAR_INFO sPrtnInfo[4]; // partitioms entrys
811 USHORT wPrtnTblSig; // partition table signature (aa55H)
812 } EXT_INFO, *PEXT_INFO;
813
814 typedef struct _PARTITIONINFO *PPARTITIONINFO;
815
816 /*
817 *@@ PARTITIONINFO:
818 * informational structure returned
819 * by doshGetPartitionsList. One of
820 * these items is created for each
821 * bootable partition.
822 */
823
824 typedef struct _PARTITIONINFO
825 {
826 BYTE bDisk; // drive number
827 CHAR cLetter; // probable drive letter or ' ' if none
828 BYTE bFSType; // file system type
829 CHAR szFSType[10]; // file system name (created by us)
830 BOOL fPrimary; // primary partition?
831 BOOL fBootable; // bootable by Boot Manager?
832 CHAR szBootName[9]; // Boot Manager name, if (fBootable)
833 ULONG ulSize; // size MBytes
834 PPARTITIONINFO pNext; // next info or NULL if last
835 } PARTITIONINFO;
836
837 UINT doshQueryDiskCount(VOID);
838
839 APIRET doshReadSector(USHORT disk,
840 void *buff,
841 USHORT head,
842 USHORT cylinder,
843 USHORT sector);
844
845 // restore original alignment
846 #pragma pack()
847
848 char* doshType2FSName(unsigned char bFSType);
849
850 APIRET doshGetBootManager(USHORT *pusDisk,
851 USHORT *pusPart,
852 PAR_INFO *BmInfo);
853
854 APIRET doshGetPartitionsList(PPARTITIONINFO *ppPartitionInfo,
855 PUSHORT pusPartitionCount,
856 PUSHORT pusContext);
857
858 APIRET doshFreePartitionsList(PPARTITIONINFO pPartitionInfo);
859
860#endif
861
862#if __cplusplus
863}
864#endif
865
Note: See TracBrowser for help on using the repository browser.