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

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