- 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,50 +23,26 @@ RtlpGetMode()
PVOID PVOID
STDCALL RtlpAllocateMemory(UINT Bytes,
ExAllocatePool( ULONG Tag)
IN POOL_TYPE PoolType,
IN SIZE_T Bytes
)
{ {
return RtlAllocateHeap ( UNREFERENCED_PARAMETER(Tag);
RtlGetProcessHeap (),
0, return RtlAllocateHeap(RtlGetProcessHeap(),
Bytes); 0,
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, RtlFreeHeap(RtlGetProcessHeap(),
Mem); 0,
} Mem);
VOID
STDCALL
ExFreePoolWithTag(IN PVOID Mem, IN ULONG Tag)
{
RtlFreeHeap (
RtlGetProcessHeap (),
0,
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);

File diff suppressed because it is too large Load diff

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 */