mirror of
https://github.com/reactos/reactos.git
synced 2024-07-21 19:58:08 +00:00
Fixed command line code.
Fixed Rtl string functions. svn path=/trunk/; revision=846
This commit is contained in:
parent
c7b7c5b0b6
commit
a1c7df6990
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* $Id: cmdline.c,v 1.9 1999/12/10 17:47:29 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
|
||||||
* FILE: lib/kernel32/proc/proc.c
|
* FILE: lib/kernel32/proc/proc.c
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
#define UNICODE
|
//#define UNICODE
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <kernel32/proc.h>
|
#include <kernel32/proc.h>
|
||||||
|
@ -18,29 +19,76 @@
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/teb.h>
|
#include <internal/teb.h>
|
||||||
|
#include <ntdll/rtl.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <kernel32/kernel32.h>
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
|
static UNICODE_STRING CommandLineStringW;
|
||||||
|
static ANSI_STRING CommandLineStringA;
|
||||||
|
|
||||||
|
static WCHAR CommandLineW[MAX_PATH];
|
||||||
static CHAR CommandLineA[MAX_PATH];
|
static CHAR CommandLineA[MAX_PATH];
|
||||||
|
|
||||||
|
static WINBOOL bCommandLineInitialized = FALSE;
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
InitCommandLines (VOID)
|
||||||
|
{
|
||||||
|
PPPB Ppb;
|
||||||
|
|
||||||
|
// initialize command line buffers
|
||||||
|
CommandLineW[0] = 0;
|
||||||
|
CommandLineStringW.Buffer = CommandLineW;
|
||||||
|
CommandLineStringW.Length = 0;
|
||||||
|
CommandLineStringW.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||||
|
|
||||||
|
CommandLineA[0] = 0;
|
||||||
|
CommandLineStringA.Buffer = CommandLineA;
|
||||||
|
CommandLineStringA.Length = 0;
|
||||||
|
CommandLineStringA.MaximumLength = MAX_PATH;
|
||||||
|
|
||||||
|
// get command line
|
||||||
|
Ppb = NtCurrentPeb()->Ppb;
|
||||||
|
RtlNormalizeProcessParams (Ppb);
|
||||||
|
|
||||||
|
RtlCopyUnicodeString (&CommandLineStringW,
|
||||||
|
&(Ppb->CommandLine));
|
||||||
|
RtlUnicodeStringToAnsiString (&CommandLineStringA,
|
||||||
|
&CommandLineStringW,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
bCommandLineInitialized = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LPSTR STDCALL GetCommandLineA(VOID)
|
LPSTR STDCALL GetCommandLineA(VOID)
|
||||||
{
|
{
|
||||||
ULONG i;
|
if (bCommandLineInitialized == FALSE)
|
||||||
PWSTR CommandLineW;
|
{
|
||||||
|
InitCommandLines ();
|
||||||
CommandLineW = GetCommandLineW();
|
}
|
||||||
for (i=0; i<MAX_PATH && CommandLineW[i]!=0; i++)
|
|
||||||
{
|
DPRINT ("CommandLine \'%s\'\n", CommandLineA);
|
||||||
CommandLineA[i] = (CHAR)CommandLineW[i];
|
|
||||||
}
|
return(CommandLineA);
|
||||||
CommandLineA[i] = 0;
|
|
||||||
return(CommandLineA);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR STDCALL GetCommandLineW (VOID)
|
LPWSTR STDCALL GetCommandLineW (VOID)
|
||||||
{
|
{
|
||||||
return (NtCurrentPeb()->Ppb->CommandLine.Buffer);
|
if (bCommandLineInitialized == FALSE)
|
||||||
|
{
|
||||||
|
InitCommandLines ();
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT ("CommandLine \'%w\'\n", CommandLineW);
|
||||||
|
|
||||||
|
return(CommandLineW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: create.c,v 1.15 1999/12/08 12:58:44 ekohl Exp $
|
/* $Id: create.c,v 1.16 1999/12/10 17:47:29 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
|
||||||
|
@ -359,23 +359,7 @@ CreatePeb (
|
||||||
ULONG PpbSize;
|
ULONG PpbSize;
|
||||||
ULONG BytesWritten;
|
ULONG BytesWritten;
|
||||||
|
|
||||||
PebBase = (PVOID)PEB_BASE;
|
/* create the PPB */
|
||||||
PebSize = 0x1000;
|
|
||||||
|
|
||||||
NtReadVirtualMemory(ProcessHandle,
|
|
||||||
(PVOID)PEB_BASE,
|
|
||||||
&Peb,
|
|
||||||
sizeof(Peb),
|
|
||||||
&BytesWritten);
|
|
||||||
|
|
||||||
Peb.Ppb = (PPPB)PEB_STARTUPINFO;
|
|
||||||
|
|
||||||
NtWriteVirtualMemory(ProcessHandle,
|
|
||||||
(PVOID)PEB_BASE,
|
|
||||||
&Peb,
|
|
||||||
sizeof(Peb),
|
|
||||||
&BytesWritten);
|
|
||||||
|
|
||||||
PpbBase = (PVOID)PEB_STARTUPINFO;
|
PpbBase = (PVOID)PEB_STARTUPINFO;
|
||||||
PpbSize = Ppb->TotalSize;
|
PpbSize = Ppb->TotalSize;
|
||||||
Status = NtAllocateVirtualMemory(ProcessHandle,
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||||
|
@ -389,13 +373,39 @@ CreatePeb (
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Ppb size %x\n", Ppb->TotalSize);
|
DPRINT("Ppb->TotalSize %x\n", Ppb->TotalSize);
|
||||||
ZwWriteVirtualMemory(ProcessHandle,
|
NtWriteVirtualMemory(ProcessHandle,
|
||||||
(PVOID)PEB_STARTUPINFO,
|
PpbBase,
|
||||||
&Ppb,
|
Ppb,
|
||||||
Ppb->TotalSize,
|
Ppb->TotalSize,
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
|
|
||||||
|
|
||||||
|
/* create the PEB */
|
||||||
|
PebBase = (PVOID)PEB_BASE;
|
||||||
|
PebSize = 0x1000;
|
||||||
|
|
||||||
|
Status = NtAllocateVirtualMemory(ProcessHandle,
|
||||||
|
&PebBase,
|
||||||
|
0,
|
||||||
|
&PebSize,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("Peb created\n");
|
||||||
|
|
||||||
|
Peb.Ppb = (PPPB)PpbBase;
|
||||||
|
|
||||||
|
NtWriteVirtualMemory(ProcessHandle,
|
||||||
|
PebBase,
|
||||||
|
&Peb,
|
||||||
|
sizeof(Peb),
|
||||||
|
&BytesWritten);
|
||||||
|
|
||||||
*PebPtr = (PPEB)PebBase;
|
*PebPtr = (PPEB)PebBase;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
@ -459,6 +469,8 @@ CreateProcessW (
|
||||||
&CommandLine_U,
|
&CommandLine_U,
|
||||||
TempCommandLine);
|
TempCommandLine);
|
||||||
|
|
||||||
|
DPRINT("CommandLine_U %w\n", CommandLine_U.Buffer);
|
||||||
|
|
||||||
RtlCreateProcessParameters (
|
RtlCreateProcessParameters (
|
||||||
&Ppb,
|
&Ppb,
|
||||||
&CommandLine_U,
|
&CommandLine_U,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.6 1999/12/08 12:58:26 ekohl Exp $
|
/* $Id: process.c,v 1.7 1999/12/10 17:48:34 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
|
||||||
|
@ -477,7 +477,7 @@ RtlCreateProcessParameters (
|
||||||
DataSize += (Reserved->Length + sizeof(WCHAR));
|
DataSize += (Reserved->Length + sizeof(WCHAR));
|
||||||
|
|
||||||
/* Calculate the required block size */
|
/* Calculate the required block size */
|
||||||
RegionSize = DataSize;
|
RegionSize = ROUNDUP(DataSize, PAGESIZE);
|
||||||
|
|
||||||
Status = NtAllocateVirtualMemory (
|
Status = NtAllocateVirtualMemory (
|
||||||
NtCurrentProcess (),
|
NtCurrentProcess (),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: unicode.c,v 1.10 1999/11/25 23:43:44 ekohl Exp $
|
/* $Id: unicode.c,v 1.11 1999/12/10 17:48:34 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -81,8 +81,6 @@ RtlAnsiStringToUnicodeString(
|
||||||
if (Length > 65535)
|
if (Length > 65535)
|
||||||
return STATUS_INVALID_PARAMETER_2;
|
return STATUS_INVALID_PARAMETER_2;
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
||||||
|
@ -95,9 +93,10 @@ RtlAnsiStringToUnicodeString(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length > DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -470,7 +469,6 @@ RtlDowncaseUnicodeString (
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->Length = SourceString->Length;
|
|
||||||
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
|
||||||
DestinationString->Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
|
DestinationString->Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
|
||||||
0,
|
0,
|
||||||
|
@ -479,8 +477,9 @@ RtlDowncaseUnicodeString (
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SourceString->Length >= DestinationString->MaximumLength)
|
if (SourceString->Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = SourceString->Length;
|
||||||
|
|
||||||
Src = SourceString->Buffer;
|
Src = SourceString->Buffer;
|
||||||
Dest = DestinationString->Buffer;
|
Dest = DestinationString->Buffer;
|
||||||
|
@ -855,8 +854,6 @@ RtlOemStringToUnicodeString (
|
||||||
if (Length > 65535)
|
if (Length > 65535)
|
||||||
return STATUS_INVALID_PARAMETER_2;
|
return STATUS_INVALID_PARAMETER_2;
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
||||||
|
@ -869,13 +866,13 @@ RtlOemStringToUnicodeString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length > DestinationString->Length)
|
if (Length > DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
memset (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
0,
|
DestinationString->Length);
|
||||||
DestinationString->Length);
|
|
||||||
|
|
||||||
Status = RtlOemToUnicodeN (DestinationString->Buffer,
|
Status = RtlOemToUnicodeN (DestinationString->Buffer,
|
||||||
DestinationString->Length,
|
DestinationString->Length,
|
||||||
|
@ -931,12 +928,6 @@ RtlUnicodeStringToAnsiString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
/* this doesn't make sense */
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -949,9 +940,10 @@ RtlUnicodeStringToAnsiString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -963,10 +955,12 @@ RtlUnicodeStringToAnsiString (
|
||||||
SourceString->Length);
|
SourceString->Length);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
if (AllocateDestinationString)
|
if (AllocateDestinationString == TRUE)
|
||||||
|
{
|
||||||
RtlFreeHeap (RtlGetProcessHeap (),
|
RtlFreeHeap (RtlGetProcessHeap (),
|
||||||
0,
|
0,
|
||||||
DestinationString->Buffer);
|
DestinationString->Buffer);
|
||||||
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,11 +1073,6 @@ RtlUnicodeStringToOemString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -1096,9 +1085,10 @@ RtlUnicodeStringToOemString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -1154,8 +1144,6 @@ RtlUpcaseUnicodeString (
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PWCHAR Src, Dest;
|
PWCHAR Src, Dest;
|
||||||
|
|
||||||
DestinationString->Length = SourceString->Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR);
|
DestinationString->MaximumLength=SourceString->Length+sizeof(WCHAR);
|
||||||
|
@ -1165,6 +1153,12 @@ RtlUpcaseUnicodeString (
|
||||||
if (DestinationString->Buffer == NULL)
|
if (DestinationString->Buffer == NULL)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SourceString->Length >= DestinationString->MaximumLength)
|
||||||
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
}
|
||||||
|
DestinationString->Length = SourceString->Length;
|
||||||
|
|
||||||
Src = SourceString->Buffer;
|
Src = SourceString->Buffer;
|
||||||
Dest = DestinationString->Buffer;
|
Dest = DestinationString->Buffer;
|
||||||
|
@ -1196,11 +1190,6 @@ RtlUpcaseUnicodeStringToAnsiString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -1212,9 +1201,10 @@ RtlUpcaseUnicodeStringToAnsiString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -1262,11 +1252,6 @@ RtlUpcaseUnicodeStringToOemString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -1278,9 +1263,10 @@ RtlUpcaseUnicodeStringToOemString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: unicode.c,v 1.10 1999/11/25 23:34:43 ekohl Exp $
|
/* $Id: unicode.c,v 1.11 1999/12/10 17:49:21 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -76,8 +76,6 @@ RtlAnsiStringToUnicodeString (
|
||||||
if (Length > 65535)
|
if (Length > 65535)
|
||||||
return STATUS_INVALID_PARAMETER_2;
|
return STATUS_INVALID_PARAMETER_2;
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
||||||
|
@ -89,13 +87,13 @@ RtlAnsiStringToUnicodeString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length > DestinationString->Length)
|
if (Length > DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
memset (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
0,
|
DestinationString->Length);
|
||||||
DestinationString->Length);
|
|
||||||
|
|
||||||
Status = RtlMultiByteToUnicodeN (DestinationString->Buffer,
|
Status = RtlMultiByteToUnicodeN (DestinationString->Buffer,
|
||||||
DestinationString->Length,
|
DestinationString->Length,
|
||||||
|
@ -464,7 +462,6 @@ RtlDowncaseUnicodeString (
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->Length = SourceString->Length;
|
|
||||||
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
|
||||||
DestinationString->Buffer = ExAllocatePool (NonPagedPool,
|
DestinationString->Buffer = ExAllocatePool (NonPagedPool,
|
||||||
SourceString->Length + sizeof(WCHAR));
|
SourceString->Length + sizeof(WCHAR));
|
||||||
|
@ -474,8 +471,9 @@ RtlDowncaseUnicodeString (
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SourceString->Length >= DestinationString->MaximumLength)
|
if (SourceString->Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = SourceString->Length;
|
||||||
|
|
||||||
Src = SourceString->Buffer;
|
Src = SourceString->Buffer;
|
||||||
Dest = DestinationString->Buffer;
|
Dest = DestinationString->Buffer;
|
||||||
|
@ -844,8 +842,6 @@ RtlOemStringToUnicodeString (
|
||||||
if (Length > 65535)
|
if (Length > 65535)
|
||||||
return STATUS_INVALID_PARAMETER_2;
|
return STATUS_INVALID_PARAMETER_2;
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = Length + sizeof(WCHAR);
|
||||||
|
@ -857,13 +853,13 @@ RtlOemStringToUnicodeString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length > DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
memset (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
0,
|
DestinationString->Length);
|
||||||
DestinationString->Length);
|
|
||||||
|
|
||||||
Status = RtlOemToUnicodeN (DestinationString->Buffer,
|
Status = RtlOemToUnicodeN (DestinationString->Buffer,
|
||||||
DestinationString->Length,
|
DestinationString->Length,
|
||||||
|
@ -913,11 +909,6 @@ RtlUnicodeStringToAnsiString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -928,9 +919,10 @@ RtlUnicodeStringToAnsiString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -1058,11 +1050,6 @@ RtlUnicodeStringToOemString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -1074,9 +1061,10 @@ RtlUnicodeStringToOemString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -1130,7 +1118,6 @@ RtlUpcaseUnicodeString (
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->Length = SourceString->Length;
|
|
||||||
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
|
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
|
||||||
DestinationString->Buffer = ExAllocatePool (NonPagedPool,
|
DestinationString->Buffer = ExAllocatePool (NonPagedPool,
|
||||||
SourceString->Length + sizeof(WCHAR));
|
SourceString->Length + sizeof(WCHAR));
|
||||||
|
@ -1140,8 +1127,9 @@ RtlUpcaseUnicodeString (
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (SourceString->Length >= DestinationString->MaximumLength)
|
if (SourceString->Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = SourceString->Length;
|
||||||
|
|
||||||
Src = SourceString->Buffer;
|
Src = SourceString->Buffer;
|
||||||
Dest = DestinationString->Buffer;
|
Dest = DestinationString->Buffer;
|
||||||
|
@ -1173,11 +1161,6 @@ RtlUpcaseUnicodeStringToAnsiString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -1188,9 +1171,10 @@ RtlUpcaseUnicodeStringToAnsiString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
@ -1234,11 +1218,6 @@ RtlUpcaseUnicodeStringToOemString (
|
||||||
else
|
else
|
||||||
Length = SourceString->Length / sizeof(WCHAR);
|
Length = SourceString->Length / sizeof(WCHAR);
|
||||||
|
|
||||||
// if (Length > 65535)
|
|
||||||
// return STATUS_INVALID_PARAMETER_2;
|
|
||||||
|
|
||||||
DestinationString->Length = Length;
|
|
||||||
|
|
||||||
if (AllocateDestinationString == TRUE)
|
if (AllocateDestinationString == TRUE)
|
||||||
{
|
{
|
||||||
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
DestinationString->MaximumLength = Length + sizeof(CHAR);
|
||||||
|
@ -1249,9 +1228,10 @@ RtlUpcaseUnicodeStringToOemString (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Length >= DestinationString->Length)
|
if (Length >= DestinationString->MaximumLength)
|
||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
DestinationString->Length = Length;
|
||||||
|
|
||||||
RtlZeroMemory (DestinationString->Buffer,
|
RtlZeroMemory (DestinationString->Buffer,
|
||||||
DestinationString->Length);
|
DestinationString->Length);
|
||||||
|
|
Loading…
Reference in a new issue