kernel32: Make export directory writable to set FT_Thunk to 0.

But don't bother on non-i386 platforms.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-09-25 13:45:04 +02:00
parent 98d7f90d1d
commit 8db14f4e18
1 changed files with 8 additions and 2 deletions

View File

@ -44,6 +44,7 @@ static STARTUPINFOA startup_infoA;
/***********************************************************************
* set_entry_point
*/
#ifdef __i386__
static void set_entry_point( HMODULE module, const char *name, DWORD rva )
{
IMAGE_EXPORT_DIRECTORY *exports;
@ -64,9 +65,12 @@ static void set_entry_point( HMODULE module, const char *name, DWORD rva )
if (!(res = strcmp( ename, name )))
{
WORD ordinal = ordinals[pos];
assert( ordinal < exports->NumberOfFunctions );
DWORD oldprot;
TRACE( "setting %s at %p to %08x\n", name, &functions[ordinal], rva );
VirtualProtect( functions + ordinal, sizeof(*functions), PAGE_READWRITE, &oldprot );
functions[ordinal] = rva;
VirtualProtect( functions + ordinal, sizeof(*functions), oldprot, NULL );
return;
}
if (res > 0) max = pos - 1;
@ -74,6 +78,7 @@ static void set_entry_point( HMODULE module, const char *name, DWORD rva )
}
}
}
#endif
/***********************************************************************
@ -134,6 +139,7 @@ static BOOL process_attach( HMODULE module )
copy_startup_info();
#ifdef __i386__
if (!(GetVersion() & 0x80000000))
{
/* Securom checks for this one when version is NT */
@ -146,7 +152,7 @@ static BOOL process_attach( HMODULE module )
if (LdrFindEntryForAddress( GetModuleHandleW( 0 ), &ldr ) || !(ldr->Flags & LDR_WINE_INTERNAL))
LoadLibraryA( "krnl386.exe16" );
}
#endif
return TRUE;
}