Commit 105b0f4e authored by Alexandre Julliard's avatar Alexandre Julliard

Use the exe name and file handle we got from the server also when

starting Win16 or DOS programs, to avoid depending on the contents of the command-line.
parent 2362380b
......@@ -333,33 +333,9 @@ load_error:
return FALSE;
}
BOOL WINAPI MZ_LoadImage( LPCSTR cmdline )
void WINAPI MZ_LoadImage( LPCSTR filename, HANDLE hFile )
{
HFILE hFile;
char *name, buffer[MAX_PATH];
LPCSTR p = strchr( cmdline, ' ' );
if (p)
{
if (!(name = HeapAlloc( GetProcessHeap(), 0, p - cmdline + 1 ))) return FALSE;
memcpy( name, cmdline, p - cmdline );
name[p - cmdline] = 0;
}
else name = (char *)cmdline;
if (!SearchPathA( NULL, name, ".exe", sizeof(buffer), buffer, NULL )) goto error;
if ((hFile = CreateFileA( buffer, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
goto error;
if (!MZ_DoLoadImage( hFile, buffer, NULL ))
{
CloseHandle( hFile );
goto error;
}
MZ_Launch();
error:
if (name != cmdline) HeapFree( GetProcessHeap(), 0, name );
return FALSE;
if (MZ_DoLoadImage( hFile, filename, NULL )) MZ_Launch();
}
BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk )
......@@ -609,11 +585,10 @@ void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval )
#else /* !MZ_SUPPORTED */
BOOL WINAPI MZ_LoadImage( LPCSTR cmdline )
void WINAPI MZ_LoadImage( LPCSTR filename, HANDLE hFile )
{
WARN("DOS executables not supported on this platform\n");
SetLastError(ERROR_BAD_FORMAT);
return FALSE;
}
BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk )
......
......@@ -7,7 +7,7 @@ import ntdll.dll
@ stdcall GetCurrent() MZ_Current
@ stdcall LoadDPMI() MZ_AllocDPMITask
@ stdcall LoadDosExe(str) MZ_LoadImage
@ stdcall LoadDosExe(str long) MZ_LoadImage
@ stdcall Exec(ptr str long ptr) MZ_Exec
@ stdcall Exit(ptr long long) MZ_Exit
......
......@@ -52,7 +52,7 @@ extern CALLOUT_TABLE Callout;
typedef struct {
struct _DOSTASK* WINAPI (*Current)( void );
struct _DOSTASK* WINAPI (*LoadDPMI)( void );
BOOL WINAPI (*LoadDosExe)( LPCSTR cmdline );
void WINAPI (*LoadDosExe)( LPCSTR filename, HANDLE hFile );
BOOL WINAPI (*Exec)( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk );
void WINAPI (*Exit)( CONTEXT86 *context, BOOL cs_psp, WORD retval );
int WINAPI (*Enter)( CONTEXT86 *context );
......
......@@ -30,7 +30,7 @@ typedef struct _DOSTASK {
#define V86_FLAG 0x00020000
extern BOOL WINAPI MZ_LoadImage( LPCSTR cmdline );
extern void WINAPI MZ_LoadImage( LPCSTR filename, HANDLE hFile );
extern BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk );
extern void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval );
extern LPDOSTASK WINAPI MZ_Current( void );
......
......@@ -14,7 +14,12 @@
#include "dosexe.h"
#include "debugtools.h"
extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN;
static char main_exe_name[MAX_PATH];
static HANDLE main_exe_file;
extern void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name,
HANDLE *win16_exe_file ) WINE_NORETURN;
extern HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file );
/***********************************************************************
* Main loop of initial task
......@@ -31,12 +36,12 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT
}
THUNK_InitCallout();
if ((instance = WinExec16( GetCommandLineA(), show )) < 32)
if ((instance = NE_StartMain( main_exe_name, main_exe_file )) < 32)
{
if (instance == 11) /* try DOS format */
{
if (DPMI_LoadDosSystem())
Dosvm.LoadDosExe( GetCommandLineA() );
Dosvm.LoadDosExe( main_exe_name, main_exe_file );
/* if we get back here it failed */
instance = GetLastError();
}
......@@ -50,6 +55,7 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT
}
ExitProcess(instance);
}
CloseHandle( main_exe_file ); /* avoid file sharing problems */
/* Start message loop for desktop window */
......@@ -68,6 +74,6 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT
*/
int main( int argc, char *argv[] )
{
PROCESS_InitWine( argc, argv );
PROCESS_InitWine( argc, argv, main_exe_name, &main_exe_file );
return 1; /* not reached */
}
......@@ -437,7 +437,7 @@ void *open_winelib_app( char *argv[] )
*
* Wine initialisation: load and start the main exe file.
*/
void PROCESS_InitWine( int argc, char *argv[] )
void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, HANDLE *win16_exe_file )
{
DWORD stack_size = 0;
......@@ -483,8 +483,9 @@ void PROCESS_InitWine( int argc, char *argv[] )
/* it must be 16-bit or DOS format */
NtCurrentTeb()->tibflags &= ~TEBF_WIN32;
current_process.flags |= PDB32_WIN16_PROC;
strcpy( win16_exe_name, main_exe_name );
main_exe_name[0] = 0;
CloseHandle( main_exe_file );
*win16_exe_file = main_exe_file;
main_exe_file = 0;
_EnterWin16Lock();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment