From 1060567cc592aaf7aa453d43a0a48bf7e9ac87f3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 25 Sep 2018 19:23:00 +0200 Subject: [PATCH] kernel32: Remove the DOS/Win16/OS2 binary distinction. They all need to be run through winevdm. Signed-off-by: Alexandre Julliard --- dlls/kernel32/kernel_private.h | 2 -- dlls/kernel32/module.c | 72 +----------------------------------------- dlls/kernel32/process.c | 8 ++--- 3 files changed, 3 insertions(+), 79 deletions(-) diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h index 9073e18489b..b465d175999 100644 --- a/dlls/kernel32/kernel_private.h +++ b/dlls/kernel32/kernel_private.h @@ -69,8 +69,6 @@ enum binary_type BINARY_UNKNOWN = 0, BINARY_PE, BINARY_WIN16, - BINARY_OS216, - BINARY_DOS, BINARY_UNIX_EXE, BINARY_UNIX_LIB }; diff --git a/dlls/kernel32/module.c b/dlls/kernel32/module.c index 31e3014924c..f03b4988479 100644 --- a/dlls/kernel32/module.c +++ b/dlls/kernel32/module.c @@ -259,54 +259,6 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule ) } -/* Check whether a file is an OS/2 or a very old Windows executable - * by testing on import of KERNEL. - * - * Reading the module imports is the only reasonable way of discerning - * old Windows binaries from OS/2 ones. - */ -static DWORD MODULE_Decide_OS2_OldWin(HANDLE hfile, const IMAGE_DOS_HEADER *mz, const IMAGE_OS2_HEADER *ne) -{ - DWORD currpos = SetFilePointer( hfile, 0, NULL, SEEK_CUR); - DWORD ret = BINARY_OS216; - LPWORD modtab = NULL; - LPSTR nametab = NULL; - DWORD len; - int i; - - /* read modref table */ - if ( (SetFilePointer( hfile, mz->e_lfanew + ne->ne_modtab, NULL, SEEK_SET ) == -1) - || (!(modtab = HeapAlloc( GetProcessHeap(), 0, ne->ne_cmod*sizeof(WORD)))) - || (!(ReadFile(hfile, modtab, ne->ne_cmod*sizeof(WORD), &len, NULL))) - || (len != ne->ne_cmod*sizeof(WORD)) ) - goto done; - - /* read imported names table */ - if ( (SetFilePointer( hfile, mz->e_lfanew + ne->ne_imptab, NULL, SEEK_SET ) == -1) - || (!(nametab = HeapAlloc( GetProcessHeap(), 0, ne->ne_enttab - ne->ne_imptab))) - || (!(ReadFile(hfile, nametab, ne->ne_enttab - ne->ne_imptab, &len, NULL))) - || (len != ne->ne_enttab - ne->ne_imptab) ) - goto done; - - for (i=0; i < ne->ne_cmod; i++) - { - LPSTR module = &nametab[modtab[i]]; - TRACE("modref: %.*s\n", module[0], &module[1]); - if (!(strncmp(&module[1], "KERNEL", module[0]))) - { /* very old Windows file */ - MESSAGE("This seems to be a very old (pre-3.0) Windows executable. Expect crashes, especially if this is a real-mode binary !\n"); - ret = BINARY_WIN16; - break; - } - } - -done: - HeapFree( GetProcessHeap(), 0, modtab); - HeapFree( GetProcessHeap(), 0, nametab); - SetFilePointer( hfile, currpos, NULL, SEEK_SET); /* restore filepos */ - return ret; -} - /*********************************************************************** * MODULE_GetBinaryType */ @@ -460,7 +412,7 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info ) * This will tell us if there is more header information * to read or not. */ - info->type = BINARY_DOS; + info->type = BINARY_WIN16; info->arch = IMAGE_FILE_MACHINE_I386; if (SetFilePointer( hfile, header.mz.e_lfanew, NULL, SEEK_SET ) == -1) return; if (!ReadFile( hfile, &ext_header, sizeof(ext_header), &len, NULL ) || len < 4) return; @@ -504,28 +456,6 @@ void MODULE_get_binary_info( HANDLE hfile, struct binary_info *info ) } } } - else if (!memcmp( &ext_header.os2.ne_magic, "NE", 2 )) - { - /* This is a Windows executable (NE) header. This can - * mean either a 16-bit OS/2 or a 16-bit Windows or even a - * DOS program (running under a DOS extender). To decide - * which, we'll have to read the NE header. - */ - if (len >= sizeof(ext_header.os2)) - { - if (ext_header.os2.ne_flags & NE_FFLAGS_LIBMODULE) info->flags |= BINARY_FLAG_DLL; - switch ( ext_header.os2.ne_exetyp ) - { - case 1: info->type = BINARY_OS216; break; /* OS/2 */ - case 2: info->type = BINARY_WIN16; break; /* Windows */ - case 3: info->type = BINARY_DOS; break; /* European MS-DOS 4.x */ - case 4: info->type = BINARY_WIN16; break; /* Windows 386; FIXME: is this 32bit??? */ - case 5: info->type = BINARY_DOS; break; /* BOSS, Borland Operating System Services */ - /* other types, e.g. 0 is: "unknown" */ - default: info->type = MODULE_Decide_OS2_OldWin(hfile, &header.mz, &ext_header.os2); break; - } - } - } } } diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index b0b5ccf5bca..e1590474e46 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -2478,9 +2478,7 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A retv = create_process( hFile, name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr, inherit, flags, startup_info, info, unixdir, &binary_info, FALSE ); break; - case BINARY_OS216: case BINARY_WIN16: - case BINARY_DOS: TRACE( "starting %s as Win16/DOS binary\n", debugstr_w(name) ); retv = create_vdm_process( name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr, inherit, flags, startup_info, info, unixdir, &binary_info, FALSE ); @@ -2498,7 +2496,7 @@ static BOOL create_process_impl( LPCWSTR app_name, LPWSTR cmd_line, LPSECURITY_A if (!strcmpiW( p, comW ) || !strcmpiW( p, pifW )) { TRACE( "starting %s as DOS binary\n", debugstr_w(name) ); - binary_info.type = BINARY_DOS; + binary_info.type = BINARY_WIN16; binary_info.arch = IMAGE_FILE_MACHINE_I386; retv = create_vdm_process( name, tidy_cmdline, envW, cur_dir, process_attr, thread_attr, inherit, flags, startup_info, info, unixdir, @@ -2640,12 +2638,10 @@ static void exec_process( LPCWSTR name ) /* check for .com or .pif extension */ if (!(p = strrchrW( name, '.' ))) break; if (strcmpiW( p, comW ) && strcmpiW( p, pifW )) break; - binary_info.type = BINARY_DOS; + binary_info.type = BINARY_WIN16; binary_info.arch = IMAGE_FILE_MACHINE_I386; /* fall through */ - case BINARY_OS216: case BINARY_WIN16: - case BINARY_DOS: TRACE( "starting %s as Win16/DOS binary\n", debugstr_w(name) ); create_vdm_process( name, GetCommandLineW(), NULL, NULL, NULL, NULL, FALSE, 0, &startup_info, &info, NULL, &binary_info, TRUE ); -- 2.11.4.GIT