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 CmImportHive(PCHAR ChunkBase, ULONG ChunkSize);
VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock); VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
VOID RtlpInitNlsTables(VOID);
NTSTATUS RtlpInitNlsSections(ULONG Mod1Start, NTSTATUS RtlpInitNlsSections(ULONG Mod1Start,
ULONG Mod1End, ULONG Mod1End,
ULONG Mod2Start, ULONG Mod2Start,

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 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 * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/main.c * FILE: ntoskrnl/ke/main.c
@ -944,6 +944,9 @@ ExpInitializeExecutive(VOID)
(PADDRESS_RANGE)&KeMemoryMap, (PADDRESS_RANGE)&KeMemoryMap,
KeMemoryMapRangeCount); KeMemoryMapRangeCount);
/* create default nls tables */
RtlpInitNlsTables();
/* /*
* Initialize the kernel debugger * 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -38,18 +38,111 @@ USHORT NlsOemLeadByteInfo = 0;
USHORT NlsAnsiCodePage = 0; USHORT NlsAnsiCodePage = 0;
USHORT NlsOemCodePage = 0; /* not exported */ USHORT NlsOemCodePage = 0; /* not exported */
PWCHAR AnsiToUnicodeTable = NULL; /* size: 256*sizeof(WCHAR) */
PWCHAR OemToUnicodeTable = NULL; /* size: 256*sizeof(WCHAR) */
#if 0 PCHAR UnicodeToAnsiTable = NULL; /* size: 65536*sizeof(CHAR) */
WCHAR AnsiToUnicodeTable[256]; PCHAR UnicodeToOemTable =NULL; /* size: 65536*sizeof(CHAR) */
WCHAR OemToUnicodeTable[256];
CHAR UnicodeToAnsiTable [65536]; PWCHAR UnicodeUpcaseTable = NULL; /* size: 65536*sizeof(WCHAR) */
CHAR UnicodeToOemTable [65536]; PWCHAR UnicodeLowercaseTable = NULL; /* size: 65536*sizeof(WCHAR) */
#endif
/* FUNCTIONS *****************************************************************/ /* 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 NTSTATUS
RtlpInitNlsSections(ULONG Mod1Start, RtlpInitNlsSections(ULONG Mod1Start,
ULONG Mod1End, ULONG Mod1End,
@ -129,35 +222,34 @@ RtlCustomCPToUnicodeN(PRTL_NLS_DATA NlsData,
PCHAR CustomString, PCHAR CustomString,
ULONG CustomSize) ULONG CustomSize)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; ULONG i;
if (NlsData->DbcsFlag == FALSE) if (NlsData->DbcsFlag == FALSE)
{ {
/* single-byte code page */ /* single-byte code page */
if (CustomSize > (UnicodeSize / sizeof(WCHAR))) if (CustomSize > (UnicodeSize / sizeof(WCHAR)))
Size = UnicodeSize / sizeof(WCHAR); Size = UnicodeSize / sizeof(WCHAR);
else else
Size = CustomSize; Size = CustomSize;
if (ResultSize != NULL) if (ResultSize != NULL)
*ResultSize = Size * sizeof(WCHAR); *ResultSize = Size * sizeof(WCHAR);
for (i = 0; i < Size; i++) for (i = 0; i < Size; i++)
{ {
*UnicodeString = NlsData->MultiByteToUnicode[(int)*CustomString]; *UnicodeString = NlsData->MultiByteToUnicode[(unsigned int)*CustomString];
UnicodeString++; UnicodeString++;
CustomString++; CustomString++;
} }
} }
else else
{ {
/* multi-byte code page */ /* multi-byte code page */
/* FIXME */ /* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
@ -165,8 +257,8 @@ VOID STDCALL
RtlGetDefaultCodePage(PUSHORT AnsiCodePage, RtlGetDefaultCodePage(PUSHORT AnsiCodePage,
PUSHORT OemCodePage) PUSHORT OemCodePage)
{ {
*AnsiCodePage = NlsAnsiCodePage; *AnsiCodePage = NlsAnsiCodePage;
*OemCodePage = NlsOemCodePage; *OemCodePage = NlsOemCodePage;
} }
@ -177,39 +269,34 @@ RtlMultiByteToUnicodeN(PWCHAR UnicodeString,
PCHAR MbString, PCHAR MbString,
ULONG MbSize) ULONG MbSize)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; 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 */ *UnicodeString = AnsiToUnicodeTable[(unsigned int)*MbString];
if (MbSize > (UnicodeSize / sizeof(WCHAR))) UnicodeString++;
Size = UnicodeSize / sizeof(WCHAR); MbString++;
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++;
}
} }
else }
{ else
/* multi-byte code page */ {
/* FIXME */ /* multi-byte code page */
/* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
@ -218,152 +305,134 @@ RtlMultiByteToUnicodeSize(PULONG UnicodeSize,
PCHAR MbString, PCHAR MbString,
ULONG MbSize) ULONG MbSize)
{ {
if (NlsMbCodePageTag == FALSE) if (NlsMbCodePageTag == FALSE)
{ {
/* single-byte code page */ /* single-byte code page */
*UnicodeSize = MbSize * sizeof (WCHAR); *UnicodeSize = MbSize * sizeof (WCHAR);
} }
else else
{ {
/* multi-byte code page */ /* multi-byte code page */
/* FIXME */ /* 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 NTSTATUS
STDCALL STDCALL
RtlOemToUnicodeN ( RtlUnicodeToMultiByteN(PCHAR MbString,
PWCHAR UnicodeString, ULONG MbSize,
ULONG UnicodeSize, PULONG ResultSize,
PULONG ResultSize, PWCHAR UnicodeString,
PCHAR OemString, ULONG UnicodeSize)
ULONG OemSize)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; 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 */ *MbString = UnicodeToAnsiTable[(unsigned int)*UnicodeString];
if (OemSize > (UnicodeSize / sizeof(WCHAR))) MbString++;
Size = UnicodeSize / sizeof(WCHAR); UnicodeString++;
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++;
}
} }
else }
{ else
/* multi-byte code page */ {
/* FIXME */ /* multi-byte code page */
/* FIXME */
}
} return(STATUS_SUCCESS);
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;
} }
@ -372,106 +441,97 @@ RtlUnicodeToMultiByteSize(PULONG MbSize,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize) ULONG UnicodeSize)
{ {
if (NlsMbCodePageTag == FALSE) if (NlsMbCodePageTag == FALSE)
{ {
/* single-byte code page */ /* single-byte code page */
*MbSize = UnicodeSize / sizeof (WCHAR); *MbSize = UnicodeSize / sizeof (WCHAR);
} }
else else
{ {
/* multi-byte code page */ /* multi-byte code page */
/* FIXME */ /* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
NTSTATUS STDCALL NTSTATUS STDCALL
RtlUnicodeToOemN ( RtlUnicodeToOemN(PCHAR OemString,
PCHAR OemString, ULONG OemSize,
ULONG OemSize, PULONG ResultSize,
PULONG ResultSize, PWCHAR UnicodeString,
PWCHAR UnicodeString, ULONG UnicodeSize)
ULONG UnicodeSize)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; 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 */ *OemString = UnicodeToOemTable[(unsigned int)*UnicodeString];
if (UnicodeSize > (OemSize * sizeof(WCHAR))) OemString++;
Size = OemSize; UnicodeString++;
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++;
}
} }
else }
{ else
/* multi-byte code page */ {
/* FIXME */ /* multi-byte code page */
/* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
NTSTATUS STDCALL NTSTATUS STDCALL
RtlUpcaseUnicodeToCustomCPN ( RtlUpcaseUnicodeToCustomCPN(PRTL_NLS_DATA NlsData,
PRTL_NLS_DATA NlsData, PCHAR CustomString,
PCHAR CustomString, ULONG CustomSize,
ULONG CustomSize, PULONG ResultSize,
PULONG ResultSize, PWCHAR UnicodeString,
PWCHAR UnicodeString, ULONG UnicodeSize)
ULONG UnicodeSize
)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; 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 */ wc = UnicodeUpcaseTable[(unsigned int)*UnicodeString];
if (UnicodeSize > (CustomSize * sizeof(WCHAR))) *CustomString = NlsData->UnicodeToMultiByte[(unsigned int)wc];
Size = CustomSize; CustomString++;
else UnicodeString++;
Size = UnicodeSize / sizeof(WCHAR);
if (ResultSize != NULL)
*ResultSize = Size;
for (i = 0; i < Size; i++)
{
/* FIXME: Upcase!! */
*CustomString = NlsData->UnicodeToMultiByte[*UnicodeString];
CustomString++;
UnicodeString++;
}
} }
else }
{ else
/* multi-byte code page */ {
/* FIXME */ /* multi-byte code page */
/* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
@ -482,40 +542,36 @@ RtlUpcaseUnicodeToMultiByteN(PCHAR MbString,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize) ULONG UnicodeSize)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; 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 */ wc = UnicodeUpcaseTable[(unsigned int)*UnicodeString];
if (UnicodeSize > (MbSize * sizeof(WCHAR))) *MbString = UnicodeToAnsiTable[(unsigned int)wc];
Size = MbSize; MbString++;
else UnicodeString++;
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++;
}
} }
else }
{ else
/* multi-byte code page */ {
/* FIXME */ /* multi-byte code page */
/* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
@ -526,40 +582,36 @@ RtlUpcaseUnicodeToOemN(PCHAR OemString,
PWCHAR UnicodeString, PWCHAR UnicodeString,
ULONG UnicodeSize) ULONG UnicodeSize)
{ {
ULONG Size = 0; ULONG Size = 0;
ULONG i; 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 */ wc = UnicodeUpcaseTable[(unsigned int)*UnicodeString];
if (UnicodeSize > (OemSize * sizeof(WCHAR))) *OemString = UnicodeToOemTable[(unsigned int)wc];
Size = OemSize; OemString++;
else UnicodeString++;
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++;
}
} }
else }
{ else
/* multi-byte code page */ {
/* FIXME */ /* multi-byte code page */
/* FIXME */
}
} return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
/* EOF */ /* 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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -704,8 +704,7 @@ RtlInitAnsiString (
} }
VOID VOID STDCALL
STDCALL
RtlInitString ( RtlInitString (
IN OUT PSTRING DestinationString, IN OUT PSTRING DestinationString,
IN PCSZ SourceString IN PCSZ SourceString
@ -728,8 +727,7 @@ RtlInitString (
} }
VOID VOID STDCALL
STDCALL
RtlInitUnicodeString ( RtlInitUnicodeString (
IN OUT PUNICODE_STRING DestinationString, IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString IN PCWSTR SourceString
@ -756,8 +754,7 @@ RtlInitUnicodeString (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL
RtlIntegerToChar ( RtlIntegerToChar (
IN ULONG Value, IN ULONG Value,
IN ULONG Base, IN ULONG Base,
@ -804,13 +801,10 @@ RtlIntegerToChar (
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlIntegerToUnicodeString(IN ULONG Value,
RtlIntegerToUnicodeString ( IN ULONG Base, /* optional */
IN ULONG Value, IN OUT PUNICODE_STRING String)
IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String
)
{ {
ANSI_STRING AnsiString; ANSI_STRING AnsiString;
CHAR Buffer[33]; CHAR Buffer[33];
@ -836,9 +830,9 @@ RtlIntegerToUnicodeString (
NTSTATUS STDCALL NTSTATUS STDCALL
RtlOemStringToCountedUnicodeString (IN OUT PUNICODE_STRING DestinationString, RtlOemStringToCountedUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN POEM_STRING SourceString, IN POEM_STRING SourceString,
IN BOOLEAN AllocateDestinationString) IN BOOLEAN AllocateDestinationString)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -890,26 +884,23 @@ RtlOemStringToCountedUnicodeString (IN OUT PUNICODE_STRING DestinationString,
} }
ULONG ULONG STDCALL
STDCALL RtlOemStringToUnicodeSize(IN POEM_STRING OemString)
RtlOemStringToUnicodeSize (
IN POEM_STRING OemString
)
{ {
ULONG Size; ULONG Size;
RtlMultiByteToUnicodeSize (&Size, RtlMultiByteToUnicodeSize(&Size,
OemString->Buffer, OemString->Buffer,
OemString->Length); OemString->Length);
return Size; return(Size);
} }
NTSTATUS STDCALL NTSTATUS STDCALL
RtlOemStringToUnicodeString (IN OUT PUNICODE_STRING DestinationString, RtlOemStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN POEM_STRING SourceString, IN POEM_STRING SourceString,
IN BOOLEAN AllocateDestinationString) IN BOOLEAN AllocateDestinationString)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -960,13 +951,10 @@ RtlOemStringToUnicodeString (IN OUT PUNICODE_STRING DestinationString,
} }
BOOLEAN BOOLEAN STDCALL
STDCALL RtlPrefixString(IN PANSI_STRING String1,
RtlPrefixString ( IN PANSI_STRING String2,
PANSI_STRING String1, IN BOOLEAN CaseInsensitive)
PANSI_STRING String2,
BOOLEAN CaseInsensitive
)
{ {
PCHAR pc1; PCHAR pc1;
PCHAR pc2; PCHAR pc2;
@ -1003,13 +991,10 @@ RtlPrefixString (
} }
BOOLEAN BOOLEAN STDCALL
STDCALL RtlPrefixUnicodeString(IN PUNICODE_STRING String1,
RtlPrefixUnicodeString ( IN PUNICODE_STRING String2,
PUNICODE_STRING String1, IN BOOLEAN CaseInsensitive)
PUNICODE_STRING String2,
BOOLEAN CaseInsensitive
)
{ {
PWCHAR pc1; PWCHAR pc1;
PWCHAR pc2; PWCHAR pc2;
@ -1047,25 +1032,23 @@ RtlPrefixUnicodeString (
} }
ULONG ULONG STDCALL
STDCALL
RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString) RtlUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
{ {
ULONG Size; ULONG Size;
RtlUnicodeToMultiByteSize (&Size, RtlUnicodeToMultiByteSize(&Size,
UnicodeString->Buffer, UnicodeString->Buffer,
UnicodeString->Length); UnicodeString->Length);
return Size; return(Size);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
RtlUnicodeStringToAnsiString (IN OUT PANSI_STRING DestinationString, IN PUNICODE_STRING SourceString,
IN PUNICODE_STRING SourceString, IN BOOLEAN AllocateDestinationString)
IN BOOLEAN AllocateDestinationString)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -1113,11 +1096,10 @@ RtlUnicodeStringToAnsiString (IN OUT PANSI_STRING DestinationString,
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUnicodeStringToCountedOemString(IN OUT POEM_STRING DestinationString,
RtlUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString, IN PUNICODE_STRING SourceString,
IN PUNICODE_STRING SourceString, IN BOOLEAN AllocateDestinationString)
IN BOOLEAN AllocateDestinationString)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -1176,13 +1158,10 @@ RtlUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString,
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUnicodeStringToInteger(IN PUNICODE_STRING String,
RtlUnicodeStringToInteger ( IN ULONG Base,
IN PUNICODE_STRING String, OUT PULONG Value)
IN ULONG Base,
OUT PULONG Value
)
{ {
PWCHAR Str; PWCHAR Str;
ULONG lenmin = 0; ULONG lenmin = 0;
@ -1266,26 +1245,22 @@ RtlUnicodeStringToInteger (
} }
ULONG ULONG STDCALL
STDCALL RtlUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
RtlUnicodeStringToOemSize (
IN PUNICODE_STRING UnicodeString
)
{ {
ULONG Size; ULONG Size;
RtlUnicodeToMultiByteSize (&Size, RtlUnicodeToMultiByteSize(&Size,
UnicodeString->Buffer, UnicodeString->Buffer,
UnicodeString->Length); UnicodeString->Length);
return(Size);
return Size;
} }
NTSTATUS STDCALL NTSTATUS STDCALL
RtlUnicodeStringToOemString (IN OUT POEM_STRING DestinationString, RtlUnicodeStringToOemString(IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString) IN BOOLEAN AllocateDestinationString)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -1312,18 +1287,18 @@ RtlUnicodeStringToOemString (IN OUT POEM_STRING DestinationString,
} }
DestinationString->Length = Length; DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer, RtlZeroMemory(DestinationString->Buffer,
DestinationString->Length); DestinationString->Length);
Status = RtlUnicodeToOemN (DestinationString->Buffer, Status = RtlUnicodeToOemN(DestinationString->Buffer,
DestinationString->Length, DestinationString->Length,
NULL, NULL,
SourceString->Buffer, SourceString->Buffer,
SourceString->Length); SourceString->Length);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
if (AllocateDestinationString) if (AllocateDestinationString)
ExFreePool (DestinationString->Buffer); ExFreePool(DestinationString->Buffer);
return Status; return Status;
} }
@ -1333,28 +1308,25 @@ RtlUnicodeStringToOemString (IN OUT POEM_STRING DestinationString,
} }
WCHAR WCHAR STDCALL
STDCALL RtlUpcaseUnicodeChar(IN WCHAR Source)
RtlUpcaseUnicodeChar (
WCHAR Source
)
{ {
if (Source < L'a') if (Source < L'a')
return Source; return(Source);
if (Source <= L'z') if (Source <= L'z')
return (Source - (L'a' - L'A')); return(Source - (L'a' - L'A'));
/* FIXME: characters above 'z' */ /* FIXME: characters above 'z' */
return Source; return(Source);
} }
NTSTATUS STDCALL NTSTATUS STDCALL
RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING DestinationString, RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString) IN BOOLEAN AllocateDestinationString)
{ {
ULONG i; ULONG i;
PWCHAR Src, Dest; PWCHAR Src, Dest;
@ -1363,16 +1335,16 @@ RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING DestinationString,
{ {
DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR); DestinationString->MaximumLength = SourceString->Length + sizeof(WCHAR);
DestinationString->Buffer = DestinationString->Buffer =
ExAllocatePoolWithTag (NonPagedPool, ExAllocatePoolWithTag(NonPagedPool,
SourceString->Length + sizeof(WCHAR), SourceString->Length + sizeof(WCHAR),
TAG_USTR); TAG_USTR);
if (DestinationString->Buffer == NULL) if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY; return(STATUS_NO_MEMORY);
} }
else else
{ {
if (SourceString->Length >= DestinationString->MaximumLength) if (SourceString->Length >= DestinationString->MaximumLength)
return STATUS_BUFFER_TOO_SMALL; return(STATUS_BUFFER_TOO_SMALL);
} }
DestinationString->Length = SourceString->Length; DestinationString->Length = SourceString->Length;
@ -1380,29 +1352,26 @@ RtlUpcaseUnicodeString (IN OUT PUNICODE_STRING DestinationString,
Dest = DestinationString->Buffer; Dest = DestinationString->Buffer;
for (i=0; i < SourceString->Length / sizeof(WCHAR); i++) for (i=0; i < SourceString->Length / sizeof(WCHAR); i++)
{ {
*Dest = RtlUpcaseUnicodeChar (*Src); *Dest = RtlUpcaseUnicodeChar(*Src);
Dest++; Dest++;
Src++; Src++;
} }
*Dest = 0; *Dest = 0;
return STATUS_SUCCESS; return(STATUS_SUCCESS);
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUpcaseUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
RtlUpcaseUnicodeStringToAnsiString ( IN PUNICODE_STRING SourceString,
IN OUT PANSI_STRING DestinationString, IN BOOLEAN AllocateDestinationString)
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
if (NlsMbCodePageTag == TRUE) if (NlsMbCodePageTag == TRUE)
Length = RtlUnicodeStringToAnsiSize (SourceString); Length = RtlUnicodeStringToAnsiSize(SourceString);
else else
Length = SourceString->Length / sizeof(WCHAR); Length = SourceString->Length / sizeof(WCHAR);
@ -1410,44 +1379,44 @@ RtlUpcaseUnicodeStringToAnsiString (
{ {
DestinationString->MaximumLength = Length + sizeof(CHAR); DestinationString->MaximumLength = Length + sizeof(CHAR);
DestinationString->Buffer = DestinationString->Buffer =
ExAllocatePoolWithTag (NonPagedPool, ExAllocatePoolWithTag(NonPagedPool,
DestinationString->MaximumLength, DestinationString->MaximumLength,
TAG_ASTR); TAG_ASTR);
if (DestinationString->Buffer == NULL) if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY; return(STATUS_NO_MEMORY);
} }
else else
{ {
if (Length >= DestinationString->MaximumLength) if (Length >= DestinationString->MaximumLength)
return STATUS_BUFFER_TOO_SMALL; return(STATUS_BUFFER_TOO_SMALL);
} }
DestinationString->Length = Length; DestinationString->Length = Length;
RtlZeroMemory (DestinationString->Buffer, RtlZeroMemory(DestinationString->Buffer,
DestinationString->Length); DestinationString->Length);
Status = RtlUpcaseUnicodeToMultiByteN (DestinationString->Buffer, Status = RtlUpcaseUnicodeToMultiByteN(DestinationString->Buffer,
DestinationString->Length, DestinationString->Length,
NULL, NULL,
SourceString->Buffer, SourceString->Buffer,
SourceString->Length); SourceString->Length);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
if (AllocateDestinationString) if (AllocateDestinationString)
ExFreePool (DestinationString->Buffer); ExFreePool(DestinationString->Buffer);
return Status; return(Status);
} }
DestinationString->Buffer[Length] = 0; DestinationString->Buffer[Length] = 0;
return STATUS_SUCCESS; return(STATUS_SUCCESS);
} }
NTSTATUS STDCALL NTSTATUS STDCALL
RtlUpcaseUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString, RtlUpcaseUnicodeStringToCountedOemString(IN OUT POEM_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString) IN BOOLEAN AllocateDestinationString)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -1506,13 +1475,10 @@ RtlUpcaseUnicodeStringToCountedOemString (IN OUT POEM_STRING DestinationString,
} }
NTSTATUS NTSTATUS STDCALL
STDCALL RtlUpcaseUnicodeStringToOemString(IN OUT POEM_STRING DestinationString,
RtlUpcaseUnicodeStringToOemString ( IN PUNICODE_STRING SourceString,
IN OUT POEM_STRING DestinationString, IN BOOLEAN AllocateDestinationString)
IN PUNICODE_STRING SourceString,
IN BOOLEAN AllocateDestinationString
)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; ULONG Length;
@ -1558,14 +1524,11 @@ RtlUpcaseUnicodeStringToOemString (
} }
CHAR CHAR STDCALL
STDCALL RtlUpperChar(IN CHAR Source)
RtlUpperChar (
IN CHAR Source
)
{ {
WCHAR Unicode; WCHAR Unicode;
CHAR Destination; CHAR Destination;
if (NlsMbCodePageTag == FALSE) if (NlsMbCodePageTag == FALSE)
{ {
@ -1592,72 +1555,61 @@ RtlUpperChar (
Destination = Source; Destination = Source;
} }
return Destination; return(Destination);
} }
VOID VOID STDCALL
STDCALL RtlUpperString(PSTRING DestinationString,
RtlUpperString(PSTRING DestinationString, PSTRING SourceString) PSTRING SourceString)
{ {
ULONG Length; ULONG Length;
ULONG i; ULONG i;
PCHAR Src; PCHAR Src;
PCHAR Dest; PCHAR Dest;
Length = min(SourceString->Length, DestinationString->MaximumLength - 1); Length = min(SourceString->Length,
DestinationString->MaximumLength - 1);
Src = SourceString->Buffer; Src = SourceString->Buffer;
Dest = DestinationString->Buffer; Dest = DestinationString->Buffer;
for (i = 0; i < Length; i++) for (i = 0; i < Length; i++)
{ {
*Dest = RtlUpperChar (*Src); *Dest = RtlUpperChar(*Src);
Src++; Src++;
Dest++; Dest++;
} }
*Dest = 0; *Dest = 0;
DestinationString->Length = SourceString->Length; DestinationString->Length = SourceString->Length;
} }
ULONG ULONG STDCALL
STDCALL RtlxAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
RtlxAnsiStringToUnicodeSize (
IN PANSI_STRING AnsiString
)
{ {
return RtlAnsiStringToUnicodeSize (AnsiString); return(RtlAnsiStringToUnicodeSize(AnsiString));
} }
ULONG ULONG STDCALL
STDCALL RtlxOemStringToUnicodeSize(IN POEM_STRING OemString)
RtlxOemStringToUnicodeSize (
IN POEM_STRING OemString
)
{ {
return RtlAnsiStringToUnicodeSize ((PANSI_STRING)OemString); return(RtlAnsiStringToUnicodeSize((PANSI_STRING)OemString));
} }
ULONG ULONG STDCALL
STDCALL RtlxUnicodeStringToAnsiSize(IN PUNICODE_STRING UnicodeString)
RtlxUnicodeStringToAnsiSize (
IN PUNICODE_STRING UnicodeString
)
{ {
return RtlUnicodeStringToAnsiSize (UnicodeString); return(RtlUnicodeStringToAnsiSize(UnicodeString));
} }
ULONG ULONG STDCALL
STDCALL RtlxUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
RtlxUnicodeStringToOemSize (
IN PUNICODE_STRING UnicodeString
)
{ {
return RtlUnicodeStringToAnsiSize (UnicodeString); return(RtlUnicodeStringToAnsiSize(UnicodeString));
} }
/* EOF */ /* EOF */