Fixed some bugs in CreateProcessA which was introduced by r16730.

svn path=/trunk/; revision=16881
This commit is contained in:
Hartmut Birr 2005-07-29 21:55:09 +00:00
parent 7559937efb
commit ade86ba7d7
3 changed files with 41 additions and 11 deletions

View file

@ -134,7 +134,7 @@ BasepCheckRealTimePrivilege(VOID);
VOID VOID
STDCALL STDCALL
BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString, BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
IN PVOID UnicodeString); OUT LPWSTR* UnicodeString);
PUNICODE_STRING PUNICODE_STRING
STDCALL STDCALL
@ -145,11 +145,16 @@ STDCALL
Basep8BitStringToLiveUnicodeString(OUT PUNICODE_STRING UnicodeString, Basep8BitStringToLiveUnicodeString(OUT PUNICODE_STRING UnicodeString,
IN LPCSTR String); IN LPCSTR String);
NTSTATUS
STDCALL
Basep8BitStringToHeapUnicodeString(OUT PUNICODE_STRING UnicodeString,
IN LPCSTR String);
typedef NTSTATUS (STDCALL *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString, typedef NTSTATUS (STDCALL *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString,
IN PANSI_STRING AnsiString, IN PANSI_STRING AnsiString,
IN BOOLEAN AllocateMemory); IN BOOLEAN AllocateMemory);
PRTL_CONVERT_STRING Basep8BitStringToUnicodeString; extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
NTSTATUS NTSTATUS
STDCALL STDCALL

View file

@ -73,13 +73,38 @@ Basep8BitStringToCachedUnicodeString(IN LPCSTR String)
return StaticString; 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 * Allocates space from the Heap and converts an Ansi String into it
*/ */
VOID VOID
STDCALL STDCALL
BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString, BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
IN PVOID UnicodeString) IN LPWSTR* UnicodeString)
{ {
ANSI_STRING AnsiTemp; ANSI_STRING AnsiTemp;
UNICODE_STRING UnicodeTemp; UNICODE_STRING UnicodeTemp;
@ -93,12 +118,12 @@ BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
UnicodeTemp.MaximumLength = RtlAnsiStringToUnicodeSize(&AnsiTemp); UnicodeTemp.MaximumLength = RtlAnsiStringToUnicodeSize(&AnsiTemp);
/* Allocate space from the Heap for the string */ /* Allocate space from the Heap for the string */
UnicodeString = RtlAllocateHeap(GetProcessHeap(), *UnicodeString = RtlAllocateHeap(GetProcessHeap(),
0, 0,
UnicodeTemp.MaximumLength); UnicodeTemp.MaximumLength);
/* Save the buffer and convert */ /* Save the buffer and convert */
UnicodeTemp.Buffer = UnicodeString; UnicodeTemp.Buffer = *UnicodeString;
RtlAnsiStringToUnicodeString(&UnicodeTemp, &AnsiTemp, FALSE); RtlAnsiStringToUnicodeString(&UnicodeTemp, &AnsiTemp, FALSE);
} }

View file

@ -639,7 +639,7 @@ CreateProcessA(LPCSTR lpApplicationName,
else else
{ {
/* Use a dynamic version */ /* Use a dynamic version */
Basep8BitStringToLiveUnicodeString(&LiveCommandLine, Basep8BitStringToHeapUnicodeString(&LiveCommandLine,
lpCommandLine); lpCommandLine);
} }
} }
@ -652,12 +652,12 @@ CreateProcessA(LPCSTR lpApplicationName,
/* Convert the Name and Directory */ /* Convert the Name and Directory */
if (lpApplicationName) if (lpApplicationName)
{ {
Basep8BitStringToLiveUnicodeString(&ApplicationName, Basep8BitStringToHeapUnicodeString(&ApplicationName,
lpApplicationName); lpApplicationName);
} }
if (lpCurrentDirectory) if (lpCurrentDirectory)
{ {
Basep8BitStringToLiveUnicodeString(&CurrentDirectory, Basep8BitStringToHeapUnicodeString(&CurrentDirectory,
lpCurrentDirectory); lpCurrentDirectory);
} }
@ -741,11 +741,11 @@ CreateProcessW(LPCWSTR lpApplicationName,
PWCHAR Extension; PWCHAR Extension;
LPWSTR QuotedCmdLine = NULL; LPWSTR QuotedCmdLine = NULL;
LPWSTR ScanString; LPWSTR ScanString;
LPWSTR NullBuffer; LPWSTR NullBuffer = NULL;
LPWSTR NameBuffer = NULL; LPWSTR NameBuffer = NULL;
WCHAR SaveChar; WCHAR SaveChar = 0;
ULONG RetVal; ULONG RetVal;
UINT Error; UINT Error = 0;
BOOLEAN SearchDone = FALSE; BOOLEAN SearchDone = FALSE;
CLIENT_ID ClientId; CLIENT_ID ClientId;
PPEB OurPeb = NtCurrentPeb(); PPEB OurPeb = NtCurrentPeb();