Index: drivers/network/tcpip/datalink/lan.c =================================================================== --- drivers/network/tcpip/datalink/lan.c (revision 71963) +++ drivers/network/tcpip/datalink/lan.c (working copy) @@ -138,8 +138,9 @@ ULONG BytesCopied; NDIS_STATUS Status; - HeaderBuffer = ExAllocatePool(NonPagedPool, - Adapter->HeaderSize); + HeaderBuffer = ExAllocatePoolWithTag(NonPagedPool, + Adapter->HeaderSize, + HEADER_TAG); if (!HeaderBuffer) return NDIS_STATUS_RESOURCES; @@ -151,7 +152,7 @@ if (BytesCopied != Adapter->HeaderSize) { /* Runt frame */ - ExFreePool(HeaderBuffer); + ExFreePoolWithTag(HeaderBuffer, HEADER_TAG); TI_DbgPrint(DEBUG_DATALINK, ("Runt frame (size %d).\n", BytesCopied)); return NDIS_STATUS_NOT_ACCEPTED; } @@ -161,7 +162,7 @@ BytesCopied, PacketType); - ExFreePool(HeaderBuffer); + ExFreePoolWithTag(HeaderBuffer, HEADER_TAG); return Status; } @@ -607,7 +608,7 @@ } else { - KeyValueInfo = ExAllocatePool(PagedPool, sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 * sizeof(WCHAR)); + KeyValueInfo = ExAllocatePoolWithTag(PagedPool, sizeof(KEY_VALUE_PARTIAL_INFORMATION) + 16 * sizeof(WCHAR), KEY_VALUE_TAG); if (!KeyValueInfo) { ZwClose(ParameterHandle); @@ -696,6 +697,7 @@ } } + ExFreePoolWithTag(KeyValueInfo, KEY_VALUE_TAG); ZwClose(ParameterHandle); } @@ -823,7 +825,7 @@ if (!Adapter->Context) return; - Context = ExAllocatePool(NonPagedPool, sizeof(RECONFIGURE_CONTEXT)); + Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(RECONFIGURE_CONTEXT), CONTEXT_TAG); if (!Context) return; @@ -836,7 +838,7 @@ if (Adapter->State == LAN_STATE_STARTED) { - ExFreePool(Context); + ExFreePoolWithTag(Context, CONTEXT_TAG); return; } @@ -848,7 +850,7 @@ if (Adapter->State == LAN_STATE_STOPPED) { - ExFreePool(Context); + ExFreePoolWithTag(Context, CONTEXT_TAG); return; } @@ -859,7 +861,7 @@ Adapter->OldState = Adapter->State; Adapter->State = LAN_STATE_RESETTING; /* Nothing else to do here */ - ExFreePool(Context); + ExFreePoolWithTag(Context, CONTEXT_TAG); return; case NDIS_STATUS_RESET_END: @@ -869,13 +871,13 @@ default: DbgPrint("Unhandled status: %x", GeneralStatus); - ExFreePool(Context); + ExFreePoolWithTag(Context, CONTEXT_TAG); return; } /* Queue the work item */ if (!ChewCreate(ReconfigureAdapterWorker, Context)) - ExFreePool(Context); + ExFreePoolWithTag(Context, CONTEXT_TAG); } VOID NTAPI ProtocolStatusComplete(NDIS_HANDLE NdisBindingContext) @@ -1108,8 +1110,8 @@ UnicodeString.MaximumLength = Information->DataLength; String->Buffer = - (PWCHAR)ExAllocatePool( NonPagedPool, - UnicodeString.MaximumLength + sizeof(WCHAR) ); + (PWCHAR)ExAllocatePoolWithTag( NonPagedPool, + UnicodeString.MaximumLength + sizeof(WCHAR), REG_STR_TAG ); if( !String->Buffer ) return STATUS_NO_MEMORY; @@ -1135,9 +1137,9 @@ BOOLEAN Deallocate) { NTSTATUS Status; UNICODE_STRING Ustr = *ResultFirst; - PWSTR new_string = ExAllocatePool + PWSTR new_string = ExAllocatePoolWithTag (PagedPool, - (ResultFirst->Length + Second->Length + sizeof(WCHAR))); + (ResultFirst->Length + Second->Length + sizeof(WCHAR)), TEMP_STRING_TAG); if( !new_string ) { return STATUS_NO_MEMORY; } @@ -1150,7 +1152,7 @@ new_string[ResultFirst->Length / sizeof(WCHAR)] = 0; Status = RtlCreateUnicodeString(ResultFirst,new_string) ? STATUS_SUCCESS : STATUS_NO_MEMORY; - ExFreePool(new_string); + ExFreePoolWithTag(new_string, TEMP_STRING_TAG); return Status; } @@ -1213,7 +1215,7 @@ NTSTATUS Status; ULONG i; KEY_BASIC_INFORMATION *Kbio = - ExAllocatePool(NonPagedPool, sizeof(KEY_BASIC_INFORMATION)); + ExAllocatePoolWithTag(NonPagedPool, sizeof(KEY_BASIC_INFORMATION), KBIO_TAG); ULONG KbioLength = sizeof(KEY_BASIC_INFORMATION), ResultLength; RtlInitUnicodeString( DeviceDesc, NULL ); @@ -1228,7 +1230,7 @@ if( !NT_SUCCESS(Status) ) { TI_DbgPrint(DEBUG_DATALINK,("Couldn't open Enum key %wZ: %x\n", &EnumKeyName, Status)); - ExFreePool( Kbio ); + ExFreePoolWithTag( Kbio, KBIO_TAG ); return Status; } @@ -1237,9 +1239,9 @@ Kbio, KbioLength, &ResultLength ); if( Status == STATUS_BUFFER_TOO_SMALL || Status == STATUS_BUFFER_OVERFLOW ) { - ExFreePool( Kbio ); + ExFreePoolWithTag( Kbio, KBIO_TAG ); KbioLength = ResultLength; - Kbio = ExAllocatePool( NonPagedPool, KbioLength ); + Kbio = ExAllocatePoolWithTag( NonPagedPool, KbioLength, KBIO_TAG ); if( !Kbio ) { TI_DbgPrint(DEBUG_DATALINK,("Failed to allocate memory\n")); ZwClose( EnumKey ); @@ -1252,7 +1254,7 @@ if( !NT_SUCCESS(Status) ) { TI_DbgPrint(DEBUG_DATALINK,("Couldn't enum key child %d\n", i)); ZwClose( EnumKey ); - ExFreePool( Kbio ); + ExFreePoolWithTag( Kbio, KBIO_TAG ); return Status; } } @@ -1266,7 +1268,7 @@ ( &EnumKeyName, &TargetKeyName, Name, DeviceDesc ); if( NT_SUCCESS(Status) ) { ZwClose( EnumKey ); - ExFreePool( Kbio ); + ExFreePoolWithTag( Kbio, KBIO_TAG ); return Status; } else Status = STATUS_SUCCESS; } @@ -1273,7 +1275,7 @@ } ZwClose( EnumKey ); - ExFreePool( Kbio ); + ExFreePoolWithTag( Kbio, KBIO_TAG ); return STATUS_UNSUCCESSFUL; } Index: drivers/network/tcpip/include/tags.h =================================================================== --- drivers/network/tcpip/include/tags.h (revision 71963) +++ drivers/network/tcpip/include/tags.h (working copy) @@ -35,3 +35,12 @@ #define OSK_SMALL_TAG 'SKSO' #define LAN_ADAPTER_TAG ' NAL' #define WQ_CONTEXT_TAG 'noCW' +#define ROUTE_ENTRY_TAG 'erCT' +#define OUT_DATA_TAG 'doCT' +#define ARP_ENTRY_TAG 'raCT' +#define KBIO_TAG 'ikCT' +#define TEMP_STRING_TAG 'tsCT' +#define CONTEXT_TAG 'xcCT' +#define KEY_VALUE_TAG 'vkCT' +#define HEADER_TAG 'rhCT' +#define REG_STR_TAG 'srCT' Index: drivers/network/tcpip/tcpip/iinfo.c =================================================================== --- drivers/network/tcpip/tcpip/iinfo.c (revision 71963) +++ drivers/network/tcpip/tcpip/iinfo.c (working copy) @@ -35,7 +35,7 @@ ("Getting IFEntry MIB (IF %08x LA %08x) (%04x:%d)\n", Interface, IF, ID.tei_entity, ID.tei_instance)); - OutData = ExAllocatePool( NonPagedPool, FIELD_OFFSET(IFEntry, if_descr[MAX_ADAPTER_DESCRIPTION_LENGTH + 1])); + OutData = ExAllocatePoolWithTag( NonPagedPool, FIELD_OFFSET(IFEntry, if_descr[MAX_ADAPTER_DESCRIPTION_LENGTH + 1]), OUT_DATA_TAG ); if( !OutData ) return TDI_NO_RESOURCES; /* Out of memory */ @@ -95,7 +95,7 @@ ID.tei_entity, ID.tei_instance, Size)); Status = InfoCopyOut( (PCHAR)OutData, Size, Buffer, BufferSize ); - ExFreePool( OutData ); + ExFreePoolWithTag( OutData, OUT_DATA_TAG ); TI_DbgPrint(DEBUG_INFO,("Returning %x\n", Status)); @@ -113,7 +113,7 @@ if (MemSize != 0) { - ArpEntries = ExAllocatePool( NonPagedPool, MemSize ); + ArpEntries = ExAllocatePoolWithTag( NonPagedPool, MemSize, ARP_ENTRY_TAG ); if( !ArpEntries ) return STATUS_NO_MEMORY; NBCopyNeighbors( Interface, ArpEntries ); @@ -120,7 +120,7 @@ Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize ); - ExFreePool( ArpEntries ); + ExFreePoolWithTag( ArpEntries, ARP_ENTRY_TAG ); } else { Index: drivers/network/tcpip/tcpip/ninfo.c =================================================================== --- drivers/network/tcpip/tcpip/ninfo.c (revision 71963) +++ drivers/network/tcpip/tcpip/ninfo.c (working copy) @@ -29,15 +29,15 @@ if (RtCount == 0) return InfoCopyOut(NULL, 0, NULL, BufferSize); - RouteEntries = ExAllocatePool( NonPagedPool, Size ); + RouteEntries = ExAllocatePoolWithTag( NonPagedPool, Size, ROUTE_ENTRY_TAG ); RtCurrent = RouteEntries; - RCache = ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ); + RCache = ExAllocatePoolWithTag( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount, FIB_TAG ); RCacheCur = RCache; if( !RCache || !RouteEntries ) { - if( RCache ) ExFreePool( RCache ); - if( RouteEntries ) ExFreePool( RouteEntries ); + if( RCache ) ExFreePoolWithTag( RCache, FIB_TAG ); + if( RouteEntries ) ExFreePoolWithTag( RouteEntries, ROUTE_ENTRY_TAG ); return TDI_NO_RESOURCES; } @@ -87,8 +87,8 @@ Status = InfoCopyOut( (PCHAR)RouteEntries, Size, Buffer, BufferSize ); - ExFreePool( RouteEntries ); - ExFreePool( RCache ); + ExFreePoolWithTag( RouteEntries, ROUTE_ENTRY_TAG ); + ExFreePoolWithTag( RCache, FIB_TAG ); TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status)); @@ -122,7 +122,7 @@ return TDI_INVALID_PARAMETER; } - IPEntry = ExAllocatePool(NonPagedPool, sizeof(IPADDR_ENTRY)); + IPEntry = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPADDR_ENTRY), IP_ADDRESS_TAG); if (!IPEntry) { TcpipReleaseSpinLock(&EntityListLock, OldIrql); @@ -147,7 +147,7 @@ InfoCopyOut((PCHAR)IPEntry, sizeof(IPADDR_ENTRY), Buffer, BufferSize); - ExFreePool(IPEntry); + ExFreePoolWithTag(IPEntry, IP_ADDRESS_TAG); return TDI_SUCCESS; } Index: ntoskrnl/mm/ARM3/pool.c =================================================================== --- ntoskrnl/mm/ARM3/pool.c (revision 71963) +++ ntoskrnl/mm/ARM3/pool.c (working copy) @@ -24,7 +24,7 @@ KGUARDED_MUTEX MmPagedPoolMutex; MM_PAGED_POOL_INFO MmPagedPoolInfo; SIZE_T MmAllocatedNonPagedPool; -ULONG MmSpecialPoolTag; +ULONG MmSpecialPoolTag = 1; ULONG MmConsumedPoolPercentage; BOOLEAN MmProtectFreedNonPagedPool; SLIST_HEADER MiNonPagedPoolSListHead; Index: ntoskrnl/mm/ARM3/special.c =================================================================== --- ntoskrnl/mm/ARM3/special.c (revision 71963) +++ ntoskrnl/mm/ARM3/special.c (working copy) @@ -80,6 +80,53 @@ if (NumberOfBytes > (PAGE_SIZE - sizeof(POOL_HEADER))) return FALSE; + if (Tag == 'enoN') + { + return TRUE; + } + + if (Tag == 'PIwl' || + Tag == 'pEnC' || + Tag == 'FrdA' || + Tag == 'CnoC' || + Tag == 'noCT' || + Tag == 'EidT' || + Tag == 'StaD' || + Tag == 'RtaD' || + Tag == 'noCQ' || + Tag == 'dAPI' || + Tag == 'FIPI' || + Tag == 'RDPI' || + Tag == 'GFPI' || + Tag == 'LHPI' || + Tag == 'TKSO' || + Tag == 'kPbN' || + Tag == ' ECN' || + Tag == 'teSP' || + Tag == 'fuBP' || + Tag == 'taDF' || + Tag == ' BIF' || + Tag == ' CFI' || + Tag == 'BidT' || + Tag == 'DSBF' || + Tag == 'OKSO' || + Tag == 'LKSO' || + Tag == 'SKSO' || + Tag == ' NAL' || + Tag == 'noCW' || + Tag == 'erCT' || + Tag == 'doCT' || + Tag == 'raCT' || + Tag == 'ikCT' || + Tag == 'tsCT' || + Tag == 'xcCT' || + Tag == 'vkCT' || + Tag == 'rhCT' || + Tag == 'srCT') + { + return TRUE; + } + return Tag == MmSpecialPoolTag; }