Release 980822
Sat Aug 22 17:46:19 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de>
* [include/dosexe.h] [include/module.h] [include/pe_image.h]
[include/process.h] [include/windows.h] [loader/dos/module.c]
[loader/module.c] [loader/ne/module.c] [loader/pe_image.c]
[scheduler/process.c] [win32/process.c]
Partially implemented CreateProcess32.
* [win32/device.c] [relay32/kernel32.spec] [scheduler/k32obj.c]
[misc/registry.c] [win32/file.c]
Partially implemented VxDCall (VMM registry services).
* [files/dos_fs.c]
DOSFS_FindNext made thread-safe.
* [include/sig_context.h] [include/syslevel.h] [loader/signal.c]
[scheduler/syslevel.c] [tools/build.c]
Replaced CALLTO16_Current_fs by SYSLEVEL_Win16CurrentTeb.
* [win32/kernel32.c]
Bugfix: QT_Thunk/FT_Thunk should return 'long' in DX:AX, not EAX.
* [if1632/relay.c] [relay32/builtin32.c] [windows/msgbox.c]
[msdos/int20.c] [msdos/int21.c]
Use ExitProcess instead of TASK_KillCurrentTask.
* [include/task.h] [include/thread.h] [loader/task.c]
[scheduler/thread.c] [include/queue.h] [windows/message.c]
[windows/queue.c] [windows/win.c]
Prevent Win32 threads from entering the TASK_Reschedule loop.
(Note: Win32 messaging still doesn't work correctly; this patch
is just preventing the system from crashing when Win32 threads
call messaging functions. Messages will probably still get lost.)
* [scheduler/critsection.c]
Deactivated the use of SEM_UNDO for the SYSTEM_LOCK semaphore;
for some reason, this leads to problems after threads terminate...
Sat Aug 22 15:00:00 1998 Jürgen Schmied <juergen.schmied@metronet.de>
* [include/authors.h]
New file, includes all names of the developer (former shell.c)
* [Makefile.in][configure][configure.in][dlls/Makefile.in]
[dlls/shell32/Makefile.in][shres.rc]
Created dlls/shell32 and moved the shell32 stuff in it.
Started to create internal resources.
* [dlls/shell32/*]
Split the shell32 implementation into smaller files.
New classes: IContextMenu, IExtractIcon, IShellView.
Implemented Shell_GetImageList().
shell32 links to comctl32 now dynamically so it can use
internal/external implementations.
* [documentation/internal-dll] [documentation/shell32]
New, could anybody do a spellcheck?
* [include/commctrl.h]
Many new LV constants, structures, functions.
* [controls/comctl32undoc.c]
Rewrote the DSA* functions.
* [windows/winpos.c]
SetShellWindow32, GetShellWindow32.
Sat Aug 22 14:02:15 1998 Alexander Lukyanov <lav@long.yar.ru>
* [loader/resource.c]
Mark last accelerator as such in LoadAccelerators32W.
* [relay32/shell32.spec] [misc/shell.c]
Add stubs for SHGetSpecialFolderPath[AW].
Sat Aug 22 02:07:42 1998 Adrian Harvey <adrian@select.com.au>
* [include/file.h] [file/file.c] [msdos/int21.c] [msdos/vxd.c]
[misc/lzexpand.c] [win32/kernel32.c] [documentation/filehandles]
Fixed file handle handling. Created universal HFILE16 to HFILE32
translation macro from msdos/int21 code by Ove Kaaven.
Used macro in all Win16 functions so that win32 handles are translated
to avoid DOS/Win16 stdxx handles.
Removed handle translation from int21.c where Win16 functions are
called. Changed remaining calls to use new macro names.
Documented filehandle handling and differences between win 16 & 32.
Fri Aug 21 20:32:49 1998 Alexandre Julliard <julliard@lrc.epfl.ch>
* [server/process.c] [server/thread.c]
Implemented object wait queues and synchronization.
Fri Aug 21 18:40:02 1998 Huw D M Davies <daviesh@abacus.physics.ox.ac.uk>
* [graphics/psdrv/*]
DEVMODE dmPaper{Width|Length} fields are in 0.1mm.
Select a 100 pixel default font in CreateDC.
Thu Aug 20 22:47:39 1998 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>
* [objects/bitmap.c]
Handle bits=32 in SetBitmapBits32 and GetBitmapBits32.
* [msdos/int21.c]
Add handling of Int21 0A and 37.
* [misc/commdlg.c]
Use MapHModuleLS and MapHModuleSL when translating HINSTANCE16 to
HINSTANCE32 and vice versa.
* [win32/file.c]
CreateFile32A: Abort if filename == NULL.
Thu Aug 20 12:28:31 1998 Marcus Meissner <marcus@jet.franken.de>
* [*/*]
Lots of missing prototypes added, some parameter types adapted to match
SDK.
* [debugger/stabs.c]
Don't loop forever if we don't find wine or one of the libxxx.so.
* [loader/ne/module.c]
Implemented MapHModuleLS,MapHModuleSL,MapHinstLS,MapHinstSL.
* [misc/network.c]
Implemented WNetGetUser32A.
* [misc/shellord.c]
Implemented ILRemoveLastID.
* [multimedia/dsound.c]
Fixed StarCraft memory leak.
* [graphics/ddraw.c]
Removed some unnecessary simple relaying functions, tried polishing
up the Xlib implementation (still doesn't work), temp. removed Xshm
code (to be remerged with working Xlib code).
Tue Aug 18 22:29:17 1998 Ove Kaaven <ovek@arcticnet.no>
* [multimedia/mmio.c] [multimedia/mmsystem.c]
Fixed most mmio bugs, fully implementing mmioSetBuffer
buffering, ability to read memory files, and the
sndPlaySound() SND_MEMORY flag. Most mmio-using programs
now work fine.
* [include/dosexe.h] [include/miscemu.h] [include/module.h]
[loader/module.c] [loader/task.c] [msdos/dosmem.c]
Improved DOS VM flexibility and portability somewhat. (Did
I get the #ifdefs right this time, BSD-ers?)
* [msdos/int21.c]
Made "Get Current PSP address" work as expected in a DOS VM.
* [loader/dos/*]
Began improving flexibility and portability somewhat. It
should be easier to add DPMI RMCB callbacks now. The
DOS VM no longer leaves big files lying around in /tmp
after a crash.
Tue Aug 18 12:38:31 1998 Turchanov Sergey <turchanov@usa.net>
* [relay32/winmm.spec]
This patch allows WinAmp to play WAV files (at least in PCM
format).
Sun Aug 16 05:34:13 1998 Pablo Saratxaga <srtxg@chanae.alphanet.ch>
* [windows/keyboard.c]
Corrected keyboard code to properly handle keys : ? ~ and "
on non US keyboards.
Sat Aug 15 18:47:14 1998 Brian Craft <bcboy@dorothy.wanglab.brandeis.edu>
* [windows/win.c]
Fixed severe bug in EnumChildWindwos().
Thu Aug 13 21:05:35 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de>
* [controls/tooltips.c]
Fixed some bugs. Added subclassing support.
* [controls/toolbar.c]
Improved tooltip integration. Fixed some bugs.
* [controls/commctrl.c]
Changed control registration and added some documentation.
Fixed ShowHideMenuCtl.
* [controls/rebar.c][include/rebar.h][include/commctrl.h]
Improved rebar implementation (still no display).
* [controls/pager.c][include/pager.h][include/commctrl.h]
Improved pager implementation (still no display).
* [misc/imagelist.c]
Fixed a bug.
* [documentation/common_controls]
Updated.
Sun Aug 9 19:50:20 1998 James Juran <jrj120@psu.edu>
* [Makefile.in] [documentation/Makefile.in]
[programs/Makefile.in] [programs/*/Makefile.in]
Added uninstall rules, cleaned up install rules a little bit.
Sun Aug 9 13:21:35 1998 Andreas Mohr <100.30936@germany.net>
* [loader/ne/module.c] [if1632/kernel.spec]
Added the undocumented HIWORD of GetModuleHandle (hFirstModule).
* [loader/ne/segment.c]
Wine forgot to set some NE_SEGFLAGS_*.
Combined with another loader change, this fixed the
"BLINKER -- error in loading module" or ghost MessageBox problem
that about 1% of all Windows programs have.
Some BLINKER programs still don't work, though.
But I'm working on it, with great help from Blinkinc.
* [loader/task.c]
InitTask needs to decrement the SP register by two as Win95 does.
Sun Aug 9 02:41:28 1998 Ulrich Weigand <weigand@informatik.uni-erlangen.de>
* [if1632/kernel.spec] [relay32/kernel32.spec] [scheduler/syslevel.c]
[loader/main.c] [win32/ordinals.c] [include/syslevel.h]
[scheduler/Makefile.in]
Implemented Win95 'syslevel' routines (including Win16Lock).
* [if1632/relay.c] [if1632/thunk.c] [tools/build.c] [loader/task.c]
[loader/ne/segment.c] [win32/kernel32.c] [memory/selector.c]
[include/stackframe.h] [include/thread.h]
16-bit %fs handling revised. Use Win16Lock where appropriate.
* [include/thread.h] [scheduler/synchro.c] [windows/message.c]
[windows/queue.c] [win32/process.c]
Implemented MsgWaitForMultipleObjects.
* [files/change.c] [files/Makefile.in] [scheduler/k32obj.c]
[win32/newfns.c]
Implemented (dummy) file change notification objects.
* [debugger/dbg.y] [scheduler/process.c] [scheduler/thread.c]
[include/process.h] [include/thread.h]
Suspend all threads except current when hitting debugger break point.
* [objects/dib.c]
Bugfix for CreateDIBSection.
diff --git a/loader/task.c b/loader/task.c
index 7d1814d..099333e 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "windows.h"
#include "user.h"
@@ -55,6 +56,9 @@
static void TASK_YieldToSystem(TDB*);
+extern BOOL32 THREAD_InitDone;
+
+
/***********************************************************************
* TASK_InstallTHHook
*/
@@ -78,7 +82,6 @@
return (hFirstTask != hTask) ? hFirstTask : 0;
}
-
/***********************************************************************
* TASK_LinkTask
*/
@@ -222,8 +225,7 @@
*/
static void TASK_CallToStart(void)
{
- int exit_code = 1;
- TDB *pTask = (TDB *)GlobalLock16( hCurrentTask );
+ TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
@@ -237,7 +239,11 @@
{
/* FIXME: all this is an ugly hack */
- FARPROC32 entry = (FARPROC32)RVA_PTR( PROCESS_Current()->exe_modref->module, OptionalHeader.AddressOfEntryPoint );
+ LPTHREAD_START_ROUTINE entry = (LPTHREAD_START_ROUTINE)
+ RVA_PTR(pModule->module32, OptionalHeader.AddressOfEntryPoint);
+ DWORD size = PE_HEADER(pModule->module32)->OptionalHeader.SizeOfStackReserve;
+ DWORD id;
+ THDB *thdb;
pTask->userhandler = (USERSIGNALPROC)&USER_SignalProc;
if (pModule->heap_size)
@@ -246,22 +252,27 @@
InitApp( pTask->hModule );
PE_InitializeDLLs( PROCESS_Current(), DLL_PROCESS_ATTACH, (LPVOID)-1 );
TRACE(relay, "(entryproc=%p)\n", entry );
- exit_code = entry();
- TASK_KillCurrentTask( exit_code );
- }
-#ifdef linux
- else if (pModule->lpDosTask)
- {
- int stat;
- while ((stat = MZ_RunModule(pModule->lpDosTask)) >= 0)
- if (stat > 0 && DOSVM_Process(pModule->lpDosTask) < 0)
- break;
+#if 1
+ ExitProcess( entry(NULL) );
+#else
+ CreateThread( NULL, size, entry, NULL, 0, &id );
+ thdb = THREAD_ID_TO_THDB( id );
- MZ_KillModule(pModule->lpDosTask);
- TASK_KillCurrentTask( 0 );
- }
+ while ( thdb->exit_code == 0x103 )
+ {
+ WaitEvent( 0 );
+ QUEUE_Signal( pTask->hSelf );
+ }
+
+ ExitProcess( thdb->exit_code );
#endif
+ }
+ else if (pModule->dos_image)
+ {
+ DOSVM_Enter( NULL );
+ ExitProcess( 0 );
+ }
else
{
/* Registers at initialization must be:
@@ -295,13 +306,17 @@
Callbacks->CallRegisterShortProc( &context, 0 );
/* This should never return */
ERR( task, "Main program returned! (should never happen)\n" );
- TASK_KillCurrentTask( 1 );
+ ExitProcess( 1 );
}
}
/***********************************************************************
* TASK_Create
+ *
+ * NOTE: This routine might be called by a Win32 thread. We don't have
+ * any real problems with that, since we operated merely on a private
+ * TDB structure that is not yet linked into the task list.
*/
HTASK16 TASK_Create( THDB *thdb, NE_MODULE *pModule, HINSTANCE16 hInstance,
HINSTANCE16 hPrevInstance, UINT16 cmdShow)
@@ -339,7 +354,7 @@
pTask->hInstance = hInstance;
pTask->hPrevInstance = hPrevInstance;
pTask->hModule = pModule->self;
- pTask->hParent = hCurrentTask;
+ pTask->hParent = GetCurrentTask();
pTask->magic = TDB_MAGIC;
pTask->nCmdShow = cmdShow;
pTask->thdb = thdb;
@@ -439,9 +454,6 @@
if (!THREAD_Current()->cur_stack)
THREAD_Current()->cur_stack = pTask->thdb->cur_stack;
- /* Add the task to the linked list */
-
- TASK_LinkTask( hTask );
TRACE(task, "module='%s' cmdline='%s' task=%04x\n",
name, cmd_line, hTask );
@@ -449,6 +461,35 @@
return hTask;
}
+/***********************************************************************
+ * TASK_StartTask
+ *
+ * NOTE: This routine might be called by a Win32 thread. Thus, we need
+ * to be careful to protect global data structures. We do this
+ * by entering the Win16Lock while linking the task into the
+ * global task list.
+ */
+void TASK_StartTask( HTASK16 hTask )
+{
+ /* Add the task to the linked list */
+
+ SYSLEVEL_EnterWin16Lock();
+ TASK_LinkTask( hTask );
+ SYSLEVEL_LeaveWin16Lock();
+
+ TRACE(task, "linked task %04x\n", hTask );
+
+ /* Get the task up and running. If we ourselves are a 16-bit task,
+ we simply Yield(). If we are 32-bit however, we need to signal
+ the main process somehow (NOT YET IMPLEMENTED!) */
+
+ if ( GetCurrentTask() )
+ if ( THREAD_IsWin16( THREAD_Current() ) )
+ Yield16();
+ else
+ FIXME(task, "Don't know how to start 16-bit task from 32-bit thread. Move the mouse!\n");
+}
+
/***********************************************************************
* TASK_DeleteTask
@@ -498,9 +539,25 @@
*/
void TASK_KillCurrentTask( INT16 exitCode )
{
- TDB* pTask = (TDB*) GlobalLock16( hCurrentTask );
+ TDB* pTask = (TDB*) GlobalLock16( GetCurrentTask() );
+ NE_MODULE* pModule = NE_GetPtr( pTask->hModule );
if (!pTask) USER_ExitWindows(); /* No current task yet */
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return;
+ }
+
+ /* Enter the Win16Lock to protect global data structures
+ NOTE: We never explicitly leave it again. This shouldn't matter
+ though, as it will be released in TASK_Reschedule and this
+ task won't ever get scheduled again ... */
+
+ SYSLEVEL_EnterWin16Lock();
+
+ assert(hCurrentTask == GetCurrentTask());
+
TRACE(task, "Killing task %04x\n", hCurrentTask );
/* Delete active sockets */
@@ -508,6 +565,12 @@
if( pTask->pwsi )
WINSOCK_DeleteTaskWSI( pTask, pTask->pwsi );
+#ifdef MZ_SUPPORTED
+ /* Kill DOS VM task */
+ if ( pModule->lpDosTask )
+ MZ_KillModule( pModule->lpDosTask );
+#endif
+
/* Perform USER cleanup */
if (pTask->userhandler)
@@ -567,9 +630,15 @@
HTASK16 hTask = 0;
STACK16FRAME *newframe16;
- SYSLEVEL_ReleaseWin16Lock();
+ /* NOTE: As we are entered from 16-bit code, we hold the Win16Lock.
+ We hang onto it thoughout most of this routine, so that accesses
+ to global variables (most notably the task list) are protected. */
+ assert(hCurrentTask == GetCurrentTask());
+
+ TRACE(task, "entered with hTask %04x (pid %d)\n", hCurrentTask, getpid());
#ifdef CONFIG_IPC
+ /* FIXME: What about the Win16Lock ??? */
dde_reschedule();
#endif
/* First check if there's a task to kill */
@@ -616,13 +685,19 @@
/* No task found, wait for some events to come in */
+ /* NOTE: We release the Win16Lock while waiting for events. This is to enable
+ Win32 threads to thunk down to 16-bit temporarily. Since Win16
+ tasks won't execute and Win32 threads are not allowed to enter
+ TASK_Reschedule anyway, there should be no re-entrancy problem ... */
+
+ SYSLEVEL_ReleaseWin16Lock();
EVENT_WaitNetEvent( TRUE, TRUE );
+ SYSLEVEL_RestoreWin16Lock();
}
if (hTask == hCurrentTask)
{
TRACE(task, "returning to the current task(%04x)\n", hTask );
- SYSLEVEL_RestoreWin16Lock();
return; /* Nothing to do */
}
pNewTask = (TDB *)GlobalLock16( hTask );
@@ -655,6 +730,12 @@
/* Switch to the new stack */
+ /* NOTE: We need to release/restore the Win16Lock, as the task
+ switched to might be at another recursion level than
+ the old task ... */
+
+ SYSLEVEL_ReleaseWin16Lock();
+
hCurrentTask = hTask;
SET_CUR_THREAD( pNewTask->thdb );
pNewTask->ss_sp = pNewTask->thdb->cur_stack;
@@ -673,6 +754,12 @@
{
MESSAGEQUEUE* pQ;
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return;
+ }
+
Callbacks->CallTaskRescheduleProc();
if( pTask )
@@ -702,7 +789,7 @@
LONG stacklow, stackhi;
if (context) EAX_reg(context) = 0;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return;
if (!(pModule = NE_GetPtr( pTask->hModule ))) return;
/* This is a hack to install task USER signal handler before
@@ -770,8 +857,15 @@
{
TDB *pTask;
- if (!hTask) hTask = hCurrentTask;
+ if (!hTask) hTask = GetCurrentTask();
pTask = (TDB *)GlobalLock16( hTask );
+
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return TRUE;
+ }
+
if (pTask->nEvents > 0)
{
pTask->nEvents--;
@@ -793,8 +887,16 @@
{
TDB *pTask;
- if (!hTask) hTask = hCurrentTask;
+ if (!hTask) hTask = GetCurrentTask();
if (!(pTask = (TDB *)GlobalLock16( hTask ))) return;
+
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ memset(0, 0, 4096);
+ return;
+ }
+
pTask->nEvents++;
}
@@ -807,7 +909,7 @@
TDB *pTask;
INT16 newpriority;
- if (!hTask) hTask = hCurrentTask;
+ if (!hTask) hTask = GetCurrentTask();
if (!(pTask = (TDB *)GlobalLock16( hTask ))) return;
newpriority = pTask->priority + delta;
if (newpriority < -32) newpriority = -32;
@@ -825,7 +927,7 @@
*/
HTASK16 WINAPI LockCurrentTask( BOOL16 bLock )
{
- if (bLock) hLockedTask = hCurrentTask;
+ if (bLock) hLockedTask = GetCurrentTask();
else hLockedTask = 0;
return hLockedTask;
}
@@ -845,9 +947,14 @@
*/
void WINAPI OldYield(void)
{
- TDB *pCurTask;
+ TDB *pCurTask = (TDB *)GlobalLock16( GetCurrentTask() );
- pCurTask = (TDB *)GlobalLock16( hCurrentTask );
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return;
+ }
+
if (pCurTask) pCurTask->nEvents++; /* Make sure we get back here */
TASK_YieldToSystem(pCurTask);
if (pCurTask) pCurTask->nEvents--;
@@ -859,7 +966,14 @@
*/
void WINAPI DirectedYield( HTASK16 hTask )
{
- TDB *pCurTask = (TDB *)GlobalLock16( hCurrentTask );
+ TDB *pCurTask = (TDB *)GlobalLock16( GetCurrentTask() );
+
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return;
+ }
+
pCurTask->hYieldTo = hTask;
OldYield();
}
@@ -870,8 +984,15 @@
*/
void WINAPI UserYield(void)
{
- TDB *pCurTask = (TDB *)GlobalLock16( hCurrentTask );
+ TDB *pCurTask = (TDB *)GlobalLock16( GetCurrentTask() );
MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16( pCurTask->hQueue );
+
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return;
+ }
+
/* Handle sent messages */
while (queue && (queue->wakeBits & QS_SENDMESSAGE))
QUEUE_ReceiveMessage( queue );
@@ -889,7 +1010,14 @@
*/
void WINAPI Yield16(void)
{
- TDB *pCurTask = (TDB *)GlobalLock16( hCurrentTask );
+ TDB *pCurTask = (TDB *)GlobalLock16( GetCurrentTask() );
+
+ if ( !THREAD_IsWin16( THREAD_Current() ) )
+ {
+ FIXME(task, "called for Win32 thread (%04x)!\n", THREAD_Current()->teb_sel);
+ return;
+ }
+
if (pCurTask) pCurTask->hYieldTo = 0;
if (pCurTask && pCurTask->hQueue) UserYield();
else OldYield();
@@ -905,7 +1033,7 @@
SEGPTR thunkaddr;
if (!hInstance) hInstance = CURRENT_DS;
- thunkaddr = TASK_AllocThunk( hCurrentTask );
+ thunkaddr = TASK_AllocThunk( GetCurrentTask() );
if (!thunkaddr) return (FARPROC16)0;
thunk = PTR_SEG_TO_LIN( thunkaddr );
lfunc = PTR_SEG_TO_LIN( func );
@@ -935,7 +1063,7 @@
void WINAPI FreeProcInstance16( FARPROC16 func )
{
TRACE(task, "(%08lx)\n", (DWORD)func );
- TASK_FreeThunk( hCurrentTask, (SEGPTR)func );
+ TASK_FreeThunk( GetCurrentTask(), (SEGPTR)func );
}
@@ -977,7 +1105,7 @@
HQUEUE16 hPrev;
TDB *pTask;
- if (!hTask) hTask = hCurrentTask;
+ if (!hTask) hTask = GetCurrentTask();
if (!(pTask = (TDB *)GlobalLock16( hTask ))) return 0;
hPrev = pTask->hQueue;
@@ -996,7 +1124,7 @@
{
TDB *pTask;
- if (!hTask) hTask = hCurrentTask;
+ if (!hTask) hTask = GetCurrentTask();
if (!(pTask = (TDB *)GlobalLock16( hTask ))) return 0;
return pTask->hQueue;
}
@@ -1012,7 +1140,7 @@
INSTANCEDATA *pData;
UINT16 copySize;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return;
if (!(pData = (INSTANCEDATA *)GlobalLock16( seg ))) return;
TRACE(task, "old=%04x:%04x new=%04x:%04x\n",
SELECTOROF( pTask->thdb->cur_stack ),
@@ -1056,7 +1184,7 @@
STACK16FRAME *oldFrame, *newFrame;
INSTANCEDATA *pData;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return;
if (!(pData = (INSTANCEDATA *)GlobalLock16(SELECTOROF(pTask->thdb->cur_stack))))
return;
if (!pData->old_ss_sp)
@@ -1116,14 +1244,14 @@
*/
HTASK16 WINAPI GetCurrentTask(void)
{
- return hCurrentTask;
+ return THREAD_InitDone? PROCESS_Current()->task : 0;
}
DWORD WINAPI WIN16_GetCurrentTask(void)
{
/* This is the version used by relay code; the first task is */
/* returned in the high word of the result */
- return MAKELONG( hCurrentTask, hFirstTask );
+ return MAKELONG( GetCurrentTask(), hFirstTask );
}
@@ -1134,7 +1262,7 @@
{
TDB *pTask;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return 0;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
return pTask->hPDB;
}
@@ -1159,7 +1287,7 @@
{
TDB *pTask;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return 0;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
return pTask->version;
}
@@ -1172,7 +1300,7 @@
TDB *pTask;
UINT16 oldMode;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return 0;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
oldMode = pTask->error_mode;
pTask->error_mode = mode;
pTask->thdb->process->error_mode = mode;
@@ -1196,7 +1324,7 @@
{
TDB *pTask;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return 0;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
return PTR_SEG_OFF_TO_SEGPTR( pTask->pdb.environment, 0 );
}
@@ -1220,7 +1348,7 @@
{
TDB *pTask;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return 0;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
return pTask->hInstance;
}
@@ -1248,7 +1376,7 @@
TDB *pTask;
FARPROC16 oldProc;
- if (!hTask) hTask = hCurrentTask;
+ if (!hTask) hTask = GetCurrentTask();
if (!(pTask = (TDB *)GlobalLock16( hTask ))) return NULL;
oldProc = (FARPROC16)pTask->userhandler;
pTask->userhandler = (USERSIGNALPROC)proc;
@@ -1271,7 +1399,7 @@
{
TDB *pTask;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return 0;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
if (oldmode) *oldmode = pTask->signal_flags;
pTask->signal_flags = newmode;
if (oldhandler) *oldhandler = pTask->sighandler;
@@ -1288,7 +1416,7 @@
{
TDB *pTask;
- if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return;
+ if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return;
pTask->discardhandler = proc;
}