Commit 974fd10c authored by Ulrich Weigand's avatar Ulrich Weigand Committed by Alexandre Julliard

System timer proc thunk creation moved out of if1632/thunk.c.

parent f0a1c2f7
......@@ -7,6 +7,9 @@
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "services.h"
#include "callback.h"
#include "stackframe.h"
#include "builtin16.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(system)
......@@ -119,6 +122,29 @@ WORD WINAPI CreateSystemTimer( WORD rate, SYSTEMTIMERPROC callback )
return 0;
}
static void SYSTEM_CallSystemTimerProc( FARPROC16 proc, WORD timer )
{
CONTEXT86 context;
memset( &context, '\0', sizeof(context) );
CS_reg( &context ) = SELECTOROF( proc );
EIP_reg( &context ) = OFFSETOF( proc );
EBP_reg( &context ) = OFFSETOF( NtCurrentTeb()->cur_stack )
+ (WORD)&((STACK16FRAME*)0)->bp;
AX_reg( &context ) = timer;
CallTo16RegisterShort( &context, 0 );
}
WORD WINAPI WIN16_CreateSystemTimer( WORD rate, FARPROC16 proc )
{
FARPROC thunk = THUNK_Alloc( proc, (RELAY)SYSTEM_CallSystemTimerProc );
WORD timer = CreateSystemTimer( rate, (SYSTEMTIMERPROC)thunk );
if (!timer) THUNK_Free( thunk );
return timer;
}
/***********************************************************************
* KillSystemTimer (SYSTEM.3)
......@@ -127,8 +153,12 @@ WORD WINAPI CreateSystemTimer( WORD rate, SYSTEMTIMERPROC callback )
*/
WORD WINAPI SYSTEM_KillSystemTimer( WORD timer )
{
if (!timer || (timer > NB_SYS_TIMERS)) return timer; /* Error */
if ( !timer || timer > NB_SYS_TIMERS || !SYS_Timers[timer-1].callback )
return timer; /* Error */
THUNK_Free( (FARPROC)SYS_Timers[timer-1].callback );
SYS_Timers[timer-1].callback = NULL;
if (!--SYS_NbTimers) SYSTEM_StopTicks();
return 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