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 (
LPSECURITY_ATTRIBUTES lpTimerAttributes,
WINBOOL bManualReset, WINBOOL bManualReset,
LPWSTR lpTimerName 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 (
LPSECURITY_ATTRIBUTES lpTimerAttributes,
WINBOOL bManualReset, WINBOOL bManualReset,
LPCSTR lpTimerName 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 (
DWORD dwDesiredAccess,
WINBOOL bInheritHandle, WINBOOL bInheritHandle,
LPCWSTR lpTimerName LPCWSTR lpTimerName)
)
{ {
NTSTATUS errCode; NTSTATUS Status;
HANDLE TimerHandle; HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName; UNICODE_STRING UnicodeName;
ULONG Attributes = 0; ULONG Attributes = 0;
if ( bInheritHandle ) if (bInheritHandle)
{
Attributes = OBJ_INHERIT; Attributes = OBJ_INHERIT;
}
RtlInitUnicodeString(&UnicodeName, lpTimerName); RtlInitUnicodeString(&UnicodeName,
lpTimerName);
InitializeObjectAttributes(&ObjectAttributes, 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 (
DWORD dwDesiredAccess,
WINBOOL bInheritHandle, WINBOOL bInheritHandle,
LPCSTR lpTimerName LPCSTR lpTimerName)
)
{ {
UNICODE_STRING TimerNameU; UNICODE_STRING TimerNameU;
ANSI_STRING TimerName; ANSI_STRING TimerName;
@ -142,40 +142,44 @@ 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,
(LARGE_INTEGER *)pDueTime,
pfnCompletionRoutine, pfnCompletionRoutine,
lpArgToCompletionRoutine, fResume, lPeriod, &pState); lpArgToCompletionRoutine,
fResume,
if ( !NT_SUCCESS(errCode) ) { lPeriod,
SetLastErrorByStatus (errCode); &pState);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
WINBOOL STDCALL CancelWaitableTimer(HANDLE hTimer)
WINBOOL STDCALL
CancelWaitableTimer(HANDLE hTimer)
{ {
NTSTATUS errCode; NTSTATUS Status;
BOOLEAN CurrentState; BOOLEAN CurrentState;
errCode = NtCancelTimer( Status = NtCancelTimer(hTimer,
hTimer, &CurrentState);
&CurrentState if (!NT_SUCCESS(Status))
); {
if ( !NT_SUCCESS(errCode) ) { SetLastErrorByStatus(Status);
SetLastErrorByStatus (errCode);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;