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

diff --git a/controls/menu.c b/controls/menu.c
index c094f2a..3451969 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -1602,7 +1602,7 @@
 
 	if( hTask )
 	{
-	    TDB* task = (TDB*)GlobalLock16( hTask );
+	    TDB* task = TASK_GetPtr( hTask );
 	    if( task )
 	    {
 		pTPWnd->hInstance = task->hInstance;
diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c
index 1d5197e..9201b22 100644
--- a/dlls/kernel/thunk.c
+++ b/dlls/kernel/thunk.c
@@ -1518,7 +1518,7 @@
                                           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 @@
                                           THUNKLET_TYPE_SL );
     if (!thunk)
     {
-        TDB *pTask = (TDB*)GlobalLock16( owner );
+        TDB *pTask = TASK_GetPtr( owner );
 
         if ( !(thunk = HeapAlloc( ThunkletHeap, 0, sizeof(THUNKLET) )) )
             return 0;
diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c
index 372397a..0d29ab4 100644
--- a/dlls/winedos/module.c
+++ b/dlls/winedos/module.c
@@ -521,7 +521,7 @@
 {
   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());
diff --git a/files/drive.c b/files/drive.c
index d5a62f6..a46a990 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -291,7 +291,7 @@
  */
 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_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_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_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 @@
     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;
diff --git a/loader/ne/module.c b/loader/ne/module.c
index de949fa..c3a4c7c 100644
--- a/loader/ne/module.c
+++ b/loader/ne/module.c
@@ -1002,7 +1002,7 @@
             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 @@
  */
 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 @@
 	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 @@
 	NE_MODULE	*pModule;
 
 	if (!hmod) {
-		TDB *pTask = (TDB*)GlobalLock16(GetCurrentTask());
-
+		TDB *pTask = TASK_GetCurrent();
 		hmod = pTask->hModule;
 	}
 	pModule = (NE_MODULE*)GlobalLock16(hmod);
diff --git a/msdos/int21.c b/msdos/int21.c
index 521bca7..2497783 100644
--- a/msdos/int21.c
+++ b/msdos/int21.c
@@ -130,7 +130,7 @@
 
 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 @@
 
     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 @@
     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 );
         }
diff --git a/scheduler/thread.c b/scheduler/thread.c
index 512d6e8..b0410f5 100644
--- a/scheduler/thread.c
+++ b/scheduler/thread.c
@@ -68,7 +68,7 @@
         /* 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 );
diff --git a/windows/winproc.c b/windows/winproc.c
index e82c350..452d089 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -1285,7 +1285,7 @@
 	     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;