Commit 180a088b authored by Alexandre Julliard's avatar Alexandre Julliard

Moved PE header definitions to winnt.h where they belong.

parent 4bdf4af1
......@@ -12,7 +12,6 @@
#include "module.h"
#include "debugger.h"
#include "win.h"
#include "peexe.h"
#include "pe_image.h"
ldt_copy_entry ldt_copy[LDT_SIZE];
......
......@@ -10,7 +10,6 @@
#include <stdio.h>
#include <string.h>
#include "neexe.h"
#include "peexe.h"
#include "module.h"
#include "file.h"
#include "debugger.h"
......
......@@ -25,7 +25,7 @@
#endif
#include "debugger.h"
#include "neexe.h"
#include "peexe.h"
#include "pe_image.h"
#include "file.h"
typedef struct {
......@@ -719,23 +719,6 @@ struct codeview_linetab_hdr
};
/*
* A simple macro that tells us whether a given COFF symbol is a
* function or not.
*/
#define N_TMASK 0x0030
#define IMAGE_SYM_DTYPE_FUNCTION 2
#define N_BTSHFT 4
#define ISFCN(x) (((x) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT))
/*
* This is what we are looking for in the COFF symbols.
*/
#define IMAGE_SYM_CLASS_EXTERNAL 0x2
#define IMAGE_SYM_CLASS_STATIC 0x3
#define IMAGE_SYM_CLASS_FILE 0x67
static
struct datatype * DEBUG_GetCVType(unsigned int typeno)
{
......
......@@ -19,7 +19,6 @@
#include <unistd.h>
#include "pe_image.h"
#include "peexe.h"
#include "debugger.h"
#define NR_TYPE_HASH 521
......
......@@ -101,12 +101,12 @@ static DWORD SHELL_GetResourceTable(HFILE hFile, LPBYTE *retptr)
if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
return 0;
size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
size = ne_header.ne_restab - ne_header.ne_rsrctab;
if( size > sizeof(NE_TYPEINFO) )
{ pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
if( pTypeInfo )
{ _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
{ _llseek(hFile, mz_header.e_lfanew+ne_header.ne_rsrctab, SEEK_SET);
if( _lread( hFile, (char*)pTypeInfo, size) != size )
{ HeapFree( GetProcessHeap(), 0, pTypeInfo);
pTypeInfo = NULL;
......
......@@ -684,12 +684,12 @@ static DWORD SHELL_GetResourceTable(HFILE hFile,LPBYTE *retptr)
if (ne_header.ne_magic != IMAGE_OS2_SIGNATURE)
return 0;
size = ne_header.rname_tab_offset - ne_header.resource_tab_offset;
size = ne_header.ne_restab - ne_header.ne_rsrctab;
if( size > sizeof(NE_TYPEINFO) )
{ pTypeInfo = (BYTE*)HeapAlloc( GetProcessHeap(), 0, size);
if( pTypeInfo )
{ _llseek(hFile, mz_header.e_lfanew+ne_header.resource_tab_offset, SEEK_SET);
{ _llseek(hFile, mz_header.e_lfanew+ne_header.ne_rsrctab, SEEK_SET);
if( _lread( hFile, (char*)pTypeInfo, size) != size )
{ HeapFree( GetProcessHeap(), 0, pTypeInfo);
pTypeInfo = NULL;
......
......@@ -67,7 +67,7 @@ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
nehdoffset = LZSeek( lzfd, 0, SEEK_CUR );
if ( sizeof(nehd) != LZRead( lzfd, &nehd, sizeof(nehd) ) ) return 0;
resTabSize = nehd.rname_tab_offset - nehd.resource_tab_offset;
resTabSize = nehd.ne_restab - nehd.ne_rsrctab;
if ( !resTabSize )
{
TRACE("No resources in NE dll\n" );
......@@ -78,7 +78,7 @@ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
resTab = HeapAlloc( GetProcessHeap(), 0, resTabSize );
if ( !resTab ) return FALSE;
LZSeek( lzfd, nehd.resource_tab_offset + nehdoffset, SEEK_SET );
LZSeek( lzfd, nehd.ne_rsrctab + nehdoffset, SEEK_SET );
if ( resTabSize != LZRead( lzfd, resTab, resTabSize ) )
{
HeapFree( GetProcessHeap(), 0, resTab );
......
......@@ -62,18 +62,6 @@ typedef enum _IMAGEHLP_STATUS_REASON {
#define SPLITSYM_EXTRACT_ALL 0x00000002
#define SPLITSYM_SYMBOLPATH_IS_SRC 0x00000004
#define IMAGE_DEBUG_TYPE_UNKNOWN 0
#define IMAGE_DEBUG_TYPE_COFF 1
#define IMAGE_DEBUG_TYPE_CODEVIEW 2
#define IMAGE_DEBUG_TYPE_FPO 3
#define IMAGE_DEBUG_TYPE_MISC 4
#define IMAGE_DEBUG_TYPE_EXCEPTION 5
#define IMAGE_DEBUG_TYPE_FIXUP 6
#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC 7
#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC 8
#define IMAGE_DEBUG_TYPE_BORLAND 9
#define IMAGE_DEBUG_TYPE_RESERVED10 10
#define FRAME_FPO 0
#define FRAME_TRAP 1
#define FRAME_TSS 2
......@@ -136,97 +124,10 @@ typedef enum _SYM_TYPE {
#define CBA_SYMBOLS_UNLOADED 0x00000004
#define CBA_DUPLICATE_SYMBOL 0x00000005
#define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
#define IMAGE_OS2_SIGNATURE 0x454E /* NE */
#define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
#define IMAGE_VXD_SIGNATURE 0x454C /* LE */
#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
/***********************************************************************
* Structures
*/
typedef struct _IMAGE_DATA_DIRECTORY {
DWORD VirtualAddress;
DWORD Size;
} IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY;
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES 16
typedef struct _IMAGE_OPTIONAL_HEADER {
/* Standard fields */
WORD Magic;
BYTE MajorLinkerVersion;
BYTE MinorLinkerVersion;
DWORD SizeOfCode;
DWORD SizeOfInitializedData;
DWORD SizeOfUninitializedData;
DWORD AddressOfEntryPoint;
DWORD BaseOfCode;
DWORD BaseOfData;
/* NT additional fields */
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;
IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES];
} IMAGE_OPTIONAL_HEADER, *PIMAGE_OPTIONAL_HEADER;
typedef struct _IMAGE_FILE_HEADER {
WORD Machine;
WORD NumberOfSections;
DWORD TimeDateStamp;
DWORD PointerToSymbolTable;
DWORD NumberOfSymbols;
WORD SizeOfOptionalHeader;
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
typedef struct _IMAGE_NT_HEADERS {
DWORD Signature;
IMAGE_FILE_HEADER FileHeader;
IMAGE_OPTIONAL_HEADER OptionalHeader;
} IMAGE_NT_HEADERS, *PIMAGE_NT_HEADERS;
#define IMAGE_SIZEOF_SHORT_NAME 8
typedef struct _IMAGE_SECTION_HEADER {
BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
union {
DWORD PhysicalAddress;
DWORD VirtualSize;
} Misc;
DWORD VirtualAddress;
DWORD SizeOfRawData;
DWORD PointerToRawData;
DWORD PointerToRelocations;
DWORD PointerToLinenumbers;
WORD NumberOfRelocations;
WORD NumberOfLinenumbers;
DWORD Characteristics;
} IMAGE_SECTION_HEADER, *PIMAGE_SECTION_HEADER;
typedef struct _LOADED_IMAGE {
LPSTR ModuleName;
HANDLE hFile;
......@@ -242,27 +143,6 @@ typedef struct _LOADED_IMAGE {
ULONG SizeOfImage;
} LOADED_IMAGE, *PLOADED_IMAGE;
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY {
DWORD Characteristics;
DWORD TimeDateStamp;
WORD MajorVersion;
WORD MinorVersion;
DWORD GlobalFlagsClear;
DWORD GlobalFlagsSet;
DWORD CriticalSectionDefaultTimeout;
DWORD DeCommitFreeBlockThreshold;
DWORD DeCommitTotalFreeThreshold;
PVOID LockPrefixTable;
DWORD MaximumAllocationSize;
DWORD VirtualMemoryThreshold;
DWORD ProcessHeapFlags;
DWORD ProcessAffinityMask;
WORD CSDVersion;
WORD Reserved1;
PVOID EditList;
DWORD Reserved[1];
} IMAGE_LOAD_CONFIG_DIRECTORY, *PIMAGE_LOAD_CONFIG_DIRECTORY;
typedef struct _WIN_CERTIFICATE {
DWORD dwLength;
WORD wRevision; /* WIN_CERT_REVISON_xxx */
......@@ -277,47 +157,6 @@ typedef struct _API_VERSION {
USHORT Reserved;
} API_VERSION, *PAPI_VERSION;
typedef struct _IMAGE_FUNCTION_ENTRY {
DWORD StartingAddress;
DWORD EndingAddress;
DWORD EndOfPrologue;
} IMAGE_FUNCTION_ENTRY, *PIMAGE_FUNCTION_ENTRY;
typedef struct _IMAGE_DEBUG_DIRECTORY {
DWORD Characteristics;
DWORD TimeDateStamp;
WORD MajorVersion;
WORD MinorVersion;
DWORD Type;
DWORD SizeOfData;
DWORD AddressOfRawData;
DWORD PointerToRawData;
} IMAGE_DEBUG_DIRECTORY, *PIMAGE_DEBUG_DIRECTORY;
typedef struct _IMAGE_COFF_SYMBOLS_HEADER {
DWORD NumberOfSymbols;
DWORD LvaToFirstSymbol;
DWORD NumberOfLinenumbers;
DWORD LvaToFirstLinenumber;
DWORD RvaToFirstByteOfCode;
DWORD RvaToLastByteOfCode;
DWORD RvaToFirstByteOfData;
DWORD RvaToLastByteOfData;
} IMAGE_COFF_SYMBOLS_HEADER, *PIMAGE_COFF_SYMBOLS_HEADER;
typedef struct _FPO_DATA {
DWORD ulOffStart;
DWORD cbProcSize;
DWORD cdwLocals;
WORD cdwParams;
unsigned cbProlog : 8;
unsigned cbRegs : 3;
unsigned fHasSEH : 1;
unsigned fUseBP : 1;
unsigned reserved : 1;
unsigned cbFrame : 2;
} FPO_DATA, *PFPO_DATA;
typedef struct _IMAGE_DEBUG_INFORMATION {
LIST_ENTRY List;
DWORD Size;
......@@ -436,115 +275,6 @@ typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
ULONG SelectedSymbol;
} IMAGEHLP_DUPLICATE_SYMBOL, *PIMAGEHLP_DUPLICATE_SYMBOL;
typedef struct _IMAGE_DOS_HEADER {
WORD e_magic;
WORD e_cblp;
WORD e_cp;
WORD e_crlc;
WORD e_cparhdr;
WORD e_minalloc;
WORD e_maxalloc;
WORD e_ss;
WORD e_sp;
WORD e_csum;
WORD e_ip;
WORD e_cs;
WORD e_lfarlc;
WORD e_ovno;
WORD e_res[4];
WORD e_oemid;
WORD e_oeminfo;
WORD e_res2[10];
LONG e_lfanew;
} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
typedef struct _IMAGE_OS2_HEADER {
WORD ne_magic;
CHAR ne_ver;
CHAR ne_rev;
WORD ne_enttab;
WORD ne_cbenttab;
LONG ne_crc;
WORD ne_flags;
WORD ne_autodata;
WORD ne_heap;
WORD ne_stack;
LONG ne_csip;
LONG ne_sssp;
WORD ne_cseg;
WORD ne_cmod;
WORD ne_cbnrestab;
WORD ne_segtab;
WORD ne_rsrctab;
WORD ne_restab;
WORD ne_modtab;
WORD ne_imptab;
LONG ne_nrestab;
WORD ne_cmovent;
WORD ne_align;
WORD ne_cres;
BYTE ne_exetyp;
BYTE ne_flagsothers;
WORD ne_pretthunks;
WORD ne_psegrefbytes;
WORD ne_swaparea;
WORD ne_expver;
} IMAGE_OS2_HEADER, *PIMAGE_OS2_HEADER;
typedef struct _IMAGE_VXD_HEADER {
WORD e32_magic;
BYTE e32_border;
BYTE e32_worder;
DWORD e32_level;
WORD e32_cpu;
WORD e32_os;
DWORD e32_ver;
DWORD e32_mflags;
DWORD e32_mpages;
DWORD e32_startobj;
DWORD e32_eip;
DWORD e32_stackobj;
DWORD e32_esp;
DWORD e32_pagesize;
DWORD e32_lastpagesize;
DWORD e32_fixupsize;
DWORD e32_fixupsum;
DWORD e32_ldrsize;
DWORD e32_ldrsum;
DWORD e32_objtab;
DWORD e32_objcnt;
DWORD e32_objmap;
DWORD e32_itermap;
DWORD e32_rsrctab;
DWORD e32_rsrccnt;
DWORD e32_restab;
DWORD e32_enttab;
DWORD e32_dirtab;
DWORD e32_dircnt;
DWORD e32_fpagetab;
DWORD e32_frectab;
DWORD e32_impmod;
DWORD e32_impmodcnt;
DWORD e32_impproc;
DWORD e32_pagesum;
DWORD e32_datapage;
DWORD e32_preload;
DWORD e32_nrestab;
DWORD e32_cbnrestab;
DWORD e32_nressum;
DWORD e32_autodata;
DWORD e32_debuginfo;
DWORD e32_debuglen;
DWORD e32_instpreload;
DWORD e32_instdemand;
DWORD e32_heapsize;
BYTE e32_res3[12];
DWORD e32_winresoff;
DWORD e32_winreslen;
WORD e32_devid;
WORD e32_ddkver;
} IMAGE_VXD_HEADER, *PIMAGE_VXD_HEADER;
/***********************************************************************
* Callbacks
*/
......@@ -821,6 +551,3 @@ extern HANDLE IMAGEHLP_hHeap;
#endif /* defined(__cplusplus) */
#endif /* __WINE_IMAGEHLP_H */
......@@ -7,81 +7,6 @@
#include "windef.h"
/*
* Old MZ header for DOS programs.
* We check only the magic and the e_lfanew offset to the new executable
* header.
*/
typedef struct
{
WORD e_magic; /* 00: MZ Header signature */
WORD e_cblp; /* 02: Bytes on last page of file */
WORD e_cp; /* 04: Pages in file */
WORD e_crlc; /* 06: Relocations */
WORD e_cparhdr; /* 08: Size of header in paragraphs */
WORD e_minalloc; /* 0a: Minimum extra paragraphs needed */
WORD e_maxalloc; /* 0c: Maximum extra paragraphs needed */
WORD e_ss; /* 0e: Initial (relative) SS value */
WORD e_sp; /* 10: Initial SP value */
WORD e_csum; /* 12: Checksum */
WORD e_ip; /* 14: Initial IP value */
WORD e_cs; /* 16: Initial (relative) CS value */
WORD e_lfarlc; /* 18: File address of relocation table */
WORD e_ovno; /* 1a: Overlay number */
WORD e_res[4]; /* 1c: Reserved words */
WORD e_oemid; /* 24: OEM identifier (for e_oeminfo) */
WORD e_oeminfo; /* 26: OEM information; e_oemid specific */
WORD e_res2[10]; /* 28: Reserved words */
DWORD e_lfanew; /* 3c: Offset to extended header */
} IMAGE_DOS_HEADER,*PIMAGE_DOS_HEADER;
#define IMAGE_DOS_SIGNATURE 0x5A4D /* MZ */
#define IMAGE_OS2_SIGNATURE 0x454E /* NE */
#define IMAGE_OS2_SIGNATURE_LE 0x454C /* LE */
#define IMAGE_OS2_SIGNATURE_LX 0x584C /* LX */
#define IMAGE_VXD_SIGNATURE 0x454C /* LE */
#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
/*
* This is the Windows executable (NE) header.
* the name IMAGE_OS2_HEADER is misleading, but in the SDK this way.
*/
typedef struct
{
WORD ne_magic; /* 00 NE signature 'NE' */
BYTE linker_version; /* 02 Linker version number */
BYTE linker_revision; /* 03 Linker revision number */
WORD entry_tab_offset; /* 04 Offset to entry table relative to NE */
WORD entry_tab_length; /* 06 Length of entry table in bytes */
DWORD reserved1; /* 08 Reserved by Microsoft */
WORD format_flags; /* 0c Flags about segments in this file */
WORD auto_data_seg; /* 0e Automatic data segment number */
WORD local_heap_length; /* 10 Initial size of local heap */
WORD stack_length; /* 12 Initial size of stack */
WORD ip; /* 14 Initial IP */
WORD cs; /* 16 Initial CS */
WORD sp; /* 18 Initial SP */
WORD ss; /* 1a Initial SS */
WORD n_segment_tab; /* 1c # of entries in segment table */
WORD n_mod_ref_tab; /* 1e # of entries in module reference tab. */
WORD nrname_tab_length; /* 20 Length of nonresident-name table */
WORD segment_tab_offset; /* 22 Offset to segment table */
WORD resource_tab_offset; /* 24 Offset to resource table */
WORD rname_tab_offset; /* 26 Offset to resident-name table */
WORD moduleref_tab_offset; /* 28 Offset to module reference table */
WORD iname_tab_offset; /* 2a Offset to imported name table */
DWORD nrname_tab_offset; /* 2c Offset to nonresident-name table */
WORD n_mov_entry_points; /* 30 # of movable entry points */
WORD align_shift_count; /* 32 Logical sector alignment shift count */
WORD n_resource_seg; /* 34 # of resource segments */
BYTE operating_system; /* 36 Flags indicating target OS */
BYTE additional_flags; /* 37 Additional information flags */
WORD fastload_offset; /* 38 Offset to fast load area */
WORD fastload_length; /* 3a Length of fast load area */
WORD reserved2; /* 3c Reserved by Microsoft */
WORD expect_version; /* 3e Expected Windows version number */
} IMAGE_OS2_HEADER,*PIMAGE_OS2_HEADER;
/*
* NE Header FORMAT FLAGS
*/
#define NE_FFLAGS_SINGLEDATA 0x0001
......
......@@ -3,7 +3,17 @@
#include "windef.h"
#include "winbase.h"
#include "peexe.h"
#define PE_HEADER(module) \
((IMAGE_NT_HEADERS*)((LPBYTE)(module) + \
(((IMAGE_DOS_HEADER*)(module))->e_lfanew)))
#define PE_SECTIONS(module) \
((IMAGE_SECTION_HEADER*)((LPBYTE)&PE_HEADER(module)->OptionalHeader + \
PE_HEADER(module)->FileHeader.SizeOfOptionalHeader))
#define RVA_PTR(module,field) ((LPBYTE)(module) + PE_HEADER(module)->field)
/* modreference used for attached processes
* all section are calculated here, relocations etc.
*/
......
......@@ -22,7 +22,6 @@
#include "wine/winbase16.h"
#include "winerror.h"
#include "module.h"
#include "peexe.h"
#include "neexe.h"
#include "task.h"
#include "selectors.h"
......
......@@ -19,7 +19,6 @@
#include "snoop.h"
#include "process.h"
#include "neexe.h"
#include "peexe.h"
#include "heap.h"
#include "module.h"
#include "pe_image.h"
......
......@@ -575,7 +575,7 @@ static BOOL MODULE_GetBinaryType( HANDLE hfile, LPCSTR filename,
&& ReadFile( hfile, &ne, sizeof(ne), &len, NULL )
&& len == sizeof(ne) )
{
switch ( ne.operating_system )
switch ( ne.ne_exetyp )
{
case 2: *lpBinaryType = SCS_WOW_BINARY; return TRUE;
case 5: *lpBinaryType = SCS_DOS_BINARY; return TRUE;
......
......@@ -14,7 +14,6 @@
#include "winerror.h"
#include "module.h"
#include "neexe.h"
#include "peexe.h"
#include "toolhelp.h"
#include "file.h"
#include "ldt.h"
......@@ -448,20 +447,20 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
size = sizeof(NE_MODULE) +
/* segment table */
ne_header.n_segment_tab * sizeof(SEGTABLEENTRY) +
ne_header.ne_cseg * sizeof(SEGTABLEENTRY) +
/* resource table */
ne_header.rname_tab_offset - ne_header.resource_tab_offset +
ne_header.ne_restab - ne_header.ne_rsrctab +
/* resident names table */
ne_header.moduleref_tab_offset - ne_header.rname_tab_offset +
ne_header.ne_modtab - ne_header.ne_restab +
/* module ref table */
ne_header.n_mod_ref_tab * sizeof(WORD) +
ne_header.ne_cmod * sizeof(WORD) +
/* imported names table */
ne_header.entry_tab_offset - ne_header.iname_tab_offset +
ne_header.ne_enttab - ne_header.ne_imptab +
/* entry table length */
ne_header.entry_tab_length +
ne_header.ne_cbenttab +
/* entry table extra conversion space */
sizeof(ET_BUNDLE) +
2 * (ne_header.entry_tab_length - ne_header.n_mov_entry_points*6) +
2 * (ne_header.ne_cbenttab - ne_header.ne_cmovent*6) +
/* loaded file info */
sizeof(OFSTRUCT)-sizeof(ofs.szPathName)+strlen(ofs.szPathName)+1;
......@@ -491,10 +490,10 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
/* Read the fast-load area */
if (ne_header.additional_flags & NE_AFLAGS_FASTLOAD)
if (ne_header.ne_flagsothers & NE_AFLAGS_FASTLOAD)
{
fastload_offset=ne_header.fastload_offset<<ne_header.align_shift_count;
fastload_length=ne_header.fastload_length<<ne_header.align_shift_count;
fastload_offset=ne_header.fastload_offset << ne_header.ne_align;
fastload_length=ne_header.fastload_length << ne_header.ne_align;
TRACE("Using fast-load area offset=%x len=%d\n",
fastload_offset, fastload_length );
if ((fastload = HeapAlloc( GetProcessHeap(), 0, fastload_length )) != NULL)
......@@ -512,15 +511,15 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
/* Get the segment table */
pModule->seg_table = (int)pData - (int)pModule;
buffer = HeapAlloc( GetProcessHeap(), 0, ne_header.n_segment_tab *
buffer = HeapAlloc( GetProcessHeap(), 0, ne_header.ne_cseg *
sizeof(struct ne_segment_table_entry_s));
if (buffer)
{
int i;
struct ne_segment_table_entry_s *pSeg;
if (!READ( mz_header.e_lfanew + ne_header.segment_tab_offset,
ne_header.n_segment_tab * sizeof(struct ne_segment_table_entry_s),
if (!READ( mz_header.e_lfanew + ne_header.ne_segtab,
ne_header.ne_cseg * sizeof(struct ne_segment_table_entry_s),
buffer ))
{
HeapFree( GetProcessHeap(), 0, buffer );
......@@ -531,7 +530,7 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
return (HMODULE16)11; /* invalid exe */
}
pSeg = (struct ne_segment_table_entry_s *)buffer;
for (i = ne_header.n_segment_tab; i > 0; i--, pSeg++)
for (i = ne_header.ne_cseg; i > 0; i--, pSeg++)
{
memcpy( pData, pSeg, sizeof(*pSeg) );
pData += sizeof(SEGTABLEENTRY);
......@@ -549,17 +548,17 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
/* Get the resource table */
if (ne_header.resource_tab_offset < ne_header.rname_tab_offset)
if (ne_header.ne_rsrctab < ne_header.ne_restab)
{
pModule->res_table = (int)pData - (int)pModule;
if (!READ(mz_header.e_lfanew + ne_header.resource_tab_offset,
ne_header.rname_tab_offset - ne_header.resource_tab_offset,
if (!READ(mz_header.e_lfanew + ne_header.ne_rsrctab,
ne_header.ne_restab - ne_header.ne_rsrctab,
pData ))
{
_lclose16( hFile );
return (HMODULE16)11; /* invalid exe */
}
pData += ne_header.rname_tab_offset - ne_header.resource_tab_offset;
pData += ne_header.ne_restab - ne_header.ne_rsrctab;
NE_InitResourceHandler( hModule );
}
else pModule->res_table = 0; /* No resource table */
......@@ -567,8 +566,8 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
/* Get the resident names table */
pModule->name_table = (int)pData - (int)pModule;
if (!READ( mz_header.e_lfanew + ne_header.rname_tab_offset,
ne_header.moduleref_tab_offset - ne_header.rname_tab_offset,
if (!READ( mz_header.e_lfanew + ne_header.ne_restab,
ne_header.ne_modtab - ne_header.ne_restab,
pData ))
{
if (fastload)
......@@ -577,15 +576,15 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
_lclose16( hFile );
return (HMODULE16)11; /* invalid exe */
}
pData += ne_header.moduleref_tab_offset - ne_header.rname_tab_offset;
pData += ne_header.ne_modtab - ne_header.ne_restab;
/* Get the module references table */
if (ne_header.n_mod_ref_tab > 0)
if (ne_header.ne_cmod > 0)
{
pModule->modref_table = (int)pData - (int)pModule;
if (!READ( mz_header.e_lfanew + ne_header.moduleref_tab_offset,
ne_header.n_mod_ref_tab * sizeof(WORD),
if (!READ( mz_header.e_lfanew + ne_header.ne_modtab,
ne_header.ne_cmod * sizeof(WORD),
pData ))
{
if (fastload)
......@@ -594,15 +593,15 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
_lclose16( hFile );
return (HMODULE16)11; /* invalid exe */
}
pData += ne_header.n_mod_ref_tab * sizeof(WORD);
pData += ne_header.ne_cmod * sizeof(WORD);
}
else pModule->modref_table = 0; /* No module references */
/* Get the imported names table */
pModule->import_table = (int)pData - (int)pModule;
if (!READ( mz_header.e_lfanew + ne_header.iname_tab_offset,
ne_header.entry_tab_offset - ne_header.iname_tab_offset,
if (!READ( mz_header.e_lfanew + ne_header.ne_imptab,
ne_header.ne_enttab - ne_header.ne_imptab,
pData ))
{
if (fastload)
......@@ -611,18 +610,18 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
_lclose16( hFile );
return (HMODULE16)11; /* invalid exe */
}
pData += ne_header.entry_tab_offset - ne_header.iname_tab_offset;
pData += ne_header.ne_enttab - ne_header.ne_imptab;
/* Load entry table, convert it to the optimized version used by Windows */
if ((pTempEntryTable = HeapAlloc( GetProcessHeap(), 0, ne_header.entry_tab_length)) != NULL)
if ((pTempEntryTable = HeapAlloc( GetProcessHeap(), 0, ne_header.ne_cbenttab)) != NULL)
{
BYTE nr_entries, type, *s;
TRACE("Converting entry table.\n");
pModule->entry_table = (int)pData - (int)pModule;
if (!READ( mz_header.e_lfanew + ne_header.entry_tab_offset,
ne_header.entry_tab_length, pTempEntryTable ))
if (!READ( mz_header.e_lfanew + ne_header.ne_enttab,
ne_header.ne_cbenttab, pTempEntryTable ))
{
HeapFree( GetProcessHeap(), 0, pTempEntryTable );
if (fastload)
......@@ -633,7 +632,7 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
}
s = pTempEntryTable;
TRACE("entry table: offs %04x, len %04x, entries %d\n", ne_header.entry_tab_offset, ne_header.entry_tab_length, *s);
TRACE("entry table: offs %04x, len %04x, entries %d\n", ne_header.ne_enttab, ne_header.ne_cbenttab, *s);
bundle = (ET_BUNDLE *)pData;
TRACE("first bundle: %p\n", bundle);
......@@ -698,8 +697,8 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
return (HMODULE16)11; /* invalid exe */
}
pData += ne_header.entry_tab_length + sizeof(ET_BUNDLE) +
2 * (ne_header.entry_tab_length - ne_header.n_mov_entry_points*6);
pData += ne_header.ne_cbenttab + sizeof(ET_BUNDLE) +
2 * (ne_header.ne_cbenttab - ne_header.ne_cmovent*6);
if ((DWORD)entry > (DWORD)pData)
ERR("converted entry table bigger than reserved space !!!\nentry: %p, pData: %p. Please report !\n", entry, pData);
......@@ -720,9 +719,9 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
/* Get the non-resident names table */
if (ne_header.nrname_tab_length)
if (ne_header.ne_cbnrestab)
{
pModule->nrname_handle = GLOBAL_Alloc( 0, ne_header.nrname_tab_length,
pModule->nrname_handle = GLOBAL_Alloc( 0, ne_header.ne_cbnrestab,
hModule, FALSE, FALSE, FALSE );
if (!pModule->nrname_handle)
{
......@@ -731,9 +730,9 @@ static HMODULE16 NE_LoadExeHeader( LPCSTR filename )
return (HMODULE16)11; /* invalid exe */
}
buffer = GlobalLock16( pModule->nrname_handle );
_llseek16( hFile, ne_header.nrname_tab_offset, SEEK_SET );
if (_hread16( hFile, buffer, ne_header.nrname_tab_length )
!= ne_header.nrname_tab_length)
_llseek16( hFile, ne_header.ne_nrestab, SEEK_SET );
if (_hread16( hFile, buffer, ne_header.ne_cbnrestab )
!= ne_header.ne_cbnrestab)
{
GlobalFree16( pModule->nrname_handle );
GlobalFree16( hModule );
......
......@@ -52,7 +52,6 @@
#include "file.h"
#include "heap.h"
#include "neexe.h"
#include "peexe.h"
#include "process.h"
#include "thread.h"
#include "pe_image.h"
......
......@@ -20,7 +20,6 @@
#include "miscemu.h"
#include "module.h"
#include "neexe.h"
#include "peexe.h"
#include "pe_image.h"
#include "process.h"
#include "queue.h"
......
......@@ -12,7 +12,6 @@
#include "wingdi.h"
#include "winuser.h"
#include "builtin32.h"
#include "peexe.h"
#include "neexe.h"
#include "heap.h"
#include "main.h"
......
......@@ -17,7 +17,6 @@
#include "builtin32.h"
#include "snoop.h"
#include "neexe.h"
#include "peexe.h"
#include "selectors.h"
#include "stackframe.h"
#include "debugtools.h"
......
......@@ -12,7 +12,6 @@
#include <string.h>
#include <windows.h>
#include "peexe.h"
#include "cvinclude.h"
/************************ sstSrcModule ************************/
......
......@@ -6,7 +6,6 @@
/* #define VERBOSE */
#include "peexe.h"
#include "neexe.h"
#include "cvinclude.h"
......
......@@ -486,8 +486,8 @@ int get_resource_table(int fd, unsigned char** lpdata, int fsize)
}
else if ( s != IMAGE_OS2_SIGNATURE) return FILE_ERROR;
s = return_data_value(dfShort, &ne_header.resource_tab_offset);
size = return_data_value(dfShort, &ne_header.rname_tab_offset);
s = return_data_value(dfShort, &ne_header.ne_rsrctab);
size = return_data_value(dfShort, &ne_header.ne_restab);
if( size > fsize ) return FILE_ERROR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment