diff --git a/reactos/lib/kernel32/include/kernel32.h b/reactos/lib/kernel32/include/kernel32.h index e1d97df4603..87817b093c0 100755 --- a/reactos/lib/kernel32/include/kernel32.h +++ b/reactos/lib/kernel32/include/kernel32.h @@ -134,7 +134,7 @@ BasepCheckRealTimePrivilege(VOID); VOID STDCALL BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString, - IN PVOID UnicodeString); + OUT LPWSTR* UnicodeString); PUNICODE_STRING STDCALL @@ -145,11 +145,16 @@ STDCALL 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 diff --git a/reactos/lib/kernel32/misc/utils.c b/reactos/lib/kernel32/misc/utils.c index 1db661d4a14..2b39d4b4fe3 100644 --- a/reactos/lib/kernel32/misc/utils.c +++ b/reactos/lib/kernel32/misc/utils.c @@ -73,13 +73,38 @@ Basep8BitStringToCachedUnicodeString(IN LPCSTR String) 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 @@ BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString, 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); } diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index f7457747022..d1b5047de7d 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -639,7 +639,7 @@ CreateProcessA(LPCSTR lpApplicationName, else { /* Use a dynamic version */ - Basep8BitStringToLiveUnicodeString(&LiveCommandLine, + Basep8BitStringToHeapUnicodeString(&LiveCommandLine, lpCommandLine); } } @@ -652,12 +652,12 @@ CreateProcessA(LPCSTR lpApplicationName, /* Convert the Name and Directory */ if (lpApplicationName) { - Basep8BitStringToLiveUnicodeString(&ApplicationName, + Basep8BitStringToHeapUnicodeString(&ApplicationName, lpApplicationName); } if (lpCurrentDirectory) { - Basep8BitStringToLiveUnicodeString(&CurrentDirectory, + Basep8BitStringToHeapUnicodeString(&CurrentDirectory, lpCurrentDirectory); } @@ -741,11 +741,11 @@ CreateProcessW(LPCWSTR lpApplicationName, 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();