home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 24
/
CD_ASCQ_24_0995.iso
/
dos
/
prg
/
dsik205
/
dsik.dat
/
INCLUDE
/
PE.H
< prev
next >
Wrap
C/C++ Source or Header
|
1995-04-10
|
11KB
|
216 lines
/****************************************************************************
*
* Digital Sound Interface Kit (DSIK)
* Version 2.00
*
* by Carlos Hasan
*
* Filename: pe.h
* Version: Revision 1.0 (EXPERIMENTAL)
*
* Language: WATCOM C
* Environment: IBM PC (DOS/4GW)
*
* Description: Portable Executable (PE) DLL loader header file.
*
* Revision History:
* ----------------
*
* Revision 1.0 94/12/18 14:33:14 chv
* Initial revision
*
****************************************************************************/
#ifndef __PE_H
#define __PE_H
#ifndef __AUDIO_H
#include <audio.h>
#endif
/* DOS/PE executable signatures */
#define DOS_MAGIC 0x5A4D /* MS-DOS executable signature */
#define PE_MAGIC 0x4550 /* COFF/PE executable signature */
/* COFF file header bit flags */
#define PE_F_RELFLG 0x0001 /* relocation info stripped */
#define PE_F_EXEC 0x0002 /* file is executable */
#define PE_F_LNNO 0x0004 /* line number info stripped */
#define PE_F_LSYMS 0x0008 /* local symbols stripped */
#define PE_F_AR16WR 0x0040 /* 16-bit architecture */
#define PE_F_SWAPLO 0x0080 /* low bytes swapped */
#define PE_F_AR32WR 0x0100 /* 32-bit architecture */
#define PE_F_NODBG 0x0200 /* debug info stripped */
#define PE_F_SYS 0x1000 /* system executable */
#define PE_F_DLL 0x2000 /* dynamic link library */
#define PE_F_SWAPHI 0x8000 /* high bytes swapped */
/* COFF file header machine type */
#define PE_M_I386 0x014C /* intel 80386 machine */
#define PE_M_R3000 0x0162 /* RISC/3000 machine */
#define PE_M_R4000 0x0166 /* RISC/4000 machine */
#define PE_M_ALPHA 0x0184 /* ALPHA machine */
/* COFF section header names */
#define PE_TEXT ".text" /* text section name */
#define PE_DATA ".data" /* data section name */
#define PE_BSS ".bss" /* bss section name */
#define PE_IDATA ".idata" /* import data section name */
#define PE_EDATA ".edata" /* export data section name */
#define PE_RELOC ".reloc" /* relocation section name */
/* COFF section bit flags */
#define PE_S_TEXT 0x00000020 /* text segment */
#define PE_S_DATA 0x00000040 /* data segment */
#define PE_S_BSS 0x00000080 /* bss segment */
#define PE_S_DISCARD 0x02000000 /* section is discardable */
#define PE_S_CACHED 0x04000000 /* section cannot be cached */
#define PE_S_PAGEABLE 0x08000000 /* section is not pageable */
#define PE_S_SHARED 0x10000000 /* section is shared */
#define PE_S_EXEC 0x20000000 /* executable section */
#define PE_S_READ 0x40000000 /* readable section */
#define PE_S_WRITE 0x80000000 /* writable section */
/* COFF relocation section types */
#define PE_R_MASK 0xF000 /* relocation type bitmask */
#define PE_R_OFFMASK 0x0FFF /* relocation offset bitmask */
#define PE_R_ABS 0x0000 /* absolute relocation */
#define PE_R_HIGH 0x1000 /* high word relocation */
#define PE_R_LOW 0x2000 /* low word relocation */
#define PE_R_HIGHLOW 0x3000 /* 32-bit relocation */
/* basic data types */
typedef unsigned char BYTE; /* 8-bit integer value */
typedef unsigned short WORD; /* 16-bit integer value */
typedef unsigned long DWORD; /* 32-bit integer value */
/* MS-DOS executable header */
typedef struct {
WORD Magic; /* magic number */
WORD LastPage; /* bytes on last page of file */
WORD NumPages; /* pages in file */
WORD NumRels; /* number of relocations */
WORD HdrSize; /* size of header in paragraphs */
WORD MinAlloc; /* minimum extra paragraphs needed */
WORD MaxAlloc; /* maximum extra paragraphs needed */
WORD SS; /* initial (relative) SS value */
WORD SP; /* initial SP value */
WORD Checksum; /* file checksum */
WORD IP; /* initial IP value */
WORD CS; /* initial (relative) CS value */
WORD RelTabPtr; /* file address of relocation table */
WORD OvlNo; /* overlay number */
WORD Pad1[4]; /* reserved words */
WORD OEMId; /* OEM identifier */
WORD OEMInfo; /* OEM information */
WORD Pad2[10]; /* reserveddwords */
DWORD NewHdrPtr; /* file address of new exe header */
} DOSHDR;
/* COFF/PE file header */
typedef struct {
DWORD Magic; /* magic number */
WORD Machine; /* machine number */
WORD NumScns; /* number of sections */
DWORD TimeDate; /* time/date stamp */
DWORD SymTabPtr; /* symbol table pointer */
DWORD NumSyms; /* number of symbols */
WORD NtHdrSize; /* size of optional header */
WORD Flags; /* flags */
} PEHDR;
/* COFF/PE optional Windows NT file header */
typedef struct {
WORD Magic; /* type of file */
WORD VStamp; /* linker version stamp */
DWORD TextSize; /* text size in bytes */
DWORD DataSize; /* initialized data size in bytes */
DWORD BssSize; /* uninitialized data size in bytes */
DWORD EntryPtr; /* entry point */
DWORD TextBase; /* base of text used for this file */
DWORD DataBase; /* base of data used for this file */
DWORD ImageBase; /* base of the file image */
DWORD ScnAlign; /* section alignment */
DWORD FileAlign; /* file alignment */
DWORD OsVersion; /* operating system version stamp */
DWORD UserVersion; /* user version stamp */
DWORD SubSysVersion; /* subsystem version stamp */
DWORD Pad; /* reserved */
DWORD ImageSize; /* size of image file */
DWORD HdrSize; /* size of executable headers */
DWORD Checksum; /* file checksum */
WORD SubSys; /* subsystem identifier */
WORD DLLFlags; /* DLL flags */
DWORD StackReserve; /* size of stack reserve */
DWORD StackCommit; /* size of stack commit */
DWORD HeapReserve; /* size of heap reserve */
DWORD HeapCommit; /* size of heap commit */
DWORD LoaderFlags; /* loader flags */
DWORD NumRVAs; /* number of directory's entries */
} PENTHDR;
/* COFF/PE section header */
typedef struct {
char Name[8]; /* section name */
DWORD PAddr; /* physical address */
DWORD VAddr; /* virtual address */
DWORD Size; /* section size */
DWORD ScnPtr; /* section file ptr */
DWORD RelPtr; /* relocation file ptr */
DWORD LnNoPtr; /* line numbers file ptr */
WORD NumRels; /* number of relocation entries */
WORD NumLnNo; /* number of line number entries */
DWORD Flags; /* flags */
} PESCN;
/* COFF/PE relocation section header */
typedef struct {
DWORD VAddr; /* virtual address of item */
DWORD Size; /* item size in bytes */
WORD Type[1]; /* relocation type */
} PERLC;
/* COFF/PE export section directory */
typedef struct {
DWORD Flags; /* flags */
DWORD TimeDate; /* time/date stamp */
DWORD VStamp; /* version stamp */
DWORD NamePtr; /* module name pointer */
DWORD OrdBase; /* ordinal base number */
DWORD NumFuncs; /* number of functions */
DWORD NumNames; /* number of names */
DWORD FuncTabPtr; /* function table pointer */
DWORD NameTabPtr; /* name table pointer */
DWORD OrdTabPtr; /* ordinal table pointer */
} PEEXP;
/* COFF/PE DLL structures */
typedef struct {
PEHDR Hdr;
PENTHDR NtHdr;
PESCN *Scn;
} PEDLL;
typedef PEDLL *HANDLE;
typedef void *(*pascal FARPROC)(void);
#ifdef __cplusplus
extern "C" {
#endif
HANDLE dLoadLibrary(char *Filename);
void dFreeLibrary(HANDLE Handle);
FARPROC dGetProcAddress(HANDLE Handle, char *ProcName);
Driver *dLoadDriver(SoundCard *SC);
#ifdef __cplusplus
}
#endif
#pragma aux dLoadLibrary "_*" parm [eax];
#pragma aux dFreeLibrary "_*" parm [eax];
#pragma aux dGetProcAddress "_*" parm [eax] [edx];
#pragma aux dLoadDriver "_*" parm [eax];
#endif