Implemented basic ANSI/OEM <--> Unicode translation tables.

svn path=/trunk/; revision=2340
This commit is contained in:
Eric Kohl 2001-11-02 09:10:49 +00:00
parent 286d73f7e6
commit b639c5def9
4 changed files with 542 additions and 533 deletions

View file

@ -53,6 +53,8 @@ VOID CmShutdownRegistry(VOID);
VOID CmImportHive(PCHAR ChunkBase, ULONG ChunkSize);
VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
VOID RtlpInitNlsTables(VOID);
NTSTATUS RtlpInitNlsSections(ULONG Mod1Start,
ULONG Mod1End,
ULONG Mod2Start,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: main.c,v 1.107 2001/09/24 00:51:16 chorns Exp $
/* $Id: main.c,v 1.108 2001/11/02 09:09:50 ekohl Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c
@ -944,6 +944,9 @@ ExpInitializeExecutive(VOID)
(PADDRESS_RANGE)&KeMemoryMap,
KeMemoryMapRangeCount);
/* create default nls tables */
RtlpInitNlsTables();
/*
* Initialize the kernel debugger
*/

View file

@ -1,4 +1,4 @@
/* $Id: nls.c,v 1.5 2001/06/29 20:42:47 ekohl Exp $
/* $Id: nls.c,v 1.6 2001/11/02 09:10:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -38,18 +38,111 @@ USHORT NlsOemLeadByteInfo = 0;
USHORT NlsAnsiCodePage = 0;
USHORT NlsOemCodePage = 0; /* not exported */
PWCHAR AnsiToUnicodeTable = NULL; /* size: 256*sizeof(WCHAR) */
PWCHAR OemToUnicodeTable = NULL; /* size: 256*sizeof(WCHAR) */
#if 0
WCHAR AnsiToUnicodeTable[256];
WCHAR OemToUnicodeTable[256];
PCHAR UnicodeToAnsiTable = NULL; /* size: 65536*sizeof(CHAR) */
PCHAR UnicodeToOemTable =NULL; /* size: 65536*sizeof(CHAR) */
CHAR UnicodeToAnsiTable [65536];
CHAR UnicodeToOemTable [65536];
#endif
PWCHAR UnicodeUpcaseTable = NULL; /* size: 65536*sizeof(WCHAR) */
PWCHAR UnicodeLowercaseTable = NULL; /* size: 65536*sizeof(WCHAR) */
/* FUNCTIONS *****************************************************************/
VOID
RtlpInitNlsTables(VOID)
{
INT i;
PCHAR pc;
PWCHAR pwc;
/* allocate and initialize ansi->unicode table */
AnsiToUnicodeTable = ExAllocatePool(NonPagedPool, 256 * sizeof(WCHAR));
if (AnsiToUnicodeTable == NULL)
{
DbgPrint("Allocation of 'AnsiToUnicodeTable' failed\n");
KeBugCheck(0);
}
pwc = AnsiToUnicodeTable;
for (i = 0; i < 256; i++, pwc++)
*pwc = (WCHAR)i;
/* allocate and initialize oem->unicode table */
OemToUnicodeTable = ExAllocatePool(NonPagedPool, 256 * sizeof(WCHAR));
if (OemToUnicodeTable == NULL)
{
DbgPrint("Allocation of 'OemToUnicodeTable' failed\n");
KeBugCheck(0);
}
pwc = OemToUnicodeTable;
for (i = 0; i < 256; i++, pwc++)
*pwc = (WCHAR)i;
/* allocate and initialize unicode->ansi table */
UnicodeToAnsiTable = ExAllocatePool(NonPagedPool, 65536 * sizeof(CHAR));
if (UnicodeToAnsiTable == NULL)
{
DbgPrint("Allocation of 'UnicodeToAnsiTable' failed\n");
KeBugCheck(0);
}
pc = UnicodeToAnsiTable;
for (i = 0; i < 256; i++, pc++)
*pc = (CHAR)i;
for (; i < 65536; i++, pc++)
*pc = 0;
/* allocate and initialize unicode->oem table */
UnicodeToOemTable = ExAllocatePool(NonPagedPool, 65536 * sizeof(CHAR));
if (UnicodeToOemTable == NULL)
{
DbgPrint("Allocation of 'UnicodeToOemTable' failed\n");
KeBugCheck(0);
}
pc = UnicodeToOemTable;
for (i = 0; i < 256; i++, pc++)
*pc = (CHAR)i;
for (; i < 65536; i++, pc++)
*pc = 0;
/* allocate and initialize unicode upcase table */
UnicodeUpcaseTable = ExAllocatePool(NonPagedPool, 65536 * sizeof(WCHAR));
if (UnicodeUpcaseTable == NULL)
{
DbgPrint("Allocation of 'UnicodeUpcaseTable' failed\n");
KeBugCheck(0);
}
pwc = UnicodeUpcaseTable;
for (i = 0; i < 65536; i++, pwc++)
*pwc = (WCHAR)i;
for (i = 'a'; i < ('z'+ 1); i++)
UnicodeUpcaseTable[i] = (WCHAR)i + (L'A' - L'a');
/* allocate and initialize unicode lowercase table */
UnicodeLowercaseTable = ExAllocatePool(NonPagedPool, 65536 * sizeof(WCHAR));
if (UnicodeLowercaseTable == NULL)
{
DbgPrint("Allocation of 'UnicodeLowercaseTable' failed\n");
KeBugCheck(0);
}
pwc = UnicodeLowercaseTable;
for (i = 0; i < 65536; i++, pwc++)
*pwc = (WCHAR)i;
for (i = 'A'; i < ('Z'+ 1); i++)
UnicodeLowercaseTable[i] = (WCHAR)i - (L'A' - L'a');
/* FIXME: initialize codepage info */
}
NTSTATUS
RtlpInitNlsSections(ULONG Mod1Start,
ULONG Mod1End,
@ -129,35 +222,34 @@ RtlCustomCPToUnicodeN(PRTL_NLS_DATA NlsData,
PCHAR CustomString,
ULONG CustomSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsData->DbcsFlag == FALSE)
{
/* single-byte code page */
if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = CustomSize;
if (NlsData->DbcsFlag == FALSE)
{
/* single-byte code page */
if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = CustomSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
*UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString];
UnicodeString++;
CustomString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
for (i = 0; i < Size; i++)
{
*UnicodeString = NlsData->MultiByteToUnicode[(unsigned int)*CustomString];
UnicodeString++;
CustomString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -165,8 +257,8 @@ VOID STDCALL
RtlGetDefaultCodePage(PUSHORT AnsiCodePage,
PUSHORT OemCodePage)
{
*AnsiCodePage = NlsAnsiCodePage;
*OemCodePage = NlsOemCodePage;
*AnsiCodePage = NlsAnsiCodePage;
*OemCodePage = NlsOemCodePage;
}
@ -177,39 +269,34 @@ RtlMultiByteToUnicodeN(PWCHAR UnicodeString,
PCHAR MbString,
ULONG MbSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsMbCodePageTag == FALSE)
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (MbSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = MbSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (MbSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = MbSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
*UnicodeString = *MbString;
#if 0
*UnicodeString = AnsiToUnicodeTable[*MbString];
#endif
UnicodeString++;
MbString++;
}
*UnicodeString = AnsiToUnicodeTable[(unsigned int)*MbString];
UnicodeString++;
MbString++;
}
else
{
/* multi-byte code page */
/* FIXME */
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -218,152 +305,134 @@ RtlMultiByteToUnicodeSize(PULONG UnicodeSize,
PCHAR MbString,
ULONG MbSize)
{
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*UnicodeSize = MbSize * sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*UnicodeSize = MbSize * sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return(STATUS_SUCCESS);
}
return STATUS_SUCCESS;
NTSTATUS STDCALL
RtlOemToUnicodeN(PWCHAR UnicodeString,
ULONG UnicodeSize,
PULONG ResultSize,
PCHAR OemString,
ULONG OemSize)
{
ULONG Size = 0;
ULONG i;
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (OemSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = OemSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
*UnicodeString = OemToUnicodeTable[(unsigned int)*OemString];
UnicodeString++;
OemString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
}
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
RtlUnicodeToCustomCPN(PRTL_NLS_DATA NlsData,
PCHAR CustomString,
ULONG CustomSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
if (NlsData->DbcsFlag == 0)
{
/* single-byte code page */
if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
Size = CustomSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*CustomString = NlsData->UnicodeToMultiByte[(unsigned int)*UnicodeString];
CustomString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
}
return(STATUS_SUCCESS);
}
NTSTATUS
STDCALL
RtlOemToUnicodeN (
PWCHAR UnicodeString,
ULONG UnicodeSize,
PULONG ResultSize,
PCHAR OemString,
ULONG OemSize)
RtlUnicodeToMultiByteN(PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsMbOemCodePageTag == FALSE)
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (OemSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR);
else
Size = OemSize;
if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++)
{
*UnicodeString = *OemString;
#if 0
*UnicodeString = OemToUnicodeTable[*OemString];
#endif
UnicodeString++;
OemString++;
}
*MbString = UnicodeToAnsiTable[(unsigned int)*UnicodeString];
MbString++;
UnicodeString++;
}
else
{
/* multi-byte code page */
/* FIXME */
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlUnicodeToCustomCPN (
PRTL_NLS_DATA NlsData,
PCHAR CustomString,
ULONG CustomSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
{
ULONG Size = 0;
ULONG i;
if (NlsData->DbcsFlag == 0)
{
/* single-byte code page */
if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
Size = CustomSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*CustomString = NlsData->UnicodeToMultiByte[*UnicodeString];
CustomString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
}
return STATUS_SUCCESS;
}
NTSTATUS
STDCALL
RtlUnicodeToMultiByteN (
PCHAR MbString,
ULONG MbSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*MbString = *UnicodeString;
#if 0
*MbString = UnicodeToAnsiTable[*UnicodeString];
#endif
MbString++;
UnicodeString++;
}
}
else
{
/* multi-byte code page */
/* FIXME */
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -372,106 +441,97 @@ RtlUnicodeToMultiByteSize(PULONG MbSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*MbSize = UnicodeSize / sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
*MbSize = UnicodeSize / sizeof (WCHAR);
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
RtlUnicodeToOemN (
PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
RtlUnicodeToOemN(PCHAR OemString,
ULONG OemSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
if (NlsMbOemCodePageTag == FALSE)
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
*OemString = *UnicodeString;
#if 0
*OemString = UnicodeToOemTable[*UnicodeString];
#endif
OemString++;
UnicodeString++;
}
*OemString = UnicodeToOemTable[(unsigned int)*UnicodeString];
OemString++;
UnicodeString++;
}
else
{
/* multi-byte code page */
/* FIXME */
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
RtlUpcaseUnicodeToCustomCPN (
PRTL_NLS_DATA NlsData,
PCHAR CustomString,
ULONG CustomSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize
)
RtlUpcaseUnicodeToCustomCPN(PRTL_NLS_DATA NlsData,
PCHAR CustomString,
ULONG CustomSize,
PULONG ResultSize,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
WCHAR wc;
if (NlsData->DbcsFlag == 0)
if (NlsData->DbcsFlag == 0)
{
/* single-byte code page */
if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
Size = CustomSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (CustomSize * sizeof(WCHAR)))
Size = CustomSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* FIXME: Upcase!! */
*CustomString = NlsData->UnicodeToMultiByte[*UnicodeString];
CustomString++;
UnicodeString++;
}
wc = UnicodeUpcaseTable[(unsigned int)*UnicodeString];
*CustomString = NlsData->UnicodeToMultiByte[(unsigned int)wc];
CustomString++;
UnicodeString++;
}
else
{
/* multi-byte code page */
/* FIXME */
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -482,40 +542,36 @@ RtlUpcaseUnicodeToMultiByteN(PCHAR MbString,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
WCHAR wc;
if (NlsMbCodePageTag == FALSE)
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (MbSize * sizeof(WCHAR)))
Size = MbSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* FIXME: Upcase !! */
*MbString = *UnicodeString;
#if 0
*MbString = UnicodeToAnsiTable[*UnicodeString];
#endif
MbString++;
UnicodeString++;
}
wc = UnicodeUpcaseTable[(unsigned int)*UnicodeString];
*MbString = UnicodeToAnsiTable[(unsigned int)wc];
MbString++;
UnicodeString++;
}
else
{
/* multi-byte code page */
/* FIXME */
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
@ -526,40 +582,36 @@ RtlUpcaseUnicodeToOemN(PCHAR OemString,
PWCHAR UnicodeString,
ULONG UnicodeSize)
{
ULONG Size = 0;
ULONG i;
ULONG Size = 0;
ULONG i;
UCHAR wc;
if (NlsMbOemCodePageTag == FALSE)
if (NlsMbOemCodePageTag == FALSE)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* single-byte code page */
if (UnicodeSize > (OemSize * sizeof(WCHAR)))
Size = OemSize;
else
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* FIXME: Upcase !! */
*OemString = *UnicodeString;
#if 0
*OemString = UnicodeToOemTable[*UnicodeString];
#endif
OemString++;
UnicodeString++;
}
wc = UnicodeUpcaseTable[(unsigned int)*UnicodeString];
*OemString = UnicodeToOemTable[(unsigned int)wc];
OemString++;
UnicodeString++;
}
else
{
/* multi-byte code page */
/* FIXME */
}
else
{
/* multi-byte code page */
/* FIXME */
}
}
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: unicode.c,v 1.18 2001/03/13 16:25:55 dwelch Exp $
/* $Id: unicode.c,v 1.19 2001/11/02 09:10:49 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -704,8 +704,7 @@ RtlInitAnsiString (
}
VOID
STDCALL
VOID STDCALL
RtlInitString (
IN OUT PSTRING DestinationString,
IN PCSZ SourceString
@ -728,8 +727,7 @@ RtlInitString (
}
VOID
STDCALL
VOID STDCALL
RtlInitUnicodeString (
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
@ -756,8 +754,7 @@ RtlInitUnicodeString (
}
NTSTATUS
STDCALL
NTSTATUS STDCALL
RtlIntegerToChar (
IN ULONG Value,
IN ULONG Base,
@ -804,13 +801,10 @@ RtlIntegerToChar (
}
NTSTATUS
STDCALL
RtlIntegerToUnicodeString (
IN ULONG Value,
IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String
)
NTSTATUS STDCALL
RtlIntegerToUnicodeString(IN ULONG Value,
IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String)
{
ANSI_STRING AnsiString;
CHAR Buffer[33];
@ -836,9 +830,9 @@ RtlIntegerToUnicodeString (
NTSTATUS STDCALL
RtlOemStringToCountedUnicodeString (IN OUT PUNICODE_STRING DestinationString,
IN POEM_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
RtlOemStringToCountedUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN POEM_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -890,26 +884,23 @@ RtlOemStringToCountedUnicodeString (IN OUT PUNICODE_STRING DestinationString,
}
ULONG
STDCALL
RtlOemStringToUnicodeSize (
IN POEM_STRING OemString
)
ULONG STDCALL
RtlOemStringToUnicodeSize(IN POEM_STRING OemString)
{
ULONG Size;
ULONG Size;
RtlMultiByteToUnicodeSize (&Size,
OemString->Buffer,
OemString->Length);
RtlMultiByteToUnicodeSize(&Size,
OemString->Buffer,
OemString->Length);
return Size;
return(Size);
}
NTSTATUS STDCALL
RtlOemStringToUnicodeString (IN OUT PUNICODE_STRING DestinationString,
IN POEM_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
RtlOemStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN POEM_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -960,13 +951,10 @@ RtlOemStringToUnicodeString (IN OUT PUNICODE_STRING DestinationString,
}
BOOLEAN
STDCALL
RtlPrefixString (
PANSI_STRING String1,
PANSI_STRING String2,
BOOLEAN CaseInsensitive
)
BOOLEAN STDCALL
RtlPrefixString(IN PANSI_STRING String1,
IN PANSI_STRING String2,
IN BOOLEAN CaseInsensitive)
{
PCHAR pc1;
PCHAR pc2;
@ -1003,13 +991,10 @@ RtlPrefixString (
}
BOOLEAN
STDCALL
RtlPrefixUnicodeString (
PUNICODE_STRING String1,
PUNICODE_STRING String2,
BOOLEAN CaseInsensitive
)
BOOLEAN STDCALL
RtlPrefixUnicodeString(IN PUNICODE_STRING String1,
IN PUNICODE_STRING String2,
IN BOOLEAN CaseInsensitive)
{
PWCHAR pc1;
PWCHAR pc2;
@ -1047,25 +1032,23 @@ RtlPrefixUnicodeString (
}
ULONG
STDCALL
ULONG STDCALL
RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
{
ULONG Size;
ULONG Size;
RtlUnicodeToMultiByteSize (&Size,
UnicodeString->Buffer,
UnicodeString->Length);
RtlUnicodeToMultiByteSize(&Size,
UnicodeString->Buffer,
UnicodeString->Length);
return Size;
return(Size);
}
NTSTATUS
STDCALL
RtlUnicodeStringToAnsiString (IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
NTSTATUS STDCALL
RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -1113,11 +1096,10 @@ RtlUnicodeStringToAnsiString (IN OUT PANSI_STRING DestinationString,
}
NTSTATUS
STDCALL
RtlUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
NTSTATUS STDCALL
RtlUnicodeStringToCountedOemString(IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -1176,13 +1158,10 @@ RtlUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString,
}
NTSTATUS
STDCALL
RtlUnicodeStringToInteger (
IN PUNICODE_STRING String,
IN ULONG Base,
OUT PULONG Value
)
NTSTATUS STDCALL
RtlUnicodeStringToInteger(IN PUNICODE_STRING String,
IN ULONG Base,
OUT PULONG Value)
{
PWCHAR Str;
ULONG lenmin = 0;
@ -1266,26 +1245,22 @@ RtlUnicodeStringToInteger (
}
ULONG
STDCALL
RtlUnicodeStringToOemSize (
IN PUNICODE_STRING UnicodeString
)
ULONG STDCALL
RtlUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
{
ULONG Size;
ULONG Size;
RtlUnicodeToMultiByteSize (&Size,
UnicodeString->Buffer,
UnicodeString->Length);
return Size;
RtlUnicodeToMultiByteSize(&Size,
UnicodeString->Buffer,
UnicodeString->Length);
return(Size);
}
NTSTATUS STDCALL
RtlUnicodeStringToOemString (IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
RtlUnicodeStringToOemString(IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -1312,18 +1287,18 @@ RtlUnicodeStringToOemString (IN OUT POEM_STRING DestinationString,
}
DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer,
DestinationString->Length);
RtlZeroMemory(DestinationString->Buffer,
DestinationString->Length);
Status = RtlUnicodeToOemN (DestinationString->Buffer,
DestinationString->Length,
NULL,
SourceString->Buffer,
SourceString->Length);
Status = RtlUnicodeToOemN(DestinationString->Buffer,
DestinationString->Length,
NULL,
SourceString->Buffer,
SourceString->Length);
if (!NT_SUCCESS(Status))
{
if (AllocateDestinationString)
ExFreePool (DestinationString->Buffer);
ExFreePool(DestinationString->Buffer);
return Status;
}
@ -1333,28 +1308,25 @@ RtlUnicodeStringToOemString (IN OUT POEM_STRING DestinationString,
}
WCHAR
STDCALL
RtlUpcaseUnicodeChar (
WCHAR Source
)
WCHAR STDCALL
RtlUpcaseUnicodeChar(IN WCHAR Source)
{
if (Source < L'a')
return Source;
if (Source < L'a')
return(Source);
if (Source <= L'z')
return (Source - (L'a' - L'A'));
if (Source <= L'z')
return(Source - (L'a' - L'A'));
/* FIXME: characters above 'z' */
/* FIXME: characters above 'z' */
return Source;
return(Source);
}
NTSTATUS STDCALL
RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
ULONG i;
PWCHAR Src, Dest;
@ -1363,16 +1335,16 @@ RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING DestinationString,
{
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
DestinationString->Buffer =
ExAllocatePoolWithTag (NonPagedPool,
SourceString->Length + sizeof(WCHAR),
TAG_USTR);
ExAllocatePoolWithTag(NonPagedPool,
SourceString->Length + sizeof(WCHAR),
TAG_USTR);
if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY;
return(STATUS_NO_MEMORY);
}
else
{
if (SourceString->Length >= DestinationString->MaximumLength)
return STATUS_BUFFER_TOO_SMALL;
return(STATUS_BUFFER_TOO_SMALL);
}
DestinationString->Length = SourceString->Length;
@ -1380,29 +1352,26 @@ RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING DestinationString,
Dest = DestinationString->Buffer;
for (i=0; i < SourceString->Length / sizeof(WCHAR); i++)
{
*Dest = RtlUpcaseUnicodeChar (*Src);
*Dest = RtlUpcaseUnicodeChar(*Src);
Dest++;
Src++;
}
*Dest = 0;
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
NTSTATUS
STDCALL
RtlUpcaseUnicodeStringToAnsiString (
IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
)
NTSTATUS STDCALL
RtlUpcaseUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
if (NlsMbCodePageTag == TRUE)
Length = RtlUnicodeStringToAnsiSize (SourceString);
Length = RtlUnicodeStringToAnsiSize(SourceString);
else
Length = SourceString->Length / sizeof(WCHAR);
@ -1410,44 +1379,44 @@ RtlUpcaseUnicodeStringToAnsiString (
{
DestinationString->MaximumLength = Length + sizeof(CHAR);
DestinationString->Buffer =
ExAllocatePoolWithTag (NonPagedPool,
DestinationString->MaximumLength,
TAG_ASTR);
ExAllocatePoolWithTag(NonPagedPool,
DestinationString->MaximumLength,
TAG_ASTR);
if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY;
return(STATUS_NO_MEMORY);
}
else
{
if (Length >= DestinationString->MaximumLength)
return STATUS_BUFFER_TOO_SMALL;
return(STATUS_BUFFER_TOO_SMALL);
}
DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer,
DestinationString->Length);
RtlZeroMemory(DestinationString->Buffer,
DestinationString->Length);
Status = RtlUpcaseUnicodeToMultiByteN (DestinationString->Buffer,
DestinationString->Length,
NULL,
SourceString->Buffer,
SourceString->Length);
Status = RtlUpcaseUnicodeToMultiByteN(DestinationString->Buffer,
DestinationString->Length,
NULL,
SourceString->Buffer,
SourceString->Length);
if (!NT_SUCCESS(Status))
{
if (AllocateDestinationString)
ExFreePool (DestinationString->Buffer);
return Status;
ExFreePool(DestinationString->Buffer);
return(Status);
}
DestinationString->Buffer[Length] = 0;
return STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
RtlUpcaseUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
RtlUpcaseUnicodeStringToCountedOemString(IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -1506,13 +1475,10 @@ RtlUpcaseUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString,
}
NTSTATUS
STDCALL
RtlUpcaseUnicodeStringToOemString (
IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
)
NTSTATUS STDCALL
RtlUpcaseUnicodeStringToOemString(IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString)
{
NTSTATUS Status;
ULONG Length;
@ -1558,14 +1524,11 @@ RtlUpcaseUnicodeStringToOemString (
}
CHAR
STDCALL
RtlUpperChar (
IN CHAR Source
)
CHAR STDCALL
RtlUpperChar(IN CHAR Source)
{
WCHAR Unicode;
CHAR Destination;
WCHAR Unicode;
CHAR Destination;
if (NlsMbCodePageTag == FALSE)
{
@ -1592,72 +1555,61 @@ RtlUpperChar (
Destination = Source;
}
return Destination;
return(Destination);
}
VOID
STDCALL
RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
VOID STDCALL
RtlUpperString(PSTRING DestinationString,
PSTRING SourceString)
{
ULONG Length;
ULONG i;
PCHAR Src;
PCHAR Dest;
ULONG Length;
ULONG i;
PCHAR Src;
PCHAR Dest;
Length = min(SourceString->Length, DestinationString->MaximumLength - 1);
Length = min(SourceString->Length,
DestinationString->MaximumLength - 1);
Src = SourceString->Buffer;
Dest = DestinationString->Buffer;
for (i = 0; i < Length; i++)
{
*Dest = RtlUpperChar (*Src);
Src++;
Dest++;
}
*Dest = 0;
Src = SourceString->Buffer;
Dest = DestinationString->Buffer;
for (i = 0; i < Length; i++)
{
*Dest = RtlUpperChar(*Src);
Src++;
Dest++;
}
*Dest = 0;
DestinationString->Length = SourceString->Length;
DestinationString->Length = SourceString->Length;
}
ULONG
STDCALL
RtlxAnsiStringToUnicodeSize (
IN PANSI_STRING AnsiString
)
ULONG STDCALL
RtlxAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
{
return RtlAnsiStringToUnicodeSize (AnsiString);
return(RtlAnsiStringToUnicodeSize(AnsiString));
}
ULONG
STDCALL
RtlxOemStringToUnicodeSize (
IN POEM_STRING OemString
)
ULONG STDCALL
RtlxOemStringToUnicodeSize(IN POEM_STRING OemString)
{
return RtlAnsiStringToUnicodeSize ((PANSI_STRING)OemString);
return(RtlAnsiStringToUnicodeSize((PANSI_STRING)OemString));
}
ULONG
STDCALL
RtlxUnicodeStringToAnsiSize (
IN PUNICODE_STRING UnicodeString
)
ULONG STDCALL
RtlxUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
{
return RtlUnicodeStringToAnsiSize (UnicodeString);
return(RtlUnicodeStringToAnsiSize(UnicodeString));
}
ULONG
STDCALL
RtlxUnicodeStringToOemSize (
IN PUNICODE_STRING UnicodeString
)
ULONG STDCALL
RtlxUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
{
return RtlUnicodeStringToAnsiSize (UnicodeString);
return(RtlUnicodeStringToAnsiSize(UnicodeString));
}
/* EOF */