mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-12-26 10:45:47 +01:00
library: move win32 definitions to win_lib.c
This commit is contained in:
parent
25f07ddb97
commit
a5258bea65
@ -16,128 +16,8 @@ GNU General Public License for more details.
|
||||
#ifndef LIBRARY_H
|
||||
#define LIBRARY_H
|
||||
|
||||
#define DOS_SIGNATURE 0x5A4D // MZ
|
||||
#define NT_SIGNATURE 0x00004550 // PE00
|
||||
#define NUMBER_OF_DIRECTORY_ENTRIES 16
|
||||
#define MAX_LIBRARY_EXPORTS 4096
|
||||
|
||||
#ifndef IMAGE_SIZEOF_BASE_RELOCATION
|
||||
#define IMAGE_SIZEOF_BASE_RELOCATION ( sizeof( IMAGE_BASE_RELOCATION ))
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// dos .exe header
|
||||
word e_magic; // magic number
|
||||
word e_cblp; // bytes on last page of file
|
||||
word e_cp; // pages in file
|
||||
word e_crlc; // relocations
|
||||
word e_cparhdr; // size of header in paragraphs
|
||||
word e_minalloc; // minimum extra paragraphs needed
|
||||
word e_maxalloc; // maximum extra paragraphs needed
|
||||
word e_ss; // initial (relative) SS value
|
||||
word e_sp; // initial SP value
|
||||
word e_csum; // checksum
|
||||
word e_ip; // initial IP value
|
||||
word e_cs; // initial (relative) CS value
|
||||
word e_lfarlc; // file address of relocation table
|
||||
word e_ovno; // overlay number
|
||||
word e_res[4]; // reserved words
|
||||
word e_oemid; // OEM identifier (for e_oeminfo)
|
||||
word e_oeminfo; // OEM information; e_oemid specific
|
||||
word e_res2[10]; // reserved words
|
||||
long e_lfanew; // file address of new exe header
|
||||
} DOS_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// win .exe header
|
||||
word Machine;
|
||||
word NumberOfSections;
|
||||
dword TimeDateStamp;
|
||||
dword PointerToSymbolTable;
|
||||
dword NumberOfSymbols;
|
||||
word SizeOfOptionalHeader;
|
||||
word Characteristics;
|
||||
} PE_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte Name[8]; // dos name length
|
||||
|
||||
union
|
||||
{
|
||||
dword PhysicalAddress;
|
||||
dword VirtualSize;
|
||||
} Misc;
|
||||
|
||||
dword VirtualAddress;
|
||||
dword SizeOfRawData;
|
||||
dword PointerToRawData;
|
||||
dword PointerToRelocations;
|
||||
dword PointerToLinenumbers;
|
||||
word NumberOfRelocations;
|
||||
word NumberOfLinenumbers;
|
||||
dword Characteristics;
|
||||
} SECTION_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dword VirtualAddress;
|
||||
dword Size;
|
||||
} DATA_DIRECTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word Magic;
|
||||
byte MajorLinkerVersion;
|
||||
byte MinorLinkerVersion;
|
||||
dword SizeOfCode;
|
||||
dword SizeOfInitializedData;
|
||||
dword SizeOfUninitializedData;
|
||||
dword AddressOfEntryPoint;
|
||||
dword BaseOfCode;
|
||||
dword BaseOfData;
|
||||
dword ImageBase;
|
||||
dword SectionAlignment;
|
||||
dword FileAlignment;
|
||||
word MajorOperatingSystemVersion;
|
||||
word MinorOperatingSystemVersion;
|
||||
word MajorImageVersion;
|
||||
word MinorImageVersion;
|
||||
word MajorSubsystemVersion;
|
||||
word MinorSubsystemVersion;
|
||||
dword Win32VersionValue;
|
||||
dword SizeOfImage;
|
||||
dword SizeOfHeaders;
|
||||
dword CheckSum;
|
||||
word Subsystem;
|
||||
word DllCharacteristics;
|
||||
dword SizeOfStackReserve;
|
||||
dword SizeOfStackCommit;
|
||||
dword SizeOfHeapReserve;
|
||||
dword SizeOfHeapCommit;
|
||||
dword LoaderFlags;
|
||||
dword NumberOfRvaAndSizes;
|
||||
|
||||
DATA_DIRECTORY DataDirectory[NUMBER_OF_DIRECTORY_ENTRIES];
|
||||
} OPTIONAL_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dword Characteristics;
|
||||
dword TimeDateStamp;
|
||||
word MajorVersion;
|
||||
word MinorVersion;
|
||||
dword Name;
|
||||
dword Base;
|
||||
dword NumberOfFunctions;
|
||||
dword NumberOfNames;
|
||||
dword AddressOfFunctions; // RVA from base of image
|
||||
dword AddressOfNames; // RVA from base of image
|
||||
dword AddressOfNameOrdinals; // RVA from base of image
|
||||
} EXPORT_DIRECTORY;
|
||||
|
||||
typedef struct dll_user_s
|
||||
{
|
||||
void *hInstance; // instance handle
|
||||
@ -146,7 +26,7 @@ typedef struct dll_user_s
|
||||
char dllName[32]; // for debug messages
|
||||
string fullPath, shortPath; // actual dll paths
|
||||
|
||||
// ordinals stuff
|
||||
// ordinals stuff, valid only on Win32
|
||||
word *ordinals;
|
||||
dword *funcs;
|
||||
char *names[MAX_LIBRARY_EXPORTS]; // max 4096 exports supported
|
||||
|
@ -94,6 +94,106 @@ const char *COM_NameForFunction( void *hInstance, void *function )
|
||||
---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define DOS_SIGNATURE 0x5A4D // MZ
|
||||
#define NT_SIGNATURE 0x00004550 // PE00
|
||||
#define NUMBER_OF_DIRECTORY_ENTRIES 16
|
||||
#ifndef IMAGE_SIZEOF_BASE_RELOCATION
|
||||
#define IMAGE_SIZEOF_BASE_RELOCATION ( sizeof( IMAGE_BASE_RELOCATION ))
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// dos .exe header
|
||||
word e_magic; // magic number
|
||||
word e_cblp; // bytes on last page of file
|
||||
word e_cp; // pages in file
|
||||
word e_crlc; // relocations
|
||||
word e_cparhdr; // size of header in paragraphs
|
||||
word e_minalloc; // minimum extra paragraphs needed
|
||||
word e_maxalloc; // maximum extra paragraphs needed
|
||||
word e_ss; // initial (relative) SS value
|
||||
word e_sp; // initial SP value
|
||||
word e_csum; // checksum
|
||||
word e_ip; // initial IP value
|
||||
word e_cs; // initial (relative) CS value
|
||||
word e_lfarlc; // file address of relocation table
|
||||
word e_ovno; // overlay number
|
||||
word e_res[4]; // reserved words
|
||||
word e_oemid; // OEM identifier (for e_oeminfo)
|
||||
word e_oeminfo; // OEM information; e_oemid specific
|
||||
word e_res2[10]; // reserved words
|
||||
long e_lfanew; // file address of new exe header
|
||||
} DOS_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// win .exe header
|
||||
word Machine;
|
||||
word NumberOfSections;
|
||||
dword TimeDateStamp;
|
||||
dword PointerToSymbolTable;
|
||||
dword NumberOfSymbols;
|
||||
word SizeOfOptionalHeader;
|
||||
word Characteristics;
|
||||
} PE_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dword VirtualAddress;
|
||||
dword Size;
|
||||
} DATA_DIRECTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
word Magic;
|
||||
byte MajorLinkerVersion;
|
||||
byte MinorLinkerVersion;
|
||||
dword SizeOfCode;
|
||||
dword SizeOfInitializedData;
|
||||
dword SizeOfUninitializedData;
|
||||
dword AddressOfEntryPoint;
|
||||
dword BaseOfCode;
|
||||
dword BaseOfData;
|
||||
dword ImageBase;
|
||||
dword SectionAlignment;
|
||||
dword FileAlignment;
|
||||
word MajorOperatingSystemVersion;
|
||||
word MinorOperatingSystemVersion;
|
||||
word MajorImageVersion;
|
||||
word MinorImageVersion;
|
||||
word MajorSubsystemVersion;
|
||||
word MinorSubsystemVersion;
|
||||
dword Win32VersionValue;
|
||||
dword SizeOfImage;
|
||||
dword SizeOfHeaders;
|
||||
dword CheckSum;
|
||||
word Subsystem;
|
||||
word DllCharacteristics;
|
||||
dword SizeOfStackReserve;
|
||||
dword SizeOfStackCommit;
|
||||
dword SizeOfHeapReserve;
|
||||
dword SizeOfHeapCommit;
|
||||
dword LoaderFlags;
|
||||
dword NumberOfRvaAndSizes;
|
||||
|
||||
DATA_DIRECTORY DataDirectory[NUMBER_OF_DIRECTORY_ENTRIES];
|
||||
} OPTIONAL_HEADER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
dword Characteristics;
|
||||
dword TimeDateStamp;
|
||||
word MajorVersion;
|
||||
word MinorVersion;
|
||||
dword Name;
|
||||
dword Base;
|
||||
dword NumberOfFunctions;
|
||||
dword NumberOfNames;
|
||||
dword AddressOfFunctions; // RVA from base of image
|
||||
dword AddressOfNames; // RVA from base of image
|
||||
dword AddressOfNameOrdinals; // RVA from base of image
|
||||
} EXPORT_DIRECTORY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PIMAGE_NT_HEADERS headers;
|
||||
@ -103,6 +203,26 @@ typedef struct
|
||||
int initialized;
|
||||
} MEMORYMODULE, *PMEMORYMODULE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
byte Name[8]; // dos name length
|
||||
|
||||
union
|
||||
{
|
||||
dword PhysicalAddress;
|
||||
dword VirtualSize;
|
||||
} Misc;
|
||||
|
||||
dword VirtualAddress;
|
||||
dword SizeOfRawData;
|
||||
dword PointerToRawData;
|
||||
dword PointerToRelocations;
|
||||
dword PointerToLinenumbers;
|
||||
word NumberOfRelocations;
|
||||
word NumberOfLinenumbers;
|
||||
dword Characteristics;
|
||||
} SECTION_HEADER;
|
||||
|
||||
// Protection flags for memory pages (Executable, Readable, Writeable)
|
||||
static int ProtectionFlags[2][2][2] =
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user