Commit 4d057619 authored by Bernd Herd's avatar Bernd Herd Committed by Alexandre Julliard

Make sure hInstance is a proper global handle and not a selector

value.
parent 07723941
......@@ -1206,7 +1206,7 @@ BOOL NE_InitProcess( NE_MODULE *pModule )
if (!(sp = pModule->sp))
sp = pSegTable[pModule->ss-1].minsize + pModule->stack_size;
sp &= ~1; sp -= sizeof(STACK16FRAME);
pTask->teb->cur_stack = PTR_SEG_OFF_TO_SEGPTR( hInstance, sp );
pTask->teb->cur_stack = PTR_SEG_OFF_TO_SEGPTR( GlobalHandleToSel16(hInstance), sp );
SYSLEVEL_LeaveWin16Lock();
......
......@@ -576,7 +576,7 @@ static VOID NE_GetDLLInitParams( NE_MODULE *pModule,
}
}
*hInst = *ds ? *ds : pModule->self;
*hInst = *ds ? GlobalHandle16(*ds) : pModule->self;
}
......@@ -834,8 +834,7 @@ HINSTANCE16 NE_GetInstance( NE_MODULE *pModule )
{
SEGTABLEENTRY *pSeg;
pSeg = NE_SEG_TABLE( pModule ) + pModule->dgroup - 1;
return SEL(pSeg->hSeg);
return pSeg->hSeg;
}
}
......
......@@ -716,7 +716,7 @@ void WINAPI InitTask16( CONTEXT86 *context )
/* Initialize the local heap */
if ( CX_reg(context) )
LocalInit16( pTask->hInstance, 0, CX_reg(context) );
LocalInit16( GlobalHandleToSel16(pTask->hInstance), 0, CX_reg(context) );
/* Initialize implicitly loaded DLLs */
NE_InitializeDLLs( pTask->hModule );
......@@ -928,6 +928,9 @@ FARPROC16 WINAPI MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
{
BYTE *thunk,*lfunc;
SEGPTR thunkaddr;
WORD hInstanceSelector;
hInstanceSelector = GlobalHandleToSel16(hInstance);
TRACE("(%08lx, %04x);", (DWORD)func, hInstance);
......@@ -948,7 +951,7 @@ FARPROC16 WINAPI MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
}
}
if ( (CURRENT_DS != hInstance)
if ( (CURRENT_DS != hInstanceSelector)
&& (hInstance != 0)
&& (hInstance != 0xffff) )
{
......@@ -961,7 +964,8 @@ FARPROC16 WINAPI MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
* We used to set hInstance to GetTaskDS16(), but this should be wrong
* as CURRENT_DS provides the DSEG value we need.
* ("calling" DS, *not* "task" DS !) */
hInstance = CURRENT_DS;
hInstanceSelector = CURRENT_DS;
hInstance = GlobalHandle16(hInstanceSelector);
/* no thunking for DLLs */
if (NE_GetPtr(FarGetOwner16(hInstance))->flags & NE_FFLAGS_LIBMODULE)
......@@ -981,8 +985,8 @@ FARPROC16 WINAPI MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
}
*thunk++ = 0xb8; /* movw instance, %ax */
*thunk++ = (BYTE)(hInstance & 0xff);
*thunk++ = (BYTE)(hInstance >> 8);
*thunk++ = (BYTE)(hInstanceSelector & 0xff);
*thunk++ = (BYTE)(hInstanceSelector >> 8);
*thunk++ = 0xea; /* ljmp func */
*(DWORD *)thunk = (DWORD)func;
return (FARPROC16)thunkaddr;
......@@ -1433,7 +1437,7 @@ HINSTANCE16 WINAPI GetTaskDS16(void)
TDB *pTask;
if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
return pTask->hInstance;
return GlobalHandleToSel16(pTask->hInstance);
}
/***********************************************************************
......@@ -1631,7 +1635,7 @@ BOOL16 WINAPI TaskNext16( TASKENTRY *lpte )
if (!lpte->hNext) return FALSE;
pTask = (TDB *)GlobalLock16( lpte->hNext );
if (!pTask || pTask->magic != TDB_MAGIC) return FALSE;
pInstData = (INSTANCEDATA *)PTR_SEG_OFF_TO_LIN( pTask->hInstance, 0 );
pInstData = (INSTANCEDATA *)PTR_SEG_OFF_TO_LIN( GlobalHandleToSel16(pTask->hInstance), 0 );
lpte->hTask = lpte->hNext;
lpte->hTaskParent = pTask->hParent;
lpte->hInst = pTask->hInstance;
......
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