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 WORD wLanguage
) )
{ {
// WCHAR ResourceNameW[MAX_PATH];
// WCHAR TypeNameW[MAX_PATH];
// WCHAR *ResourceName = ResourceNameW;
// WCHAR *TypeName = TypeNameW;
UNICODE_STRING TypeU; UNICODE_STRING TypeU;
UNICODE_STRING NameU; UNICODE_STRING NameU;
ANSI_STRING Type; ANSI_STRING Type;
@ -136,7 +131,7 @@ FindResourceExW (
return NULL; return NULL;
} }
else else
nType = lpType; nType = (ULONG)lpType;
Status = LdrFindResource_U(hModule,&ResourceDataEntry,lpName, nType,wLanguage); Status = LdrFindResource_U(hModule,&ResourceDataEntry,lpName, nType,wLanguage);
if ( !NT_SUCCESS(Status ) ) { 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -30,16 +30,20 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
WINBOOL STDCALL CreateProcessA(LPCSTR lpApplicationName, WINBOOL
LPSTR lpCommandLine, STDCALL
LPSECURITY_ATTRIBUTES lpProcessAttributes, CreateProcessA (
LPSECURITY_ATTRIBUTES lpThreadAttributes, LPCSTR lpApplicationName,
WINBOOL bInheritHandles, LPSTR lpCommandLine,
DWORD dwCreationFlags, LPSECURITY_ATTRIBUTES lpProcessAttributes,
LPVOID lpEnvironment, LPSECURITY_ATTRIBUTES lpThreadAttributes,
LPCSTR lpCurrentDirectory, WINBOOL bInheritHandles,
LPSTARTUPINFOA lpStartupInfo, DWORD dwCreationFlags,
LPPROCESS_INFORMATION lpProcessInformation) LPVOID lpEnvironment,
LPCSTR lpCurrentDirectory,
LPSTARTUPINFOA lpStartupInfo,
LPPROCESS_INFORMATION lpProcessInformation
)
/* /*
* FUNCTION: The CreateProcess function creates a new process and its * FUNCTION: The CreateProcess function creates a new process and its
* primary thread. The new process executes the specified executable file * primary thread. The new process executes the specified executable file
@ -57,34 +61,65 @@ WINBOOL STDCALL CreateProcessA(LPCSTR lpApplicationName,
* lpProcessInformation = Pointer to process information * lpProcessInformation = Pointer to process information
*/ */
{ {
WCHAR ApplicationNameW[MAX_PATH]; UNICODE_STRING ApplicationNameU;
WCHAR CommandLineW[MAX_PATH]; UNICODE_STRING CurrentDirectoryU;
WCHAR CurrentDirectoryW[MAX_PATH]; UNICODE_STRING CommandLineU;
PWSTR PApplicationNameW; ANSI_STRING ApplicationName;
PWSTR PCommandLineW; ANSI_STRING CurrentDirectory;
PWSTR PCurrentDirectoryW; ANSI_STRING CommandLine;
WINBOOL Result;
DPRINT("CreateProcessA\n");
DPRINT("CreateProcessA\n");
PApplicationNameW = InternalAnsiToUnicode(ApplicationNameW,
lpApplicationName, RtlInitAnsiString (&CommandLine,
MAX_PATH); lpCommandLine);
PCommandLineW = InternalAnsiToUnicode(CommandLineW, RtlInitAnsiString (&ApplicationName,
lpCommandLine, (LPSTR)lpApplicationName);
MAX_PATH); RtlInitAnsiString (&CurrentDirectory,
PCurrentDirectoryW = InternalAnsiToUnicode(CurrentDirectoryW, (LPSTR)lpCurrentDirectory);
lpCurrentDirectory,
MAX_PATH); /* convert ansi (or oem) strings to unicode */
return CreateProcessW(PApplicationNameW, if (bIsFileApiAnsi)
PCommandLineW, {
lpProcessAttributes, RtlAnsiStringToUnicodeString (&CommandLineU,
lpThreadAttributes, &CommandLine,
bInheritHandles, TRUE);
dwCreationFlags, RtlAnsiStringToUnicodeString (&ApplicationNameU,
lpEnvironment, &ApplicationName,
PCurrentDirectoryW, TRUE);
(LPSTARTUPINFOW)lpStartupInfo, RtlAnsiStringToUnicodeString (&CurrentDirectoryU,
lpProcessInformation); &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) #define STACK_TOP (0xb0000000)
@ -442,6 +477,11 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
*/ */
hSection = KlMapFile (lpApplicationName, lpCommandLine); hSection = KlMapFile (lpApplicationName, lpCommandLine);
if (hSection == NULL)
{
RtlDestroyProcessParameters (Ppb);
return FALSE;
}
/* /*
* Create a new process * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -106,7 +106,7 @@ GetExitCodeProcess (
return FALSE; return FALSE;
} }
memcpy(lpExitCode, &ProcessBasic.ExitStatus, sizeof(DWORD)); 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 HANDLE
STDCALL STDCALL
OpenProcess ( OpenProcess (
@ -249,7 +221,7 @@ RegisterWaitForInputIdle (
WaitForInputIdleType lpfnRegisterWaitForInputIdle WaitForInputIdleType lpfnRegisterWaitForInputIdle
) )
{ {
lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle; lpfnGlobalRegisterWaitForInputIdle = lpfnRegisterWaitForInputIdle;
return; return;
} }
@ -257,7 +229,7 @@ RegisterWaitForInputIdle (
DWORD DWORD
STDCALL STDCALL
WaitForInputIdle ( WaitForInputIdle (
HANDLE hProcess, HANDLE hProcess,
DWORD dwMilliseconds DWORD dwMilliseconds
) )
{ {
@ -265,14 +237,23 @@ WaitForInputIdle (
} }
VOID STDCALL Sleep (DWORD dwMilliseconds) VOID
STDCALL
Sleep (
DWORD dwMilliseconds
)
{ {
SleepEx (dwMilliseconds, FALSE); SleepEx (dwMilliseconds, FALSE);
return; return;
} }
DWORD STDCALL SleepEx(DWORD dwMilliseconds,
BOOL bAlertable) DWORD
STDCALL
SleepEx (
DWORD dwMilliseconds,
BOOL bAlertable
)
{ {
TIME Interval; TIME Interval;
NTSTATUS errCode; NTSTATUS errCode;
@ -412,8 +393,7 @@ FlushInstructionCache (
errCode = NtFlushInstructionCache( errCode = NtFlushInstructionCache(
hProcess, hProcess,
(PVOID) lpBaseAddress, (PVOID) lpBaseAddress,
dwSize dwSize);
);
if (!NT_SUCCESS(errCode)) if (!NT_SUCCESS(errCode))
{ {
SetLastError(RtlNtStatusToDosError(errCode)); SetLastError(RtlNtStatusToDosError(errCode));
@ -429,10 +409,8 @@ ExitProcess (
UINT uExitCode UINT uExitCode
) )
{ {
NtTerminateProcess( NtTerminateProcess (NtCurrentProcess (),
NtCurrentProcess(), uExitCode);
uExitCode
);
} }
@ -443,16 +421,18 @@ TerminateProcess (
UINT uExitCode UINT uExitCode
) )
{ {
NTSTATUS errCode; NTSTATUS errCode;
errCode = NtTerminateProcess(hProcess, uExitCode);
if (!NT_SUCCESS(errCode)) errCode = NtTerminateProcess(hProcess, uExitCode);
{ if (!NT_SUCCESS(errCode))
SetLastError(RtlNtStatusToDosError(errCode)); {
return FALSE; SetLastError(RtlNtStatusToDosError(errCode));
} return FALSE;
return TRUE; }
return TRUE;
} }
VOID VOID
STDCALL STDCALL
FatalAppExitA ( FatalAppExitA (
@ -460,18 +440,20 @@ FatalAppExitA (
LPCSTR lpMessageText LPCSTR lpMessageText
) )
{ {
WCHAR MessageTextW[MAX_PATH]; UNICODE_STRING MessageTextU;
UINT i; ANSI_STRING MessageText;
i = 0;
while ((*lpMessageText)!=0 && i < 35)
{
MessageTextW[i] = *lpMessageText;
lpMessageText++;
i++;
}
MessageTextW[i] = 0;
return FatalAppExitW(uAction,MessageTextW); RtlInitAnsiString (&MessageText,
(LPSTR)lpMessageText);
RtlAnsiStringToUnicodeString (&MessageTextU,
&MessageText,
TRUE);
FatalAppExitW (uAction,
MessageTextU.Buffer);
RtlFreeUnicodeString (&MessageTextU);
} }