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

handle.
This commit is contained in:
Alexandre Julliard 2001-04-04 00:21:05 +00:00
parent 3e7497f20e
commit 2ec34e48a3
8 changed files with 18 additions and 19 deletions

View File

@ -1602,7 +1602,7 @@ BOOL MENU_PatchResidentPopup( HQUEUE16 checkQueue, WND* checkWnd )
if( hTask ) if( hTask )
{ {
TDB* task = (TDB*)GlobalLock16( hTask ); TDB* task = TASK_GetPtr( hTask );
if( task ) if( task )
{ {
pTPWnd->hInstance = task->hInstance; pTPWnd->hInstance = task->hInstance;

View File

@ -1518,7 +1518,7 @@ FARPROC THUNK_AllocLSThunklet( SEGPTR target, DWORD relay,
THUNKLET_TYPE_LS ); THUNKLET_TYPE_LS );
if (!thunk) if (!thunk)
{ {
TDB *pTask = (TDB*)GlobalLock16( owner ); TDB *pTask = TASK_GetPtr( owner );
if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) ) if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
return 0; return 0;
@ -1551,7 +1551,7 @@ SEGPTR THUNK_AllocSLThunklet( FARPROC target, DWORD relay,
THUNKLET_TYPE_SL ); THUNKLET_TYPE_SL );
if (!thunk) if (!thunk)
{ {
TDB *pTask = (TDB*)GlobalLock16( owner ); TDB *pTask = TASK_GetPtr( owner );
if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) ) if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
return 0; return 0;

View File

@ -521,7 +521,7 @@ static void MZ_Launch(void)
{ {
LPDOSTASK lpDosTask = MZ_Current(); LPDOSTASK lpDosTask = MZ_Current();
CONTEXT context; CONTEXT context;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
BYTE *psp_start = PTR_REAL_TO_LIN( lpDosTask->psp_seg, 0 ); BYTE *psp_start = PTR_REAL_TO_LIN( lpDosTask->psp_seg, 0 );
MZ_FillPSP(psp_start, GetCommandLineA()); MZ_FillPSP(psp_start, GetCommandLineA());

View File

@ -291,7 +291,7 @@ int DRIVE_IsValid( int drive )
*/ */
int DRIVE_GetCurrentDrive(void) int DRIVE_GetCurrentDrive(void)
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
if (pTask && (pTask->curdrive & 0x80)) return pTask->curdrive & ~0x80; if (pTask && (pTask->curdrive & 0x80)) return pTask->curdrive & ~0x80;
return DRIVE_CurDrive; return DRIVE_CurDrive;
} }
@ -302,7 +302,7 @@ int DRIVE_GetCurrentDrive(void)
*/ */
int DRIVE_SetCurrentDrive( int drive ) int DRIVE_SetCurrentDrive( int drive )
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
if (!DRIVE_IsValid( drive )) if (!DRIVE_IsValid( drive ))
{ {
SetLastError( ERROR_INVALID_DRIVE ); SetLastError( ERROR_INVALID_DRIVE );
@ -391,7 +391,7 @@ const char * DRIVE_GetRoot( int drive )
*/ */
const char * DRIVE_GetDosCwd( int drive ) const char * DRIVE_GetDosCwd( int drive )
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
if (!DRIVE_IsValid( drive )) return NULL; if (!DRIVE_IsValid( drive )) return NULL;
/* Check if we need to change the directory to the new task. */ /* 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 ) const char * DRIVE_GetUnixCwd( int drive )
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
if (!DRIVE_IsValid( drive )) return NULL; if (!DRIVE_IsValid( drive )) return NULL;
/* Check if we need to change the directory to the new task. */ /* 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]; char buffer[MAX_PATHNAME_LEN];
LPSTR unix_cwd; LPSTR unix_cwd;
BY_HANDLE_FILE_INFORMATION info; BY_HANDLE_FILE_INFORMATION info;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
strcpy( buffer, "A:" ); strcpy( buffer, "A:" );
buffer[0] += drive; buffer[0] += drive;

View File

@ -1002,7 +1002,7 @@ static HINSTANCE16 NE_CreateThread( NE_MODULE *pModule, WORD cmdShow, LPCSTR cmd
CloseHandle( hThread ); CloseHandle( hThread );
return exit_code; return exit_code;
} }
if (!(pTask = (TDB *)GlobalLock16( hTask ))) break; if (!(pTask = TASK_GetPtr( hTask ))) break;
instance = pTask->hInstance; instance = pTask->hInstance;
GlobalUnlock16( hTask ); GlobalUnlock16( hTask );
} while (!instance); } while (!instance);
@ -1113,7 +1113,7 @@ HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file )
*/ */
DWORD NE_StartTask(void) DWORD NE_StartTask(void)
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
NE_MODULE *pModule = NE_GetPtr( pTask->hModule ); NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
HINSTANCE16 hInstance, hPrevInstance; HINSTANCE16 hInstance, hPrevInstance;
SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule ); SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
@ -1685,7 +1685,7 @@ HMODULE16 WINAPI MapHModuleLS(HMODULE hmod) {
NE_MODULE *pModule; NE_MODULE *pModule;
if (!hmod) if (!hmod)
return ((TDB*)GlobalLock16(GetCurrentTask()))->hInstance; return TASK_GetCurrent()->hInstance;
if (!HIWORD(hmod)) if (!HIWORD(hmod))
return hmod; /* we already have a 16 bit module handle */ return hmod; /* we already have a 16 bit module handle */
pModule = (NE_MODULE*)GlobalLock16(hFirstModule); pModule = (NE_MODULE*)GlobalLock16(hFirstModule);
@ -1704,8 +1704,7 @@ HMODULE WINAPI MapHModuleSL(HMODULE16 hmod) {
NE_MODULE *pModule; NE_MODULE *pModule;
if (!hmod) { if (!hmod) {
TDB *pTask = (TDB*)GlobalLock16(GetCurrentTask()); TDB *pTask = TASK_GetCurrent();
hmod = pTask->hModule; hmod = pTask->hModule;
} }
pModule = (NE_MODULE*)GlobalLock16(hmod); pModule = (NE_MODULE*)GlobalLock16(hmod);

View File

@ -130,7 +130,7 @@ static BOOL INT21_CreateHeap(void)
static BYTE *GetCurrentDTA( CONTEXT86 *context ) static BYTE *GetCurrentDTA( CONTEXT86 *context )
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
/* FIXME: This assumes DTA was set correctly! */ /* FIXME: This assumes DTA was set correctly! */
return (BYTE *)CTX_SEG_OFF_TO_LIN( context, SELECTOROF(pTask->dta), 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 */ case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
pTask->dta = MAKESEGPTR(context->SegDs,DX_reg(context)); pTask->dta = MAKESEGPTR(context->SegDs,DX_reg(context));
TRACE("Set DTA: %08lx\n", pTask->dta); TRACE("Set DTA: %08lx\n", pTask->dta);
} }
@ -1352,7 +1352,7 @@ void WINAPI DOS3Call( CONTEXT86 *context )
case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */ case 0x2f: /* GET DISK TRANSFER AREA ADDRESS */
TRACE("GET DISK TRANSFER AREA ADDRESS\n"); TRACE("GET DISK TRANSFER AREA ADDRESS\n");
{ {
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() ); TDB *pTask = TASK_GetCurrent();
context->SegEs = SELECTOROF( pTask->dta ); context->SegEs = SELECTOROF( pTask->dta );
BX_reg(context) = OFFSETOF( pTask->dta ); BX_reg(context) = OFFSETOF( pTask->dta );
} }

View File

@ -68,7 +68,7 @@ TEB *THREAD_IdToTEB( DWORD id )
/* Allow task handles to be used; convert to main thread */ /* Allow task handles to be used; convert to main thread */
if ( IsTask16( id ) ) if ( IsTask16( id ) )
{ {
TDB *pTask = (TDB *)GlobalLock16( id ); TDB *pTask = TASK_GetPtr( id );
if (pTask) return pTask->teb; if (pTask) return pTask->teb;
} }
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );

View File

@ -1285,7 +1285,7 @@ INT WINPROC_MapMsg16To32A( UINT16 msg16, WPARAM16 wParam16, UINT *pmsg32,
message queues. message queues.
*/ */
HTASK16 htask = (HTASK16) *plparam; HTASK16 htask = (HTASK16) *plparam;
DWORD idThread = (DWORD)((TDB*)GlobalLock16(htask))->teb->tid; DWORD idThread = (DWORD)TASK_GetPtr(htask)->teb->tid;
*plparam = (LPARAM) idThread; *plparam = (LPARAM) idThread;
} }
return 1; return 1;