Author: ion
Date: Sat Jul 23 10:08:57 2011
New Revision: 52796
URL:
http://svn.reactos.org/svn/reactos?rev=52796&view=rev
Log:
[KERNEL32]: And finally, the timer APIs and bugs #20 and #21.
Modified:
trunk/reactos/dll/win32/kernel32/client/synch.c
Modified: trunk/reactos/dll/win32/kernel32/client/synch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/synch.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/synch.c [iso-8859-1] Sat Jul 23 10:08:57 2011
@@ -257,125 +257,14 @@
*/
HANDLE
WINAPI
-CreateWaitableTimerExA(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL,
- IN LPCSTR lpTimerName OPTIONAL,
- IN DWORD dwFlags,
- IN DWORD dwDesiredAccess)
-{
- NTSTATUS Status;
- ANSI_STRING AnsiName;
- PUNICODE_STRING UnicodeCache;
- LPCWSTR UnicodeName = NULL;
-
- /* Check for a name */
- if (lpTimerName)
- {
- /* Use TEB Cache */
- UnicodeCache = &NtCurrentTeb()->StaticUnicodeString;
-
- /* Convert to unicode */
- RtlInitAnsiString(&AnsiName, lpTimerName);
- Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE);
- if (!NT_SUCCESS(Status))
- {
- /* Conversion failed */
- SetLastErrorByStatus(Status);
- return NULL;
- }
-
- /* Otherwise, save the buffer */
- UnicodeName = (LPCWSTR)UnicodeCache->Buffer;
- }
-
- /* Call the Unicode API */
- return CreateWaitableTimerExW(lpTimerAttributes,
- UnicodeName,
- dwFlags,
- dwDesiredAccess);
-}
-
-/*
- * @implemented
- */
-HANDLE
-WINAPI
-CreateWaitableTimerExW(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL,
- IN LPCWSTR lpTimerName OPTIONAL,
- IN DWORD dwFlags,
- IN DWORD dwDesiredAccess)
-{
- NTSTATUS Status;
- OBJECT_ATTRIBUTES LocalAttributes;
- POBJECT_ATTRIBUTES ObjectAttributes;
- HANDLE Handle;
- UNICODE_STRING ObjectName;
- TIMER_TYPE TimerType;
-
- /* Now check if we got a name */
- if (lpTimerName) RtlInitUnicodeString(&ObjectName, lpTimerName);
-
- if (dwFlags & ~(CREATE_WAITABLE_TIMER_MANUAL_RESET))
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- TimerType = (dwFlags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? NotificationTimer :
SynchronizationTimer;
-
- /* Now convert the object attributes */
- ObjectAttributes = BasepConvertObjectAttributes(&LocalAttributes,
- lpTimerAttributes,
- lpTimerName ? &ObjectName :
NULL);
-
- /* Create the timer */
- Status = NtCreateTimer(&Handle,
- (ACCESS_MASK)dwDesiredAccess,
- ObjectAttributes,
- TimerType);
- if (NT_SUCCESS(Status))
- {
- /* Check if the object already existed */
- if (Status == STATUS_OBJECT_NAME_EXISTS)
- {
- /* Set distinguished Win32 error code */
- SetLastError(ERROR_ALREADY_EXISTS);
- }
- else
- {
- /* Otherwise, set success */
- SetLastError(ERROR_SUCCESS);
- }
-
- /* Return the handle */
- return Handle;
- }
- else
- {
- /* Convert the NT Status and fail */
- SetLastErrorByStatus(Status);
- return NULL;
- }
-
-}
-
-/*
- * @implemented
- */
-HANDLE
-WINAPI
CreateWaitableTimerW(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL,
IN BOOL bManualReset,
IN LPCWSTR lpTimerName OPTIONAL)
{
- DWORD dwFlags = 0;
-
- if (bManualReset)
- dwFlags |= CREATE_WAITABLE_TIMER_MANUAL_RESET;
-
- return CreateWaitableTimerExW(lpTimerAttributes,
- lpTimerName,
- dwFlags,
- TIMER_ALL_ACCESS);
+ CreateNtObjectFromWin32Api(WaitableTimer, Timer, TIMER,
+ lpTimerAttributes,
+ lpTimerName,
+ bManualReset ? NotificationTimer : SynchronizationTimer);
}
/*
@@ -387,15 +276,7 @@
IN BOOL bManualReset,
IN LPCSTR lpTimerName OPTIONAL)
{
- DWORD dwFlags = 0;
-
- if (bManualReset)
- dwFlags |= CREATE_WAITABLE_TIMER_MANUAL_RESET;
-
- return CreateWaitableTimerExA(lpTimerAttributes,
- lpTimerName,
- dwFlags,
- TIMER_ALL_ACCESS);
+ ConvertWin32AnsiObjectApiToUnicodeApi(WaitableTimer, lpTimerName, lpTimerAttributes,
bManualReset);
}
/*
@@ -407,38 +288,7 @@
IN BOOL bInheritHandle,
IN LPCWSTR lpTimerName)
{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING ObjectName;
- NTSTATUS Status;
- HANDLE Handle;
-
- /* Make sure we got a name */
- if (!lpTimerName)
- {
- /* Fail without one */
- SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
- return NULL;
- }
-
- /* Initialize the object name and attributes */
- RtlInitUnicodeString(&ObjectName, lpTimerName);
- InitializeObjectAttributes(&ObjectAttributes,
- &ObjectName,
- bInheritHandle ? OBJ_INHERIT : 0,
- hBaseDir,
- NULL);
-
- /* Open the timer */
- Status = NtOpenTimer(&Handle, dwDesiredAccess, &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- /* Convert the status and fail */
- SetLastErrorByStatus(Status);
- return NULL;
- }
-
- /* Return the handle */
- return Handle;
+ OpenNtObjectFromWin32Api(Timer, dwDesiredAccess, bInheritHandle, lpTimerName);
}
/*
@@ -450,37 +300,7 @@
IN BOOL bInheritHandle,
IN LPCSTR lpTimerName)
{
- NTSTATUS Status;
- ANSI_STRING AnsiName;
- PUNICODE_STRING UnicodeCache;
-
- /* Check for a name */
- if (lpTimerName)
- {
- /* Use TEB Cache */
- UnicodeCache = &NtCurrentTeb()->StaticUnicodeString;
-
- /* Convert to unicode */
- RtlInitAnsiString(&AnsiName, lpTimerName);
- Status = RtlAnsiStringToUnicodeString(UnicodeCache, &AnsiName, FALSE);
- if (!NT_SUCCESS(Status))
- {
- /* Conversion failed */
- SetLastErrorByStatus(Status);
- return NULL;
- }
- }
- else
- {
- /* We need a name */
- SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
- }
-
- /* Call the Unicode API */
- return OpenWaitableTimerW(dwDesiredAccess,
- bInheritHandle,
- (LPCWSTR)UnicodeCache->Buffer);
+ ConvertOpenWin32AnsiObjectApiToUnicodeApi(WaitableTimer, dwDesiredAccess,
bInheritHandle, lpTimerName);
}
/*