Fixed some bugs in CreateProcessA which was introduced by r16730.
Modified: trunk/reactos/lib/kernel32/include/kernel32.h
Modified: trunk/reactos/lib/kernel32/misc/utils.c
Modified: trunk/reactos/lib/kernel32/process/create.c

Modified: trunk/reactos/lib/kernel32/include/kernel32.h
--- trunk/reactos/lib/kernel32/include/kernel32.h	2005-07-29 20:24:48 UTC (rev 16880)
+++ trunk/reactos/lib/kernel32/include/kernel32.h	2005-07-29 21:55:09 UTC (rev 16881)
@@ -134,7 +134,7 @@
 VOID
 STDCALL
 BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
-                                   IN PVOID UnicodeString);
+                                   OUT LPWSTR* UnicodeString);
                                    
 PUNICODE_STRING
 STDCALL
@@ -145,11 +145,16 @@
 Basep8BitStringToLiveUnicodeString(OUT PUNICODE_STRING UnicodeString,
                                    IN LPCSTR String);
 
+NTSTATUS
+STDCALL
+Basep8BitStringToHeapUnicodeString(OUT PUNICODE_STRING UnicodeString,
+                                   IN LPCSTR String);
+
 typedef NTSTATUS (STDCALL *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString,
                                                 IN PANSI_STRING AnsiString,
                                                 IN BOOLEAN AllocateMemory);
                                                 
-PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
+extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
 
 NTSTATUS
 STDCALL

Modified: trunk/reactos/lib/kernel32/misc/utils.c
--- trunk/reactos/lib/kernel32/misc/utils.c	2005-07-29 20:24:48 UTC (rev 16880)
+++ trunk/reactos/lib/kernel32/misc/utils.c	2005-07-29 21:55:09 UTC (rev 16881)
@@ -73,13 +73,38 @@
     return StaticString;
 }
 
+NTSTATUS
+STDCALL
+Basep8BitStringToHeapUnicodeString(OUT PUNICODE_STRING UnicodeString,
+                                   IN LPCSTR String)
+{
+    ANSI_STRING AnsiString;
+    NTSTATUS Status;
+    
+    DPRINT("Basep8BitStringToCachedUnicodeString\n");
+    
+    /* Initialize an ANSI String */
+    RtlInitAnsiString(&AnsiString, String);
+    
+    /* Convert it */
+    Status = Basep8BitStringToUnicodeString(UnicodeString, &AnsiString, TRUE);
+    
+    /* Handle failure */
+    /* Return Status */
+    if (!NT_SUCCESS(Status))
+    {
+        SetLastErrorByStatus(Status);
+    }
+    return Status;
+}
+
 /*
  * Allocates space from the Heap and converts an Ansi String into it
  */
 VOID
 STDCALL
 BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
-                                   IN PVOID UnicodeString)
+                                   IN LPWSTR* UnicodeString)
 {
     ANSI_STRING AnsiTemp;
     UNICODE_STRING UnicodeTemp;
@@ -93,12 +118,12 @@
     UnicodeTemp.MaximumLength = RtlAnsiStringToUnicodeSize(&AnsiTemp);
     
     /* Allocate space from the Heap for the string */
-    UnicodeString = RtlAllocateHeap(GetProcessHeap(),
+    *UnicodeString = RtlAllocateHeap(GetProcessHeap(),
                                     0,
                                     UnicodeTemp.MaximumLength);
                                     
     /* Save the buffer and convert */
-    UnicodeTemp.Buffer = UnicodeString;
+    UnicodeTemp.Buffer = *UnicodeString;
     RtlAnsiStringToUnicodeString(&UnicodeTemp, &AnsiTemp, FALSE);
 }
 

Modified: trunk/reactos/lib/kernel32/process/create.c
--- trunk/reactos/lib/kernel32/process/create.c	2005-07-29 20:24:48 UTC (rev 16880)
+++ trunk/reactos/lib/kernel32/process/create.c	2005-07-29 21:55:09 UTC (rev 16881)
@@ -639,7 +639,7 @@
         else
         {
             /* Use a dynamic version */
-            Basep8BitStringToLiveUnicodeString(&LiveCommandLine, 
+            Basep8BitStringToHeapUnicodeString(&LiveCommandLine, 
                                                lpCommandLine);
         }
     }
@@ -652,12 +652,12 @@
     /* Convert the Name and Directory */
     if (lpApplicationName)
     {
-        Basep8BitStringToLiveUnicodeString(&ApplicationName, 
+        Basep8BitStringToHeapUnicodeString(&ApplicationName, 
                                            lpApplicationName);
     }
     if (lpCurrentDirectory)
     {
-        Basep8BitStringToLiveUnicodeString(&CurrentDirectory, 
+        Basep8BitStringToHeapUnicodeString(&CurrentDirectory, 
                                            lpCurrentDirectory);
     }
     
@@ -741,11 +741,11 @@
     PWCHAR Extension;
     LPWSTR QuotedCmdLine = NULL;
     LPWSTR ScanString;
-    LPWSTR NullBuffer;
+    LPWSTR NullBuffer = NULL;
     LPWSTR NameBuffer = NULL;
-    WCHAR SaveChar;
+    WCHAR SaveChar = 0;
     ULONG RetVal;
-    UINT Error;
+    UINT Error = 0;
     BOOLEAN SearchDone = FALSE;
     CLIENT_ID ClientId;
     PPEB OurPeb = NtCurrentPeb();