Only create the 16-bit dummy module when we need really it.
This commit is contained in:
parent
69c7164977
commit
c7a51eec43
|
@ -1272,7 +1272,6 @@ static void MODULE_FlushModrefs(void)
|
||||||
|
|
||||||
if (wm->dlhandle) wine_dll_unload( wm->dlhandle );
|
if (wm->dlhandle) wine_dll_unload( wm->dlhandle );
|
||||||
else NtUnmapViewOfSection( GetCurrentProcess(), wm->ldr.BaseAddress );
|
else NtUnmapViewOfSection( GetCurrentProcess(), wm->ldr.BaseAddress );
|
||||||
FreeLibrary16( wm->hDummyMod );
|
|
||||||
if (cached_modref == wm) cached_modref = NULL;
|
if (cached_modref == wm) cached_modref = NULL;
|
||||||
RtlFreeHeap( ntdll_get_process_heap(), 0, wm->deps );
|
RtlFreeHeap( ntdll_get_process_heap(), 0, wm->deps );
|
||||||
RtlFreeHeap( ntdll_get_process_heap(), 0, wm );
|
RtlFreeHeap( ntdll_get_process_heap(), 0, wm );
|
||||||
|
|
|
@ -130,7 +130,6 @@ typedef struct _wine_modref
|
||||||
{
|
{
|
||||||
struct _wine_modref *next;
|
struct _wine_modref *next;
|
||||||
struct _wine_modref *prev;
|
struct _wine_modref *prev;
|
||||||
HMODULE16 hDummyMod; /* Win16 dummy module */
|
|
||||||
void *dlhandle; /* handle returned by dlopen() */
|
void *dlhandle; /* handle returned by dlopen() */
|
||||||
LDR_MODULE ldr;
|
LDR_MODULE ldr;
|
||||||
|
|
||||||
|
@ -184,7 +183,7 @@ enum binary_type
|
||||||
extern NTSTATUS MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
|
extern NTSTATUS MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
|
||||||
extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
|
extern NTSTATUS MODULE_DllThreadAttach( LPVOID lpReserved );
|
||||||
extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
|
extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
|
||||||
extern HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 );
|
extern HMODULE16 MODULE_CreateDummyModule( HMODULE module32 );
|
||||||
extern enum binary_type MODULE_GetBinaryType( HANDLE hfile );
|
extern enum binary_type MODULE_GetBinaryType( HANDLE hfile );
|
||||||
extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
|
extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
|
||||||
extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
|
extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
|
||||||
|
|
|
@ -90,7 +90,7 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
|
||||||
*
|
*
|
||||||
* Create a dummy NE module for Win32 or Winelib.
|
* Create a dummy NE module for Win32 or Winelib.
|
||||||
*/
|
*/
|
||||||
HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
HMODULE16 MODULE_CreateDummyModule( HMODULE module32 )
|
||||||
{
|
{
|
||||||
HMODULE16 hModule;
|
HMODULE16 hModule;
|
||||||
NE_MODULE *pModule;
|
NE_MODULE *pModule;
|
||||||
|
@ -100,8 +100,13 @@ HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
||||||
const char* basename;
|
const char* basename;
|
||||||
OFSTRUCT *ofs;
|
OFSTRUCT *ofs;
|
||||||
int of_size, size;
|
int of_size, size;
|
||||||
|
char filename[MAX_PATH];
|
||||||
|
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( module32 );
|
||||||
|
|
||||||
|
if (!nt) return (HMODULE16)11; /* invalid exe */
|
||||||
|
|
||||||
/* Extract base filename */
|
/* Extract base filename */
|
||||||
|
GetModuleFileNameA( module32, filename, sizeof(filename) );
|
||||||
basename = strrchr(filename, '\\');
|
basename = strrchr(filename, '\\');
|
||||||
if (!basename) basename = filename;
|
if (!basename) basename = filename;
|
||||||
else basename++;
|
else basename++;
|
||||||
|
@ -131,7 +136,7 @@ HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
||||||
pModule->magic = IMAGE_OS2_SIGNATURE;
|
pModule->magic = IMAGE_OS2_SIGNATURE;
|
||||||
pModule->count = 1;
|
pModule->count = 1;
|
||||||
pModule->next = 0;
|
pModule->next = 0;
|
||||||
pModule->flags = 0;
|
pModule->flags = NE_FFLAGS_WIN32;
|
||||||
pModule->dgroup = 0;
|
pModule->dgroup = 0;
|
||||||
pModule->ss = 1;
|
pModule->ss = 1;
|
||||||
pModule->cs = 2;
|
pModule->cs = 2;
|
||||||
|
@ -146,15 +151,10 @@ HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
||||||
pModule->module32 = module32;
|
pModule->module32 = module32;
|
||||||
|
|
||||||
/* Set version and flags */
|
/* Set version and flags */
|
||||||
if (module32)
|
pModule->expected_version = ((nt->OptionalHeader.MajorSubsystemVersion & 0xff) << 8 ) |
|
||||||
{
|
(nt->OptionalHeader.MinorSubsystemVersion & 0xff);
|
||||||
IMAGE_NT_HEADERS *nt = RtlImageNtHeader( module32 );
|
if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL)
|
||||||
pModule->expected_version = ((nt->OptionalHeader.MajorSubsystemVersion & 0xff) << 8 ) |
|
pModule->flags |= NE_FFLAGS_LIBMODULE | NE_FFLAGS_SINGLEDATA;
|
||||||
(nt->OptionalHeader.MinorSubsystemVersion & 0xff);
|
|
||||||
pModule->flags |= NE_FFLAGS_WIN32;
|
|
||||||
if (nt->FileHeader.Characteristics & IMAGE_FILE_DLL)
|
|
||||||
pModule->flags |= NE_FFLAGS_LIBMODULE | NE_FFLAGS_SINGLEDATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set loaded file information */
|
/* Set loaded file information */
|
||||||
ofs = (OFSTRUCT *)(pModule + 1);
|
ofs = (OFSTRUCT *)(pModule + 1);
|
||||||
|
@ -186,6 +186,7 @@ HMODULE16 MODULE_CreateDummyModule( LPCSTR filename, HMODULE module32 )
|
||||||
(int)pStr - (int)pModule;
|
(int)pStr - (int)pModule;
|
||||||
|
|
||||||
NE_RegisterModule( pModule );
|
NE_RegisterModule( pModule );
|
||||||
|
LoadLibraryA( filename ); /* increment the ref count of the 32-bit module */
|
||||||
return hModule;
|
return hModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1714,7 +1714,9 @@ BOOL16 WINAPI IsRomFile16( HFILE16 unused )
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* MapHModuleLS (KERNEL32.@)
|
* MapHModuleLS (KERNEL32.@)
|
||||||
*/
|
*/
|
||||||
HMODULE16 WINAPI MapHModuleLS(HMODULE hmod) {
|
HMODULE16 WINAPI MapHModuleLS(HMODULE hmod)
|
||||||
|
{
|
||||||
|
HMODULE16 ret;
|
||||||
NE_MODULE *pModule;
|
NE_MODULE *pModule;
|
||||||
|
|
||||||
if (!hmod)
|
if (!hmod)
|
||||||
|
@ -1727,7 +1729,12 @@ HMODULE16 WINAPI MapHModuleLS(HMODULE hmod) {
|
||||||
return pModule->self;
|
return pModule->self;
|
||||||
pModule = (NE_MODULE*)GlobalLock16(pModule->next);
|
pModule = (NE_MODULE*)GlobalLock16(pModule->next);
|
||||||
}
|
}
|
||||||
return 0;
|
if ((ret = MODULE_CreateDummyModule( hmod )) < 32)
|
||||||
|
{
|
||||||
|
SetLastError(ret);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "wine/winbase16.h"
|
#include "winbase.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "snoop.h"
|
#include "snoop.h"
|
||||||
#include "wine/server.h"
|
#include "wine/server.h"
|
||||||
|
@ -183,7 +183,6 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
|
||||||
IMAGE_DATA_DIRECTORY *dir;
|
IMAGE_DATA_DIRECTORY *dir;
|
||||||
IMAGE_EXPORT_DIRECTORY *pe_export = NULL;
|
IMAGE_EXPORT_DIRECTORY *pe_export = NULL;
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
HMODULE16 hModule16;
|
|
||||||
|
|
||||||
/* Retrieve DataDirectory entries */
|
/* Retrieve DataDirectory entries */
|
||||||
|
|
||||||
|
@ -247,29 +246,12 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
|
||||||
dir = nt->OptionalHeader.DataDirectory+15;
|
dir = nt->OptionalHeader.DataDirectory+15;
|
||||||
if (dir->Size) FIXME("Unknown directory 15 ignored\n" );
|
if (dir->Size) FIXME("Unknown directory 15 ignored\n" );
|
||||||
|
|
||||||
/* Create 16-bit dummy module */
|
|
||||||
|
|
||||||
if ((hModule16 = MODULE_CreateDummyModule( filename, hModule )) < 32)
|
|
||||||
{
|
|
||||||
SetLastError( (DWORD)hModule16 ); /* This should give the correct error */
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate and fill WINE_MODREF */
|
/* Allocate and fill WINE_MODREF */
|
||||||
|
|
||||||
if (!(wm = MODULE_AllocModRef( hModule, filename )))
|
if (!(wm = MODULE_AllocModRef( hModule, filename ))) return NULL;
|
||||||
{
|
|
||||||
FreeLibrary16( hModule16 );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
wm->hDummyMod = hModule16;
|
|
||||||
|
|
||||||
if ( builtin )
|
if ( builtin )
|
||||||
{
|
|
||||||
NE_MODULE *pModule = (NE_MODULE *)GlobalLock16( hModule16 );
|
|
||||||
pModule->flags |= NE_FFLAGS_BUILTIN;
|
|
||||||
wm->ldr.Flags |= LDR_WINE_INTERNAL;
|
wm->ldr.Flags |= LDR_WINE_INTERNAL;
|
||||||
}
|
|
||||||
else if ( flags & DONT_RESOLVE_DLL_REFERENCES )
|
else if ( flags & DONT_RESOLVE_DLL_REFERENCES )
|
||||||
wm->ldr.Flags |= LDR_DONT_RESOLVE_REFS;
|
wm->ldr.Flags |= LDR_DONT_RESOLVE_REFS;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue