Fixed timer access right

svn path=/trunk/; revision=1624
This commit is contained in:
Eric Kohl 2001-02-17 00:07:49 +00:00
parent 9f2db0a1d2
commit 0e40521339

View file

@ -1,8 +1,8 @@
/* $Id: timer.c,v 1.7 2001/01/27 19:35:04 ekohl Exp $ /* $Id: timer.c,v 1.8 2001/02/17 00:07:49 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: lib/kernel32/mem/timer.c * FILE: lib/kernel32/synch/timer.c
* PURPOSE: Implementing timer * PURPOSE: Implementing timer
* PROGRAMMER: * PROGRAMMER:
*/ */
@ -13,21 +13,20 @@
#include <kernel32/error.h> #include <kernel32/error.h>
#include <windows.h> #include <windows.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
HANDLE HANDLE STDCALL
STDCALL CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes,
CreateWaitableTimerW ( WINBOOL bManualReset,
LPSECURITY_ATTRIBUTES lpTimerAttributes, LPWSTR lpTimerName)
WINBOOL bManualReset,
LPWSTR lpTimerName
)
{ {
NTSTATUS errCode; NTSTATUS Status;
HANDLE TimerHandle; HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName; UNICODE_STRING UnicodeName;
ULONG TimerType; ULONG TimerType;
if (bManualReset) if (bManualReset)
@ -39,25 +38,27 @@ CreateWaitableTimerW (
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName, &UnicodeName,
0, 0,
NULL, hBaseDir,
NULL); NULL);
//TIMER_ALL_ACCESS
errCode = NtCreateTimer(&TimerHandle, Status = NtCreateTimer(&TimerHandle,
0, TIMER_ALL_ACCESS,
&ObjectAttributes, &ObjectAttributes,
TimerType); TimerType);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return NULL;
}
return TimerHandle; return TimerHandle;
} }
HANDLE HANDLE STDCALL
STDCALL CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes,
CreateWaitableTimerA ( WINBOOL bManualReset,
LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCSTR lpTimerName)
WINBOOL bManualReset,
LPCSTR lpTimerName
)
{ {
UNICODE_STRING TimerNameU; UNICODE_STRING TimerNameU;
ANSI_STRING TimerName; ANSI_STRING TimerName;
@ -79,48 +80,47 @@ CreateWaitableTimerA (
} }
HANDLE HANDLE STDCALL
STDCALL OpenWaitableTimerW(DWORD dwDesiredAccess,
OpenWaitableTimerW ( WINBOOL bInheritHandle,
DWORD dwDesiredAccess, LPCWSTR lpTimerName)
WINBOOL bInheritHandle,
LPCWSTR lpTimerName
)
{ {
NTSTATUS errCode; NTSTATUS Status;
HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
ULONG Attributes = 0;
HANDLE TimerHandle; if (bInheritHandle)
OBJECT_ATTRIBUTES ObjectAttributes; {
UNICODE_STRING UnicodeName; Attributes = OBJ_INHERIT;
ULONG Attributes = 0; }
if ( bInheritHandle ) RtlInitUnicodeString(&UnicodeName,
Attributes = OBJ_INHERIT; lpTimerName);
InitializeObjectAttributes(&ObjectAttributes,
RtlInitUnicodeString(&UnicodeName, lpTimerName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName, &UnicodeName,
Attributes, Attributes,
NULL, hBaseDir,
NULL); NULL);
errCode = NtOpenTimer( Status = NtOpenTimer(&TimerHandle,
&TimerHandle, dwDesiredAccess,
dwDesiredAccess, &ObjectAttributes);
&ObjectAttributes if (!NT_SUCCESS(Status))
); {
SetLastErrorByStatus(Status);
return NULL;
}
return TimerHandle; return TimerHandle;
} }
HANDLE HANDLE STDCALL
STDCALL OpenWaitableTimerA(DWORD dwDesiredAccess,
OpenWaitableTimerA ( WINBOOL bInheritHandle,
DWORD dwDesiredAccess, LPCSTR lpTimerName)
WINBOOL bInheritHandle,
LPCSTR lpTimerName
)
{ {
UNICODE_STRING TimerNameU; UNICODE_STRING TimerNameU;
ANSI_STRING TimerName; ANSI_STRING TimerName;
@ -142,43 +142,47 @@ OpenWaitableTimerA (
} }
WINBOOL STDCALL SetWaitableTimer( WINBOOL STDCALL
HANDLE hTimer, SetWaitableTimer(HANDLE hTimer,
const LARGE_INTEGER *pDueTime, const LARGE_INTEGER *pDueTime,
LONG lPeriod, LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine, PTIMERAPCROUTINE pfnCompletionRoutine,
LPVOID lpArgToCompletionRoutine, LPVOID lpArgToCompletionRoutine,
WINBOOL fResume WINBOOL fResume)
)
{ {
NTSTATUS errCode; NTSTATUS Status;
BOOLEAN pState; BOOLEAN pState;
errCode = NtSetTimer(hTimer, (LARGE_INTEGER *)pDueTime, Status = NtSetTimer(hTimer,
pfnCompletionRoutine, (LARGE_INTEGER *)pDueTime,
lpArgToCompletionRoutine, fResume, lPeriod, &pState); pfnCompletionRoutine,
lpArgToCompletionRoutine,
if ( !NT_SUCCESS(errCode) ) { fResume,
SetLastErrorByStatus (errCode); lPeriod,
return FALSE; &pState);
} if (!NT_SUCCESS(Status))
return TRUE; {
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
} }
WINBOOL STDCALL CancelWaitableTimer(HANDLE hTimer)
{
NTSTATUS errCode;
BOOLEAN CurrentState;
errCode = NtCancelTimer( WINBOOL STDCALL
hTimer, CancelWaitableTimer(HANDLE hTimer)
&CurrentState {
); NTSTATUS Status;
if ( !NT_SUCCESS(errCode) ) { BOOLEAN CurrentState;
SetLastErrorByStatus (errCode);
return FALSE; Status = NtCancelTimer(hTimer,
} &CurrentState);
return TRUE; if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
} }
/* EOF */ /* EOF */