Commit in reactos/lib/kernel32 on MAIN
synch/event.c+36-471.18 -> 1.19
     /mutex.c+23-311.8 -> 1.9
     /sem.c+20-371.8 -> 1.9
     /timer.c+53-291.16 -> 1.17
thread/thread.c+6-111.53 -> 1.54
+138-155
5 modified files
minor fixes

reactos/lib/kernel32/synch
event.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- event.c	23 Jan 2004 21:16:04 -0000	1.18
+++ event.c	24 Oct 2004 12:16:54 -0000	1.19
@@ -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 @@
    ANSI_STRING EventName;
    HANDLE EventHandle;
 
-   RtlInitUnicodeString (&EventNameU, NULL);
-
    if (lpName)
      {
 	RtlInitAnsiString(&EventName,
@@ -46,7 +44,7 @@
    EventHandle = CreateEventW(lpEventAttributes,
 			      bManualReset,
 			      bInitialState,
-			      EventNameU.Buffer);
+			      (lpName ? EventNameU.Buffer : NULL));
 
    if (lpName)
      {
@@ -68,31 +66,27 @@
 {
    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 @@
    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 @@
 
    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,

reactos/lib/kernel32/synch
mutex.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- mutex.c	23 Jan 2004 21:16:04 -0000	1.8
+++ mutex.c	24 Oct 2004 12:16:54 -0000	1.9
@@ -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 @@
 {
    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 @@
 				&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 @@
    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,

reactos/lib/kernel32/synch
sem.c 1.8 -> 1.9
diff -u -r1.8 -r1.9
--- sem.c	23 Jan 2004 21:16:04 -0000	1.8
+++ sem.c	24 Oct 2004 12:16:54 -0000	1.9
@@ -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 @@
 {
    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 @@
 				&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 @@
    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,

reactos/lib/kernel32/synch
timer.c 1.16 -> 1.17
diff -u -r1.16 -r1.17
--- timer.c	13 Jun 2004 20:04:56 -0000	1.16
+++ timer.c	24 Oct 2004 12:16:54 -0000	1.17
@@ -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 @@
    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 @@
 	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 @@
    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 @@
 		   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);
-
-	TimerHandle = OpenWaitableTimerW (dwDesiredAccess,
-	                                  bInheritHandle,
-	                                  TimerNameU.Buffer);
+   RtlInitAnsiString (&TimerName,
+                     (LPSTR)lpTimerName);
+   RtlAnsiStringToUnicodeString (&TimerNameU,
+                                 &TimerName,
+                                 TRUE);
+
+   TimerHandle = OpenWaitableTimerW (dwDesiredAccess,
+                                     bInheritHandle,
+                                     TimerNameU.Buffer);
 
-	RtlFreeUnicodeString (&TimerNameU);
+   RtlFreeUnicodeString (&TimerNameU);
 
-	return TimerHandle;
+   return TimerHandle;
 }
 
 

reactos/lib/kernel32/thread
thread.c 1.53 -> 1.54
diff -u -r1.53 -r1.54
--- thread.c	24 Sep 2004 20:55:58 -0000	1.53
+++ thread.c	24 Oct 2004 12:16:54 -0000	1.54
@@ -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 @@
    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,
CVSspam 0.2.8