Commit 8c63d02d authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Move waitable timer functions to kernelbase.

parent 59126688
......@@ -212,7 +212,7 @@
@ stdcall CancelSynchronousIo(long)
# @ stub CancelThreadpoolIo
@ stdcall CancelTimerQueueTimer(ptr ptr)
@ stdcall CancelWaitableTimer(long)
@ stdcall -import CancelWaitableTimer(long)
@ stdcall ChangeTimerQueueTimer(ptr ptr long long)
# @ stub CheckElevation
# @ stub CheckElevationEnabled
......@@ -343,8 +343,8 @@
@ stub CreateVirtualBuffer
@ stdcall CreateWaitableTimerA(ptr long str)
@ stdcall CreateWaitableTimerExA(ptr str long long)
@ stdcall CreateWaitableTimerExW(ptr wstr long long)
@ stdcall CreateWaitableTimerW(ptr long wstr)
@ stdcall -import CreateWaitableTimerExW(ptr wstr long long)
@ stdcall -import CreateWaitableTimerW(ptr long wstr)
# @ stub CtrlRoutine
@ stdcall DeactivateActCtx(long long)
@ stdcall DebugActiveProcess(long)
......@@ -1133,7 +1133,7 @@
# @ stub OpenThreadToken
@ stdcall -i386 OpenVxDHandle(long)
@ stdcall OpenWaitableTimerA(long long str)
@ stdcall OpenWaitableTimerW(long long wstr)
@ stdcall -import OpenWaitableTimerW(long long wstr)
@ stdcall OutputDebugStringA(str)
@ stdcall OutputDebugStringW(wstr)
@ stdcall PeekConsoleInputA(ptr ptr long ptr)
......@@ -1474,8 +1474,8 @@
@ stdcall SetVolumeLabelW(wstr wstr)
@ stdcall SetVolumeMountPointA(str str)
@ stdcall SetVolumeMountPointW(wstr wstr)
@ stdcall SetWaitableTimer(long ptr long ptr ptr long)
@ stdcall SetWaitableTimerEx(long ptr long ptr ptr ptr long)
@ stdcall -import SetWaitableTimer(long ptr long ptr ptr long)
@ stdcall -import SetWaitableTimerEx(long ptr long ptr ptr ptr long)
# @ stub SetXStateFeaturesMask
@ stdcall SetupComm(long long long)
@ stub ShowConsoleCursor
......
......@@ -646,16 +646,6 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR
/***********************************************************************
* CreateWaitableTimerW (KERNEL32.@)
*/
HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name )
{
return CreateWaitableTimerExW( sa, name, manual ? CREATE_WAITABLE_TIMER_MANUAL_RESET : 0,
TIMER_ALL_ACCESS );
}
/***********************************************************************
* CreateWaitableTimerExA (KERNEL32.@)
*/
HANDLE WINAPI CreateWaitableTimerExA( SECURITY_ATTRIBUTES *sa, LPCSTR name, DWORD flags, DWORD access )
......@@ -674,28 +664,6 @@ HANDLE WINAPI CreateWaitableTimerExA( SECURITY_ATTRIBUTES *sa, LPCSTR name, DWOR
/***********************************************************************
* CreateWaitableTimerExW (KERNEL32.@)
*/
HANDLE WINAPI CreateWaitableTimerExW( SECURITY_ATTRIBUTES *sa, LPCWSTR name, DWORD flags, DWORD access )
{
HANDLE handle;
NTSTATUS status;
UNICODE_STRING nameW;
OBJECT_ATTRIBUTES attr;
get_create_object_attributes( &attr, &nameW, sa, name );
status = NtCreateTimer( &handle, access, &attr,
(flags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? NotificationTimer : SynchronizationTimer );
if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return handle;
}
/***********************************************************************
* OpenWaitableTimerA (KERNEL32.@)
*/
HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
......@@ -714,79 +682,6 @@ HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
/***********************************************************************
* OpenWaitableTimerW (KERNEL32.@)
*/
HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE handle;
UNICODE_STRING nameW;
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
if (!is_version_nt()) access = TIMER_ALL_ACCESS;
if (!get_open_object_attributes( &attr, &nameW, inherit, name )) return 0;
status = NtOpenTimer(&handle, access, &attr);
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
return handle;
}
/***********************************************************************
* SetWaitableTimer (KERNEL32.@)
*/
BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG period,
PTIMERAPCROUTINE callback, LPVOID arg, BOOL resume )
{
NTSTATUS status = NtSetTimer(handle, when, (PTIMER_APC_ROUTINE)callback,
arg, resume, period, NULL);
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
if (status != STATUS_TIMER_RESUME_IGNORED) return FALSE;
}
return TRUE;
}
/***********************************************************************
* SetWaitableTimerEx (KERNEL32.@)
*/
BOOL WINAPI SetWaitableTimerEx( HANDLE handle, const LARGE_INTEGER *when, LONG period,
PTIMERAPCROUTINE callback, LPVOID arg, REASON_CONTEXT *context, ULONG tolerabledelay )
{
static int once;
if (!once++)
{
FIXME("(%p, %p, %d, %p, %p, %p, %d) semi-stub\n",
handle, when, period, callback, arg, context, tolerabledelay);
}
return SetWaitableTimer(handle, when, period, callback, arg, FALSE);
}
/***********************************************************************
* CancelWaitableTimer (KERNEL32.@)
*/
BOOL WINAPI CancelWaitableTimer( HANDLE handle )
{
NTSTATUS status;
status = NtCancelTimer(handle, NULL);
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
return TRUE;
}
/***********************************************************************
* CreateTimerQueue (KERNEL32.@)
*/
HANDLE WINAPI CreateTimerQueue(void)
......
......@@ -106,7 +106,7 @@
@ stdcall CancelIoEx(long ptr) kernel32.CancelIoEx
@ stdcall CancelSynchronousIo(long) kernel32.CancelSynchronousIo
@ stub CancelThreadpoolIo
@ stdcall CancelWaitableTimer(long) kernel32.CancelWaitableTimer
@ stdcall CancelWaitableTimer(long)
# @ stub CeipIsOptedIn
@ stdcall ChangeTimerQueueTimer(ptr ptr long long) kernel32.ChangeTimerQueueTimer
@ stdcall CharLowerA(str)
......@@ -231,8 +231,8 @@
@ stdcall CreateThreadpoolWork(ptr ptr ptr) kernel32.CreateThreadpoolWork
@ stdcall CreateTimerQueue() kernel32.CreateTimerQueue
@ stdcall CreateTimerQueueTimer(ptr long ptr ptr long long long) kernel32.CreateTimerQueueTimer
@ stdcall CreateWaitableTimerExW(ptr wstr long long) kernel32.CreateWaitableTimerExW
@ stdcall CreateWaitableTimerW(ptr long wstr) kernel32.CreateWaitableTimerW
@ stdcall CreateWaitableTimerExW(ptr wstr long long)
@ stdcall CreateWaitableTimerW(ptr long wstr)
@ stdcall CreateWellKnownSid(long ptr ptr ptr)
# @ stub CtrlRoutine
# @ stub CveEventWrite
......@@ -1002,7 +1002,7 @@
# @ stub OpenStateExplicitForUserSidString
@ stdcall OpenThread(long long long) kernel32.OpenThread
@ stdcall OpenThreadToken(long long long ptr)
@ stdcall OpenWaitableTimerW(long long wstr) kernel32.OpenWaitableTimerW
@ stdcall OpenWaitableTimerW(long long wstr)
@ stdcall OutputDebugStringA(str) kernel32.OutputDebugStringA
@ stdcall OutputDebugStringW(wstr) kernel32.OutputDebugStringW
# @ stub OverrideRoamingDataModificationTimesInRange
......@@ -1504,8 +1504,8 @@
@ stdcall SetTokenInformation(long long ptr long)
@ stdcall SetUnhandledExceptionFilter(ptr) kernel32.SetUnhandledExceptionFilter
@ stdcall SetUserGeoID(long) kernel32.SetUserGeoID
@ stdcall SetWaitableTimer(long ptr long ptr ptr long) kernel32.SetWaitableTimer
@ stdcall SetWaitableTimerEx(long ptr long ptr ptr ptr long) kernel32.SetWaitableTimerEx
@ stdcall SetWaitableTimer(long ptr long ptr ptr long)
@ stdcall SetWaitableTimerEx(long ptr long ptr ptr ptr long)
# @ stub SetXStateFeaturesMask
@ stdcall SetupComm(long long long) kernel32.SetupComm
# @ stub SharedLocalIsEnabled
......
......@@ -433,3 +433,101 @@ BOOL WINAPI DECLSPEC_HOTPATCH ReleaseSemaphore( HANDLE handle, LONG count, LONG
{
return set_ntstatus( NtReleaseSemaphore( handle, count, (PULONG)previous ));
}
/***********************************************************************
* Waitable timers
***********************************************************************/
/***********************************************************************
* CreateWaitableTimerW (kernelbase.@)
*/
HANDLE WINAPI DECLSPEC_HOTPATCH CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name )
{
return CreateWaitableTimerExW( sa, name, manual ? CREATE_WAITABLE_TIMER_MANUAL_RESET : 0,
TIMER_ALL_ACCESS );
}
/***********************************************************************
* CreateWaitableTimerExW (kernelbase.@)
*/
HANDLE WINAPI DECLSPEC_HOTPATCH CreateWaitableTimerExW( SECURITY_ATTRIBUTES *sa, LPCWSTR name,
DWORD flags, DWORD access )
{
HANDLE handle;
NTSTATUS status;
UNICODE_STRING nameW;
OBJECT_ATTRIBUTES attr;
get_create_object_attributes( &attr, &nameW, sa, name );
status = NtCreateTimer( &handle, access, &attr,
(flags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? NotificationTimer : SynchronizationTimer );
if (status == STATUS_OBJECT_NAME_EXISTS)
SetLastError( ERROR_ALREADY_EXISTS );
else
SetLastError( RtlNtStatusToDosError(status) );
return handle;
}
/***********************************************************************
* OpenWaitableTimerW (kernelbase.@)
*/
HANDLE WINAPI DECLSPEC_HOTPATCH OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
{
HANDLE handle;
UNICODE_STRING nameW;
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
if (!is_version_nt()) access = TIMER_ALL_ACCESS;
if (!get_open_object_attributes( &attr, &nameW, inherit, name )) return 0;
status = NtOpenTimer( &handle, access, &attr );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return 0;
}
return handle;
}
/***********************************************************************
* SetWaitableTimer (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG period,
PTIMERAPCROUTINE callback, LPVOID arg, BOOL resume )
{
NTSTATUS status = NtSetTimer( handle, when, (PTIMER_APC_ROUTINE)callback,
arg, resume, period, NULL );
return set_ntstatus( status ) || status == STATUS_TIMER_RESUME_IGNORED;
}
/***********************************************************************
* SetWaitableTimerEx (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH SetWaitableTimerEx( HANDLE handle, const LARGE_INTEGER *when, LONG period,
PTIMERAPCROUTINE callback, LPVOID arg,
REASON_CONTEXT *context, ULONG tolerabledelay )
{
static int once;
if (!once++) FIXME( "(%p, %p, %d, %p, %p, %p, %d) semi-stub\n",
handle, when, period, callback, arg, context, tolerabledelay );
return SetWaitableTimer( handle, when, period, callback, arg, FALSE );
}
/***********************************************************************
* CancelWaitableTimer (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH CancelWaitableTimer( HANDLE handle )
{
return set_ntstatus( NtCancelTimer( handle, NULL ));
}
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