kernel32: Add support for loading stand-alone 16-bit modules.

This commit is contained in:
Alexandre Julliard 2009-02-24 18:09:09 +01:00
parent af2e40ea26
commit cd6295d276
1 changed files with 19 additions and 3 deletions

View File

@ -1045,7 +1045,7 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_
NE_MODULE *pModule; NE_MODULE *pModule;
const IMAGE_DOS_HEADER *descr = NULL; const IMAGE_DOS_HEADER *descr = NULL;
const char *file_name = NULL; const char *file_name = NULL;
char dllname[20], owner[20], *p; char dllname[32], owner[20], *p;
const char *basename; const char *basename;
int owner_exists = FALSE; int owner_exists = FALSE;
@ -1056,14 +1056,30 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_
if ((p = strrchr( basename, '\\' ))) basename = p + 1; if ((p = strrchr( basename, '\\' ))) basename = p + 1;
if ((p = strrchr( basename, '/' ))) basename = p + 1; if ((p = strrchr( basename, '/' ))) basename = p + 1;
if (strlen(basename) < sizeof(dllname)-4) if (strlen(basename) < sizeof(dllname)-6)
{ {
strcpy( dllname, basename ); strcpy( dllname, basename );
p = strrchr( dllname, '.' ); p = strrchr( dllname, '.' );
if (!p) strcat( dllname, ".dll" ); if (!p) strcat( dllname, ".dll" );
for (p = dllname; *p; p++) if (*p >= 'A' && *p <= 'Z') *p += 32; for (p = dllname; *p; p++) if (*p >= 'A' && *p <= 'Z') *p += 32;
if (wine_dll_get_owner( dllname, owner, sizeof(owner), &owner_exists ) != -1) strcpy( p, "16" );
if ((mod32 = LoadLibraryA( dllname )))
{
if (!(descr = (void *)GetProcAddress( mod32, "__wine_spec_dos_header" )))
{
WARN( "loaded %s but does not contain a 16-bit module\n", debugstr_a(dllname) );
FreeLibrary( mod32 );
}
else
{
TRACE( "found %s with embedded 16-bit module\n", debugstr_a(dllname) );
file_name = basename;
}
}
*p = 0;
if (!descr && wine_dll_get_owner( dllname, owner, sizeof(owner), &owner_exists ) != -1)
{ {
mod32 = LoadLibraryA( owner ); mod32 = LoadLibraryA( owner );
if (mod32) if (mod32)