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
* PROJECT: ReactOS kernel
* FILE: lib/kernel32/mem/timer.c
* FILE: lib/kernel32/synch/timer.c
* PURPOSE: Implementing timer
* PROGRAMMER:
*/
@ -13,21 +13,20 @@
#include <kernel32/error.h>
#include <windows.h>
#define NDEBUG
#include <kernel32/kernel32.h>
/* FUNCTIONS *****************************************************************/
HANDLE
STDCALL
CreateWaitableTimerW (
LPSECURITY_ATTRIBUTES lpTimerAttributes,
HANDLE STDCALL
CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes,
WINBOOL bManualReset,
LPWSTR lpTimerName
)
LPWSTR lpTimerName)
{
NTSTATUS errCode;
NTSTATUS Status;
HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
ULONG TimerType;
if (bManualReset)
@ -39,25 +38,27 @@ CreateWaitableTimerW (
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
0,
NULL,
hBaseDir,
NULL);
//TIMER_ALL_ACCESS
errCode = NtCreateTimer(&TimerHandle,
0,
Status = NtCreateTimer(&TimerHandle,
TIMER_ALL_ACCESS,
&ObjectAttributes,
TimerType);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return NULL;
}
return TimerHandle;
}
HANDLE
STDCALL
CreateWaitableTimerA (
LPSECURITY_ATTRIBUTES lpTimerAttributes,
HANDLE STDCALL
CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes,
WINBOOL bManualReset,
LPCSTR lpTimerName
)
LPCSTR lpTimerName)
{
UNICODE_STRING TimerNameU;
ANSI_STRING TimerName;
@ -79,48 +80,47 @@ CreateWaitableTimerA (
}
HANDLE
STDCALL
OpenWaitableTimerW (
DWORD dwDesiredAccess,
HANDLE STDCALL
OpenWaitableTimerW(DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
LPCWSTR lpTimerName
)
LPCWSTR lpTimerName)
{
NTSTATUS errCode;
NTSTATUS Status;
HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
ULONG Attributes = 0;
if ( bInheritHandle )
if (bInheritHandle)
{
Attributes = OBJ_INHERIT;
}
RtlInitUnicodeString(&UnicodeName, lpTimerName);
RtlInitUnicodeString(&UnicodeName,
lpTimerName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
Attributes,
NULL,
hBaseDir,
NULL);
errCode = NtOpenTimer(
&TimerHandle,
Status = NtOpenTimer(&TimerHandle,
dwDesiredAccess,
&ObjectAttributes
);
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return NULL;
}
return TimerHandle;
}
HANDLE
STDCALL
OpenWaitableTimerA (
DWORD dwDesiredAccess,
HANDLE STDCALL
OpenWaitableTimerA(DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
LPCSTR lpTimerName
)
LPCSTR lpTimerName)
{
UNICODE_STRING TimerNameU;
ANSI_STRING TimerName;
@ -142,40 +142,44 @@ OpenWaitableTimerA (
}
WINBOOL STDCALL SetWaitableTimer(
HANDLE hTimer,
WINBOOL STDCALL
SetWaitableTimer(HANDLE hTimer,
const LARGE_INTEGER *pDueTime,
LONG lPeriod,
PTIMERAPCROUTINE pfnCompletionRoutine,
LPVOID lpArgToCompletionRoutine,
WINBOOL fResume
)
WINBOOL fResume)
{
NTSTATUS errCode;
NTSTATUS Status;
BOOLEAN pState;
errCode = NtSetTimer(hTimer, (LARGE_INTEGER *)pDueTime,
Status = NtSetTimer(hTimer,
(LARGE_INTEGER *)pDueTime,
pfnCompletionRoutine,
lpArgToCompletionRoutine, fResume, lPeriod, &pState);
if ( !NT_SUCCESS(errCode) ) {
SetLastErrorByStatus (errCode);
lpArgToCompletionRoutine,
fResume,
lPeriod,
&pState);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
}
WINBOOL STDCALL CancelWaitableTimer(HANDLE hTimer)
WINBOOL STDCALL
CancelWaitableTimer(HANDLE hTimer)
{
NTSTATUS errCode;
NTSTATUS Status;
BOOLEAN CurrentState;
errCode = NtCancelTimer(
hTimer,
&CurrentState
);
if ( !NT_SUCCESS(errCode) ) {
SetLastErrorByStatus (errCode);
Status = NtCancelTimer(hTimer,
&CurrentState);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;