Commit 2ec34e48 authored by Alexandre Julliard's avatar Alexandre Julliard

Added TASK_GetPtr/TASK_GetCurrent functions to get the TDB for a task

handle.
parent 3e7497f2
......@@ -1602,7 +1602,7 @@ BOOL MENU_PatchResidentPopup( HQUEUE16 checkQueue, WND* checkWnd )
if( hTask )
{
TDB* task = (TDB*)GlobalLock16( hTask );
TDB* task = TASK_GetPtr( hTask );
if( task )
{
pTPWnd->hInstance = task->hInstance;
......
......@@ -1518,7 +1518,7 @@ FARPROC THUNK_AllocLSThunklet( SEGPTR target, DWORD relay,
THUNKLET_TYPE_LS );
if (!thunk)
{
TDB *pTask = (TDB*)GlobalLock16( owner );
TDB *pTask = TASK_GetPtr( owner );
if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
return 0;
......@@ -1551,7 +1551,7 @@ SEGPTR THUNK_AllocSLThunklet( FARPROC target, DWORD relay,
THUNKLET_TYPE_SL );
if (!thunk)
{
TDB *pTask = (TDB*)GlobalLock16( owner );
TDB *pTask = TASK_GetPtr( owner );
if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
return 0;
......
......@@ -521,7 +521,7 @@ static void MZ_Launch(void)
{
LPDOSTASK lpDosTask = MZ_Current();
CONTEXT context;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
BYTE *psp_start = PTR_REAL_TO_LIN( lpDosTask->psp_seg, 0 );
MZ_FillPSP(psp_start, GetCommandLineA());
......
......@@ -291,7 +291,7 @@ int DRIVE_IsValid( int drive )
*/
int DRIVE_GetCurrentDrive(void)
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
if (pTask && (pTask->curdrive & 0x80)) return pTask->curdrive & ~0x80;
return DRIVE_CurDrive;
}
......@@ -302,7 +302,7 @@ int DRIVE_GetCurrentDrive(void)
*/
int DRIVE_SetCurrentDrive( int drive )
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
if (!DRIVE_IsValid( drive ))
{
SetLastError( ERROR_INVALID_DRIVE );
......@@ -391,7 +391,7 @@ const char * DRIVE_GetRoot( int drive )
*/
const char * DRIVE_GetDosCwd( int drive )
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
if (!DRIVE_IsValid( drive )) return NULL;
/* Check if we need to change the directory to the new task. */
......@@ -412,7 +412,7 @@ const char * DRIVE_GetDosCwd( int drive )
*/
const char * DRIVE_GetUnixCwd( int drive )
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
if (!DRIVE_IsValid( drive )) return NULL;
/* Check if we need to change the directory to the new task. */
......@@ -672,7 +672,7 @@ int DRIVE_Chdir( int drive, const char *path )
char buffer[MAX_PATHNAME_LEN];
LPSTR unix_cwd;
BY_HANDLE_FILE_INFORMATION info;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
strcpy( buffer, "A:" );
buffer[0] += drive;
......
......@@ -1002,7 +1002,7 @@ static HINSTANCE16 NE_CreateThread( NE_MODULE *pModule, WORD cmdShow, LPCSTR cmd
CloseHandle( hThread );
return exit_code;
}
if (!(pTask = (TDB *)GlobalLock16( hTask ))) break;
if (!(pTask = TASK_GetPtr( hTask ))) break;
instance = pTask->hInstance;
GlobalUnlock16( hTask );
} while (!instance);
......@@ -1113,7 +1113,7 @@ HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file )
*/
DWORD NE_StartTask(void)
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
HINSTANCE16 hInstance, hPrevInstance;
SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
......@@ -1685,7 +1685,7 @@ HMODULE16 WINAPI MapHModuleLS(HMODULE hmod) {
NE_MODULE *pModule;
if (!hmod)
return ((TDB*)GlobalLock16(GetCurrentTask()))->hInstance;
return TASK_GetCurrent()->hInstance;
if (!HIWORD(hmod))
return hmod; /* we already have a 16 bit module handle */
pModule = (NE_MODULE*)GlobalLock16(hFirstModule);
......@@ -1704,8 +1704,7 @@ HMODULE WINAPI MapHModuleSL(HMODULE16 hmod) {
NE_MODULE *pModule;
if (!hmod) {
TDB *pTask = (TDB*)GlobalLock16(GetCurrentTask());
TDB *pTask = TASK_GetCurrent();
hmod = pTask->hModule;
}
pModule = (NE_MODULE*)GlobalLock16(hmod);
......
......@@ -130,7 +130,7 @@ static BOOL INT21_CreateHeap(void)
static BYTE *GetCurrentDTA( CONTEXT86 *context )
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
/* FIXME: This assumes DTA was set correctly! */
return (BYTE *)CTX_SEG_OFF_TO_LIN( context, SELECTOROF(pTask->dta),
......@@ -1300,7 +1300,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
pTask->dta = MAKESEGPTR(context->SegDs,DX_reg(context));
TRACE("Set DTA: %08lx\n", pTask->dta);
}
......@@ -1352,7 +1352,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */
TRACE("GET DISK TRANSFER AREA ADDRESS\n");
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
TDB *pTask = TASK_GetCurrent();
context->SegEs = SELECTOROF( pTask->dta );
BX_reg(context) = OFFSETOF( pTask->dta );
}
......
......@@ -68,7 +68,7 @@ TEB *THREAD_IdToTEB( DWORD id )
/* Allow task handles to be used; convert to main thread */
if ( IsTask16( id ) )
{
TDB *pTask = (TDB *)GlobalLock16( id );
TDB *pTask = TASK_GetPtr( id );
if (pTask) return pTask->teb;
}
SetLastError( ERROR_INVALID_PARAMETER );
......
......@@ -1285,7 +1285,7 @@ INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
message queues.
*/
HTASK16 htask = (HTASK16) *plparam;
DWORD idThread = (DWORD)((TDB*)GlobalLock16(htask))->teb->tid;
DWORD idThread = (DWORD)TASK_GetPtr(htask)->teb->tid;
*plparam = (LPARAM) idThread;
}
return 1;
......
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