mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 16:14:40 +00:00
Prevent unaligned access to NE in-memory module data.
This commit is contained in:
parent
e709cdbae3
commit
acefd16bee
|
@ -356,7 +356,7 @@ HMODULE MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
|||
+ strlen(filename) + 1;
|
||||
size = sizeof(NE_MODULE) +
|
||||
/* loaded file info */
|
||||
of_size +
|
||||
((of_size + 3) & ~3) +
|
||||
/* segment table: DS,CS */
|
||||
2 * sizeof(SEGTABLEENTRY) +
|
||||
/* name table */
|
||||
|
@ -405,7 +405,7 @@ HMODULE MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
|||
ofs->cBytes = of_size < 256 ? of_size : 255; /* FIXME */
|
||||
strcpy( ofs->szPathName, filename );
|
||||
|
||||
pSegment = (SEGTABLEENTRY*)((char*)(pModule + 1) + of_size);
|
||||
pSegment = (SEGTABLEENTRY*)((char*)(pModule + 1) + ((of_size + 3) & ~3));
|
||||
pModule->seg_table = (int)pSegment - (int)pModule;
|
||||
/* Data segment */
|
||||
pSegment->size = 0;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include "wine/port.h"
|
||||
#include "wine/winbase16.h"
|
||||
#include "wine/library.h"
|
||||
#include "winerror.h"
|
||||
|
@ -264,9 +265,9 @@ WORD NE_GetOrdinal( HMODULE16 hModule, const char *name )
|
|||
{
|
||||
if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len ))
|
||||
{
|
||||
TRACE(" Found: ordinal=%d\n",
|
||||
*(WORD *)(cpnt + *cpnt + 1) );
|
||||
return *(WORD *)(cpnt + *cpnt + 1);
|
||||
WORD ordinal = GET_UA_WORD( cpnt + *cpnt + 1 );
|
||||
TRACE(" Found: ordinal=%d\n", ordinal );
|
||||
return ordinal;
|
||||
}
|
||||
cpnt += *cpnt + 1 + sizeof(WORD);
|
||||
}
|
||||
|
@ -282,9 +283,9 @@ WORD NE_GetOrdinal( HMODULE16 hModule, const char *name )
|
|||
{
|
||||
if (((BYTE)*cpnt == len) && !memcmp( cpnt+1, buffer, len ))
|
||||
{
|
||||
TRACE(" Found: ordinal=%d\n",
|
||||
*(WORD *)(cpnt + *cpnt + 1) );
|
||||
return *(WORD *)(cpnt + *cpnt + 1);
|
||||
WORD ordinal = GET_UA_WORD( cpnt + *cpnt + 1 );
|
||||
TRACE(" Found: ordinal=%d\n", ordinal );
|
||||
return ordinal;
|
||||
}
|
||||
cpnt += *cpnt + 1 + sizeof(WORD);
|
||||
}
|
||||
|
@ -331,7 +332,7 @@ FARPROC16 NE_GetEntryPointEx( HMODULE16 hModule, WORD ordinal, BOOL16 snoop )
|
|||
entry++;
|
||||
|
||||
sel = entry->segnum;
|
||||
offset = entry->offs;
|
||||
offset = GET_UA_WORD( &entry->offs );
|
||||
|
||||
if (sel == 0xfe) sel = 0xffff; /* constant entry */
|
||||
else sel = GlobalHandleToSel16(NE_SEG_TABLE(pModule)[sel-1].hSeg);
|
||||
|
@ -372,7 +373,7 @@ BOOL16 NE_SetEntryPoint( HMODULE16 hModule, WORD ordinal, WORD offset )
|
|||
for (i=0; i < (ordinal - bundle->first - 1); i++)
|
||||
entry++;
|
||||
|
||||
entry->offs = offset;
|
||||
PUT_UA_WORD( &entry->offs, offset );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "windef.h"
|
||||
#include "wine/port.h"
|
||||
#include "wine/winbase16.h"
|
||||
#include "wine/library.h"
|
||||
#include "global.h"
|
||||
|
@ -259,7 +260,7 @@ BOOL NE_InitResourceHandler( HMODULE16 hModule )
|
|||
|
||||
while(pTypeInfo->type_id)
|
||||
{
|
||||
pTypeInfo->resloader = DefResourceHandlerProc;
|
||||
PUT_UA_DWORD( &pTypeInfo->resloader, (DWORD)DefResourceHandlerProc );
|
||||
pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -285,8 +286,8 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId,
|
|||
{
|
||||
if (!(pTypeInfo = NE_FindTypeSection( pResTab, pTypeInfo, typeId )))
|
||||
break;
|
||||
prevHandler = pTypeInfo->resloader;
|
||||
pTypeInfo->resloader = resourceHandler;
|
||||
prevHandler = (FARPROC16)GET_UA_DWORD( &pTypeInfo->resloader );
|
||||
PUT_UA_DWORD( &pTypeInfo->resloader, (DWORD)resourceHandler );
|
||||
pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
|
||||
}
|
||||
return prevHandler;
|
||||
|
@ -483,10 +484,10 @@ HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc )
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( pTypeInfo->resloader
|
||||
&& pTypeInfo->resloader != DefResourceHandlerProc )
|
||||
FARPROC16 resloader = (FARPROC16)GET_UA_DWORD( &pTypeInfo->resloader );
|
||||
if ( resloader && resloader != DefResourceHandlerProc )
|
||||
pNameInfo->handle = NE_CallTo16_word_www(
|
||||
pTypeInfo->resloader, pNameInfo->handle, pModule->self, hRsrc );
|
||||
resloader, pNameInfo->handle, pModule->self, hRsrc );
|
||||
else
|
||||
pNameInfo->handle = NE_DefResourceHandler(
|
||||
pNameInfo->handle, pModule->self, hRsrc );
|
||||
|
|
Loading…
Reference in a new issue