Author: pschweitzer
Date: Sat May 27 17:29:11 2017
New Revision: 74683
URL:
http://svn.reactos.org/svn/reactos?rev=74683&view=rev
Log:
[RDBSS]
[RXCE]
Try to make use of wrapper more 'properly'. Now, we use wrappers for ASSERT and
memory management.
This allows us to allocate memory with low priority (which isn't supported by ReactOS
yet :-().
Note that we go a bit farther than MS: we also define RxFreePoolWithTag() and make use of
it.
This should make Thomas happy :-)
CORE-11327
Modified:
trunk/reactos/sdk/include/ddk/rxovride.h
trunk/reactos/sdk/include/ddk/rxpooltg.h
trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c
trunk/reactos/sdk/lib/drivers/rxce/rxce.c
Modified: trunk/reactos/sdk/include/ddk/rxovride.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/rxovride.h…
==============================================================================
--- trunk/reactos/sdk/include/ddk/rxovride.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/include/ddk/rxovride.h [iso-8859-1] Sat May 27 17:29:11 2017
@@ -1,3 +1,11 @@
#ifndef NO_RXOVRIDE_GLOBAL
#include <struchdr.h>
#endif
+
+#ifndef RX_POOL_WRAPPER
+#define RX_POOL_WRAPPER 1
+#endif
+
+#ifndef RDBSS_ASSERTS
+#define RDBSS_ASSERTS 1
+#endif
Modified: trunk/reactos/sdk/include/ddk/rxpooltg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/ddk/rxpooltg.h…
==============================================================================
--- trunk/reactos/sdk/include/ddk/rxpooltg.h [iso-8859-1] (original)
+++ trunk/reactos/sdk/include/ddk/rxpooltg.h [iso-8859-1] Sat May 27 17:29:11 2017
@@ -9,5 +9,14 @@
#define RX_WORKQ_POOLTAG ('qWxR')
#define RX_MISC_POOLTAG ('sMxR')
#define RX_IRPC_POOLTAG ('rIxR')
+#ifdef __REACTOS__
+#define RX_TLC_POOLTAG ('??xR')
+#endif
+
+extern ULONG RxExplodePoolTags;
+
+#define RX_DEFINE_POOLTAG(ExplodedPoolTag, DefaultPoolTag) ((RxExplodePoolTags == 0) ?
(DefaultPoolTag) : (ExplodedPoolTag))
+
+#define RX_DIRCTL_POOLTAG RX_DEFINE_POOLTAG('cDxR', RX_MISC_POOLTAG)
#endif
Modified: trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/rdbsslib/r…
==============================================================================
--- trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/drivers/rdbsslib/rdbss.c [iso-8859-1] Sat May 27 17:29:11 2017
@@ -61,6 +61,13 @@
RxAddToTopLevelIrpAllocatedContextsList(
PRX_TOPLEVELIRP_CONTEXT TopLevelContext);
+VOID
+RxAssert(
+ PVOID Assert,
+ PVOID File,
+ ULONG Line,
+ PVOID Message);
+
NTSTATUS
NTAPI
RxCommonCleanup(
@@ -449,6 +456,24 @@
NTSTATUS
RxXXXControlFileCallthru(
PRX_CONTEXT Context);
+
+PVOID
+NTAPI
+_RxAllocatePoolWithTag(
+ _In_ POOL_TYPE PoolType,
+ _In_ SIZE_T NumberOfBytes,
+ _In_ ULONG Tag);
+
+VOID
+NTAPI
+_RxFreePool(
+ _In_ PVOID Buffer);
+
+VOID
+NTAPI
+_RxFreePoolWithTag(
+ _In_ PVOID Buffer,
+ _In_ ULONG Tag);
WCHAR RxStarForTemplate = '*';
WCHAR Rx8QMdot3QM[] = L">>>>>>>>.>>>*";
@@ -537,6 +562,29 @@
DECLARE_CONST_UNICODE_STRING(unknownId, L"???");
+#if RDBSS_ASSERTS
+#ifdef ASSERT
+#undef ASSERT
+#endif
+
+#define ASSERT(exp) \
+ if (!(exp)) \
+ { \
+ RxAssert(#exp, __FILE__, __LINE__, NULL); \
+ }
+#endif
+
+#if RX_POOL_WRAPPER
+#undef RxAllocatePool
+#undef RxAllocatePoolWithTag
+#undef RxFreePool
+
+#define RxAllocatePool(P, S) _RxAllocatePoolWithTag(P, S, 0)
+#define RxAllocatePoolWithTag _RxAllocatePoolWithTag
+#define RxFreePool _RxFreePool
+#define RxFreePoolWithTag _RxFreePoolWithTag
+#endif
+
/* FUNCTIONS ****************************************************************/
VOID
@@ -715,7 +763,7 @@
return STATUS_OBJECT_PATH_INVALID;
}
- CanonicalName->Buffer = ExAllocatePoolWithTag(PagedPool | POOL_COLD_ALLOCATION,
CanonicalLength, RX_MISC_POOLTAG);
+ CanonicalName->Buffer = RxAllocatePoolWithTag(PagedPool | POOL_COLD_ALLOCATION,
CanonicalLength, RX_MISC_POOLTAG);
if (CanonicalName->Buffer == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -3102,7 +3150,7 @@
RxInitializeDispatcher();
- ExInitializeNPagedLookasideList(&RxContextLookasideList,
ExAllocatePoolWithTag, ExFreePool, 0, sizeof(RX_CONTEXT), RX_IRPC_POOLTAG, 4);
+ ExInitializeNPagedLookasideList(&RxContextLookasideList,
RxAllocatePoolWithTag, RxFreePool, 0, sizeof(RX_CONTEXT), RX_IRPC_POOLTAG, 4);
InitializeListHead(&RxIrpsList);
KeInitializeSpinLock(&RxIrpsListSpinLock);
@@ -3276,7 +3324,6 @@
VNetRoot = (PV_NET_ROOT)RxContext->Create.pVNetRoot;
ASSERT(NetRoot == VNetRoot->NetRoot);
- TableAcquired = FALSE;
Status = STATUS_SUCCESS;
AcquiredExclusive = FALSE;
@@ -3553,7 +3600,7 @@
if (Context->Create.CanonicalNameBuffer != NULL)
{
- ExFreePoolWithTag(Context->Create.CanonicalNameBuffer, RX_MISC_POOLTAG);
+ RxFreePoolWithTag(Context->Create.CanonicalNameBuffer, RX_MISC_POOLTAG);
Context->Create.CanonicalNameBuffer = NULL;
Context->AlsoCanonicalNameBuffer = NULL;
}
@@ -4825,7 +4872,7 @@
RxContext->MajorFunction = IRP_MJ_CREATE;
/* Fake canon name */
- RxContext->PrefixClaim.SuppliedPathName.Buffer =
ExAllocatePoolWithTag(NonPagedPool, QueryRequest->PathNameLength, RX_MISC_POOLTAG);
+ RxContext->PrefixClaim.SuppliedPathName.Buffer =
RxAllocatePoolWithTag(NonPagedPool, QueryRequest->PathNameLength, RX_MISC_POOLTAG);
if (RxContext->PrefixClaim.SuppliedPathName.Buffer == NULL)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
@@ -4885,7 +4932,7 @@
{
if (RxContext->PrefixClaim.SuppliedPathName.Buffer != NULL)
{
- ExFreePoolWithTag(RxContext->PrefixClaim.SuppliedPathName.Buffer,
RX_MISC_POOLTAG);
+ RxFreePoolWithTag(RxContext->PrefixClaim.SuppliedPathName.Buffer,
RX_MISC_POOLTAG);
}
RxpPrepareCreateContextForReuse(RxContext);
@@ -5151,14 +5198,14 @@
{
Fobx->ContainsWildCards = FsRtlDoesNameContainWildCards(FileName);
- Fobx->UnicodeQueryTemplate.Buffer = RxAllocatePoolWithTag(PagedPool,
FileName->Length, 'cDxR');
+ Fobx->UnicodeQueryTemplate.Buffer = RxAllocatePoolWithTag(PagedPool,
FileName->Length, RX_DIRCTL_POOLTAG);
if (Fobx->UnicodeQueryTemplate.Buffer != NULL)
{
/* UNICODE_STRING; length has to be even */
if ((FileName->Length & 1) != 0)
{
Status = STATUS_INVALID_PARAMETER;
- RxFreePool(Fobx->UnicodeQueryTemplate.Buffer);
+ RxFreePoolWithTag(Fobx->UnicodeQueryTemplate.Buffer,
RX_DIRCTL_POOLTAG);
}
else
{
@@ -6001,7 +6048,7 @@
/* If not TLC provider, allocate one */
if (TopLevelContext == NULL)
{
- TopLevelContext = RxAllocatePoolWithTag(NonPagedPool,
sizeof(RX_TOPLEVELIRP_CONTEXT), '??xR');
+ TopLevelContext = RxAllocatePoolWithTag(NonPagedPool,
sizeof(RX_TOPLEVELIRP_CONTEXT), RX_TLC_POOLTAG);
if (TopLevelContext == NULL)
{
return FALSE;
@@ -6129,7 +6176,7 @@
if (BooleanFlagOn(TopLevelContext->Flags, RX_TOPLEVELCTX_FLAG_FROM_POOL))
{
RxRemoveFromTopLevelIrpAllocatedContextsList(TopLevelContext);
- ExFreePool(TopLevelContext);
+ RxFreePoolWithTag(TopLevelContext, RX_TLC_POOLTAG);
}
}
Modified: trunk/reactos/sdk/lib/drivers/rxce/rxce.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/drivers/rxce/rxce.…
==============================================================================
--- trunk/reactos/sdk/lib/drivers/rxce/rxce.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/drivers/rxce/rxce.c [iso-8859-1] Sat May 27 17:29:11 2017
@@ -69,6 +69,24 @@
RxWorkItemDispatcher(
PVOID Context);
+PVOID
+NTAPI
+_RxAllocatePoolWithTag(
+ _In_ POOL_TYPE PoolType,
+ _In_ SIZE_T NumberOfBytes,
+ _In_ ULONG Tag);
+
+VOID
+NTAPI
+_RxFreePool(
+ _In_ PVOID Buffer);
+
+VOID
+NTAPI
+_RxFreePoolWithTag(
+ _In_ PVOID Buffer,
+ _In_ ULONG Tag);
+
extern ULONG ReadAheadGranularity;
volatile LONG RxNumberOfActiveFcbs = 0;
@@ -86,12 +104,14 @@
RX_WORK_QUEUE_DISPATCHER RxDispatcherWorkQueues;
FAST_MUTEX RxLowIoPagingIoSyncMutex;
BOOLEAN RxContinueFromAssert = TRUE;
+ULONG RxExplodePoolTags = 1;
#if DBG
BOOLEAN DumpDispatchRoutine = TRUE;
#else
BOOLEAN DumpDispatchRoutine = FALSE;
#endif
+#if RDBSS_ASSERTS
#ifdef ASSERT
#undef ASSERT
#endif
@@ -101,6 +121,18 @@
{ \
RxAssert(#exp, __FILE__, __LINE__, NULL); \
}
+#endif
+
+#if RX_POOL_WRAPPER
+#undef RxAllocatePool
+#undef RxAllocatePoolWithTag
+#undef RxFreePool
+
+#define RxAllocatePool(P, S) _RxAllocatePoolWithTag(P, S, 0)
+#define RxAllocatePoolWithTag _RxAllocatePoolWithTag
+#define RxFreePool _RxFreePool
+#define RxFreePoolWithTag _RxFreePoolWithTag
+#endif
/* FUNCTIONS ****************************************************************/
@@ -225,7 +257,7 @@
/* Otherwise, allocate it */
else
{
- Buffer = ExAllocatePoolWithTag(PoolType, NameSize + FcbSize + SrvOpenSize +
FobxSize + NonPagedSize, RX_FCB_POOLTAG);
+ Buffer = RxAllocatePoolWithTag(PoolType, NameSize + FcbSize + SrvOpenSize +
FobxSize + NonPagedSize, RX_FCB_POOLTAG);
if (Buffer == NULL)
{
return NULL;
@@ -260,10 +292,10 @@
/* If we were not allocated from non paged, allocate the NON_PAGED_FCB now */
if (PoolType != NonPagedPool)
{
- NonPagedFcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(NON_PAGED_FCB),
RX_NONPAGEDFCB_POOLTAG);
+ NonPagedFcb = RxAllocatePoolWithTag(NonPagedPool, sizeof(NON_PAGED_FCB),
RX_NONPAGEDFCB_POOLTAG);
if (NonPagedFcb == NULL)
{
- ExFreePoolWithTag(Buffer, RX_FCB_POOLTAG);
+ RxFreePoolWithTag(Buffer, RX_FCB_POOLTAG);
return NULL;
}
@@ -399,7 +431,7 @@
/* Now, allocate the object */
ObjectSize = ExtensionSize + StructSize + NameLength;
- Object = ExAllocatePoolWithTag(NonPagedPool, ObjectSize, Tag);
+ Object = RxAllocatePoolWithTag(NonPagedPool, ObjectSize, Tag);
if (Object == NULL)
{
return NULL;
@@ -731,7 +763,7 @@
ASSERT(*LockHoldingState == LHS_ExclusiveLockHeld);
/* Allocate the context */
- Context = ExAllocatePoolWithTag(PagedPool, sizeof(MRX_CREATENETROOT_CONTEXT),
RX_SRVCALL_POOLTAG);
+ Context = RxAllocatePoolWithTag(PagedPool, sizeof(MRX_CREATENETROOT_CONTEXT),
RX_SRVCALL_POOLTAG);
if (Context == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -797,7 +829,7 @@
RxTransitionVNetRoot(VirtualNetRoot, VRootCondition);
/* Context is not longer needed */
- ExFreePoolWithTag(Context, RX_SRVCALL_POOLTAG);
+ RxFreePoolWithTag(Context, RX_SRVCALL_POOLTAG);
DPRINT("Status: %x\n", Status);
@@ -829,7 +861,7 @@
ASSERT(*LockHoldingState == LHS_ExclusiveLockHeld);
/* Allocate the context for mini-rdr */
- Calldown = ExAllocatePoolWithTag(NonPagedPool, sizeof(MRX_SRVCALLDOWN_STRUCTURE),
RX_SRVCALL_POOLTAG);
+ Calldown = RxAllocatePoolWithTag(NonPagedPool, sizeof(MRX_SRVCALLDOWN_STRUCTURE),
RX_SRVCALL_POOLTAG);
if (Calldown == NULL)
{
SrvCall->Context = NULL;
@@ -1893,7 +1925,7 @@
PRX_WORK_DISPATCH_ITEM DispatchItem;
/* Allocate a bit of context */
- DispatchItem = ExAllocatePoolWithTag(PagedPool, sizeof(RX_WORK_DISPATCH_ITEM),
RX_WORKQ_POOLTAG);
+ DispatchItem = RxAllocatePoolWithTag(PagedPool, sizeof(RX_WORK_DISPATCH_ITEM),
RX_WORKQ_POOLTAG);
if (DispatchItem == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
@@ -1909,7 +1941,7 @@
Status = RxInsertWorkQueueItem(pMRxDeviceObject, WorkQueueType, DispatchItem);
if (!NT_SUCCESS(Status))
{
- ExFreePoolWithTag(DispatchItem, RX_WORKQ_POOLTAG);
+ RxFreePoolWithTag(DispatchItem, RX_WORKQ_POOLTAG);
DPRINT1("RxInsertWorkQueueItem failed! Queue: %ld, Routine: %p, Context: %p,
Status: %lx\n", WorkQueueType, Routine, pContext, Status);
}
@@ -2188,7 +2220,7 @@
Entry = ThisFcb->BufferedLocks.List;
ThisFcb->BufferedLocks.List = Entry->Next;
- ExFreePool(Entry);
+ RxFreePool(Entry);
}
}
@@ -2221,7 +2253,7 @@
/* Now, release everything */
if (ThisFcb->pBufferingStateChangeCompletedEvent != NULL)
{
- ExFreePool(ThisFcb->pBufferingStateChangeCompletedEvent);
+ RxFreePool(ThisFcb->pBufferingStateChangeCompletedEvent);
}
if (ThisFcb->MRxDispatch != NULL)
@@ -2965,7 +2997,7 @@
RxAcquirePrefixTableLockExclusive(PrefixTable, TRUE);
RxTransitionSrvCall(SrvCall, Condition);
- ExFreePoolWithTag(Calldown, RX_SRVCALL_POOLTAG);
+ RxFreePoolWithTag(Calldown, RX_SRVCALL_POOLTAG);
/* If async, finish it here, otherwise, caller has already finished the stuff */
if (BooleanFlagOn(Context->Flags, RX_CONTEXT_FLAG_ASYNC_OPERATION))
@@ -2994,7 +3026,7 @@
{
if (Context->Info.Buffer != NULL)
{
- ExFreePool(Context->Info.Buffer);
+ RxFreePool(Context->Info.Buffer);
Context->Info.Buffer = NULL;
}
}
@@ -5397,17 +5429,17 @@
/* Only free what could have been allocated */
if (UserName != NULL)
{
- ExFreePool(UserName);
+ RxFreePool(UserName);
}
if (UserDomainName != NULL)
{
- ExFreePool(UserDomainName);
+ RxFreePool(UserDomainName);
}
if (Password != NULL)
{
- ExFreePool(Password);
+ RxFreePool(Password);
}
/* And remove the possibly set CSC agent flag */
@@ -5639,7 +5671,43 @@
DispatchItem->DispatchRoutine(DispatchItem->DispatchRoutineParameter);
- ExFreePoolWithTag(DispatchItem, RX_WORKQ_POOLTAG);
+ RxFreePoolWithTag(DispatchItem, RX_WORKQ_POOLTAG);
+}
+
+/*
+ * @implemented
+ */
+PVOID
+NTAPI
+_RxAllocatePoolWithTag(
+ _In_ POOL_TYPE PoolType,
+ _In_ SIZE_T NumberOfBytes,
+ _In_ ULONG Tag)
+{
+ return ExAllocatePoolWithTagPriority(PoolType, NumberOfBytes, Tag, LowPoolPriority);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+_RxFreePool(
+ _In_ PVOID Buffer)
+{
+ ExFreePoolWithTag(Buffer, 0);
+}
+
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+_RxFreePoolWithTag(
+ _In_ PVOID Buffer,
+ _In_ ULONG Tag)
+{
+ ExFreePoolWithTag(Buffer, Tag);
}
NTSTATUS