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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -32,8 +32,6 @@ CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
ANSI_STRING EventName; ANSI_STRING EventName;
HANDLE EventHandle; HANDLE EventHandle;
RtlInitUnicodeString (&EventNameU, NULL);
if (lpName) if (lpName)
{ {
RtlInitAnsiString(&EventName, RtlInitAnsiString(&EventName,
@ -46,7 +44,7 @@ CreateEventA(LPSECURITY_ATTRIBUTES lpEventAttributes,
EventHandle = CreateEventW(lpEventAttributes, EventHandle = CreateEventW(lpEventAttributes,
bManualReset, bManualReset,
bInitialState, bInitialState,
EventNameU.Buffer); (lpName ? EventNameU.Buffer : NULL));
if (lpName) if (lpName)
{ {
@ -68,31 +66,27 @@ CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes,
{ {
NTSTATUS Status; NTSTATUS Status;
HANDLE hEvent; HANDLE hEvent;
UNICODE_STRING EventNameString; UNICODE_STRING UnicodeName;
OBJECT_ATTRIBUTES ObjectAttributes; 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) if (lpName != NULL)
{ {
RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName); RtlInitUnicodeString(&UnicodeName, (LPWSTR)lpName);
ObjectAttributes.ObjectName = &EventNameString; }
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, Status = NtCreateEvent(&hEvent,
@ -123,26 +117,26 @@ OpenEventA(DWORD dwDesiredAccess,
ANSI_STRING EventName; ANSI_STRING EventName;
HANDLE EventHandle; HANDLE EventHandle;
if (lpName == NULL)
{
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
return NULL;
}
RtlInitUnicodeString(&EventNameU, RtlInitUnicodeString(&EventNameU,
NULL); NULL);
if (lpName) RtlInitAnsiString(&EventName,
{ (LPSTR)lpName);
RtlInitAnsiString(&EventName, RtlAnsiStringToUnicodeString(&EventNameU,
(LPSTR)lpName); &EventName,
RtlAnsiStringToUnicodeString(&EventNameU, TRUE);
&EventName,
TRUE);
}
EventHandle = OpenEventW(dwDesiredAccess, EventHandle = OpenEventW(dwDesiredAccess,
bInheritHandle, bInheritHandle,
EventNameU.Buffer); EventNameU.Buffer);
if (lpName) RtlFreeUnicodeString(&EventNameU);
{
RtlFreeUnicodeString(&EventNameU);
}
return EventHandle; return EventHandle;
} }
@ -169,16 +163,11 @@ OpenEventW(DWORD dwDesiredAccess,
RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName); RtlInitUnicodeString(&EventNameString, (LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes(&ObjectAttributes,
ObjectAttributes.RootDirectory = hBaseDir; &EventNameString,
ObjectAttributes.ObjectName = &EventNameString; (bInheritHandle ? OBJ_INHERIT : 0),
ObjectAttributes.Attributes = 0; hBaseDir,
ObjectAttributes.SecurityDescriptor = NULL; NULL);
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
Status = NtOpenEvent(&hEvent, Status = NtOpenEvent(&hEvent,
dwDesiredAccess, 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -57,23 +57,25 @@ CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes,
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status; NTSTATUS Status;
UNICODE_STRING NameString; UNICODE_STRING UnicodeName;
HANDLE MutantHandle; HANDLE MutantHandle;
RtlInitUnicodeString(&NameString, if (lpName != NULL)
(LPWSTR)lpName); {
RtlInitUnicodeString(&UnicodeName,
(LPWSTR)lpName);
}
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes(&ObjectAttributes,
ObjectAttributes.RootDirectory = hBaseDir; (lpName ? &UnicodeName : NULL),
ObjectAttributes.ObjectName = &NameString; 0,
ObjectAttributes.Attributes = 0; hBaseDir,
ObjectAttributes.SecurityDescriptor = NULL; NULL);
ObjectAttributes.SecurityQualityOfService = NULL;
if (lpMutexAttributes != NULL) if (lpMutexAttributes != NULL)
{ {
ObjectAttributes.SecurityDescriptor = lpMutexAttributes->lpSecurityDescriptor; ObjectAttributes.SecurityDescriptor = lpMutexAttributes->lpSecurityDescriptor;
if (lpMutexAttributes->bInheritHandle == TRUE) if (lpMutexAttributes->bInheritHandle)
{ {
ObjectAttributes.Attributes |= OBJ_INHERIT; ObjectAttributes.Attributes |= OBJ_INHERIT;
} }
@ -119,16 +121,11 @@ OpenMutexA(DWORD dwDesiredAccess,
&Name, &Name,
TRUE); TRUE);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes(&ObjectAttributes,
ObjectAttributes.RootDirectory = hBaseDir; &NameU,
ObjectAttributes.ObjectName = &NameU; (bInheritHandle ? OBJ_INHERIT : 0),
ObjectAttributes.Attributes = 0; hBaseDir,
ObjectAttributes.SecurityDescriptor = NULL; NULL);
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
Status = NtOpenMutant(&Handle, Status = NtOpenMutant(&Handle,
(ACCESS_MASK)dwDesiredAccess, (ACCESS_MASK)dwDesiredAccess,
@ -168,16 +165,11 @@ OpenMutexW(DWORD dwDesiredAccess,
RtlInitUnicodeString(&Name, RtlInitUnicodeString(&Name,
(LPWSTR)lpName); (LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes(&ObjectAttributes,
ObjectAttributes.RootDirectory = hBaseDir; &Name,
ObjectAttributes.ObjectName = &Name; (bInheritHandle ? OBJ_INHERIT : 0),
ObjectAttributes.Attributes = 0; hBaseDir,
ObjectAttributes.SecurityDescriptor = NULL; NULL);
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
Status = NtOpenMutant(&Handle, Status = NtOpenMutant(&Handle,
(ACCESS_MASK)dwDesiredAccess, (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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -60,31 +60,24 @@ CreateSemaphoreW(LPSECURITY_ATTRIBUTES lpSemaphoreAttributes,
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status; NTSTATUS Status;
UNICODE_STRING NameString; UNICODE_STRING UnicodeName;
HANDLE SemaphoreHandle; HANDLE SemaphoreHandle;
if (lpName) if (lpName != NULL)
{ {
NameString.Length = lstrlenW(lpName)*sizeof(WCHAR); RtlInitUnicodeString(&UnicodeName, lpName);
}
else
{
NameString.Length = 0;
} }
NameString.Buffer = (WCHAR *)lpName; InitializeObjectAttributes(&ObjectAttributes,
NameString.MaximumLength = NameString.Length; (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) if (lpSemaphoreAttributes != NULL)
{ {
ObjectAttributes.SecurityDescriptor = lpSemaphoreAttributes->lpSecurityDescriptor; ObjectAttributes.SecurityDescriptor = lpSemaphoreAttributes->lpSecurityDescriptor;
if (lpSemaphoreAttributes->bInheritHandle == TRUE) if (lpSemaphoreAttributes->bInheritHandle)
{ {
ObjectAttributes.Attributes |= OBJ_INHERIT; ObjectAttributes.Attributes |= OBJ_INHERIT;
} }
@ -130,16 +123,11 @@ OpenSemaphoreA(DWORD dwDesiredAccess,
&Name, &Name,
TRUE); TRUE);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes(&ObjectAttributes,
ObjectAttributes.RootDirectory = hBaseDir; &NameU,
ObjectAttributes.ObjectName = &NameU; (bInheritHandle ? OBJ_INHERIT : 0),
ObjectAttributes.Attributes = 0; hBaseDir,
ObjectAttributes.SecurityDescriptor = NULL; NULL);
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
Status = NtOpenSemaphore(&Handle, Status = NtOpenSemaphore(&Handle,
(ACCESS_MASK)dwDesiredAccess, (ACCESS_MASK)dwDesiredAccess,
@ -179,16 +167,11 @@ OpenSemaphoreW(DWORD dwDesiredAccess,
RtlInitUnicodeString(&Name, RtlInitUnicodeString(&Name,
(LPWSTR)lpName); (LPWSTR)lpName);
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes(&ObjectAttributes,
ObjectAttributes.RootDirectory = hBaseDir; &Name,
ObjectAttributes.ObjectName = &Name; (bInheritHandle ? OBJ_INHERIT : 0),
ObjectAttributes.Attributes = 0; hBaseDir,
ObjectAttributes.SecurityDescriptor = NULL; NULL);
ObjectAttributes.SecurityQualityOfService = NULL;
if (bInheritHandle == TRUE)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
Status = NtOpenSemaphore(&Handle, Status = NtOpenSemaphore(&Handle,
(ACCESS_MASK)dwDesiredAccess, (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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -36,13 +36,25 @@ CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes,
else else
TimerType = SynchronizationTimer; TimerType = SynchronizationTimer;
RtlInitUnicodeString(&UnicodeName, lpTimerName); if (lpTimerName)
{
RtlInitUnicodeString(&UnicodeName, lpTimerName);
}
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName, (lpTimerName ? &UnicodeName : NULL),
0, 0,
hBaseDir, hBaseDir,
NULL); NULL);
if (lpTimerAttributes != NULL)
{
ObjectAttributes.SecurityDescriptor = lpTimerAttributes->lpSecurityDescriptor;
if(lpTimerAttributes->bInheritHandle)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
}
Status = NtCreateTimer(&TimerHandle, Status = NtCreateTimer(&TimerHandle,
TIMER_ALL_ACCESS, TIMER_ALL_ACCESS,
&ObjectAttributes, &ObjectAttributes,
@ -69,17 +81,23 @@ CreateWaitableTimerA(LPSECURITY_ATTRIBUTES lpTimerAttributes,
ANSI_STRING TimerName; ANSI_STRING TimerName;
HANDLE TimerHandle; HANDLE TimerHandle;
RtlInitAnsiString (&TimerName, if (lpTimerName != NULL)
(LPSTR)lpTimerName); {
RtlAnsiStringToUnicodeString (&TimerNameU, RtlInitAnsiString (&TimerName,
&TimerName, (LPSTR)lpTimerName);
TRUE); RtlAnsiStringToUnicodeString (&TimerNameU,
&TimerName,
TRUE);
}
TimerHandle = CreateWaitableTimerW (lpTimerAttributes, TimerHandle = CreateWaitableTimerW (lpTimerAttributes,
bManualReset, bManualReset,
TimerNameU.Buffer); (lpTimerName ? TimerNameU.Buffer : NULL));
RtlFreeUnicodeString (&TimerNameU); if (lpTimerName != NULL)
{
RtlFreeUnicodeString (&TimerNameU);
}
return TimerHandle; return TimerHandle;
} }
@ -97,18 +115,18 @@ OpenWaitableTimerW(DWORD dwDesiredAccess,
HANDLE TimerHandle; HANDLE TimerHandle;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING UnicodeName; UNICODE_STRING UnicodeName;
ULONG Attributes = 0;
if (lpTimerName == NULL)
if (bInheritHandle)
{ {
Attributes = OBJ_INHERIT; SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
return NULL;
} }
RtlInitUnicodeString(&UnicodeName, RtlInitUnicodeString(&UnicodeName,
lpTimerName); lpTimerName);
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&UnicodeName, &UnicodeName,
Attributes, (bInheritHandle ? OBJ_INHERIT : 0),
hBaseDir, hBaseDir,
NULL); NULL);
@ -133,23 +151,29 @@ OpenWaitableTimerA(DWORD dwDesiredAccess,
BOOL bInheritHandle, BOOL bInheritHandle,
LPCSTR lpTimerName) LPCSTR lpTimerName)
{ {
UNICODE_STRING TimerNameU; UNICODE_STRING TimerNameU;
ANSI_STRING TimerName; ANSI_STRING TimerName;
HANDLE TimerHandle; HANDLE TimerHandle;
if (lpTimerName == NULL)
{
SetLastErrorByStatus(STATUS_INVALID_PARAMETER);
return NULL;
}
RtlInitAnsiString (&TimerName, RtlInitAnsiString (&TimerName,
(LPSTR)lpTimerName); (LPSTR)lpTimerName);
RtlAnsiStringToUnicodeString (&TimerNameU, RtlAnsiStringToUnicodeString (&TimerNameU,
&TimerName, &TimerName,
TRUE); TRUE);
TimerHandle = OpenWaitableTimerW (dwDesiredAccess, TimerHandle = OpenWaitableTimerW (dwDesiredAccess,
bInheritHandle, bInheritHandle,
TimerNameU.Buffer); 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -268,16 +268,11 @@ OpenThread(
ClientId.UniqueProcess = INVALID_HANDLE_VALUE; ClientId.UniqueProcess = INVALID_HANDLE_VALUE;
ClientId.UniqueThread = (HANDLE)dwThreadId; ClientId.UniqueThread = (HANDLE)dwThreadId;
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES); InitializeObjectAttributes (&ObjectAttributes,
ObjectAttributes.RootDirectory = (HANDLE)NULL; NULL,
ObjectAttributes.SecurityDescriptor = NULL; (bInheritHandle ? OBJ_INHERIT : 0),
ObjectAttributes.SecurityQualityOfService = NULL; NULL,
ObjectAttributes.ObjectName = NULL; NULL);
if (bInheritHandle == TRUE)
ObjectAttributes.Attributes = OBJ_INHERIT;
else
ObjectAttributes.Attributes = 0;
errCode = NtOpenThread(&ThreadHandle, errCode = NtOpenThread(&ThreadHandle,
dwDesiredAccess, dwDesiredAccess,