mirror of
https://github.com/reactos/reactos.git
synced 2025-04-17 19:27:00 +00:00
- 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:
parent
7b6225c3b5
commit
f479dd02aa
8 changed files with 248 additions and 524 deletions
|
@ -23,48 +23,24 @@ RtlpGetMode()
|
|||
|
||||
|
||||
PVOID
|
||||
STDCALL
|
||||
ExAllocatePool(
|
||||
IN POOL_TYPE PoolType,
|
||||
IN SIZE_T Bytes
|
||||
)
|
||||
RtlpAllocateMemory(UINT Bytes,
|
||||
ULONG Tag)
|
||||
{
|
||||
return RtlAllocateHeap (
|
||||
RtlGetProcessHeap (),
|
||||
UNREFERENCED_PARAMETER(Tag);
|
||||
|
||||
return RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
Bytes);
|
||||
}
|
||||
|
||||
PVOID
|
||||
STDCALL
|
||||
ExAllocatePoolWithTag(
|
||||
IN POOL_TYPE PoolType,
|
||||
IN SIZE_T Bytes,
|
||||
IN ULONG Tag
|
||||
)
|
||||
{
|
||||
return RtlAllocateHeap (
|
||||
RtlGetProcessHeap (),
|
||||
0,
|
||||
Bytes);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExFreePool(IN PVOID Mem)
|
||||
RtlpFreeMemory(PVOID Mem,
|
||||
ULONG Tag)
|
||||
{
|
||||
RtlFreeHeap (
|
||||
RtlGetProcessHeap (),
|
||||
0,
|
||||
Mem);
|
||||
}
|
||||
UNREFERENCED_PARAMETER(Tag);
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
ExFreePoolWithTag(IN PVOID Mem, IN ULONG Tag)
|
||||
{
|
||||
RtlFreeHeap (
|
||||
RtlGetProcessHeap (),
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
Mem);
|
||||
}
|
||||
|
|
|
@ -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 */
|
|
@ -23,6 +23,8 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define TAG_RTLREGISTRY TAG('R', 't', 'l', 'R')
|
||||
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
|
@ -305,11 +307,10 @@ RtlFormatCurrentUserKeyPath (OUT PUNICODE_STRING KeyPath)
|
|||
|
||||
KeyPath->Length = 0;
|
||||
KeyPath->MaximumLength = Length;
|
||||
KeyPath->Buffer = ExAllocatePool (PagedPool,
|
||||
KeyPath->MaximumLength);
|
||||
KeyPath->Buffer = RtlpAllocateStringMemory(KeyPath->MaximumLength, TAG_USTR);
|
||||
if (KeyPath->Buffer == NULL)
|
||||
{
|
||||
DPRINT1 ("ExAllocatePool() failed\n");
|
||||
DPRINT1 ("RtlpAllocateMemory() failed\n");
|
||||
RtlFreeUnicodeString (&SidString);
|
||||
return STATUS_NO_TOKEN;
|
||||
}
|
||||
|
@ -450,7 +451,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
QueryEntry->Name);
|
||||
|
||||
BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096;
|
||||
ValueInfo = ExAllocatePool(PagedPool, BufferSize);
|
||||
ValueInfo = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
|
||||
if (ValueInfo == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -467,7 +468,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
{
|
||||
if (QueryEntry->Flags & RTL_QUERY_REGISTRY_REQUIRED)
|
||||
{
|
||||
ExFreePool(ValueInfo);
|
||||
RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
|
||||
Status = STATUS_OBJECT_NAME_NOT_FOUND;
|
||||
break;
|
||||
}
|
||||
|
@ -483,7 +484,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
{
|
||||
ValueString->Length = SourceString->Length;
|
||||
ValueString->MaximumLength = SourceString->MaximumLength;
|
||||
ValueString->Buffer = ExAllocatePool(PagedPool, BufferSize);
|
||||
ValueString->Buffer = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
|
||||
if (!ValueString->Buffer)
|
||||
break;
|
||||
ValueString->Buffer[0] = 0;
|
||||
|
@ -521,7 +522,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
if (ValueString->Buffer == NULL)
|
||||
{
|
||||
ValueString->MaximumLength = ValueInfo->DataLength;
|
||||
ValueString->Buffer = ExAllocatePool(PagedPool, ValueString->MaximumLength);
|
||||
ValueString->Buffer = RtlpAllocateMemory(ValueString->MaximumLength, TAG_RTLREGISTRY);
|
||||
if (ValueString->Buffer == NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -544,7 +545,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
|
||||
ValueString = (PUNICODE_STRING)QueryEntry->EntryContext;
|
||||
|
||||
ExpandBuffer = ExAllocatePool(PagedPool, ValueInfo->DataLength * 2);
|
||||
ExpandBuffer = RtlpAllocateMemory(ValueInfo->DataLength * 2, TAG_RTLREGISTRY);
|
||||
if (ExpandBuffer == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -567,7 +568,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
{
|
||||
ValueString->MaximumLength = EnvExpandedValue.Length + sizeof(WCHAR);
|
||||
ValueString->Length = EnvExpandedValue.Length;
|
||||
ValueString->Buffer = ExAllocatePool(PagedPool, ValueString->MaximumLength);
|
||||
ValueString->Buffer = RtlpAllocateMemory(ValueString->MaximumLength, TAG_RTLREGISTRY);
|
||||
if (ValueString->Buffer == NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -585,7 +586,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
ValueString->Length);
|
||||
((PWSTR)ValueString->Buffer)[ValueString->Length / sizeof(WCHAR)] = 0;
|
||||
|
||||
ExFreePool(ExpandBuffer);
|
||||
RtlpFreeMemory(ExpandBuffer, TAG_RTLREGISTRY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -601,7 +602,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
|
||||
}
|
||||
|
||||
ExFreePool(ValueInfo);
|
||||
RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -612,7 +613,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
QueryEntry->Name);
|
||||
|
||||
BufferSize = sizeof (KEY_VALUE_PARTIAL_INFORMATION) + 4096;
|
||||
ValueInfo = ExAllocatePool(PagedPool, BufferSize);
|
||||
ValueInfo = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
|
||||
if (ValueInfo == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -661,7 +662,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
{
|
||||
DPRINT("Expand REG_EXPAND_SZ type\n");
|
||||
|
||||
ExpandBuffer = ExAllocatePool(PagedPool, ValueInfo->DataLength * 2);
|
||||
ExpandBuffer = RtlpAllocateMemory(ValueInfo->DataLength * 2, TAG_RTLREGISTRY);
|
||||
if (ExpandBuffer == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -688,7 +689,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
Context,
|
||||
QueryEntry->EntryContext);
|
||||
|
||||
ExFreePool(ExpandBuffer);
|
||||
RtlpFreeMemory(ExpandBuffer, TAG_RTLREGISTRY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -706,7 +707,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
|
||||
}
|
||||
|
||||
ExFreePool(ValueInfo);
|
||||
RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
|
||||
if (!NT_SUCCESS(Status))
|
||||
break;
|
||||
}
|
||||
|
@ -727,14 +728,14 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
DPRINT("Enumerate values\n");
|
||||
|
||||
BufferSize = sizeof(KEY_VALUE_FULL_INFORMATION) + 4096;
|
||||
FullValueInfo = ExAllocatePool(PagedPool, BufferSize);
|
||||
FullValueInfo = RtlpAllocateMemory(BufferSize, TAG_RTLREGISTRY);
|
||||
if (FullValueInfo == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
break;
|
||||
}
|
||||
ValueNameSize = 256 * sizeof(WCHAR);
|
||||
ValueName = ExAllocatePool(PagedPool, ValueNameSize);
|
||||
ValueName = RtlpAllocateMemory(ValueNameSize, TAG_RTLREGISTRY);
|
||||
if (ValueName == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -767,9 +768,9 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
if (FullValueInfo->NameLength > ValueNameSize - sizeof(WCHAR))
|
||||
{
|
||||
/* Should not happen, because the name length is limited to 255 characters */
|
||||
ExFreePool(ValueName);
|
||||
RtlpFreeMemory(ValueName, TAG_RTLREGISTRY);
|
||||
ValueNameSize = FullValueInfo->NameLength + sizeof(WCHAR);
|
||||
ValueName = ExAllocatePool(PagedPool, ValueNameSize);
|
||||
ValueName = RtlpAllocateMemory(ValueNameSize, TAG_RTLREGISTRY);
|
||||
if (ValueName == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -808,7 +809,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
DPRINT("Expand REG_EXPAND_SZ type\n");
|
||||
|
||||
StringPtr = (PWSTR)((ULONG_PTR)FullValueInfo + FullValueInfo->DataOffset);
|
||||
ExpandBuffer = ExAllocatePool(PagedPool, FullValueInfo->DataLength * 2);
|
||||
ExpandBuffer = RtlpAllocateMemory(FullValueInfo->DataLength * 2, TAG_RTLREGISTRY);
|
||||
if (ExpandBuffer == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
|
@ -835,7 +836,7 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
Context,
|
||||
QueryEntry->EntryContext);
|
||||
|
||||
ExFreePool(ExpandBuffer);
|
||||
RtlpFreeMemory(ExpandBuffer, TAG_RTLREGISTRY);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -855,8 +856,8 @@ RtlQueryRegistryValues(IN ULONG RelativeTo,
|
|||
Index++;
|
||||
}
|
||||
|
||||
ExFreePool(FullValueInfo);
|
||||
ExFreePool(ValueName);
|
||||
RtlpFreeMemory(FullValueInfo, TAG_RTLREGISTRY);
|
||||
RtlpFreeMemory(ValueName, TAG_RTLREGISTRY);
|
||||
if (!NT_SUCCESS(Status))
|
||||
break;
|
||||
}
|
||||
|
@ -963,7 +964,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
|
|||
{
|
||||
BufferLength = SubKeyName->MaximumLength +
|
||||
sizeof(KEY_BASIC_INFORMATION);
|
||||
KeyInfo = ExAllocatePool(PagedPool, BufferLength);
|
||||
KeyInfo = RtlpAllocateMemory(BufferLength, TAG_RTLREGISTRY);
|
||||
if (KeyInfo == NULL)
|
||||
return(STATUS_NO_MEMORY);
|
||||
}
|
||||
|
@ -992,7 +993,7 @@ RtlpNtEnumerateSubKey(IN HANDLE KeyHandle,
|
|||
|
||||
if (KeyInfo != NULL)
|
||||
{
|
||||
ExFreePool(KeyInfo);
|
||||
RtlpFreeMemory(KeyInfo, TAG_RTLREGISTRY);
|
||||
}
|
||||
|
||||
return(Status);
|
||||
|
@ -1050,7 +1051,7 @@ RtlpNtQueryValueKey(IN HANDLE KeyHandle,
|
|||
if (DataLength != NULL)
|
||||
BufferLength = *DataLength;
|
||||
|
||||
ValueInfo = ExAllocatePool(PagedPool, BufferLength);
|
||||
ValueInfo = RtlpAllocateMemory(BufferLength, TAG_RTLREGISTRY);
|
||||
if (ValueInfo == NULL)
|
||||
return(STATUS_NO_MEMORY);
|
||||
|
||||
|
@ -1076,7 +1077,7 @@ RtlpNtQueryValueKey(IN HANDLE KeyHandle,
|
|||
}
|
||||
}
|
||||
|
||||
ExFreePool(ValueInfo);
|
||||
RtlpFreeMemory(ValueInfo, TAG_RTLREGISTRY);
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
/* Helper Header */
|
||||
#include <reactos/helper.h>
|
||||
|
||||
/* LIBSUPP Header */
|
||||
#include "libsupp.h"
|
||||
|
||||
/* FIXME: Move this somewhere else, maybe */
|
||||
#ifdef DBG
|
||||
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()
|
||||
#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 */
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#define TAG_SID TAG('p', 'S', 'i', 'd')
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
BOOLEAN STDCALL
|
||||
|
@ -244,8 +246,8 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
|
|||
if (Sid == NULL)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
pSid = (PSID)ExAllocatePool(PagedPool,
|
||||
sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
|
||||
pSid = RtlpAllocateMemory(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG),
|
||||
TAG_SID);
|
||||
if (pSid == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -294,7 +296,7 @@ RtlFreeSid(IN PSID Sid)
|
|||
{
|
||||
PAGED_CODE_RTL();
|
||||
|
||||
ExFreePool(Sid);
|
||||
RtlpFreeMemory(Sid, TAG_SID);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -370,7 +372,8 @@ RtlConvertSidToUnicodeString(PUNICODE_STRING String,
|
|||
Length = (wcs - Buffer) * sizeof(WCHAR);
|
||||
if (AllocateBuffer)
|
||||
{
|
||||
String->Buffer = ExAllocatePool(PagedPool,Length + sizeof(WCHAR));
|
||||
String->Buffer = RtlpAllocateMemory(Length + sizeof(WCHAR),
|
||||
TAG_SID);
|
||||
if (String->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
String->MaximumLength = Length + sizeof(WCHAR);
|
||||
|
|
|
@ -27,11 +27,6 @@
|
|||
|
||||
/* 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 NlsMbOemCodePageTag;
|
||||
|
||||
|
@ -386,15 +381,15 @@ VOID
|
|||
STDCALL
|
||||
RtlFreeAnsiString(IN PANSI_STRING AnsiString)
|
||||
{
|
||||
if (AnsiString->Buffer == NULL)
|
||||
return;
|
||||
|
||||
ExFreePoolWithTag(AnsiString->Buffer, TAG_ASTR);
|
||||
if (AnsiString->Buffer != NULL)
|
||||
{
|
||||
RtlpFreeStringMemory(AnsiString->Buffer, TAG_ASTR);
|
||||
|
||||
AnsiString->Buffer = NULL;
|
||||
AnsiString->Length = 0;
|
||||
AnsiString->MaximumLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -404,15 +399,15 @@ VOID
|
|||
STDCALL
|
||||
RtlFreeOemString(IN POEM_STRING OemString)
|
||||
{
|
||||
if (OemString->Buffer == NULL)
|
||||
return;
|
||||
|
||||
ExFreePoolWithTag(OemString->Buffer, TAG_OSTR);
|
||||
if (OemString->Buffer != NULL)
|
||||
{
|
||||
RtlpFreeStringMemory(OemString->Buffer, TAG_OSTR);
|
||||
|
||||
OemString->Buffer = NULL;
|
||||
OemString->Length = 0;
|
||||
OemString->MaximumLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -422,15 +417,15 @@ VOID
|
|||
STDCALL
|
||||
RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
|
||||
{
|
||||
if (UnicodeString->Buffer == NULL)
|
||||
return;
|
||||
|
||||
ExFreePoolWithTag(UnicodeString->Buffer, TAG_USTR);
|
||||
if (UnicodeString->Buffer != NULL)
|
||||
{
|
||||
RtlpFreeStringMemory(UnicodeString->Buffer, TAG_USTR);
|
||||
|
||||
UnicodeString->Buffer = NULL;
|
||||
UnicodeString->Length = 0;
|
||||
UnicodeString->MaximumLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
|
@ -696,9 +691,8 @@ RtlIntegerToUnicodeString(
|
|||
Base,
|
||||
sizeof(Buffer),
|
||||
Buffer);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
AnsiString.Buffer = Buffer;
|
||||
AnsiString.Length = strlen (Buffer);
|
||||
AnsiString.MaximumLength = sizeof(Buffer);
|
||||
|
@ -706,6 +700,7 @@ RtlIntegerToUnicodeString(
|
|||
Status = RtlAnsiStringToUnicodeString (String,
|
||||
&AnsiString,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -733,9 +728,8 @@ RtlInt64ToUnicodeString (
|
|||
Base,
|
||||
sizeof(Buffer),
|
||||
Buffer);
|
||||
if (!NT_SUCCESS(Status))
|
||||
return Status;
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
AnsiString.Buffer = Buffer;
|
||||
AnsiString.Length = strlen (Buffer);
|
||||
AnsiString.MaximumLength = sizeof(Buffer);
|
||||
|
@ -743,6 +737,7 @@ RtlInt64ToUnicodeString (
|
|||
Status = RtlAnsiStringToUnicodeString (String,
|
||||
&AnsiString,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -972,22 +967,22 @@ RtlUnicodeStringToOemSize(
|
|||
}
|
||||
|
||||
/*
|
||||
* private
|
||||
* @implemented
|
||||
*
|
||||
|
||||
* NOTES
|
||||
* This function always writes a terminating '\0'.
|
||||
* It performs a partial copy if ansi is too small.
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpUnicodeStringToAnsiString(
|
||||
STDCALL
|
||||
RtlUnicodeStringToAnsiString(
|
||||
IN OUT PANSI_STRING AnsiDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
ULONG Length; //including nullterm
|
||||
ULONG Length; /* including nullterm */
|
||||
|
||||
if (NlsMbCodePageTag == TRUE)
|
||||
{
|
||||
|
@ -1000,7 +995,7 @@ RtlpUnicodeStringToAnsiString(
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
AnsiDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_ASTR);
|
||||
AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
|
||||
if (AnsiDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -1012,7 +1007,7 @@ RtlpUnicodeStringToAnsiString(
|
|||
}
|
||||
else if (Length > AnsiDest->MaximumLength)
|
||||
{
|
||||
//make room for nullterm
|
||||
/* make room for nullterm */
|
||||
AnsiDest->Length = AnsiDest->MaximumLength - sizeof(CHAR);
|
||||
}
|
||||
|
||||
|
@ -1024,7 +1019,7 @@ RtlpUnicodeStringToAnsiString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(AnsiDest->Buffer, TAG_ASTR);
|
||||
RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1032,44 +1027,23 @@ RtlpUnicodeStringToAnsiString(
|
|||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @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
|
||||
* This function always writes a terminating '\0'.
|
||||
* Does NOT perform a partial copy if unicode is too small!
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpOemStringToUnicodeString(
|
||||
STDCALL
|
||||
RtlOemStringToUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN POEM_STRING OemSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Length; //including nullterm
|
||||
ULONG Length; /* including nullterm */
|
||||
|
||||
if (NlsMbOemCodePageTag == TRUE)
|
||||
Length = RtlOemStringToUnicodeSize(OemSource);
|
||||
|
@ -1083,7 +1057,7 @@ RtlpOemStringToUnicodeString(
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_USTR);
|
||||
UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
|
||||
if (UniDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -1095,7 +1069,7 @@ RtlpOemStringToUnicodeString(
|
|||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
//FIXME: Do we need this????? -Gunnar
|
||||
/* FIXME: Do we need this????? -Gunnar */
|
||||
RtlZeroMemory (UniDest->Buffer,
|
||||
UniDest->Length);
|
||||
|
||||
|
@ -1107,7 +1081,7 @@ RtlpOemStringToUnicodeString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(UniDest->Buffer, TAG_USTR);
|
||||
RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1120,35 +1094,14 @@ RtlpOemStringToUnicodeString(
|
|||
* @implemented
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpUnicodeStringToOemString(
|
||||
STDCALL
|
||||
RtlUnicodeStringToOemString(
|
||||
IN OUT POEM_STRING OemDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
ULONG Length; //including nullterm
|
||||
|
@ -1165,7 +1118,7 @@ RtlpUnicodeStringToOemString(
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR);
|
||||
OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
|
||||
if (OemDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -1189,7 +1142,7 @@ RtlpUnicodeStringToOemString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR);
|
||||
RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1197,26 +1150,6 @@ RtlpUnicodeStringToOemString(
|
|||
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)
|
||||
|
||||
|
||||
|
@ -1278,23 +1211,23 @@ done:
|
|||
return Length;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* private
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* Same as RtlOemStringToUnicodeString but doesn't write terminating null
|
||||
* A partial copy is NOT performed if the dest buffer is too small!
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpOemStringToCountedUnicodeString(
|
||||
STDCALL
|
||||
RtlOemStringToCountedUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN POEM_STRING OemSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Length; //excluding nullterm
|
||||
ULONG Length; /* excluding nullterm */
|
||||
|
||||
if (NlsMbCodePageTag == TRUE)
|
||||
Length = RtlOemStringToUnicodeSize(OemSource) - sizeof(WCHAR);
|
||||
|
@ -1306,7 +1239,7 @@ RtlpOemStringToCountedUnicodeString(
|
|||
|
||||
if (AllocateDestinationString == TRUE)
|
||||
{
|
||||
UniDest->Buffer = ExAllocatePoolWithTag (PoolType, Length, TAG_USTR);
|
||||
UniDest->Buffer = RtlpAllocateStringMemory (Length, TAG_USTR);
|
||||
if (UniDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -1327,33 +1260,13 @@ RtlpOemStringToCountedUnicodeString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(UniDest->Buffer, TAG_USTR);
|
||||
RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
|
||||
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
|
||||
*
|
||||
|
@ -1577,18 +1490,15 @@ STDCALL
|
|||
RtlEraseUnicodeString(
|
||||
IN PUNICODE_STRING String)
|
||||
{
|
||||
if (String->Buffer == NULL)
|
||||
return;
|
||||
|
||||
if (String->MaximumLength == 0)
|
||||
return;
|
||||
|
||||
memset (String->Buffer,
|
||||
0,
|
||||
if (String->Buffer != NULL &&
|
||||
String->MaximumLength != 0)
|
||||
{
|
||||
RtlZeroMemory (String->Buffer,
|
||||
String->MaximumLength);
|
||||
|
||||
String->Length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
@ -1643,19 +1553,18 @@ RtlHashUnicodeString(
|
|||
}
|
||||
|
||||
/*
|
||||
* private
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* Same as RtlUnicodeStringToOemString but doesn't write terminating null
|
||||
* Does a partial copy if the dest buffer is too small
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpUnicodeStringToCountedOemString(
|
||||
STDCALL
|
||||
RtlUnicodeStringToCountedOemString(
|
||||
IN OUT POEM_STRING OemDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Length; //excluding nullterm
|
||||
|
@ -1672,7 +1581,7 @@ RtlpUnicodeStringToCountedOemString(
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR);
|
||||
OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
|
||||
if (OemDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -1695,32 +1604,12 @@ RtlpUnicodeStringToCountedOemString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR);
|
||||
RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
|
||||
}
|
||||
|
||||
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
|
||||
*/
|
||||
|
@ -1771,19 +1660,18 @@ RtlLargeIntegerToChar(
|
|||
}
|
||||
|
||||
/*
|
||||
* private
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* 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.
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpUpcaseUnicodeString(
|
||||
STDCALL
|
||||
RtlUpcaseUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN PCUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
ULONG i;
|
||||
PWCHAR Src, Dest;
|
||||
|
@ -1791,7 +1679,7 @@ RtlpUpcaseUnicodeString(
|
|||
if (AllocateDestinationString == TRUE)
|
||||
{
|
||||
UniDest->MaximumLength = UniSource->Length;
|
||||
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, UniDest->MaximumLength, TAG_USTR);
|
||||
UniDest->Buffer = RtlpAllocateStringMemory(UniDest->MaximumLength, TAG_USTR);
|
||||
if (UniDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -1818,40 +1706,18 @@ RtlpUpcaseUnicodeString(
|
|||
* @implemented
|
||||
*
|
||||
* 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'.
|
||||
* It performs a partial copy if ansi is too small.
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpUpcaseUnicodeStringToAnsiString(
|
||||
STDCALL
|
||||
RtlUpcaseUnicodeStringToAnsiString(
|
||||
IN OUT PANSI_STRING AnsiDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Length; //including nullterm
|
||||
ULONG Length; /* including nullterm */
|
||||
|
||||
if (NlsMbCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize(UniSource);
|
||||
|
@ -1865,7 +1731,7 @@ RtlpUpcaseUnicodeStringToAnsiString(
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
AnsiDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_ASTR);
|
||||
AnsiDest->Buffer = RtlpAllocateStringMemory(Length, TAG_ASTR);
|
||||
if (AnsiDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -1877,11 +1743,11 @@ RtlpUpcaseUnicodeStringToAnsiString(
|
|||
}
|
||||
else if (Length > AnsiDest->MaximumLength)
|
||||
{
|
||||
//make room for nullterm
|
||||
/* make room for nullterm */
|
||||
AnsiDest->Length = AnsiDest->MaximumLength - sizeof(CHAR);
|
||||
}
|
||||
|
||||
//FIXME: do we need this??????? -Gunnar
|
||||
/* FIXME: do we need this??????? -Gunnar */
|
||||
RtlZeroMemory (AnsiDest->Buffer,
|
||||
AnsiDest->Length);
|
||||
|
||||
|
@ -1893,7 +1759,7 @@ RtlpUpcaseUnicodeStringToAnsiString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(AnsiDest->Buffer, TAG_ASTR);
|
||||
RtlpFreeStringMemory(AnsiDest->Buffer, TAG_ASTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1905,39 +1771,18 @@ RtlpUpcaseUnicodeStringToAnsiString(
|
|||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* See RtlpUpcaseUnicodeStringToAnsiString
|
||||
* This function always writes a terminating '\0'.
|
||||
* It performs a partial copy if ansi is too small.
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
RtlUpcaseUnicodeStringToAnsiString(
|
||||
IN OUT PANSI_STRING AnsiDest,
|
||||
RtlUpcaseUnicodeStringToCountedOemString(
|
||||
IN OUT POEM_STRING OemDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
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;
|
||||
ULONG Length; //excluding nullterm
|
||||
ULONG Length; /* excluding nullterm */
|
||||
|
||||
if (NlsMbCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize(UniSource) - sizeof(CHAR);
|
||||
|
@ -1951,11 +1796,11 @@ RtlpUpcaseUnicodeStringToCountedOemString(
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR);
|
||||
OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
|
||||
if (OemDest->Buffer == NULL)
|
||||
return(STATUS_NO_MEMORY);
|
||||
|
||||
//FIXME: Do we need this?????
|
||||
/* FIXME: Do we need this????? */
|
||||
RtlZeroMemory (OemDest->Buffer, Length);
|
||||
|
||||
OemDest->MaximumLength = (WORD)Length;
|
||||
|
@ -1977,7 +1822,7 @@ RtlpUpcaseUnicodeStringToCountedOemString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR);
|
||||
RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1986,42 +1831,20 @@ RtlpUpcaseUnicodeStringToCountedOemString(
|
|||
|
||||
/*
|
||||
* @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
|
||||
* Oem string is allways nullterminated
|
||||
* It performs a partial copy if oem is too small.
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpUpcaseUnicodeStringToOemString (
|
||||
STDCALL
|
||||
RtlUpcaseUnicodeStringToOemString (
|
||||
IN OUT POEM_STRING OemDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType
|
||||
IN BOOLEAN AllocateDestinationString
|
||||
)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Length; //including nullterm
|
||||
ULONG Length; /* including nullterm */
|
||||
|
||||
if (NlsMbOemCodePageTag == TRUE)
|
||||
Length = RtlUnicodeStringToAnsiSize(UniSource);
|
||||
|
@ -2035,11 +1858,11 @@ RtlpUpcaseUnicodeStringToOemString (
|
|||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
OemDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_OSTR);
|
||||
OemDest->Buffer = RtlpAllocateStringMemory(Length, TAG_OSTR);
|
||||
if (OemDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
//FIXME: Do we need this????
|
||||
/* FIXME: Do we need this???? */
|
||||
RtlZeroMemory (OemDest->Buffer, Length);
|
||||
|
||||
OemDest->MaximumLength = (WORD)Length;
|
||||
|
@ -2050,7 +1873,7 @@ RtlpUpcaseUnicodeStringToOemString (
|
|||
}
|
||||
else if (Length > OemDest->MaximumLength)
|
||||
{
|
||||
//make room for nullterm
|
||||
/* make room for nullterm */
|
||||
OemDest->Length = OemDest->MaximumLength - sizeof(CHAR);
|
||||
}
|
||||
|
||||
|
@ -2062,7 +1885,7 @@ RtlpUpcaseUnicodeStringToOemString (
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(OemDest->Buffer, TAG_OSTR);
|
||||
RtlpFreeStringMemory(OemDest->Buffer, TAG_OSTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2070,26 +1893,6 @@ RtlpUpcaseUnicodeStringToOemString (
|
|||
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
|
||||
*
|
||||
|
@ -2284,41 +2087,11 @@ RtlCopyUnicodeString(
|
|||
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
|
||||
*
|
||||
* NOTES
|
||||
* See RtlpCreateUnicodeString
|
||||
* Creates a nullterminated UNICODE_STRING
|
||||
*/
|
||||
BOOLEAN
|
||||
STDCALL
|
||||
|
@ -2326,9 +2099,21 @@ RtlCreateUnicodeString(
|
|||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN PCWSTR Source)
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
DPRINT("RtlCreateUnicodeString\n");
|
||||
return RtlpCreateUnicodeString(UniDest, Source, PagedPool);
|
||||
Length = (wcslen (Source) + 1) * sizeof(WCHAR);
|
||||
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
|
||||
* 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.
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpDowncaseUnicodeString(
|
||||
NTSTATUS STDCALL
|
||||
RtlDowncaseUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN PUNICODE_STRING UniSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
ULONG i;
|
||||
PWCHAR Src, Dest;
|
||||
|
||||
if (AllocateDestinationString)
|
||||
{
|
||||
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, UniSource->Length, TAG_USTR);
|
||||
UniDest->Buffer = RtlpAllocateStringMemory(UniSource->Length, TAG_USTR);
|
||||
if (UniDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -2411,25 +2194,6 @@ RtlpDowncaseUnicodeString(
|
|||
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
|
||||
*
|
||||
|
@ -2459,19 +2223,18 @@ RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
|||
}
|
||||
|
||||
/*
|
||||
* private
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* This function always writes a terminating '\0'.
|
||||
* If the dest buffer is too small a partial copy is NOT performed!
|
||||
*/
|
||||
NTSTATUS
|
||||
FASTCALL
|
||||
RtlpAnsiStringToUnicodeString(
|
||||
STDCALL
|
||||
RtlAnsiStringToUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN PANSI_STRING AnsiSource,
|
||||
IN BOOLEAN AllocateDestinationString,
|
||||
IN POOL_TYPE PoolType)
|
||||
IN BOOLEAN AllocateDestinationString)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
ULONG Length; //including nullterm
|
||||
|
@ -2486,7 +2249,7 @@ RtlpAnsiStringToUnicodeString(
|
|||
|
||||
if (AllocateDestinationString == TRUE)
|
||||
{
|
||||
UniDest->Buffer = ExAllocatePoolWithTag(PoolType, Length, TAG_USTR);
|
||||
UniDest->Buffer = RtlpAllocateStringMemory(Length, TAG_USTR);
|
||||
if (UniDest->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -2512,7 +2275,7 @@ RtlpAnsiStringToUnicodeString(
|
|||
|
||||
if (!NT_SUCCESS(Status) && AllocateDestinationString)
|
||||
{
|
||||
ExFreePoolWithTag(UniDest->Buffer, TAG_USTR);
|
||||
RtlpFreeStringMemory(UniDest->Buffer, TAG_USTR);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -2520,26 +2283,6 @@ RtlpAnsiStringToUnicodeString(
|
|||
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
|
||||
*
|
||||
|
@ -2621,7 +2364,7 @@ RtlxAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
|
|||
ULONG STDCALL
|
||||
RtlxOemStringToUnicodeSize(IN POEM_STRING OemString)
|
||||
{
|
||||
return RtlOemStringToUnicodeSize((PANSI_STRING)OemString);
|
||||
return RtlOemStringToUnicodeSize(OemString);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2647,13 +2390,15 @@ RtlxUnicodeStringToOemSize(IN PUNICODE_STRING UnicodeString)
|
|||
|
||||
/*
|
||||
* @implemented
|
||||
*
|
||||
* NOTES
|
||||
* See RtlpDuplicateUnicodeString
|
||||
*/
|
||||
NTSTATUS STDCALL
|
||||
RtlpDuplicateUnicodeString(
|
||||
RtlDuplicateUnicodeString(
|
||||
INT AddNull,
|
||||
IN PUNICODE_STRING SourceString,
|
||||
PUNICODE_STRING DestinationString,
|
||||
POOL_TYPE PoolType)
|
||||
PUNICODE_STRING DestinationString)
|
||||
{
|
||||
if (SourceString == NULL || DestinationString == NULL)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
@ -2667,12 +2412,12 @@ RtlpDuplicateUnicodeString(
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned int DestMaxLength = SourceString->Length;
|
||||
UINT DestMaxLength = SourceString->Length;
|
||||
|
||||
if (AddNull)
|
||||
DestMaxLength += sizeof(UNICODE_NULL);
|
||||
|
||||
DestinationString->Buffer = ExAllocatePool(PoolType, DestMaxLength);
|
||||
DestinationString->Buffer = RtlpAllocateStringMemory(DestMaxLength, TAG_USTR);
|
||||
if (DestinationString->Buffer == NULL)
|
||||
return STATUS_NO_MEMORY;
|
||||
|
||||
|
@ -2687,25 +2432,6 @@ RtlpDuplicateUnicodeString(
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -70,8 +70,8 @@ BOOLEAN CmImportSystemHive(PCHAR ChunkBase, ULONG ChunkSize);
|
|||
BOOLEAN CmImportHardwareHive(PCHAR ChunkBase, ULONG ChunkSize);
|
||||
VOID KdInitSystem(ULONG Reserved, PLOADER_PARAMETER_BLOCK LoaderBlock);
|
||||
|
||||
BOOLEAN
|
||||
FASTCALL
|
||||
/* FIXME - RtlpCreateUnicodeString is obsolete and should be removed ASAP! */
|
||||
BOOLEAN FASTCALL
|
||||
RtlpCreateUnicodeString(
|
||||
IN OUT PUNICODE_STRING UniDest,
|
||||
IN PCWSTR Source,
|
||||
|
|
|
@ -23,6 +23,24 @@ RtlpGetMode()
|
|||
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
|
||||
*/
|
||||
|
@ -281,4 +299,28 @@ RtlpGetAtomEntry(PRTL_ATOM_TABLE AtomTable, ULONG Index)
|
|||
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 */
|
||||
|
|
Loading…
Reference in a new issue