minor fixes

svn path=/trunk/; revision=11411
This commit is contained in:
Thomas Bluemel 2004-10-24 12:16:54 +00:00
parent f443b5edcf
commit 0dd86887a1
5 changed files with 137 additions and 154 deletions

View file

@ -1,4 +1,4 @@
/* $Id: event.c,v 1.18 2004/01/23 21:16:04 ekohl Exp $
/* $Id: event.c,v 1.19 2004/10/24 12:16:54 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -32,8 +32,6 @@ CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
ANSI_STRING EventName;
HANDLE EventHandle;
RtlInitUnicodeString (&EventNameU, NULL);
if (lpName)
{
RtlInitAnsiString(&EventName,
@ -46,7 +44,7 @@ CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
EventHandle = CreateEventW(lpEventAttributes,
bManualReset,
bInitialState,
EventNameU.Buffer);
(lpName ? EventNameU.Buffer : NULL));
if (lpName)
{
@ -68,31 +66,27 @@ CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes,
{
NTSTATUS Status;
HANDLE hEvent;
UNICODE_STRING EventNameString;
UNICODE_STRING UnicodeName;
OBJECT_ATTRIBUTES ObjectAttributes;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = NULL;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (NULL != lpEventAttributes)
{
if (sizeof(SECURITY_ATTRIBUTES) < lpEventAttributes->nLength)
{
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
ObjectAttributes.SecurityDescriptor = lpEventAttributes->lpSecurityDescriptor;
ObjectAttributes.Attributes = lpEventAttributes->bInheritHandle ? OBJ_INHERIT : 0;
}
if (lpName != NULL)
{
RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName);
ObjectAttributes.ObjectName = &EventNameString;
RtlInitUnicodeString(&UnicodeName, (LPWSTR)lpName);
}
InitializeObjectAttributes(&ObjectAttributes,
(lpName ? &UnicodeName : NULL),
0,
hBaseDir,
NULL);
if (lpEventAttributes != NULL)
{
ObjectAttributes.SecurityDescriptor = lpEventAttributes->lpSecurityDescriptor;
if (lpEventAttributes->bInheritHandle)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
}
Status = NtCreateEvent(&hEvent,
@ -123,26 +117,26 @@ OpenEventA(DWORD dwDesiredAccess,
ANSI_STRING EventName;
HANDLE EventHandle;
if (lpName == NULL)
{
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
return NULL;
}
RtlInitUnicodeString(&EventNameU,
NULL);
if (lpName)
{
RtlInitAnsiString(&EventName,
(LPSTR)lpName);
RtlAnsiStringToUnicodeString(&EventNameU,
&EventName,
TRUE);
}
RtlInitAnsiString(&EventName,
(LPSTR)lpName);
RtlAnsiStringToUnicodeString(&EventNameU,
&EventName,
TRUE);
EventHandle = OpenEventW(dwDesiredAccess,
bInheritHandle,
EventNameU.Buffer);
if (lpName)
{
RtlFreeUnicodeString(&EventNameU);
}
RtlFreeUnicodeString(&EventNameU);
return EventHandle;
}
@ -169,16 +163,11 @@ OpenEventW(DWORD dwDesiredAccess,
RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &EventNameString;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
InitializeObjectAttributes(&ObjectAttributes,
&EventNameString,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = NtOpenEvent(&hEvent,
dwDesiredAccess,

View file

@ -1,4 +1,4 @@
/* $Id: mutex.c,v 1.8 2004/01/23 21:16:04 ekohl Exp $
/* $Id: mutex.c,v 1.9 2004/10/24 12:16:54 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -57,23 +57,25 @@ CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes,
{
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
UNICODE_STRING NameString;
UNICODE_STRING UnicodeName;
HANDLE MutantHandle;
RtlInitUnicodeString(&NameString,
(LPWSTR)lpName);
if (lpName != NULL)
{
RtlInitUnicodeString(&UnicodeName,
(LPWSTR)lpName);
}
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &NameString;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
InitializeObjectAttributes(&ObjectAttributes,
(lpName ? &UnicodeName : NULL),
0,
hBaseDir,
NULL);
if (lpMutexAttributes != NULL)
{
ObjectAttributes.SecurityDescriptor = lpMutexAttributes->lpSecurityDescriptor;
if (lpMutexAttributes->bInheritHandle == TRUE)
if (lpMutexAttributes->bInheritHandle)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
@ -119,16 +121,11 @@ OpenMutexA(DWORD dwDesiredAccess,
&Name,
TRUE);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &NameU;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
InitializeObjectAttributes(&ObjectAttributes,
&NameU,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = NtOpenMutant(&Handle,
(ACCESS_MASK)dwDesiredAccess,
@ -168,16 +165,11 @@ OpenMutexW(DWORD dwDesiredAccess,
RtlInitUnicodeString(&Name,
(LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &Name;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
InitializeObjectAttributes(&ObjectAttributes,
&Name,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = NtOpenMutant(&Handle,
(ACCESS_MASK)dwDesiredAccess,

View file

@ -1,4 +1,4 @@
/* $Id: sem.c,v 1.8 2004/01/23 21:16:04 ekohl Exp $
/* $Id: sem.c,v 1.9 2004/10/24 12:16:54 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -60,31 +60,24 @@ CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
{
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
UNICODE_STRING NameString;
UNICODE_STRING UnicodeName;
HANDLE SemaphoreHandle;
if (lpName)
if (lpName != NULL)
{
NameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
}
else
{
NameString.Length = 0;
RtlInitUnicodeString(&UnicodeName, lpName);
}
NameString.Buffer = (WCHAR *)lpName;
NameString.MaximumLength = NameString.Length;
InitializeObjectAttributes(&ObjectAttributes,
(lpName ? &UnicodeName : NULL),
0,
hBaseDir,
NULL);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &NameString;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (lpSemaphoreAttributes != NULL)
{
ObjectAttributes.SecurityDescriptor = lpSemaphoreAttributes->lpSecurityDescriptor;
if (lpSemaphoreAttributes->bInheritHandle == TRUE)
if (lpSemaphoreAttributes->bInheritHandle)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
@ -130,16 +123,11 @@ OpenSemaphoreA(DWORD dwDesiredAccess,
&Name,
TRUE);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &NameU;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
InitializeObjectAttributes(&ObjectAttributes,
&NameU,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = NtOpenSemaphore(&Handle,
(ACCESS_MASK)dwDesiredAccess,
@ -179,16 +167,11 @@ OpenSemaphoreW(DWORD dwDesiredAccess,
RtlInitUnicodeString(&Name,
(LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = hBaseDir;
ObjectAttributes.ObjectName = &Name;
ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
InitializeObjectAttributes(&ObjectAttributes,
&Name,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
Status = NtOpenSemaphore(&Handle,
(ACCESS_MASK)dwDesiredAccess,

View file

@ -1,4 +1,4 @@
/* $Id: timer.c,v 1.16 2004/06/13 20:04:56 navaraf Exp $
/* $Id: timer.c,v 1.17 2004/10/24 12:16:54 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -36,13 +36,25 @@ CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes,
else
TimerType = SynchronizationTimer;
RtlInitUnicodeString(&UnicodeName, lpTimerName);
if (lpTimerName)
{
RtlInitUnicodeString(&UnicodeName, lpTimerName);
}
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
(lpTimerName ? &UnicodeName : NULL),
0,
hBaseDir,
NULL);
if (lpTimerAttributes != NULL)
{
ObjectAttributes.SecurityDescriptor = lpTimerAttributes->lpSecurityDescriptor;
if(lpTimerAttributes->bInheritHandle)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
}
Status = NtCreateTimer(&TimerHandle,
TIMER_ALL_ACCESS,
&ObjectAttributes,
@ -69,17 +81,23 @@ CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes,
ANSI_STRING TimerName;
HANDLE TimerHandle;
RtlInitAnsiString (&TimerName,
(LPSTR)lpTimerName);
RtlAnsiStringToUnicodeString (&TimerNameU,
&TimerName,
TRUE);
if (lpTimerName != NULL)
{
RtlInitAnsiString (&TimerName,
(LPSTR)lpTimerName);
RtlAnsiStringToUnicodeString (&TimerNameU,
&TimerName,
TRUE);
}
TimerHandle = CreateWaitableTimerW (lpTimerAttributes,
bManualReset,
TimerNameU.Buffer);
(lpTimerName ? TimerNameU.Buffer : NULL));
RtlFreeUnicodeString (&TimerNameU);
if (lpTimerName != NULL)
{
RtlFreeUnicodeString (&TimerNameU);
}
return TimerHandle;
}
@ -97,18 +115,18 @@ OpenWaitableTimerW(DWORD dwDesiredAccess,
HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName;
ULONG Attributes = 0;
if (bInheritHandle)
if (lpTimerName == NULL)
{
Attributes = OBJ_INHERIT;
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
return NULL;
}
RtlInitUnicodeString(&UnicodeName,
lpTimerName);
InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName,
Attributes,
(bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir,
NULL);
@ -133,23 +151,29 @@ OpenWaitableTimerA(DWORD dwDesiredAccess,
BOOL bInheritHandle,
LPCSTR lpTimerName)
{
UNICODE_STRING TimerNameU;
ANSI_STRING TimerName;
HANDLE TimerHandle;
UNICODE_STRING TimerNameU;
ANSI_STRING TimerName;
HANDLE TimerHandle;
if (lpTimerName == NULL)
{
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
return NULL;
}
RtlInitAnsiString (&TimerName,
(LPSTR)lpTimerName);
RtlAnsiStringToUnicodeString (&TimerNameU,
&TimerName,
TRUE);
RtlInitAnsiString (&TimerName,
(LPSTR)lpTimerName);
RtlAnsiStringToUnicodeString (&TimerNameU,
&TimerName,
TRUE);
TimerHandle = OpenWaitableTimerW (dwDesiredAccess,
bInheritHandle,
TimerNameU.Buffer);
TimerHandle = OpenWaitableTimerW (dwDesiredAccess,
bInheritHandle,
TimerNameU.Buffer);
RtlFreeUnicodeString (&TimerNameU);
RtlFreeUnicodeString (&TimerNameU);
return TimerHandle;
return TimerHandle;
}

View file

@ -1,4 +1,4 @@
/* $Id: thread.c,v 1.53 2004/09/24 20:55:58 weiden Exp $
/* $Id: thread.c,v 1.54 2004/10/24 12:16:54 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -268,16 +268,11 @@ OpenThread(
ClientId.UniqueProcess = INVALID_HANDLE_VALUE;
ClientId.UniqueThread = (HANDLE)dwThreadId;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
ObjectAttributes.RootDirectory = (HANDLE)NULL;
ObjectAttributes.SecurityDescriptor = NULL;
ObjectAttributes.SecurityQualityOfService = NULL;
ObjectAttributes.ObjectName = NULL;
if (bInheritHandle == TRUE)
ObjectAttributes.Attributes = OBJ_INHERIT;
else
ObjectAttributes.Attributes = 0;
InitializeObjectAttributes (&ObjectAttributes,
NULL,
(bInheritHandle ? OBJ_INHERIT : 0),
NULL,
NULL);
errCode = NtOpenThread(&ThreadHandle,
dwDesiredAccess,