Commit ff35e1fb authored by Ulrich Weigand's avatar Ulrich Weigand Committed by Alexandre Julliard

Use Callout table instead of direct GetProcAddress.

UserYield moved to USER.
parent 61439d27
...@@ -604,20 +604,13 @@ void TASK_KillCurrentTask( INT16 exitCode ) ...@@ -604,20 +604,13 @@ void TASK_KillCurrentTask( INT16 exitCode )
USER_ExitWindows(); USER_ExitWindows();
} }
if (!__winelib)
{
/* FIXME: Hack! Send a message to the initial task so that /* FIXME: Hack! Send a message to the initial task so that
* the GetMessage wakes up and the initial task can check whether * the GetMessage wakes up and the initial task can check whether
* it is the only remaining one and terminate itself ... * it is the only remaining one and terminate itself ...
* The initial task should probably install hooks or something * The initial task should probably install hooks or something
* to get informed about task termination :-/ * to get informed about task termination :-/
*/ */
HTASK16 hTask = PROCESS_Initial()->task; Callout.PostAppMessage16( PROCESS_Initial()->task, WM_NULL, 0, 0 );
HMODULE16 hModule = GetModuleHandle16( "USER" );
FARPROC16 postFunc = WIN32_GetProcAddress16( hModule, "PostAppMessage" );
if (postFunc)
Callbacks->CallPostAppMessageProc( postFunc, hTask, WM_NULL, 0, 0 );
}
/* Remove the task from the list to be sure we never switch back to it */ /* Remove the task from the list to be sure we never switch back to it */
TASK_UnlinkTask( hCurrentTask ); TASK_UnlinkTask( hCurrentTask );
...@@ -1043,33 +1036,6 @@ void WINAPI DirectedYield( HTASK16 hTask ) ...@@ -1043,33 +1036,6 @@ void WINAPI DirectedYield( HTASK16 hTask )
TRACE(task, "%04x: back from DirectedYield(%04x)\n", pCurTask->hSelf, hTask ); TRACE(task, "%04x: back from DirectedYield(%04x)\n", pCurTask->hSelf, hTask );
} }
/***********************************************************************
* UserYield (USER.332)
*/
void WINAPI UserYield(void)
{
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 );
OldYield();
queue = (MESSAGEQUEUE *)GlobalLock16( pCurTask->hQueue );
while (queue && (queue->wakeBits & QS_SENDMESSAGE))
QUEUE_ReceiveMessage( queue );
}
/*********************************************************************** /***********************************************************************
* Yield16 (KERNEL.29) * Yield16 (KERNEL.29)
*/ */
...@@ -1084,7 +1050,7 @@ void WINAPI Yield16(void) ...@@ -1084,7 +1050,7 @@ void WINAPI Yield16(void)
} }
if (pCurTask) pCurTask->hYieldTo = 0; if (pCurTask) pCurTask->hYieldTo = 0;
if (pCurTask && pCurTask->hQueue) UserYield(); if (pCurTask && pCurTask->hQueue) Callout.UserYield();
else OldYield(); else OldYield();
} }
...@@ -1260,7 +1226,7 @@ HQUEUE16 WINAPI GetTaskQueue( HTASK16 hTask ) ...@@ -1260,7 +1226,7 @@ HQUEUE16 WINAPI GetTaskQueue( HTASK16 hTask )
*/ */
HQUEUE16 WINAPI SetThreadQueue( DWORD thread, HQUEUE16 hQueue ) HQUEUE16 WINAPI SetThreadQueue( DWORD thread, HQUEUE16 hQueue )
{ {
THDB *thdb = THREAD_IdToTHDB( thread ); THDB *thdb = thread? THREAD_IdToTHDB( thread ) : THREAD_Current();
HQUEUE16 oldQueue = thdb? thdb->teb.queue : 0; HQUEUE16 oldQueue = thdb? thdb->teb.queue : 0;
if ( thdb ) if ( thdb )
...@@ -1279,7 +1245,7 @@ HQUEUE16 WINAPI SetThreadQueue( DWORD thread, HQUEUE16 hQueue ) ...@@ -1279,7 +1245,7 @@ HQUEUE16 WINAPI SetThreadQueue( DWORD thread, HQUEUE16 hQueue )
*/ */
HQUEUE16 WINAPI GetThreadQueue( DWORD thread ) HQUEUE16 WINAPI GetThreadQueue( DWORD thread )
{ {
THDB *thdb = THREAD_IdToTHDB( thread ); THDB *thdb = thread? THREAD_IdToTHDB( thread ) : THREAD_Current();
return (HQUEUE16)(thdb? thdb->teb.queue : 0); return (HQUEUE16)(thdb? thdb->teb.queue : 0);
} }
...@@ -1288,7 +1254,7 @@ HQUEUE16 WINAPI GetThreadQueue( DWORD thread ) ...@@ -1288,7 +1254,7 @@ HQUEUE16 WINAPI GetThreadQueue( DWORD thread )
*/ */
VOID WINAPI SetFastQueue( DWORD thread, HANDLE32 hQueue ) VOID WINAPI SetFastQueue( DWORD thread, HANDLE32 hQueue )
{ {
THDB *thdb = THREAD_IdToTHDB( thread ); THDB *thdb = thread? THREAD_IdToTHDB( thread ) : THREAD_Current();
if ( thdb ) thdb->teb.queue = (HQUEUE16) hQueue; if ( thdb ) thdb->teb.queue = (HQUEUE16) hQueue;
} }
...@@ -1300,14 +1266,10 @@ HANDLE32 WINAPI GetFastQueue( void ) ...@@ -1300,14 +1266,10 @@ HANDLE32 WINAPI GetFastQueue( void )
THDB *thdb = THREAD_Current(); THDB *thdb = THREAD_Current();
if (!thdb) return 0; if (!thdb) return 0;
if (!(thdb->teb.queue)) if (!thdb->teb.queue)
{ Callout.InitThreadInput( 0, THREAD_IsWin16(thdb)? 4 : 5 );
HMODULE16 hModule = GetModuleHandle16( "USER" );
FARPROC16 proc = WIN32_GetProcAddress16( hModule, "InitThreadInput" );
Callbacks->CallBootAppProc( proc, 0, THREAD_IsWin16(thdb)? 4 : 5 ); /* FIXME! */
}
if (!(thdb->teb.queue)) if (!thdb->teb.queue)
FIXME( task, "(): should initialize thread-local queue, expect failure!\n" ); FIXME( task, "(): should initialize thread-local queue, expect failure!\n" );
return (HANDLE32)thdb->teb.queue; return (HANDLE32)thdb->teb.queue;
......
...@@ -41,30 +41,26 @@ BOOL32 MAIN_EmulatorInit(void) ...@@ -41,30 +41,26 @@ BOOL32 MAIN_EmulatorInit(void)
return TRUE; return TRUE;
} }
typedef BOOL32 (*WINAPI tGetMessage)(MSG32* lpmsg,HWND32 hwnd,UINT32 min,UINT32 max);
typedef BOOL32 (*WINAPI tTranslateMessage)(const MSG32* msg);
typedef LONG (*WINAPI tDispatchMessage)( const MSG32* msg );
/*********************************************************************** /***********************************************************************
* Main loop of initial task * Main loop of initial task
*/ */
void MAIN_EmulatorRun( void ) void MAIN_EmulatorRun( void )
{ {
extern void THUNK_InitCallout( void );
char startProg[256], defProg[256]; char startProg[256], defProg[256];
HINSTANCE32 handle; HINSTANCE32 handle;
int i; int i;
MSG32 msg;
tGetMessage pGetMessage;
tTranslateMessage pTranslateMessage;
tDispatchMessage pDispatchMessage;
HMODULE32 hModule;
MSG32 msg;
/* Load system DLLs into the initial process (and initialize them) */ /* Load system DLLs into the initial process (and initialize them) */
if ( !LoadLibrary16("GDI.EXE" ) || !LoadLibrary32A("GDI32.DLL" ) if ( !LoadLibrary16("GDI.EXE" ) || !LoadLibrary32A("GDI32.DLL" )
|| !LoadLibrary16("USER.EXE") || !LoadLibrary32A("USER32.DLL")) || !LoadLibrary16("USER.EXE") || !LoadLibrary32A("USER32.DLL"))
ExitProcess( 1 ); ExitProcess( 1 );
/* Get pointers to USER routines called by KERNEL */
THUNK_InitCallout();
/* Add the Default Program if no program on the command line */ /* Add the Default Program if no program on the command line */
if (!MAIN_argv[1]) if (!MAIN_argv[1])
{ {
...@@ -107,19 +103,10 @@ void MAIN_EmulatorRun( void ) ...@@ -107,19 +103,10 @@ void MAIN_EmulatorRun( void )
/* Start message loop for desktop window */ /* Start message loop for desktop window */
hModule = GetModuleHandle32A( "USER32" ); while ( GetNumTasks() > 1 && Callout.GetMessage32A( &msg, 0, 0, 0 ) )
pGetMessage = (tGetMessage)GetProcAddress32( hModule, "GetMessageA" );
pTranslateMessage = (tTranslateMessage)GetProcAddress32( hModule, "TranslateMessage" );
pDispatchMessage = (tDispatchMessage)GetProcAddress32( hModule, "DispatchMessageA" );
assert( pGetMessage );
assert( pTranslateMessage );
assert( pDispatchMessage );
while ( GetNumTasks() > 1 && pGetMessage( &msg, 0, 0, 0 ) )
{ {
pTranslateMessage( &msg ); Callout.TranslateMessage32( &msg );
pDispatchMessage( &msg ); Callout.DispatchMessage32A( &msg );
} }
ExitProcess( 0 ); ExitProcess( 0 );
......
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