- Removed the Rtlp* string functions from the shared rtl library since they don't make sense in umode

- Moved RtlpCreateUnicodeString to ntoskrnl for now, it however is depreciated but still used in various places
- Added RtlpAllocateMemory and RtlpFreeMemory for rtl memory allocations (from paged pool in ntoskrnl and from the process heap in ntdll) that replace the ExAllocatePool* and ExFreePool implementations in ntdll

svn path=/trunk/; revision=16673
This commit is contained in:
Thomas Bluemel 2005-07-20 23:35:59 +00:00
parent 7b6225c3b5
commit f479dd02aa
8 changed files with 248 additions and 524 deletions

View file

@ -23,48 +23,24 @@ RtlpGetMode()
PVOID PVOID
STDCALL RtlpAllocateMemory(UINT Bytes,
ExAllocatePool( ULONG Tag)
IN POOL_TYPE PoolType,
IN SIZE_T Bytes
)
{ {
return RtlAllocateHeap ( UNREFERENCED_PARAMETER(Tag);
RtlGetProcessHeap (),
return RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
Bytes); Bytes);
} }
PVOID
STDCALL
ExAllocatePoolWithTag(
IN POOL_TYPE PoolType,
IN SIZE_T Bytes,
IN ULONG Tag
)
{
return RtlAllocateHeap (
RtlGetProcessHeap (),
0,
Bytes);
}
VOID VOID
STDCALL RtlpFreeMemory(PVOID Mem,
ExFreePool(IN PVOID Mem) ULONG Tag)
{ {
RtlFreeHeap ( UNREFERENCED_PARAMETER(Tag);
RtlGetProcessHeap (),
0,
Mem);
}
VOID RtlFreeHeap(RtlGetProcessHeap(),
STDCALL
ExFreePoolWithTag(IN PVOID Mem, IN ULONG Tag)
{
RtlFreeHeap (
RtlGetProcessHeap (),
0, 0,
Mem); Mem);
} }

View file

@ -1,31 +0,0 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS System Libraries
* FILE: lib/rtl/libsupp.h
* PURPOSE: Run-Time Library Kernel Support Header
* PROGRAMMER: Alex Ionescu
*/
/* INCLUDES ******************************************************************/
#define TAG_RTL TAG('R','t', 'l', ' ')
PVOID
STDCALL
ExAllocatePoolWithTag(
IN POOL_TYPE PoolType,
IN SIZE_T NumberOfBytes,
IN ULONG Tag
);
VOID
STDCALL
ExFreePoolWithTag(
IN PVOID Pool,
IN ULONG Tag
);
#define ExAllocatePool(p,n) ExAllocatePoolWithTag(p,n, TAG_RTL)
#define ExFreePool(P) ExFreePoolWithTag(P, TAG_RTL)
/* EOF */

View file

@ -23,6 +23,8 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#define TAG_RTLREGISTRY TAG('R', 't', 'l', 'R')
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
@ -305,11 +307,10 @@ RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath)
KeyPath->Length = 0; KeyPath->Length = 0;
KeyPath->MaximumLength = Length; KeyPath->MaximumLength = Length;
KeyPath->Buffer = ExAllocatePool (PagedPool, KeyPath->Buffer = RtlpAllocateStringMemory(KeyPath->MaximumLength, TAG_USTR);
KeyPath->MaximumLength);
if (KeyPath->Buffer == NULL) if (KeyPath->Buffer == NULL)
{ {
DPRINT1 ("ExAllocatePool() failed\n"); DPRINT1 ("RtlpAllocateMemory() failed\n");
RtlFreeUnicodeString (&SidString); RtlFreeUnicodeString (&SidString);
return STATUS_NO_TOKEN; return STATUS_NO_TOKEN;
} }
@ -450,7 +451,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
QueryEntry->Name); QueryEntry->Name);
BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096; BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096;
ValueInfo = ExAllocatePool(PagedPool, BufferSize); ValueInfo = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
if (ValueInfo == NULL) if (ValueInfo == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -467,7 +468,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
{ {
if (QueryEntry->Flags & RTL_QUERY_REGISTRY_REQUIRED) if (QueryEntry->Flags & RTL_QUERY_REGISTRY_REQUIRED)
{ {
ExFreePool(ValueInfo); RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
Status = STATUS_OBJECT_NAME_NOT_FOUND; Status = STATUS_OBJECT_NAME_NOT_FOUND;
break; break;
} }
@ -483,7 +484,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
{ {
ValueString->Length = SourceString->Length; ValueString->Length = SourceString->Length;
ValueString->MaximumLength = SourceString->MaximumLength; ValueString->MaximumLength = SourceString->MaximumLength;
ValueString->Buffer = ExAllocatePool(PagedPool, BufferSize); ValueString->Buffer = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
if (!ValueString->Buffer) if (!ValueString->Buffer)
break; break;
ValueString->Buffer[0] = 0; ValueString->Buffer[0] = 0;
@ -521,7 +522,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
if (ValueString->Buffer == NULL) if (ValueString->Buffer == NULL)
{ {
ValueString->MaximumLength = ValueInfo->DataLength; ValueString->MaximumLength = ValueInfo->DataLength;
ValueString->Buffer = ExAllocatePool(PagedPool, ValueString->MaximumLength); ValueString->Buffer = RtlpAllocateMemory(ValueString->MaximumLength, TAG_RTLREGISTRY);
if (ValueString->Buffer == NULL) if (ValueString->Buffer == NULL)
{ {
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
@ -544,7 +545,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
ValueString = (PUNICODE_STRING)QueryEntry->EntryContext; ValueString = (PUNICODE_STRING)QueryEntry->EntryContext;
ExpandBuffer = ExAllocatePool(PagedPool, ValueInfo->DataLength * 2); ExpandBuffer = RtlpAllocateMemory(ValueInfo->DataLength * 2, TAG_RTLREGISTRY);
if (ExpandBuffer == NULL) if (ExpandBuffer == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -567,7 +568,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
{ {
ValueString->MaximumLength = EnvExpandedValue.Length + sizeof(WCHAR); ValueString->MaximumLength = EnvExpandedValue.Length + sizeof(WCHAR);
ValueString->Length = EnvExpandedValue.Length; ValueString->Length = EnvExpandedValue.Length;
ValueString->Buffer = ExAllocatePool(PagedPool, ValueString->MaximumLength); ValueString->Buffer = RtlpAllocateMemory(ValueString->MaximumLength, TAG_RTLREGISTRY);
if (ValueString->Buffer == NULL) if (ValueString->Buffer == NULL)
{ {
Status = STATUS_INSUFFICIENT_RESOURCES; Status = STATUS_INSUFFICIENT_RESOURCES;
@ -585,7 +586,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
ValueString->Length); ValueString->Length);
((PWSTR)ValueString->Buffer)[ValueString->Length / sizeof(WCHAR)] = 0; ((PWSTR)ValueString->Buffer)[ValueString->Length / sizeof(WCHAR)] = 0;
ExFreePool(ExpandBuffer); RtlpFreeMemory(ExpandBuffer, TAG_RTLREGISTRY);
} }
else else
{ {
@ -601,7 +602,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
} }
ExFreePool(ValueInfo); RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
} }
else else
{ {
@ -612,7 +613,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
QueryEntry->Name); QueryEntry->Name);
BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096; BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096;
ValueInfo = ExAllocatePool(PagedPool, BufferSize); ValueInfo = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
if (ValueInfo == NULL) if (ValueInfo == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -661,7 +662,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
{ {
DPRINT("Expand REG_EXPAND_SZ type\n"); DPRINT("Expand REG_EXPAND_SZ type\n");
ExpandBuffer = ExAllocatePool(PagedPool, ValueInfo->DataLength * 2); ExpandBuffer = RtlpAllocateMemory(ValueInfo->DataLength * 2, TAG_RTLREGISTRY);
if (ExpandBuffer == NULL) if (ExpandBuffer == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -688,7 +689,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
Context, Context,
QueryEntry->EntryContext); QueryEntry->EntryContext);
ExFreePool(ExpandBuffer); RtlpFreeMemory(ExpandBuffer, TAG_RTLREGISTRY);
} }
else else
{ {
@ -706,7 +707,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
} }
ExFreePool(ValueInfo); RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
break; break;
} }
@ -727,14 +728,14 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
DPRINT("Enumerate values\n"); DPRINT("Enumerate values\n");
BufferSize = sizeof(KEY_VALUE_FULL_INFORMATION) + 4096; BufferSize = sizeof(KEY_VALUE_FULL_INFORMATION) + 4096;
FullValueInfo = ExAllocatePool(PagedPool, BufferSize); FullValueInfo = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
if (FullValueInfo == NULL) if (FullValueInfo == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
break; break;
} }
ValueNameSize = 256 * sizeof(WCHAR); ValueNameSize = 256 * sizeof(WCHAR);
ValueName = ExAllocatePool(PagedPool, ValueNameSize); ValueName = RtlpAllocateMemory(ValueNameSize, TAG_RTLREGISTRY);
if (ValueName == NULL) if (ValueName == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -767,9 +768,9 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
if (FullValueInfo->NameLength > ValueNameSize - sizeof(WCHAR)) if (FullValueInfo->NameLength > ValueNameSize - sizeof(WCHAR))
{ {
/* Should not happen, because the name length is limited to 255 characters */ /* Should not happen, because the name length is limited to 255 characters */
ExFreePool(ValueName); RtlpFreeMemory(ValueName, TAG_RTLREGISTRY);
ValueNameSize = FullValueInfo->NameLength + sizeof(WCHAR); ValueNameSize = FullValueInfo->NameLength + sizeof(WCHAR);
ValueName = ExAllocatePool(PagedPool, ValueNameSize); ValueName = RtlpAllocateMemory(ValueNameSize, TAG_RTLREGISTRY);
if (ValueName == NULL) if (ValueName == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -808,7 +809,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
DPRINT("Expand REG_EXPAND_SZ type\n"); DPRINT("Expand REG_EXPAND_SZ type\n");
StringPtr = (PWSTR)((ULONG_PTR)FullValueInfo + FullValueInfo->DataOffset); StringPtr = (PWSTR)((ULONG_PTR)FullValueInfo + FullValueInfo->DataOffset);
ExpandBuffer = ExAllocatePool(PagedPool, FullValueInfo->DataLength * 2); ExpandBuffer = RtlpAllocateMemory(FullValueInfo->DataLength * 2, TAG_RTLREGISTRY);
if (ExpandBuffer == NULL) if (ExpandBuffer == NULL)
{ {
Status = STATUS_NO_MEMORY; Status = STATUS_NO_MEMORY;
@ -835,7 +836,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
Context, Context,
QueryEntry->EntryContext); QueryEntry->EntryContext);
ExFreePool(ExpandBuffer); RtlpFreeMemory(ExpandBuffer, TAG_RTLREGISTRY);
} }
else else
{ {
@ -855,8 +856,8 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
Index++; Index++;
} }
ExFreePool(FullValueInfo); RtlpFreeMemory(FullValueInfo, TAG_RTLREGISTRY);
ExFreePool(ValueName); RtlpFreeMemory(ValueName, TAG_RTLREGISTRY);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
break; break;
} }
@ -963,7 +964,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
{ {
BufferLength = SubKeyName->MaximumLength + BufferLength = SubKeyName->MaximumLength +
sizeof(KEY_BASIC_INFORMATION); sizeof(KEY_BASIC_INFORMATION);
KeyInfo = ExAllocatePool(PagedPool, BufferLength); KeyInfo = RtlpAllocateMemory(BufferLength, TAG_RTLREGISTRY);
if (KeyInfo == NULL) if (KeyInfo == NULL)
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
} }
@ -992,7 +993,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
if (KeyInfo != NULL) if (KeyInfo != NULL)
{ {
ExFreePool(KeyInfo); RtlpFreeMemory(KeyInfo, TAG_RTLREGISTRY);
} }
return(Status); return(Status);
@ -1050,7 +1051,7 @@ RtlpNtQueryValueKey(IN HANDLE KeyHandle,
if (DataLength != NULL) if (DataLength != NULL)
BufferLength = *DataLength; BufferLength = *DataLength;
ValueInfo = ExAllocatePool(PagedPool, BufferLength); ValueInfo = RtlpAllocateMemory(BufferLength, TAG_RTLREGISTRY);
if (ValueInfo == NULL) if (ValueInfo == NULL)
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
@ -1076,7 +1077,7 @@ RtlpNtQueryValueKey(IN HANDLE KeyHandle,
} }
} }
ExFreePool(ValueInfo); RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
return(Status); return(Status);
} }

View file

@ -16,9 +16,6 @@
/* Helper Header */ /* Helper Header */
#include <reactos/helper.h> #include <reactos/helper.h>
/* LIBSUPP Header */
#include "libsupp.h"
/* FIXME: Move this somewhere else, maybe */ /* FIXME: Move this somewhere else, maybe */
#ifdef DBG #ifdef DBG
extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line); extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
@ -27,4 +24,14 @@ extern VOID FASTCALL CHECK_PAGED_CODE_RTL(char *file, int line);
#define PAGED_CODE_RTL() #define PAGED_CODE_RTL()
#endif #endif
extern PVOID RtlpAllocateMemory(UINT Bytes, ULONG Tag);
extern VOID RtlpFreeMemory(PVOID Mem, ULONG Tag);
#define RtlpAllocateStringMemory RtlpAllocateMemory
#define RtlpFreeStringMemory RtlpFreeMemory
#define TAG_USTR TAG('U', 'S', 'T', 'R')
#define TAG_ASTR TAG('A', 'S', 'T', 'R')
#define TAG_OSTR TAG('O', 'S', 'T', 'R')
/* EOF */ /* EOF */

View file

@ -16,6 +16,8 @@
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#define TAG_SID TAG('p', 'S', 'i', 'd')
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
BOOLEAN STDCALL BOOLEAN STDCALL
@ -244,8 +246,8 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
if (Sid == NULL) if (Sid == NULL)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
pSid = (PSID)ExAllocatePool(PagedPool, pSid = RtlpAllocateMemory(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG),
sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG)); TAG_SID);
if (pSid == NULL) if (pSid == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -294,7 +296,7 @@ RtlFreeSid(IN PSID Sid)
{ {
PAGED_CODE_RTL(); PAGED_CODE_RTL();
ExFreePool(Sid); RtlpFreeMemory(Sid, TAG_SID);
return NULL; return NULL;
} }
@ -370,7 +372,8 @@ RtlConvertSidToUnicodeString(PUNICODE_STRING String,
Length = (wcs - Buffer) * sizeof(WCHAR); Length = (wcs - Buffer) * sizeof(WCHAR);
if (AllocateBuffer) if (AllocateBuffer)
{ {
String->Buffer = ExAllocatePool(PagedPool,Length + sizeof(WCHAR)); String->Buffer = RtlpAllocateMemory(Length + sizeof(WCHAR),
TAG_SID);
if (String->Buffer == NULL) if (String->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
String->MaximumLength = Length + sizeof(WCHAR); String->MaximumLength = Length + sizeof(WCHAR);

View file

@ -27,11 +27,6 @@
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
#define TAG_USTR TAG('U', 'S', 'T', 'R')
#define TAG_ASTR TAG('A', 'S', 'T', 'R')
#define TAG_OSTR TAG('O', 'S', 'T', 'R')
extern BOOLEAN NlsMbCodePageTag; extern BOOLEAN NlsMbCodePageTag;
extern BOOLEAN NlsMbOemCodePageTag; extern BOOLEAN NlsMbOemCodePageTag;
@ -386,14 +381,14 @@ VOID
STDCALL STDCALL
RtlFreeAnsiString(IN PANSI_STRING AnsiString) RtlFreeAnsiString(IN PANSI_STRING AnsiString)
{ {
if (AnsiString->Buffer == NULL) if (AnsiString->Buffer != NULL)
return; {
RtlpFreeStringMemory(AnsiString->Buffer, TAG_ASTR);
ExFreePoolWithTag(AnsiString->Buffer, TAG_ASTR);
AnsiString->Buffer = NULL; AnsiString->Buffer = NULL;
AnsiString->Length = 0; AnsiString->Length = 0;
AnsiString->MaximumLength = 0; AnsiString->MaximumLength = 0;
}
} }
@ -404,14 +399,14 @@ VOID
STDCALL STDCALL
RtlFreeOemString(IN POEM_STRING OemString) RtlFreeOemString(IN POEM_STRING OemString)
{ {
if (OemString->Buffer == NULL) if (OemString->Buffer != NULL)
return; {
RtlpFreeStringMemory(OemString->Buffer, TAG_OSTR);
ExFreePoolWithTag(OemString->Buffer, TAG_OSTR);
OemString->Buffer = NULL; OemString->Buffer = NULL;
OemString->Length = 0; OemString->Length = 0;
OemString->MaximumLength = 0; OemString->MaximumLength = 0;
}
} }
@ -422,14 +417,14 @@ VOID
STDCALL STDCALL
RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString) RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
{ {
if (UnicodeString->Buffer == NULL) if (UnicodeString->Buffer != NULL)
return; {
RtlpFreeStringMemory(UnicodeString->Buffer, TAG_USTR);
ExFreePoolWithTag(UnicodeString->Buffer, TAG_USTR);
UnicodeString->Buffer = NULL; UnicodeString->Buffer = NULL;
UnicodeString->Length = 0; UnicodeString->Length = 0;
UnicodeString->MaximumLength = 0; UnicodeString->MaximumLength = 0;
}
} }
/* /*
@ -696,9 +691,8 @@ RtlIntegerToUnicodeString(
Base, Base,
sizeof(Buffer), sizeof(Buffer),
Buffer); Buffer);
if (!NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
return Status; {
AnsiString.Buffer = Buffer; AnsiString.Buffer = Buffer;
AnsiString.Length = strlen (Buffer); AnsiString.Length = strlen (Buffer);
AnsiString.MaximumLength = sizeof(Buffer); AnsiString.MaximumLength = sizeof(Buffer);
@ -706,6 +700,7 @@ RtlIntegerToUnicodeString(
Status = RtlAnsiStringToUnicodeString (String, Status = RtlAnsiStringToUnicodeString (String,
&AnsiString, &AnsiString,
FALSE); FALSE);
}
return Status; return Status;
} }
@ -733,9 +728,8 @@ RtlInt64ToUnicodeString (
Base, Base,
sizeof(Buffer), sizeof(Buffer),
Buffer); Buffer);
if (!NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
return Status; {
AnsiString.Buffer = Buffer; AnsiString.Buffer = Buffer;
AnsiString.Length = strlen (Buffer); AnsiString.Length = strlen (Buffer);
AnsiString.MaximumLength = sizeof(Buffer); AnsiString.MaximumLength = sizeof(Buffer);
@ -743,6 +737,7 @@ RtlInt64ToUnicodeString (
Status = RtlAnsiStringToUnicodeString (String, Status = RtlAnsiStringToUnicodeString (String,
&AnsiString, &AnsiString,
FALSE); FALSE);
}
return Status; return Status;
} }
@ -972,22 +967,22 @@ RtlUnicodeStringToOemSize(
} }
/* /*
* private * @implemented
* *
* NOTES * NOTES
* This function always writes a terminating '\0'. * This function always writes a terminating '\0'.
* It performs a partial copy if ansi is too small. * It performs a partial copy if ansi is too small.
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpUnicodeStringToAnsiString( RtlUnicodeStringToAnsiString(
IN OUT PANSI_STRING AnsiDest, IN OUT PANSI_STRING AnsiDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
ULONG Length; //including nullterm ULONG Length; /* including nullterm */
if (NlsMbCodePageTag == TRUE) if (NlsMbCodePageTag == TRUE)
{ {
@ -1000,7 +995,7 @@ RtlpUnicodeStringToAnsiString(
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
AnsiDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_ASTR); AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
if (AnsiDest->Buffer == NULL) if (AnsiDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -1012,7 +1007,7 @@ RtlpUnicodeStringToAnsiString(
} }
else if (Length > AnsiDest->MaximumLength) else if (Length > AnsiDest->MaximumLength)
{ {
//make room for nullterm /* make room for nullterm */
AnsiDest->Length = AnsiDest->MaximumLength - sizeof(CHAR); AnsiDest->Length = AnsiDest->MaximumLength - sizeof(CHAR);
} }
@ -1024,7 +1019,7 @@ RtlpUnicodeStringToAnsiString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(AnsiDest->Buffer, TAG_ASTR); RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
return Status; return Status;
} }
@ -1032,44 +1027,23 @@ RtlpUnicodeStringToAnsiString(
return Status; return Status;
} }
/* /*
* @implemented * @implemented
* *
* NOTES
* See RtlpUnicodeStringToAnsiString
*/
NTSTATUS
STDCALL
RtlUnicodeStringToAnsiString(
IN OUT PANSI_STRING AnsiDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpUnicodeStringToAnsiString(
AnsiDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/*
* private
*
* NOTES * NOTES
* This function always writes a terminating '\0'. * This function always writes a terminating '\0'.
* Does NOT perform a partial copy if unicode is too small! * Does NOT perform a partial copy if unicode is too small!
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpOemStringToUnicodeString( RtlOemStringToUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN POEM_STRING OemSource, IN POEM_STRING OemSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //including nullterm ULONG Length; /* including nullterm */
if (NlsMbOemCodePageTag == TRUE) if (NlsMbOemCodePageTag == TRUE)
Length = RtlOemStringToUnicodeSize(OemSource); Length = RtlOemStringToUnicodeSize(OemSource);
@ -1083,7 +1057,7 @@ RtlpOemStringToUnicodeString(
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_USTR); UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
if (UniDest->Buffer == NULL) if (UniDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -1095,7 +1069,7 @@ RtlpOemStringToUnicodeString(
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
} }
//FIXME: Do we need this????? -Gunnar /* FIXME: Do we need this????? -Gunnar */
RtlZeroMemory (UniDest->Buffer, RtlZeroMemory (UniDest->Buffer,
UniDest->Length); UniDest->Length);
@ -1107,7 +1081,7 @@ RtlpOemStringToUnicodeString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(UniDest->Buffer, TAG_USTR); RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
return Status; return Status;
} }
@ -1120,35 +1094,14 @@ RtlpOemStringToUnicodeString(
* @implemented * @implemented
* *
* NOTES * NOTES
* See RtlpOemStringToUnicodeString
*/
NTSTATUS
STDCALL
RtlOemStringToUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN POEM_STRING OemSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpOemStringToUnicodeString(
UniDest,
OemSource,
AllocateDestinationString,
PagedPool);
}
/*
* private
*
* NOTES
* This function always '\0' terminates the string returned. * This function always '\0' terminates the string returned.
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpUnicodeStringToOemString( RtlUnicodeStringToOemString(
IN OUT POEM_STRING OemDest, IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
ULONG Length; //including nullterm ULONG Length; //including nullterm
@ -1165,7 +1118,7 @@ RtlpUnicodeStringToOemString(
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR); OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
if (OemDest->Buffer == NULL) if (OemDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -1189,7 +1142,7 @@ RtlpUnicodeStringToOemString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR); RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
return Status; return Status;
} }
@ -1197,26 +1150,6 @@ RtlpUnicodeStringToOemString(
return Status; return Status;
} }
/*
* @implemented
*
* NOTES
* See RtlpUnicodeStringToOemString.
*/
NTSTATUS
STDCALL
RtlUnicodeStringToOemString(
IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpUnicodeStringToOemString(
OemDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
#define ITU_IMPLEMENTED_TESTS (IS_TEXT_UNICODE_ODD_LENGTH|IS_TEXT_UNICODE_SIGNATURE) #define ITU_IMPLEMENTED_TESTS (IS_TEXT_UNICODE_ODD_LENGTH|IS_TEXT_UNICODE_SIGNATURE)
@ -1278,23 +1211,23 @@ done:
return Length; return Length;
} }
/* /*
* private * @implemented
* *
* NOTES * NOTES
* Same as RtlOemStringToUnicodeString but doesn't write terminating null * Same as RtlOemStringToUnicodeString but doesn't write terminating null
* A partial copy is NOT performed if the dest buffer is too small! * A partial copy is NOT performed if the dest buffer is too small!
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpOemStringToCountedUnicodeString( RtlOemStringToCountedUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN POEM_STRING OemSource, IN POEM_STRING OemSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //excluding nullterm ULONG Length; /* excluding nullterm */
if (NlsMbCodePageTag == TRUE) if (NlsMbCodePageTag == TRUE)
Length = RtlOemStringToUnicodeSize(OemSource) - sizeof(WCHAR); Length = RtlOemStringToUnicodeSize(OemSource) - sizeof(WCHAR);
@ -1306,7 +1239,7 @@ RtlpOemStringToCountedUnicodeString(
if (AllocateDestinationString == TRUE) if (AllocateDestinationString == TRUE)
{ {
UniDest->Buffer = ExAllocatePoolWithTag (PoolType, Length, TAG_USTR); UniDest->Buffer = RtlpAllocateStringMemory (Length, TAG_USTR);
if (UniDest->Buffer == NULL) if (UniDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -1327,33 +1260,13 @@ RtlpOemStringToCountedUnicodeString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(UniDest->Buffer, TAG_USTR); RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
return Status; return Status;
} }
return Status; return Status;
} }
/*
* @implemented
*
* NOTES
* See RtlpOemStringToCountedUnicodeString
*/
NTSTATUS
STDCALL
RtlOemStringToCountedUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN POEM_STRING OemSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpOemStringToCountedUnicodeString(
UniDest,
OemSource,
AllocateDestinationString,
PagedPool);
}
/* /*
* @implemented * @implemented
* *
@ -1577,17 +1490,14 @@ STDCALL
RtlEraseUnicodeString( RtlEraseUnicodeString(
IN PUNICODE_STRING String) IN PUNICODE_STRING String)
{ {
if (String->Buffer == NULL) if (String->Buffer != NULL &&
return; String->MaximumLength != 0)
{
if (String->MaximumLength == 0) RtlZeroMemory (String->Buffer,
return;
memset (String->Buffer,
0,
String->MaximumLength); String->MaximumLength);
String->Length = 0; String->Length = 0;
}
} }
/* /*
@ -1643,19 +1553,18 @@ RtlHashUnicodeString(
} }
/* /*
* private * @implemented
* *
* NOTES * NOTES
* Same as RtlUnicodeStringToOemString but doesn't write terminating null * Same as RtlUnicodeStringToOemString but doesn't write terminating null
* Does a partial copy if the dest buffer is too small * Does a partial copy if the dest buffer is too small
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpUnicodeStringToCountedOemString( RtlUnicodeStringToCountedOemString(
IN OUT POEM_STRING OemDest, IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //excluding nullterm ULONG Length; //excluding nullterm
@ -1672,7 +1581,7 @@ RtlpUnicodeStringToCountedOemString(
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR); OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
if (OemDest->Buffer == NULL) if (OemDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -1695,32 +1604,12 @@ RtlpUnicodeStringToCountedOemString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR); RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
} }
return Status; return Status;
} }
/*
* @implemented
*
* NOTES
* See RtlpUnicodeStringToCountedOemString.
*/
NTSTATUS
STDCALL
RtlUnicodeStringToCountedOemString(
IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpUnicodeStringToCountedOemString(
OemDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/* /*
* @implemented * @implemented
*/ */
@ -1771,19 +1660,18 @@ RtlLargeIntegerToChar(
} }
/* /*
* private * @implemented
* *
* NOTES * NOTES
* dest is never '\0' terminated because it may be equal to src, and src * dest is never '\0' terminated because it may be equal to src, and src
* might not be '\0' terminated. dest->Length is only set upon success. * might not be '\0' terminated. dest->Length is only set upon success.
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpUpcaseUnicodeString( RtlUpcaseUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN PCUNICODE_STRING UniSource, IN PCUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
ULONG i; ULONG i;
PWCHAR Src, Dest; PWCHAR Src, Dest;
@ -1791,7 +1679,7 @@ RtlpUpcaseUnicodeString(
if (AllocateDestinationString == TRUE) if (AllocateDestinationString == TRUE)
{ {
UniDest->MaximumLength = UniSource->Length; UniDest->MaximumLength = UniSource->Length;
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, UniDest->MaximumLength, TAG_USTR); UniDest->Buffer = RtlpAllocateStringMemory(UniDest->MaximumLength, TAG_USTR);
if (UniDest->Buffer == NULL) if (UniDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
@ -1818,40 +1706,18 @@ RtlpUpcaseUnicodeString(
* @implemented * @implemented
* *
* NOTES * NOTES
* See RtlpUpcaseUnicodeString
*/
NTSTATUS
STDCALL
RtlUpcaseUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN PCUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpUpcaseUnicodeString(
UniDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/*
* private
*
* NOTES
* This function always writes a terminating '\0'. * This function always writes a terminating '\0'.
* It performs a partial copy if ansi is too small. * It performs a partial copy if ansi is too small.
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpUpcaseUnicodeStringToAnsiString( RtlUpcaseUnicodeStringToAnsiString(
IN OUT PANSI_STRING AnsiDest, IN OUT PANSI_STRING AnsiDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //including nullterm ULONG Length; /* including nullterm */
if (NlsMbCodePageTag == TRUE) if (NlsMbCodePageTag == TRUE)
Length = RtlUnicodeStringToAnsiSize(UniSource); Length = RtlUnicodeStringToAnsiSize(UniSource);
@ -1865,7 +1731,7 @@ RtlpUpcaseUnicodeStringToAnsiString(
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
AnsiDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_ASTR); AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
if (AnsiDest->Buffer == NULL) if (AnsiDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -1877,11 +1743,11 @@ RtlpUpcaseUnicodeStringToAnsiString(
} }
else if (Length > AnsiDest->MaximumLength) else if (Length > AnsiDest->MaximumLength)
{ {
//make room for nullterm /* make room for nullterm */
AnsiDest->Length = AnsiDest->MaximumLength - sizeof(CHAR); AnsiDest->Length = AnsiDest->MaximumLength - sizeof(CHAR);
} }
//FIXME: do we need this??????? -Gunnar /* FIXME: do we need this??????? -Gunnar */
RtlZeroMemory (AnsiDest->Buffer, RtlZeroMemory (AnsiDest->Buffer,
AnsiDest->Length); AnsiDest->Length);
@ -1893,7 +1759,7 @@ RtlpUpcaseUnicodeStringToAnsiString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(AnsiDest->Buffer, TAG_ASTR); RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
return Status; return Status;
} }
@ -1905,39 +1771,18 @@ RtlpUpcaseUnicodeStringToAnsiString(
* @implemented * @implemented
* *
* NOTES * NOTES
* See RtlpUpcaseUnicodeStringToAnsiString * This function always writes a terminating '\0'.
* It performs a partial copy if ansi is too small.
*/ */
NTSTATUS NTSTATUS
STDCALL STDCALL
RtlUpcaseUnicodeStringToAnsiString( RtlUpcaseUnicodeStringToCountedOemString(
IN OUT PANSI_STRING AnsiDest, IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString) IN BOOLEAN AllocateDestinationString)
{
return RtlpUpcaseUnicodeStringToAnsiString(
AnsiDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/*
* private
*
* NOTES
* Same as RtlUpcaseUnicodeStringToOemString but doesn't write terminating null
* It performs a partial copy if oem is too small.
*/
NTSTATUS
FASTCALL
RtlpUpcaseUnicodeStringToCountedOemString(
IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString,
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //excluding nullterm ULONG Length; /* excluding nullterm */
if (NlsMbCodePageTag == TRUE) if (NlsMbCodePageTag == TRUE)
Length = RtlUnicodeStringToAnsiSize(UniSource) - sizeof(CHAR); Length = RtlUnicodeStringToAnsiSize(UniSource) - sizeof(CHAR);
@ -1951,11 +1796,11 @@ RtlpUpcaseUnicodeStringToCountedOemString(
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR); OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
if (OemDest->Buffer == NULL) if (OemDest->Buffer == NULL)
return(STATUS_NO_MEMORY); return(STATUS_NO_MEMORY);
//FIXME: Do we need this????? /* FIXME: Do we need this????? */
RtlZeroMemory (OemDest->Buffer, Length); RtlZeroMemory (OemDest->Buffer, Length);
OemDest->MaximumLength = (WORD)Length; OemDest->MaximumLength = (WORD)Length;
@ -1977,7 +1822,7 @@ RtlpUpcaseUnicodeStringToCountedOemString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR); RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
return Status; return Status;
} }
@ -1986,42 +1831,20 @@ RtlpUpcaseUnicodeStringToCountedOemString(
/* /*
* @implemented * @implemented
*
* NOTES
* See RtlpUpcaseUnicodeStringToCountedOemString
*/
NTSTATUS
STDCALL
RtlUpcaseUnicodeStringToCountedOemString(
IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpUpcaseUnicodeStringToCountedOemString(
OemDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/*
* private
*
* NOTES * NOTES
* Oem string is allways nullterminated * Oem string is allways nullterminated
* It performs a partial copy if oem is too small. * It performs a partial copy if oem is too small.
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpUpcaseUnicodeStringToOemString ( RtlUpcaseUnicodeStringToOemString (
IN OUT POEM_STRING OemDest, IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString
IN POOL_TYPE PoolType
) )
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //including nullterm ULONG Length; /* including nullterm */
if (NlsMbOemCodePageTag == TRUE) if (NlsMbOemCodePageTag == TRUE)
Length = RtlUnicodeStringToAnsiSize(UniSource); Length = RtlUnicodeStringToAnsiSize(UniSource);
@ -2035,11 +1858,11 @@ RtlpUpcaseUnicodeStringToOemString (
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR); OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
if (OemDest->Buffer == NULL) if (OemDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
//FIXME: Do we need this???? /* FIXME: Do we need this???? */
RtlZeroMemory (OemDest->Buffer, Length); RtlZeroMemory (OemDest->Buffer, Length);
OemDest->MaximumLength = (WORD)Length; OemDest->MaximumLength = (WORD)Length;
@ -2050,7 +1873,7 @@ RtlpUpcaseUnicodeStringToOemString (
} }
else if (Length > OemDest->MaximumLength) else if (Length > OemDest->MaximumLength)
{ {
//make room for nullterm /* make room for nullterm */
OemDest->Length = OemDest->MaximumLength - sizeof(CHAR); OemDest->Length = OemDest->MaximumLength - sizeof(CHAR);
} }
@ -2062,7 +1885,7 @@ RtlpUpcaseUnicodeStringToOemString (
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR); RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
return Status; return Status;
} }
@ -2070,26 +1893,6 @@ RtlpUpcaseUnicodeStringToOemString (
return Status; return Status;
} }
/*
* @implemented
* NOTES
* See RtlpUpcaseUnicodeStringToOemString
*/
NTSTATUS
STDCALL
RtlUpcaseUnicodeStringToOemString (
IN OUT POEM_STRING OemDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString
)
{
return RtlpUpcaseUnicodeStringToOemString(
OemDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/* /*
* @implemented * @implemented
* *
@ -2284,41 +2087,11 @@ RtlCopyUnicodeString(
DestinationString->Length = copylen; DestinationString->Length = copylen;
} }
/*
* private
*
* Creates a nullterminated UNICODE_STRING
*/
BOOLEAN
FASTCALL
RtlpCreateUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN PCWSTR Source,
IN POOL_TYPE PoolType)
{
ULONG Length;
Length = (wcslen (Source) + 1) * sizeof(WCHAR);
PoolType = PagedPool;
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_USTR);
if (UniDest->Buffer == NULL)
return FALSE;
memmove (UniDest->Buffer,
Source,
Length);
UniDest->MaximumLength = Length;
UniDest->Length = Length - sizeof (WCHAR);
return TRUE;
}
/* /*
* @implemented * @implemented
* *
* NOTES * NOTES
* See RtlpCreateUnicodeString * Creates a nullterminated UNICODE_STRING
*/ */
BOOLEAN BOOLEAN
STDCALL STDCALL
@ -2326,9 +2099,21 @@ RtlCreateUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN PCWSTR Source) IN PCWSTR Source)
{ {
ULONG Length;
DPRINT("RtlCreateUnicodeString\n"); Length = (wcslen (Source) + 1) * sizeof(WCHAR);
return RtlpCreateUnicodeString(UniDest, Source, PagedPool); UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
if (UniDest->Buffer == NULL)
return FALSE;
RtlCopyMemory (UniDest->Buffer,
Source,
Length);
UniDest->MaximumLength = Length;
UniDest->Length = Length - sizeof (WCHAR);
return TRUE;
} }
/* /*
@ -2354,27 +2139,25 @@ RtlCreateUnicodeStringFromAsciiz(
} }
/* /*
* private * @implemented
* *
* NOTES * NOTES
* Dest is never '\0' terminated because it may be equal to src, and src * Dest is never '\0' terminated because it may be equal to src, and src
* might not be '\0' terminated. * might not be '\0' terminated.
* Dest->Length is only set upon success. * Dest->Length is only set upon success.
*/ */
NTSTATUS NTSTATUS STDCALL
FASTCALL RtlDowncaseUnicodeString(
RtlpDowncaseUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN PUNICODE_STRING UniSource, IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
ULONG i; ULONG i;
PWCHAR Src, Dest; PWCHAR Src, Dest;
if (AllocateDestinationString) if (AllocateDestinationString)
{ {
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, UniSource->Length, TAG_USTR); UniDest->Buffer = RtlpAllocateStringMemory(UniSource->Length, TAG_USTR);
if (UniDest->Buffer == NULL) if (UniDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -2411,25 +2194,6 @@ RtlpDowncaseUnicodeString(
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/*
* @implemented
*
* NOTES
* See RtlpDowncaseUnicodeString
*/
NTSTATUS STDCALL
RtlDowncaseUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN PUNICODE_STRING UniSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpDowncaseUnicodeString(
UniDest,
UniSource,
AllocateDestinationString,
PagedPool);
}
/* /*
* @implemented * @implemented
* *
@ -2459,19 +2223,18 @@ RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
} }
/* /*
* private * @implemented
* *
* NOTES * NOTES
* This function always writes a terminating '\0'. * This function always writes a terminating '\0'.
* If the dest buffer is too small a partial copy is NOT performed! * If the dest buffer is too small a partial copy is NOT performed!
*/ */
NTSTATUS NTSTATUS
FASTCALL STDCALL
RtlpAnsiStringToUnicodeString( RtlAnsiStringToUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN PANSI_STRING AnsiSource, IN PANSI_STRING AnsiSource,
IN BOOLEAN AllocateDestinationString, IN BOOLEAN AllocateDestinationString)
IN POOL_TYPE PoolType)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG Length; //including nullterm ULONG Length; //including nullterm
@ -2486,7 +2249,7 @@ RtlpAnsiStringToUnicodeString(
if (AllocateDestinationString == TRUE) if (AllocateDestinationString == TRUE)
{ {
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_USTR); UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
if (UniDest->Buffer == NULL) if (UniDest->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -2512,7 +2275,7 @@ RtlpAnsiStringToUnicodeString(
if (!NT_SUCCESS(Status) && AllocateDestinationString) if (!NT_SUCCESS(Status) && AllocateDestinationString)
{ {
ExFreePoolWithTag(UniDest->Buffer, TAG_USTR); RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
return Status; return Status;
} }
@ -2520,26 +2283,6 @@ RtlpAnsiStringToUnicodeString(
return Status; return Status;
} }
/*
* @implemented
*
* NOTES
* See RtlpAnsiStringToUnicodeString
*/
NTSTATUS
STDCALL
RtlAnsiStringToUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN PANSI_STRING AnsiSource,
IN BOOLEAN AllocateDestinationString)
{
return RtlpAnsiStringToUnicodeString(
UniDest,
AnsiSource,
AllocateDestinationString,
PagedPool);
}
/* /*
* @implemented * @implemented
* *
@ -2621,7 +2364,7 @@ RtlxAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
ULONG STDCALL ULONG STDCALL
RtlxOemStringToUnicodeSize(IN POEM_STRING OemString) RtlxOemStringToUnicodeSize(IN POEM_STRING OemString)
{ {
return RtlOemStringToUnicodeSize((PANSI_STRING)OemString); return RtlOemStringToUnicodeSize(OemString);
} }
@ -2647,13 +2390,15 @@ RtlxUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
/* /*
* @implemented * @implemented
*
* NOTES
* See RtlpDuplicateUnicodeString
*/ */
NTSTATUS STDCALL NTSTATUS STDCALL
RtlpDuplicateUnicodeString( RtlDuplicateUnicodeString(
INT AddNull, INT AddNull,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,
PUNICODE_STRING DestinationString, PUNICODE_STRING DestinationString)
POOL_TYPE PoolType)
{ {
if (SourceString == NULL || DestinationString == NULL) if (SourceString == NULL || DestinationString == NULL)
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
@ -2667,12 +2412,12 @@ RtlpDuplicateUnicodeString(
} }
else else
{ {
unsigned int DestMaxLength = SourceString->Length; UINT DestMaxLength = SourceString->Length;
if (AddNull) if (AddNull)
DestMaxLength += sizeof(UNICODE_NULL); DestMaxLength += sizeof(UNICODE_NULL);
DestinationString->Buffer = ExAllocatePool(PoolType, DestMaxLength); DestinationString->Buffer = RtlpAllocateStringMemory(DestMaxLength, TAG_USTR);
if (DestinationString->Buffer == NULL) if (DestinationString->Buffer == NULL)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
@ -2687,25 +2432,6 @@ RtlpDuplicateUnicodeString(
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
/*
* @implemented
*
* NOTES
* See RtlpDuplicateUnicodeString
*/
NTSTATUS STDCALL
RtlDuplicateUnicodeString(
INT AddNull,
IN PUNICODE_STRING SourceString,
PUNICODE_STRING DestinationString)
{
return RtlpDuplicateUnicodeString(
AddNull,
SourceString,
DestinationString,
PagedPool);
}
/* /*
* @implemented * @implemented
*/ */

View file

@ -70,8 +70,8 @@ BOOLEAN CmImportSystemHive(PCHAR ChunkBase, ULONG ChunkSize);
BOOLEAN CmImportHardwareHive(PCHAR ChunkBase, ULONG ChunkSize); BOOLEAN CmImportHardwareHive(PCHAR ChunkBase, ULONG ChunkSize);
VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock); VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
BOOLEAN /* FIXME - RtlpCreateUnicodeString is obsolete and should be removed ASAP! */
FASTCALL BOOLEAN FASTCALL
RtlpCreateUnicodeString( RtlpCreateUnicodeString(
IN OUT PUNICODE_STRING UniDest, IN OUT PUNICODE_STRING UniDest,
IN PCWSTR Source, IN PCWSTR Source,

View file

@ -23,6 +23,24 @@ RtlpGetMode()
return KernelMode; return KernelMode;
} }
PVOID
RtlpAllocateMemory(UINT Bytes,
ULONG Tag)
{
return ExAllocatePoolWithTag(PagedPool,
(SIZE_T)Bytes,
Tag);
}
VOID
RtlpFreeMemory(PVOID Mem,
ULONG Tag)
{
ExFreePoolWithTag(Mem,
Tag);
}
/* /*
* @implemented * @implemented
*/ */
@ -281,4 +299,28 @@ RtlpGetAtomEntry(PRTL_ATOM_TABLE AtomTable, ULONG Index)
return NULL; return NULL;
} }
/* FIXME - RtlpCreateUnicodeString is obsolete and should be removed ASAP! */
BOOLEAN FASTCALL
RtlpCreateUnicodeString(
IN OUT PUNICODE_STRING UniDest,
IN PCWSTR Source,
IN POOL_TYPE PoolType)
{
ULONG Length;
Length = (wcslen (Source) + 1) * sizeof(WCHAR);
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG('U', 'S', 'T', 'R'));
if (UniDest->Buffer == NULL)
return FALSE;
RtlCopyMemory (UniDest->Buffer,
Source,
Length);
UniDest->MaximumLength = Length;
UniDest->Length = Length - sizeof (WCHAR);
return TRUE;
}
/* EOF */ /* EOF */