Fixed ANSI/OEM <--> Unicode conversions

svn path=/trunk/; revision=1061
This commit is contained in:
Eric Kohl 2000-03-16 01:14:58 +00:00
parent b820741431
commit 15c9809105
3 changed files with 122 additions and 105 deletions

View file

@ -27,11 +27,6 @@ FindResourceExA(
WORD wLanguage
)
{
// WCHAR ResourceNameW[MAX_PATH];
// WCHAR TypeNameW[MAX_PATH];
// WCHAR *ResourceName = ResourceNameW;
// WCHAR *TypeName = TypeNameW;
UNICODE_STRING TypeU;
UNICODE_STRING NameU;
ANSI_STRING Type;
@ -136,7 +131,7 @@ FindResourceExW (
return NULL;
}
else
nType = lpType;
nType = (ULONG)lpType;
Status = LdrFindResource_U(hModule,&ResourceDataEntry,lpName, nType,wLanguage);
if ( !NT_SUCCESS(Status ) ) {

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.22 2000/02/19 19:35:57 ekohl Exp $
/* $Id: create.c,v 1.23 2000/03/16 01:14:37 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -30,16 +30,20 @@
/* FUNCTIONS ****************************************************************/
WINBOOL STDCALL CreateProcessA(LPCSTR lpApplicationName,
LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
WINBOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation)
WINBOOL
STDCALL
CreateProcessA (
LPCSTR lpApplicationName,
LPSTR lpCommandLine,
LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPSECURITY_ATTRIBUTES lpThreadAttributes,
WINBOOL bInheritHandles,
DWORD dwCreationFlags,
LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
/*
* FUNCTION: The CreateProcess function creates a new process and its
* primary thread. The new process executes the specified executable file
@ -57,34 +61,65 @@ WINBOOL STDCALL CreateProcessA(LPCSTR lpApplicationName,
* lpProcessInformation = Pointer to process information
*/
{
WCHAR ApplicationNameW[MAX_PATH];
WCHAR CommandLineW[MAX_PATH];
WCHAR CurrentDirectoryW[MAX_PATH];
PWSTR PApplicationNameW;
PWSTR PCommandLineW;
PWSTR PCurrentDirectoryW;
DPRINT("CreateProcessA\n");
PApplicationNameW = InternalAnsiToUnicode(ApplicationNameW,
lpApplicationName,
MAX_PATH);
PCommandLineW = InternalAnsiToUnicode(CommandLineW,
lpCommandLine,
MAX_PATH);
PCurrentDirectoryW = InternalAnsiToUnicode(CurrentDirectoryW,
lpCurrentDirectory,
MAX_PATH);
return CreateProcessW(PApplicationNameW,
PCommandLineW,
lpProcessAttributes,
lpThreadAttributes,
bInheritHandles,
dwCreationFlags,
lpEnvironment,
PCurrentDirectoryW,
(LPSTARTUPINFOW)lpStartupInfo,
lpProcessInformation);
UNICODE_STRING ApplicationNameU;
UNICODE_STRING CurrentDirectoryU;
UNICODE_STRING CommandLineU;
ANSI_STRING ApplicationName;
ANSI_STRING CurrentDirectory;
ANSI_STRING CommandLine;
WINBOOL Result;
DPRINT("CreateProcessA\n");
RtlInitAnsiString (&CommandLine,
lpCommandLine);
RtlInitAnsiString (&ApplicationName,
(LPSTR)lpApplicationName);
RtlInitAnsiString (&CurrentDirectory,
(LPSTR)lpCurrentDirectory);
/* convert ansi (or oem) strings to unicode */
if (bIsFileApiAnsi)
{
RtlAnsiStringToUnicodeString (&CommandLineU,
&CommandLine,
TRUE);
RtlAnsiStringToUnicodeString (&ApplicationNameU,
&ApplicationName,
TRUE);
RtlAnsiStringToUnicodeString (&CurrentDirectoryU,
&CurrentDirectory,
TRUE);
}
else
{
RtlOemStringToUnicodeString (&CommandLineU,
&CommandLine,
TRUE);
RtlOemStringToUnicodeString (&ApplicationNameU,
&ApplicationName,
TRUE);
RtlOemStringToUnicodeString (&CurrentDirectoryU,
&CurrentDirectory,
TRUE);
}
Result = CreateProcessW (ApplicationNameU.Buffer,
CommandLineU.Buffer,
lpProcessAttributes,
lpThreadAttributes,
bInheritHandles,
dwCreationFlags,
lpEnvironment,
CurrentDirectoryU.Buffer,
(LPSTARTUPINFOW)lpStartupInfo,
lpProcessInformation);
RtlFreeUnicodeString (&ApplicationNameU);
RtlFreeUnicodeString (&CommandLineU);
RtlFreeUnicodeString (&CurrentDirectoryU);
return Result;
}
#define STACK_TOP (0xb0000000)
@ -442,6 +477,11 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
*/
hSection = KlMapFile (lpApplicationName, lpCommandLine);
if (hSection == NULL)
{
RtlDestroyProcessParameters (Ppb);
return FALSE;
}
/*
* Create a new process

View file

@ -1,4 +1,4 @@
/* $Id: proc.c,v 1.30 2000/02/19 19:35:57 ekohl Exp $
/* $Id: proc.c,v 1.31 2000/03/16 01:14:37 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -106,7 +106,7 @@ GetExitCodeProcess (
return FALSE;
}
memcpy(lpExitCode, &ProcessBasic.ExitStatus, sizeof(DWORD));
return TRUE;
return TRUE;
}
@ -136,34 +136,6 @@ GetProcessId (
}
PWSTR
InternalAnsiToUnicode (
PWSTR Out,
LPCSTR In,
ULONG MaxLength
)
{
ULONG i;
if (In == NULL)
{
return(NULL);
}
else
{
i = 0;
while ((*In)!=0 && i < MaxLength)
{
Out[i] = *In;
In++;
i++;
}
Out[i] = 0;
return(Out);
}
}
HANDLE
STDCALL
OpenProcess (
@ -249,7 +221,7 @@ RegisterWaitForInputIdle (
WaitForInputIdleType lpfnRegisterWaitForInputIdle
)
{
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
return;
}
@ -257,7 +229,7 @@ RegisterWaitForInputIdle (
DWORD
STDCALL
WaitForInputIdle (
HANDLE hProcess,
HANDLE hProcess,
DWORD dwMilliseconds
)
{
@ -265,14 +237,23 @@ WaitForInputIdle (
}
VOID STDCALL Sleep (DWORD dwMilliseconds)
VOID
STDCALL
Sleep (
DWORD dwMilliseconds
)
{
SleepEx (dwMilliseconds, FALSE);
return;
}
DWORD STDCALL SleepEx(DWORD dwMilliseconds,
BOOL bAlertable)
DWORD
STDCALL
SleepEx (
DWORD dwMilliseconds,
BOOL bAlertable
)
{
TIME Interval;
NTSTATUS errCode;
@ -412,8 +393,7 @@ FlushInstructionCache (
errCode = NtFlushInstructionCache(
hProcess,
(PVOID) lpBaseAddress,
dwSize
);
dwSize);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
@ -429,10 +409,8 @@ ExitProcess (
UINT uExitCode
)
{
NtTerminateProcess(
NtCurrentProcess(),
uExitCode
);
NtTerminateProcess (NtCurrentProcess (),
uExitCode);
}
@ -443,16 +421,18 @@ TerminateProcess (
UINT uExitCode
)
{
NTSTATUS errCode;
errCode = NtTerminateProcess(hProcess, uExitCode);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return TRUE;
NTSTATUS errCode;
errCode = NtTerminateProcess(hProcess, uExitCode);
if (!NT_SUCCESS(errCode))
{
SetLastError(RtlNtStatusToDosError(errCode));
return FALSE;
}
return TRUE;
}
VOID
STDCALL
FatalAppExitA (
@ -460,18 +440,20 @@ FatalAppExitA (
LPCSTR lpMessageText
)
{
WCHAR MessageTextW[MAX_PATH];
UINT i;
i = 0;
while ((*lpMessageText)!=0 && i < 35)
{
MessageTextW[i] = *lpMessageText;
lpMessageText++;
i++;
}
MessageTextW[i] = 0;
UNICODE_STRING MessageTextU;
ANSI_STRING MessageText;
return FatalAppExitW(uAction,MessageTextW);
RtlInitAnsiString (&MessageText,
(LPSTR)lpMessageText);
RtlAnsiStringToUnicodeString (&MessageTextU,
&MessageText,
TRUE);
FatalAppExitW (uAction,
MessageTextU.Buffer);
RtlFreeUnicodeString (&MessageTextU);
}