Commit 4417574d authored by Alexandre Julliard's avatar Alexandre Julliard

Renamed some fields in NE_MODULE to use the same name as in the

exported IMAGE_OS2_HEADER structure.
parent 03776ec9
......@@ -31,43 +31,41 @@
/* In-memory module structure. See 'Windows Internals' p. 219 */
typedef struct _NE_MODULE
{
WORD magic; /* 00 'NE' signature */
WORD count; /* 02 Usage count */
WORD entry_table; /* 04 Near ptr to entry table */
HMODULE16 next; /* 06 Selector to next module */
WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP */
WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) */
WORD flags; /* 0c Module flags */
WORD dgroup; /* 0e Logical segment for DGROUP */
WORD heap_size; /* 10 Initial heap size */
WORD stack_size; /* 12 Initial stack size */
WORD ip; /* 14 Initial ip */
WORD cs; /* 16 Initial cs (logical segment) */
WORD sp; /* 18 Initial stack pointer */
WORD ss; /* 1a Initial ss (logical segment) */
WORD seg_count; /* 1c Number of segments in segment table */
WORD modref_count; /* 1e Number of module references */
WORD nrname_size; /* 20 Size of non-resident names table */
WORD seg_table; /* 22 Near ptr to segment table */
WORD res_table; /* 24 Near ptr to resource table */
WORD name_table; /* 26 Near ptr to resident names table */
WORD modref_table; /* 28 Near ptr to module reference table */
WORD import_table; /* 2a Near ptr to imported names table */
DWORD nrname_fpos; /* 2c File offset of non-resident names table */
WORD moveable_entries; /* 30 Number of moveable entries in entry table*/
WORD alignment; /* 32 Alignment shift count */
WORD truetype; /* 34 Set to 2 if TrueType font */
BYTE os_flags; /* 36 Operating system flags */
BYTE misc_flags; /* 37 Misc. flags */
HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize */
HANDLE16 nrname_handle; /* 3a Handle to non-resident name table */
WORD min_swap_area; /* 3c Min. swap area size */
WORD expected_version; /* 3e Expected Windows version */
WORD ne_magic; /* 00 'NE' signature */
WORD count; /* 02 Usage count (ne_ver/ne_rev on disk) */
WORD ne_enttab; /* 04 Near ptr to entry table */
HMODULE16 next; /* 06 Selector to next module (ne_cbenttab on disk) */
WORD dgroup_entry; /* 08 Near ptr to segment entry for DGROUP (ne_crc on disk) */
WORD fileinfo; /* 0a Near ptr to file info (OFSTRUCT) (ne_crc on disk) */
WORD ne_flags; /* 0c Module flags */
WORD ne_autodata; /* 0e Logical segment for DGROUP */
WORD ne_heap; /* 10 Initial heap size */
WORD ne_stack; /* 12 Initial stack size */
DWORD ne_csip; /* 14 Initial cs:ip */
DWORD ne_sssp; /* 18 Initial ss:sp */
WORD ne_cseg; /* 1c Number of segments in segment table */
WORD ne_cmod; /* 1e Number of module references */
WORD ne_cbnrestab; /* 20 Size of non-resident names table */
WORD ne_segtab; /* 22 Near ptr to segment table */
WORD ne_rsrctab; /* 24 Near ptr to resource table */
WORD ne_restab; /* 26 Near ptr to resident names table */
WORD ne_modtab; /* 28 Near ptr to module reference table */
WORD ne_imptab; /* 2a Near ptr to imported names table */
DWORD ne_nrestab; /* 2c File offset of non-resident names table */
WORD ne_cmovent; /* 30 Number of moveable entries in entry table*/
WORD ne_align; /* 32 Alignment shift count */
WORD ne_cres; /* 34 # of resource segments */
BYTE ne_exetyp; /* 36 Operating system flags */
BYTE ne_flagsothers; /* 37 Misc. flags */
HANDLE16 dlls_to_init; /* 38 List of DLLs to initialize (ne_pretthunks on disk) */
HANDLE16 nrname_handle; /* 3a Handle to non-resident name table (ne_psegrefbytes on disk) */
WORD ne_swaparea; /* 3c Min. swap area size */
WORD ne_expver; /* 3e Expected Windows version */
/* From here, these are extra fields not present in normal Windows */
HMODULE module32; /* 40 PE module handle for Win32 modules */
HMODULE16 self; /* 44 Handle for this module */
WORD self_loading_sel; /* 46 Selector used for self-loading apps. */
LPVOID hRsrcMap; /* 48 HRSRC 16->32 map (for 32-bit modules) */
LPVOID rsrc32_map; /* 48 HRSRC 16->32 map (for 32-bit modules) */
HANDLE fd; /* 4c handle to the binary file */
} NE_MODULE;
......@@ -104,7 +102,7 @@ extern THHOOK *pThhook;
#include "poppack.h"
#define NE_SEG_TABLE(pModule) \
((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->seg_table))
((SEGTABLEENTRY *)((char *)(pModule) + (pModule)->ne_segtab))
#define NE_MODULE_NAME(pModule) \
(((OFSTRUCT *)((char*)(pModule) + (pModule)->fileinfo))->szPathName)
......
......@@ -1657,7 +1657,7 @@ DWORD WINAPI GetHeapSpaces16( HMODULE16 module )
DWORD spaces;
if (!(pModule = NE_GetPtr( module ))) return 0;
CURRENT_DS = GlobalHandleToSel16((NE_SEG_TABLE( pModule ) + pModule->dgroup - 1)->hSeg);
CURRENT_DS = GlobalHandleToSel16((NE_SEG_TABLE( pModule ) + pModule->ne_autodata - 1)->hSeg);
spaces = MAKELONG( LocalCountFree16(), LocalHeapSize16() );
CURRENT_DS = oldDS;
return spaces;
......
......@@ -239,7 +239,7 @@ static const CALLFROM16 *get_entry_point( STACK16FRAME *frame, LPSTR module, LPS
max_offset = 0;
*pOrd = 0;
bundle = (ET_BUNDLE *)((BYTE *)pModule + pModule->entry_table);
bundle = (ET_BUNDLE *)((BYTE *)pModule + pModule->ne_enttab);
do
{
entry = (ET_ENTRY *)((BYTE *)bundle+6);
......@@ -260,7 +260,7 @@ static const CALLFROM16 *get_entry_point( STACK16FRAME *frame, LPSTR module, LPS
/* Search for the name in the resident names table */
/* (built-in modules have no non-resident table) */
p = (BYTE *)pModule + pModule->name_table;
p = (BYTE *)pModule + pModule->ne_restab;
memcpy( module, p + 1, *p );
module[*p] = 0;
......
......@@ -72,7 +72,7 @@ typedef struct _HRSRC_MAP
*/
static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HRSRC hRsrc32, WORD type )
{
HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap;
HRSRC_MAP *map = pModule->rsrc32_map;
HRSRC_ELEM *newElem;
int i;
......@@ -84,7 +84,7 @@ static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HRSRC hRsrc32, WORD type )
ERR("Cannot allocate HRSRC map\n" );
return 0;
}
pModule->hRsrcMap = map;
pModule->rsrc32_map = map;
}
/* Check whether HRSRC32 already in map */
......@@ -125,7 +125,7 @@ static HRSRC16 MapHRsrc32To16( NE_MODULE *pModule, HRSRC hRsrc32, WORD type )
*/
static HRSRC MapHRsrc16To32( NE_MODULE *pModule, HRSRC16 hRsrc16 )
{
HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap;
HRSRC_MAP *map = pModule->rsrc32_map;
if ( !map || !hRsrc16 || hRsrc16 > map->nUsed ) return 0;
return map->elem[hRsrc16-1].hRsrc;
......@@ -136,7 +136,7 @@ static HRSRC MapHRsrc16To32( NE_MODULE *pModule, HRSRC16 hRsrc16 )
*/
static WORD MapHRsrc16ToType( NE_MODULE *pModule, HRSRC16 hRsrc16 )
{
HRSRC_MAP *map = (HRSRC_MAP *)pModule->hRsrcMap;
HRSRC_MAP *map = pModule->rsrc32_map;
if ( !map || !hRsrc16 || hRsrc16 > map->nUsed ) return 0;
return map->elem[hRsrc16-1].type;
......@@ -184,7 +184,7 @@ static inline FARPROC16 get_default_res_handler(void)
*/
static DWORD NE_FindNameTableId( NE_MODULE *pModule, LPCSTR typeId, LPCSTR resId )
{
NE_TYPEINFO *pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
NE_TYPEINFO *pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->ne_rsrctab + 2);
NE_NAMEINFO *pNameInfo;
HGLOBAL16 handle;
WORD *p;
......@@ -332,10 +332,10 @@ HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
{
HANDLE fd;
NE_MODULE* pModule = NE_GetPtr( hModule );
if (pModule && (pModule->flags & NE_FFLAGS_BUILTIN))
if (pModule && (pModule->ne_flags & NE_FFLAGS_BUILTIN))
{
HGLOBAL16 handle;
WORD sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
WORD sizeShift = *(WORD *)((char *)pModule + pModule->ne_rsrctab);
NE_NAMEINFO* pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
if ( hMemObj )
......@@ -347,7 +347,7 @@ HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
{
/* NOTE: hRsrcMap points to start of built-in resource data */
memcpy( GlobalLock16( handle ),
(char *)pModule->hRsrcMap + (pNameInfo->offset << sizeShift),
(char *)pModule->rsrc32_map + (pNameInfo->offset << sizeShift),
pNameInfo->length << sizeShift );
}
return handle;
......@@ -355,7 +355,7 @@ HGLOBAL16 WINAPI NE_DefResourceHandler( HGLOBAL16 hMemObj, HMODULE16 hModule,
if (pModule && (fd = NE_OpenFile( pModule )) != INVALID_HANDLE_VALUE)
{
HGLOBAL16 handle;
WORD sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
WORD sizeShift = *(WORD *)((char *)pModule + pModule->ne_rsrctab);
NE_NAMEINFO* pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
TRACE("loading, pos=%d, len=%d\n",
......@@ -390,9 +390,9 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId, FARPROC
FARPROC16 prevHandler = NULL;
NE_MODULE *pModule = NE_GetPtr( hModule );
if (!pModule || !pModule->res_table) return NULL;
if (!pModule || !pModule->ne_rsrctab) return NULL;
pResTab = (LPBYTE)pModule + pModule->res_table;
pResTab = (LPBYTE)pModule + pModule->ne_rsrctab;
pTypeInfo = (NE_TYPEINFO *)(pResTab + 2);
TRACE("module=%04x type=%s\n", hModule, debugstr_a(typeId) );
......@@ -892,11 +892,11 @@ HGLOBAL16 WINAPI AllocResource16( HMODULE16 hModule, HRSRC16 hRsrc, DWORD size)
HGLOBAL16 ret;
NE_MODULE *pModule = NE_GetPtr( hModule );
if (!pModule || !pModule->res_table || !hRsrc) return 0;
if (!pModule || !pModule->ne_rsrctab || !hRsrc) return 0;
TRACE("module=%04x res=%04x size=%ld\n", hModule, hRsrc, size );
sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
sizeShift = *(WORD *)((char *)pModule + pModule->ne_rsrctab);
pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
if (size < (DWORD)pNameInfo->length << sizeShift)
size = (DWORD)pNameInfo->length << sizeShift;
......@@ -934,13 +934,13 @@ INT16 WINAPI AccessResource16( HINSTANCE16 hModule, HRSRC16 hRsrc )
HFILE16 fd;
NE_MODULE *pModule = NE_GetPtr( hModule );
if (!pModule || !pModule->res_table || !hRsrc) return -1;
if (!pModule || !pModule->ne_rsrctab || !hRsrc) return -1;
TRACE("module=%04x res=%04x\n", pModule->self, hRsrc );
if ((fd = _lopen16( NE_MODULE_NAME(pModule), OF_READ )) != HFILE_ERROR16)
{
WORD sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
WORD sizeShift = *(WORD *)((char *)pModule + pModule->ne_rsrctab);
NE_NAMEINFO *pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
_llseek16( fd, (int)pNameInfo->offset << sizeShift, SEEK_SET );
}
......@@ -969,7 +969,7 @@ HRSRC16 WINAPI FindResource16( HMODULE16 hModule, LPCSTR name, LPCSTR type )
TRACE("module=%04x name=%s type=%s\n", pModule->self, debugstr_a(name), debugstr_a(type) );
if (!pModule->res_table) return 0;
if (!pModule->ne_rsrctab) return 0;
type = get_res_name( type );
name = get_res_name( name );
......@@ -983,7 +983,7 @@ HRSRC16 WINAPI FindResource16( HMODULE16 hModule, LPCSTR name, LPCSTR type )
name = (LPCSTR)(ULONG_PTR)HIWORD(id);
}
}
pResTab = (LPBYTE)pModule + pModule->res_table;
pResTab = (LPBYTE)pModule + pModule->ne_rsrctab;
pTypeInfo = (NE_TYPEINFO *)( pResTab + 2 );
for (;;)
......@@ -1025,7 +1025,7 @@ HGLOBAL16 WINAPI LoadResource16( HMODULE16 hModule, HRSRC16 hRsrc )
/* first, verify hRsrc (just an offset from pModule to the needed pNameInfo) */
d = pModule->res_table + 2;
d = pModule->ne_rsrctab + 2;
pTypeInfo = (NE_TYPEINFO *)((char *)pModule + d);
while( hRsrc > d )
{
......@@ -1111,9 +1111,9 @@ DWORD WINAPI SizeofResource16( HMODULE16 hModule, HRSRC16 hRsrc )
if (!hRsrc) return 0;
if (!(pModule = get_module( hModule ))) return 0;
if (pModule->res_table)
if (pModule->ne_rsrctab)
{
WORD sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
WORD sizeShift = *(WORD *)((char *)pModule + pModule->ne_rsrctab);
NE_NAMEINFO *pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
return (DWORD)pNameInfo->length << sizeShift;
}
......@@ -1141,9 +1141,9 @@ BOOL16 WINAPI FreeResource16( HGLOBAL16 handle )
/* Try NE resource first */
if (pModule && pModule->res_table)
if (pModule && pModule->ne_rsrctab)
{
NE_TYPEINFO *pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->res_table + 2);
NE_TYPEINFO *pTypeInfo = (NE_TYPEINFO *)((char *)pModule + pModule->ne_rsrctab + 2);
while (pTypeInfo->type_id)
{
WORD count;
......
......@@ -193,7 +193,7 @@ SNOOP16_GetProcAddress16(HMODULE16 hmod,DWORD ordinal,FARPROC16 origfun) {
fun->origfun = origfun;
if (fun->name)
return (FARPROC16)(SEGPTR)MAKELONG(((char*)fun-(char*)dll->funs),dll->funhandle);
cpnt = (unsigned char *)pModule + pModule->name_table;
cpnt = (unsigned char *)pModule + pModule->ne_restab;
while (*cpnt) {
cpnt += *cpnt + 1 + sizeof(WORD);
if (*(WORD*)(cpnt+*cpnt+1) == ordinal) {
......
......@@ -273,7 +273,7 @@ static TDB *TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, LPCSTR cmdline, BYT
pTask->hSelf = hTask;
pTask->version = pModule ? pModule->expected_version : 0x0400;
pTask->version = pModule ? pModule->ne_expver : 0x0400;
pTask->hModule = hModule;
pTask->hParent = GetCurrentTask();
pTask->magic = TDB_MAGIC;
......@@ -856,7 +856,7 @@ FARPROC16 WINAPI MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
hInstance = GlobalHandle16(hInstanceSelector);
/* no thunking for DLLs */
if (NE_GetPtr(FarGetOwner16(hInstance))->flags & NE_FFLAGS_LIBMODULE)
if (NE_GetPtr(FarGetOwner16(hInstance))->ne_flags & NE_FFLAGS_LIBMODULE)
return func;
thunkaddr = TASK_AllocThunk();
......@@ -916,10 +916,10 @@ static BOOL TASK_GetCodeSegment( FARPROC16 proc, NE_MODULE **ppModule,
/* Try pair of module handle / segment number */
pModule = (NE_MODULE *) GlobalLock16( HIWORD( proc ) );
if ( pModule && pModule->magic == IMAGE_OS2_SIGNATURE )
if ( pModule && pModule->ne_magic == IMAGE_OS2_SIGNATURE )
{
segNr = LOWORD( proc );
if ( segNr && segNr <= pModule->seg_count )
if ( segNr && segNr <= pModule->ne_cseg )
pSeg = NE_SEG_TABLE( pModule ) + segNr-1;
}
......@@ -938,11 +938,11 @@ static BOOL TASK_GetCodeSegment( FARPROC16 proc, NE_MODULE **ppModule,
pSeg = pModule? NE_SEG_TABLE( pModule ) : NULL;
if ( pModule )
for ( segNr = 1; segNr <= pModule->seg_count; segNr++, pSeg++ )
for ( segNr = 1; segNr <= pModule->ne_cseg; segNr++, pSeg++ )
if ( GlobalHandleToSel16(pSeg->hSeg) == selector )
break;
if ( pModule && segNr > pModule->seg_count )
if ( pModule && segNr > pModule->ne_cseg )
pSeg = NULL;
}
......@@ -992,10 +992,10 @@ BOOL16 WINAPI GetCodeInfo16( FARPROC16 proc, SEGINFO *segInfo )
segInfo->flags = pSeg->flags;
segInfo->cbAlloc = pSeg->minsize;
segInfo->h = pSeg->hSeg;
segInfo->alignShift = pModule->alignment;
segInfo->alignShift = pModule->ne_align;
if ( segNr == pModule->dgroup )
segInfo->cbAlloc += pModule->heap_size + pModule->stack_size;
if ( segNr == pModule->ne_autodata )
segInfo->cbAlloc += pModule->ne_heap + pModule->ne_stack;
/* Return module handle in %es */
......@@ -1377,7 +1377,7 @@ static inline HMODULE16 GetExePtrHelper( HANDLE16 handle, HTASK16 *hTask )
/* Check for module handle */
if (!(ptr = GlobalLock16( handle ))) return 0;
if (((NE_MODULE *)ptr)->magic == IMAGE_OS2_SIGNATURE) return handle;
if (((NE_MODULE *)ptr)->ne_magic == IMAGE_OS2_SIGNATURE) return handle;
/* Search for this handle inside all tasks */
......@@ -1396,7 +1396,7 @@ static inline HMODULE16 GetExePtrHelper( HANDLE16 handle, HTASK16 *hTask )
owner = FarGetOwner16( handle );
if (!(ptr = GlobalLock16( owner ))) return 0;
if (((NE_MODULE *)ptr)->magic == IMAGE_OS2_SIGNATURE) return owner;
if (((NE_MODULE *)ptr)->ne_magic == IMAGE_OS2_SIGNATURE) return owner;
/* Search for the owner inside all tasks */
......
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