mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-05 20:49:46 +00:00
Perform NE_InitProcess in the context of the new task.
This commit is contained in:
parent
37b51f4acc
commit
b18dbd26c5
|
@ -25,7 +25,6 @@
|
|||
#include "wingdi.h"
|
||||
#include "wine/winuser16.h"
|
||||
#include "winerror.h"
|
||||
#include "process.h"
|
||||
#include "drive.h"
|
||||
#include "file.h"
|
||||
#include "heap.h"
|
||||
|
@ -509,17 +508,16 @@ done:
|
|||
*
|
||||
* Helper function for DIR_SearchPath.
|
||||
*/
|
||||
static BOOL DIR_TryModulePath( LPCSTR name, DOS_FULL_NAME *full_name )
|
||||
static BOOL DIR_TryModulePath( LPCSTR name, DOS_FULL_NAME *full_name, BOOL win32 )
|
||||
{
|
||||
PDB *pdb = PROCESS_Current();
|
||||
|
||||
/* FIXME: for now, GetModuleFileNameA can't return more */
|
||||
/* than OFS_MAXPATHNAME. This may change with Win32. */
|
||||
|
||||
char buffer[OFS_MAXPATHNAME];
|
||||
LPSTR p;
|
||||
|
||||
if (pdb->flags & PDB32_WIN16_PROC) {
|
||||
if (!win32)
|
||||
{
|
||||
if (!GetCurrentTask()) return FALSE;
|
||||
if (!GetModuleFileName16( GetCurrentTask(), buffer, sizeof(buffer) ))
|
||||
buffer[0]='\0';
|
||||
|
@ -595,7 +593,7 @@ DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
|
|||
|
||||
/* Try the path of the current executable (for Win32 search order) */
|
||||
|
||||
if (win32 && DIR_TryModulePath( name, full_name )) goto done;
|
||||
if (win32 && DIR_TryModulePath( name, full_name, win32 )) goto done;
|
||||
|
||||
/* Try the current directory */
|
||||
|
||||
|
@ -613,7 +611,7 @@ DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
|
|||
|
||||
/* Try the path of the current executable (for Win16 search order) */
|
||||
|
||||
if (!win32 && DIR_TryModulePath( name, full_name )) goto done;
|
||||
if (!win32 && DIR_TryModulePath( name, full_name, win32 )) goto done;
|
||||
|
||||
/* Try all directories in path */
|
||||
|
||||
|
|
|
@ -149,7 +149,6 @@ extern BOOL TASK_Create( struct _NE_MODULE *pModule, UINT16 cmdShow,
|
|||
extern void TASK_KillTask( HTASK16 hTask );
|
||||
extern HTASK16 TASK_GetNextTask( HTASK16 hTask );
|
||||
extern void TASK_Reschedule(void);
|
||||
extern void TASK_CallToStart(void);
|
||||
extern void TASK_InstallTHHook( THHOOK *pNewThook );
|
||||
extern void TASK_CallTaskSignalProc( UINT16 uCode, HANDLE16 hTaskOrModule );
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ static NE_MODULE *pCachedModule = 0; /* Module cached by NE_OpenFile */
|
|||
|
||||
static HINSTANCE16 NE_LoadModule( LPCSTR name, BOOL lib_only );
|
||||
static BOOL16 NE_FreeModule( HMODULE16 hModule, BOOL call_wep );
|
||||
static HINSTANCE16 NE_InitProcess( NE_MODULE *pModule, HTASK hTask );
|
||||
static void NE_InitProcess(void) WINE_NORETURN;
|
||||
|
||||
static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_only );
|
||||
|
||||
|
@ -997,9 +997,11 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
|
|||
TEB *teb = NULL;
|
||||
BOOL lib_only = !paramBlock || (paramBlock == (LPVOID)-1);
|
||||
LOADPARAMS16 *params;
|
||||
HINSTANCE16 instance;
|
||||
HINSTANCE16 instance = 0;
|
||||
HMODULE16 hModule;
|
||||
NE_MODULE *pModule;
|
||||
HTASK hTask;
|
||||
TDB *pTask;
|
||||
LPSTR cmdline;
|
||||
WORD cmdShow;
|
||||
int socket;
|
||||
|
@ -1050,7 +1052,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
|
|||
CloseHandle( req->handle );
|
||||
|
||||
if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
|
||||
teb->startup = TASK_CallToStart;
|
||||
teb->startup = NE_InitProcess;
|
||||
|
||||
/* Create a task for this process */
|
||||
|
||||
|
@ -1059,13 +1061,22 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
|
|||
cmdline = PTR_SEG_TO_LIN( params->cmdLine );
|
||||
if (!TASK_Create( pModule, cmdShow, teb, cmdline + 1, *cmdline )) goto error;
|
||||
|
||||
if ((instance = NE_InitProcess( pModule, teb->htask16 )) < 32) goto error;
|
||||
hTask = teb->htask16;
|
||||
|
||||
if (SYSDEPS_SpawnThread( teb ) == -1) goto error;
|
||||
|
||||
/* Post event to start the task */
|
||||
PostEvent16( teb->htask16 );
|
||||
OldYield16();
|
||||
PostEvent16( hTask );
|
||||
|
||||
/* Wait until we get the instance handle */
|
||||
do
|
||||
{
|
||||
DirectedYield16( hTask );
|
||||
if (!IsTask16( hTask )) break;
|
||||
if (!(pTask = (TDB *)GlobalLock16( hTask ))) break;
|
||||
instance = pTask->hInstance;
|
||||
GlobalUnlock16( hTask );
|
||||
} while (!instance);
|
||||
|
||||
return instance;
|
||||
|
||||
|
@ -1079,11 +1090,11 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
|
|||
/**********************************************************************
|
||||
* NE_InitProcess
|
||||
*/
|
||||
static HINSTANCE16 NE_InitProcess( NE_MODULE *pModule, HTASK hTask )
|
||||
static void NE_InitProcess(void)
|
||||
{
|
||||
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
|
||||
NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
|
||||
HINSTANCE16 hInstance, hPrevInstance;
|
||||
TDB *pTask;
|
||||
|
||||
SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
|
||||
WORD sp;
|
||||
|
||||
|
@ -1116,9 +1127,10 @@ static HINSTANCE16 NE_InitProcess( NE_MODULE *pModule, HTASK hTask )
|
|||
|
||||
if ( hInstance >= 32 )
|
||||
{
|
||||
CONTEXT86 context;
|
||||
|
||||
/* Enter instance handles into task struct */
|
||||
|
||||
pTask = (TDB *)GlobalLock16( hTask );
|
||||
pTask->hInstance = hInstance;
|
||||
pTask->hPrevInstance = hPrevInstance;
|
||||
|
||||
|
@ -1129,10 +1141,41 @@ static HINSTANCE16 NE_InitProcess( NE_MODULE *pModule, HTASK hTask )
|
|||
sp &= ~1;
|
||||
sp -= sizeof(STACK16FRAME);
|
||||
pTask->teb->cur_stack = PTR_SEG_OFF_TO_SEGPTR( GlobalHandleToSel16(hInstance), sp );
|
||||
|
||||
/* Registers at initialization must be:
|
||||
* ax zero
|
||||
* bx stack size in bytes
|
||||
* cx heap size in bytes
|
||||
* si previous app instance
|
||||
* di current app instance
|
||||
* bp zero
|
||||
* es selector to the PSP
|
||||
* ds dgroup of the application
|
||||
* ss stack selector
|
||||
* sp top of the stack
|
||||
*/
|
||||
memset( &context, 0, sizeof(context) );
|
||||
CS_reg(&context) = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg);
|
||||
DS_reg(&context) = GlobalHandleToSel16(pTask->hInstance);
|
||||
ES_reg(&context) = pTask->hPDB;
|
||||
EIP_reg(&context) = pModule->ip;
|
||||
EBX_reg(&context) = pModule->stack_size;
|
||||
ECX_reg(&context) = pModule->heap_size;
|
||||
EDI_reg(&context) = pTask->hInstance;
|
||||
ESI_reg(&context) = pTask->hPrevInstance;
|
||||
|
||||
/* Now call 16-bit entry point */
|
||||
|
||||
TRACE("Starting main program: cs:ip=%04lx:%04lx ds=%04lx ss:sp=%04x:%04x\n",
|
||||
CS_reg(&context), EIP_reg(&context), DS_reg(&context),
|
||||
SELECTOROF(pTask->teb->cur_stack),
|
||||
OFFSETOF(pTask->teb->cur_stack) );
|
||||
|
||||
ExitThread( Callbacks->CallRegisterShortProc( &context, 0 ) );
|
||||
}
|
||||
|
||||
SYSLEVEL_LeaveWin16Lock();
|
||||
return hInstance;
|
||||
ExitThread( hInstance );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -212,57 +212,6 @@ static BOOL TASK_FreeThunk( HTASK16 hTask, SEGPTR thunk )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TASK_CallToStart
|
||||
*
|
||||
* 32-bit entry point for a new task. This function is responsible for
|
||||
* setting up the registers and jumping to the 16-bit entry point.
|
||||
*/
|
||||
void TASK_CallToStart(void)
|
||||
{
|
||||
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
|
||||
NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
|
||||
SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
|
||||
CONTEXT86 context;
|
||||
|
||||
SYSLEVEL_EnterWin16Lock();
|
||||
|
||||
/* Add task to 16-bit scheduler pool if necessary */
|
||||
if ( hCurrentTask != GetCurrentTask() )
|
||||
TASK_Reschedule();
|
||||
|
||||
/* Registers at initialization must be:
|
||||
* ax zero
|
||||
* bx stack size in bytes
|
||||
* cx heap size in bytes
|
||||
* si previous app instance
|
||||
* di current app instance
|
||||
* bp zero
|
||||
* es selector to the PSP
|
||||
* ds dgroup of the application
|
||||
* ss stack selector
|
||||
* sp top of the stack
|
||||
*/
|
||||
|
||||
memset( &context, 0, sizeof(context) );
|
||||
CS_reg(&context) = GlobalHandleToSel16(pSegTable[pModule->cs - 1].hSeg);
|
||||
DS_reg(&context) = GlobalHandleToSel16(pTask->hInstance);
|
||||
ES_reg(&context) = pTask->hPDB;
|
||||
EIP_reg(&context) = pModule->ip;
|
||||
EBX_reg(&context) = pModule->stack_size;
|
||||
ECX_reg(&context) = pModule->heap_size;
|
||||
EDI_reg(&context) = pTask->hInstance;
|
||||
ESI_reg(&context) = pTask->hPrevInstance;
|
||||
|
||||
TRACE("Starting main program: cs:ip=%04lx:%04lx ds=%04lx ss:sp=%04x:%04x\n",
|
||||
CS_reg(&context), EIP_reg(&context), DS_reg(&context),
|
||||
SELECTOROF(pTask->teb->cur_stack),
|
||||
OFFSETOF(pTask->teb->cur_stack) );
|
||||
|
||||
Callbacks->CallRegisterShortProc( &context, 0 );
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* TASK_Create
|
||||
*
|
||||
|
@ -287,18 +236,18 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
|
|||
|
||||
/* Fill the task structure */
|
||||
|
||||
pTask->nEvents = 0;
|
||||
pTask->hSelf = hTask;
|
||||
pTask->flags = 0;
|
||||
pTask->hSelf = hTask;
|
||||
|
||||
if (teb->tibflags & TEBF_WIN32) pTask->flags |= TDBF_WIN32;
|
||||
if (teb->tibflags & TEBF_WIN32)
|
||||
{
|
||||
pTask->flags |= TDBF_WIN32;
|
||||
pTask->hInstance = pModule->self;
|
||||
pTask->hPrevInstance = 0;
|
||||
/* NOTE: for 16-bit tasks, the instance handles are updated later on
|
||||
in NE_InitProcess */
|
||||
}
|
||||
if (pModule->lpDosTask) pTask->flags |= TDBF_WINOLDAP;
|
||||
|
||||
pTask->hInstance = pModule->self;
|
||||
pTask->hPrevInstance = 0;
|
||||
/* NOTE: for 16-bit tasks, the instance handles are updated later on
|
||||
in NE_InitProcess */
|
||||
|
||||
pTask->version = pModule->expected_version;
|
||||
pTask->hModule = pModule->self;
|
||||
pTask->hParent = GetCurrentTask();
|
||||
|
|
Loading…
Reference in a new issue