mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-05 14:08:21 +00:00
Determine expected_version of PE buddies from the SubsystemVersion.
This commit is contained in:
parent
ae8342df48
commit
e7957d6b48
|
@ -183,7 +183,7 @@ extern void MODULE_DllThreadDetach( LPVOID lpReserved );
|
|||
extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
|
||||
extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
|
||||
extern WINE_MODREF *MODULE_FindModule( LPCSTR path );
|
||||
extern HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName );
|
||||
extern HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName, WORD version );
|
||||
extern FARPROC16 WINAPI WIN32_GetProcAddress16( HMODULE hmodule, LPCSTR name );
|
||||
extern SEGPTR WINAPI HasGPHandler16( SEGPTR address );
|
||||
extern void MODULE_WalkModref( DWORD id );
|
||||
|
|
|
@ -28,7 +28,7 @@ extern DWORD PE_SizeofResource(HMODULE,HRSRC);
|
|||
extern struct _wine_modref *PE_LoadLibraryExA(LPCSTR, DWORD, DWORD *);
|
||||
extern void PE_UnloadLibrary(struct _wine_modref *);
|
||||
extern HGLOBAL PE_LoadResource(struct _wine_modref *wm,HRSRC);
|
||||
extern HMODULE PE_LoadImage( HFILE hFile, OFSTRUCT *ofs, LPCSTR *modName );
|
||||
extern HMODULE PE_LoadImage( HFILE hFile, OFSTRUCT *ofs, LPCSTR *modName, WORD *version );
|
||||
extern struct _wine_modref *PE_CreateModule( HMODULE hModule, OFSTRUCT *ofs,
|
||||
DWORD flags, BOOL builtin );
|
||||
extern BOOL PE_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmd_line, LPCSTR env,
|
||||
|
|
|
@ -469,7 +469,7 @@ BOOL MZ_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmdline, LPCSTR env,
|
|||
|
||||
if ((!env)&&pdb) env = pdb->env_db->environ;
|
||||
if (alloc) {
|
||||
if ((hModule = MODULE_CreateDummyModule(ofs, NULL)) < 32) {
|
||||
if ((hModule = MODULE_CreateDummyModule(ofs, NULL, 0)) < 32) {
|
||||
SetLastError(hModule);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] )
|
|||
PROCESS_Current()->exe_modref = wm;
|
||||
|
||||
strcpy( ofs.szPathName, wm->modname );
|
||||
if ((hModule = MODULE_CreateDummyModule( &ofs, NULL )) < 32) return 0;
|
||||
if ((hModule = MODULE_CreateDummyModule( &ofs, NULL, 0 )) < 32) return 0;
|
||||
pModule = (NE_MODULE *)GlobalLock16( hModule );
|
||||
pModule->flags = NE_FFLAGS_WIN32;
|
||||
pModule->module32 = wm->module;
|
||||
|
|
|
@ -333,7 +333,7 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
|
|||
*
|
||||
* Create a dummy NE module for Win32 or Winelib.
|
||||
*/
|
||||
HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName )
|
||||
HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName, WORD version )
|
||||
{
|
||||
HMODULE hModule;
|
||||
NE_MODULE *pModule;
|
||||
|
@ -375,7 +375,7 @@ HMODULE MODULE_CreateDummyModule( const OFSTRUCT *ofs, LPCSTR modName )
|
|||
pModule->nrname_size = 0;
|
||||
pModule->fileinfo = sizeof(NE_MODULE);
|
||||
pModule->os_flags = NE_OSFLAGS_WINDOWS;
|
||||
pModule->expected_version = 0x030a;
|
||||
pModule->expected_version = version;
|
||||
pModule->self = hModule;
|
||||
|
||||
/* Set loaded file information */
|
||||
|
@ -1470,7 +1470,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
|
|||
break;
|
||||
}
|
||||
|
||||
ERR_(module)("Failed to load module '%s'; error=0x%08lx, \n", libname, err);
|
||||
WARN_(module)("Failed to load module '%s'; error=0x%08lx, \n", libname, err);
|
||||
SetLastError(err);
|
||||
LeaveCriticalSection(&PROCESS_Current()->crit_section);
|
||||
return NULL;
|
||||
|
|
|
@ -1377,17 +1377,15 @@ WORD WINAPI GetExpWinVer16( HMODULE16 hModule )
|
|||
/*
|
||||
* For built-in modules, fake the expected version the module should
|
||||
* have according to the Windows version emulated by Wine
|
||||
*
|
||||
* FIXME: Should we really do this for Win32 dummy modules as well?
|
||||
*/
|
||||
if ( (pModule->flags & NE_FFLAGS_BUILTIN)
|
||||
|| (pModule->flags & NE_FFLAGS_WIN32) )
|
||||
if ( !pModule->expected_version )
|
||||
{
|
||||
OSVERSIONINFOA versionInfo;
|
||||
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
|
||||
|
||||
if ( GetVersionExA( &versionInfo ) )
|
||||
return (versionInfo.dwMajorVersion & 0xff) << 8
|
||||
pModule->expected_version =
|
||||
(versionInfo.dwMajorVersion & 0xff) << 8
|
||||
| (versionInfo.dwMinorVersion & 0xff);
|
||||
}
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ static void do_relocations( unsigned int load_addr, IMAGE_BASE_RELOCATION *r )
|
|||
* BUT we have to map the whole image anyway, for Win32 programs sometimes
|
||||
* want to access them. (HMODULE32 point to the start of it)
|
||||
*/
|
||||
HMODULE PE_LoadImage( HFILE hFile, OFSTRUCT *ofs, LPCSTR *modName )
|
||||
HMODULE PE_LoadImage( HFILE hFile, OFSTRUCT *ofs, LPCSTR *modName, WORD *version )
|
||||
{
|
||||
HMODULE hModule;
|
||||
HANDLE mapping;
|
||||
|
@ -663,6 +663,10 @@ HMODULE PE_LoadImage( HFILE hFile, OFSTRUCT *ofs, LPCSTR *modName )
|
|||
if (dir->Size)
|
||||
*modName = (LPCSTR)RVA(((PIMAGE_EXPORT_DIRECTORY)RVA(dir->VirtualAddress))->Name);
|
||||
|
||||
/* Get expected OS / Subsystem version */
|
||||
*version = ( (nt->OptionalHeader.MajorSubsystemVersion & 0xff) << 8 )
|
||||
| (nt->OptionalHeader.MinorSubsystemVersion & 0xff);
|
||||
|
||||
/* We don't need the orignal mapping any more */
|
||||
UnmapViewOfFile( (LPVOID)hModule );
|
||||
return (HMODULE)load_addr;
|
||||
|
@ -882,6 +886,7 @@ WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags, DWORD *err)
|
|||
WINE_MODREF *wm;
|
||||
char dllname[256], *p;
|
||||
HFILE hFile;
|
||||
WORD version = 0;
|
||||
|
||||
/* Append .DLL to name if no extension present */
|
||||
strcpy( dllname, name );
|
||||
|
@ -892,7 +897,7 @@ WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags, DWORD *err)
|
|||
hFile = OpenFile( dllname, &ofs, OF_READ | OF_SHARE_DENY_WRITE );
|
||||
if ( hFile != HFILE_ERROR )
|
||||
{
|
||||
hModule32 = PE_LoadImage( hFile, &ofs, &modName );
|
||||
hModule32 = PE_LoadImage( hFile, &ofs, &modName, &version );
|
||||
CloseHandle( hFile );
|
||||
if(!hModule32)
|
||||
{
|
||||
|
@ -907,7 +912,7 @@ WINE_MODREF *PE_LoadLibraryExA (LPCSTR name, DWORD flags, DWORD *err)
|
|||
}
|
||||
|
||||
/* Create 16-bit dummy module */
|
||||
if ((hModule16 = MODULE_CreateDummyModule( &ofs, modName )) < 32)
|
||||
if ((hModule16 = MODULE_CreateDummyModule( &ofs, modName, version )) < 32)
|
||||
{
|
||||
*err = (DWORD)hModule16; /* This should give the correct error */
|
||||
return NULL;
|
||||
|
@ -954,12 +959,13 @@ BOOL PE_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmd_line, LPCSTR env,
|
|||
LPPROCESS_INFORMATION info )
|
||||
{
|
||||
LPCSTR modName = NULL;
|
||||
WORD version = 0;
|
||||
HMODULE16 hModule16;
|
||||
HMODULE hModule32;
|
||||
NE_MODULE *pModule;
|
||||
|
||||
/* Load file */
|
||||
if ( (hModule32 = PE_LoadImage( hFile, ofs, &modName )) < 32 )
|
||||
if ( (hModule32 = PE_LoadImage( hFile, ofs, &modName, &version )) < 32 )
|
||||
{
|
||||
SetLastError( hModule32 );
|
||||
return FALSE;
|
||||
|
@ -973,7 +979,7 @@ BOOL PE_CreateProcess( HFILE hFile, OFSTRUCT *ofs, LPCSTR cmd_line, LPCSTR env,
|
|||
#endif
|
||||
|
||||
/* Create 16-bit dummy module */
|
||||
if ( (hModule16 = MODULE_CreateDummyModule( ofs, modName )) < 32 )
|
||||
if ( (hModule16 = MODULE_CreateDummyModule( ofs, modName, version )) < 32 )
|
||||
{
|
||||
SetLastError( hModule16 );
|
||||
return FALSE;
|
||||
|
|
|
@ -487,7 +487,7 @@ WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR path, DWORD flags, DWORD *err)
|
|||
}
|
||||
|
||||
/* Create 16-bit dummy module */
|
||||
if ((hModule16 = MODULE_CreateDummyModule( &ofs, modName )) < 32)
|
||||
if ((hModule16 = MODULE_CreateDummyModule( &ofs, modName, 0 )) < 32)
|
||||
{
|
||||
*err = (DWORD)hModule16;
|
||||
return NULL; /* FIXME: Should unload the builtin module */
|
||||
|
|
|
@ -873,7 +873,7 @@ static int BuildModule16( FILE *outfile, int max_code_offset,
|
|||
pModule->dlls_to_init = 0;
|
||||
pModule->nrname_handle = 0;
|
||||
pModule->min_swap_area = 0;
|
||||
pModule->expected_version = 0x030a;
|
||||
pModule->expected_version = 0;
|
||||
pModule->module32 = 0;
|
||||
pModule->self = 0;
|
||||
pModule->self_loading_sel = 0;
|
||||
|
|
Loading…
Reference in a new issue