kernel32: Change MODULE_GetBinaryType return value to make dll a flag instead of a type.
This commit is contained in:
parent
5323a454c8
commit
f274d1d03f
|
@ -83,21 +83,19 @@ extern DWORD __wine_emulate_instruction( EXCEPTION_RECORD *rec, CONTEXT86 *conte
|
||||||
extern LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs );
|
extern LONG CALLBACK INSTR_vectored_handler( EXCEPTION_POINTERS *ptrs );
|
||||||
|
|
||||||
/* return values for MODULE_GetBinaryType */
|
/* return values for MODULE_GetBinaryType */
|
||||||
enum binary_type
|
#define BINARY_UNKNOWN 0x00
|
||||||
{
|
#define BINARY_PE 0x01
|
||||||
BINARY_UNKNOWN,
|
#define BINARY_WIN16 0x02
|
||||||
BINARY_PE_EXE,
|
#define BINARY_OS216 0x03
|
||||||
BINARY_PE_DLL,
|
#define BINARY_DOS 0x04
|
||||||
BINARY_WIN16,
|
#define BINARY_UNIX_EXE 0x05
|
||||||
BINARY_OS216,
|
#define BINARY_UNIX_LIB 0x06
|
||||||
BINARY_DOS,
|
#define BINARY_TYPE_MASK 0x0f
|
||||||
BINARY_UNIX_EXE,
|
#define BINARY_FLAG_DLL 0x10
|
||||||
BINARY_UNIX_LIB
|
|
||||||
};
|
|
||||||
|
|
||||||
/* module.c */
|
/* module.c */
|
||||||
extern WCHAR *MODULE_get_dll_load_path( LPCWSTR module );
|
extern WCHAR *MODULE_get_dll_load_path( LPCWSTR module );
|
||||||
extern enum binary_type MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end );
|
extern DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end );
|
||||||
|
|
||||||
extern BOOL NLS_IsUnicodeOnlyLcid(LCID);
|
extern BOOL NLS_IsUnicodeOnlyLcid(LCID);
|
||||||
|
|
||||||
|
|
|
@ -178,11 +178,10 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
|
||||||
* FIXME: is reading the module imports the only way of discerning
|
* FIXME: is reading the module imports the only way of discerning
|
||||||
* old Windows binaries from OS/2 ones ? At least it seems so...
|
* old Windows binaries from OS/2 ones ? At least it seems so...
|
||||||
*/
|
*/
|
||||||
static enum binary_type MODULE_Decide_OS2_OldWin(HANDLE hfile, const IMAGE_DOS_HEADER *mz,
|
static DWORD MODULE_Decide_OS2_OldWin(HANDLE hfile, const IMAGE_DOS_HEADER *mz, const IMAGE_OS2_HEADER *ne)
|
||||||
const IMAGE_OS2_HEADER *ne)
|
|
||||||
{
|
{
|
||||||
DWORD currpos = SetFilePointer( hfile, 0, NULL, SEEK_CUR);
|
DWORD currpos = SetFilePointer( hfile, 0, NULL, SEEK_CUR);
|
||||||
enum binary_type ret = BINARY_OS216;
|
DWORD ret = BINARY_OS216;
|
||||||
LPWORD modtab = NULL;
|
LPWORD modtab = NULL;
|
||||||
LPSTR nametab = NULL;
|
LPSTR nametab = NULL;
|
||||||
DWORD len;
|
DWORD len;
|
||||||
|
@ -227,7 +226,7 @@ good:
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* MODULE_GetBinaryType
|
* MODULE_GetBinaryType
|
||||||
*/
|
*/
|
||||||
enum binary_type MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
|
DWORD MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **res_end )
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -305,13 +304,14 @@ enum binary_type MODULE_GetBinaryType( HANDLE hfile, void **res_start, void **re
|
||||||
{
|
{
|
||||||
if (len >= sizeof(ext_header.nt.FileHeader))
|
if (len >= sizeof(ext_header.nt.FileHeader))
|
||||||
{
|
{
|
||||||
|
DWORD ret = BINARY_PE;
|
||||||
|
if (ext_header.nt.FileHeader.Characteristics & IMAGE_FILE_DLL) ret |= BINARY_FLAG_DLL;
|
||||||
if (len < sizeof(ext_header.nt)) /* clear remaining part of header if missing */
|
if (len < sizeof(ext_header.nt)) /* clear remaining part of header if missing */
|
||||||
memset( (char *)&ext_header.nt + len, 0, sizeof(ext_header.nt) - len );
|
memset( (char *)&ext_header.nt + len, 0, sizeof(ext_header.nt) - len );
|
||||||
if (res_start) *res_start = (void *)ext_header.nt.OptionalHeader.ImageBase;
|
if (res_start) *res_start = (void *)ext_header.nt.OptionalHeader.ImageBase;
|
||||||
if (res_end) *res_end = (void *)(ext_header.nt.OptionalHeader.ImageBase +
|
if (res_end) *res_end = (void *)(ext_header.nt.OptionalHeader.ImageBase +
|
||||||
ext_header.nt.OptionalHeader.SizeOfImage);
|
ext_header.nt.OptionalHeader.SizeOfImage);
|
||||||
if (ext_header.nt.FileHeader.Characteristics & IMAGE_FILE_DLL) return BINARY_PE_DLL;
|
return ret;
|
||||||
return BINARY_PE_EXE;
|
|
||||||
}
|
}
|
||||||
return BINARY_DOS;
|
return BINARY_DOS;
|
||||||
}
|
}
|
||||||
|
@ -384,6 +384,7 @@ BOOL WINAPI GetBinaryTypeW( LPCWSTR lpApplicationName, LPDWORD lpBinaryType )
|
||||||
{
|
{
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
|
DWORD binary_type;
|
||||||
|
|
||||||
TRACE("%s\n", debugstr_w(lpApplicationName) );
|
TRACE("%s\n", debugstr_w(lpApplicationName) );
|
||||||
|
|
||||||
|
@ -401,7 +402,8 @@ BOOL WINAPI GetBinaryTypeW( LPCWSTR lpApplicationName, LPDWORD lpBinaryType )
|
||||||
|
|
||||||
/* Check binary type
|
/* Check binary type
|
||||||
*/
|
*/
|
||||||
switch(MODULE_GetBinaryType( hfile, NULL, NULL ))
|
binary_type = MODULE_GetBinaryType( hfile, NULL, NULL );
|
||||||
|
switch (binary_type & BINARY_TYPE_MASK)
|
||||||
{
|
{
|
||||||
case BINARY_UNKNOWN:
|
case BINARY_UNKNOWN:
|
||||||
{
|
{
|
||||||
|
@ -424,8 +426,7 @@ BOOL WINAPI GetBinaryTypeW( LPCWSTR lpApplicationName, LPDWORD lpBinaryType )
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BINARY_PE_EXE:
|
case BINARY_PE:
|
||||||
case BINARY_PE_DLL:
|
|
||||||
*lpBinaryType = SCS_32BIT_BINARY;
|
*lpBinaryType = SCS_32BIT_BINARY;
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1909,6 +1909,7 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB
|
||||||
WCHAR name[MAX_PATH];
|
WCHAR name[MAX_PATH];
|
||||||
WCHAR *tidy_cmdline, *p, *envW = env;
|
WCHAR *tidy_cmdline, *p, *envW = env;
|
||||||
void *res_start, *res_end;
|
void *res_start, *res_end;
|
||||||
|
DWORD binary_type;
|
||||||
|
|
||||||
/* Process the AppName and/or CmdLine to get module name and path */
|
/* Process the AppName and/or CmdLine to get module name and path */
|
||||||
|
|
||||||
|
@ -1966,9 +1967,15 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( MODULE_GetBinaryType( hFile, &res_start, &res_end ))
|
binary_type = MODULE_GetBinaryType( hFile, &res_start, &res_end );
|
||||||
|
if (binary_type & BINARY_FLAG_DLL)
|
||||||
{
|
{
|
||||||
case BINARY_PE_EXE:
|
TRACE( "not starting %s since it is a dll\n", debugstr_w(name) );
|
||||||
|
SetLastError( ERROR_BAD_EXE_FORMAT );
|
||||||
|
}
|
||||||
|
else switch (binary_type & BINARY_TYPE_MASK)
|
||||||
|
{
|
||||||
|
case BINARY_PE:
|
||||||
TRACE( "starting %s as Win32 binary (%p-%p)\n", debugstr_w(name), res_start, res_end );
|
TRACE( "starting %s as Win32 binary (%p-%p)\n", debugstr_w(name), res_start, res_end );
|
||||||
retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
|
retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
|
||||||
inherit, flags, startup_info, info, unixdir, res_start, res_end, FALSE );
|
inherit, flags, startup_info, info, unixdir, res_start, res_end, FALSE );
|
||||||
|
@ -1980,10 +1987,6 @@ BOOL WINAPI CreateProcessW( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_ATTRIB
|
||||||
retv = create_vdm_process( name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
|
retv = create_vdm_process( name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
|
||||||
inherit, flags, startup_info, info, unixdir, FALSE );
|
inherit, flags, startup_info, info, unixdir, FALSE );
|
||||||
break;
|
break;
|
||||||
case BINARY_PE_DLL:
|
|
||||||
TRACE( "not starting %s since it is a dll\n", debugstr_w(name) );
|
|
||||||
SetLastError( ERROR_BAD_EXE_FORMAT );
|
|
||||||
break;
|
|
||||||
case BINARY_UNIX_LIB:
|
case BINARY_UNIX_LIB:
|
||||||
TRACE( "%s is a Unix library, starting as Winelib app\n", debugstr_w(name) );
|
TRACE( "%s is a Unix library, starting as Winelib app\n", debugstr_w(name) );
|
||||||
retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
|
retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr,
|
||||||
|
@ -2046,6 +2049,7 @@ static void exec_process( LPCWSTR name )
|
||||||
void *res_start, *res_end;
|
void *res_start, *res_end;
|
||||||
STARTUPINFOW startup_info;
|
STARTUPINFOW startup_info;
|
||||||
PROCESS_INFORMATION info;
|
PROCESS_INFORMATION info;
|
||||||
|
DWORD binary_type;
|
||||||
|
|
||||||
hFile = open_exe_file( name );
|
hFile = open_exe_file( name );
|
||||||
if (!hFile || hFile == INVALID_HANDLE_VALUE) return;
|
if (!hFile || hFile == INVALID_HANDLE_VALUE) return;
|
||||||
|
@ -2055,9 +2059,11 @@ static void exec_process( LPCWSTR name )
|
||||||
|
|
||||||
/* Determine executable type */
|
/* Determine executable type */
|
||||||
|
|
||||||
switch( MODULE_GetBinaryType( hFile, &res_start, &res_end ))
|
binary_type = MODULE_GetBinaryType( hFile, &res_start, &res_end );
|
||||||
|
if (binary_type & BINARY_FLAG_DLL) return;
|
||||||
|
switch (binary_type & BINARY_TYPE_MASK)
|
||||||
{
|
{
|
||||||
case BINARY_PE_EXE:
|
case BINARY_PE:
|
||||||
TRACE( "starting %s as Win32 binary (%p-%p)\n", debugstr_w(name), res_start, res_end );
|
TRACE( "starting %s as Win32 binary (%p-%p)\n", debugstr_w(name), res_start, res_end );
|
||||||
create_process( hFile, name, GetCommandLineW(), NULL, NULL, NULL, NULL,
|
create_process( hFile, name, GetCommandLineW(), NULL, NULL, NULL, NULL,
|
||||||
FALSE, 0, &startup_info, &info, NULL, res_start, res_end, TRUE );
|
FALSE, 0, &startup_info, &info, NULL, res_start, res_end, TRUE );
|
||||||
|
|
Loading…
Reference in New Issue