- Remove memtrack and use tags instead (ExAllocatePoolWithTag/ExFreePoolWithTag)
authorCameron Gutman <aicommander@gmail.com>
Sat, 21 Nov 2009 23:53:43 +0000 (23:53 +0000)
committerCameron Gutman <aicommander@gmail.com>
Sat, 21 Nov 2009 23:53:43 +0000 (23:53 +0000)
 - Cleanup DriverEntry
 - Remove DEFINE_TAG
 - Remove checkpoints in TiCreateFileObject

svn path=/trunk/; revision=44266

35 files changed:
reactos/drivers/network/tcpip/datalink/lan.c
reactos/drivers/network/tcpip/include/address.h
reactos/drivers/network/tcpip/include/debug.h
reactos/drivers/network/tcpip/include/dispatch.h
reactos/drivers/network/tcpip/include/ip.h
reactos/drivers/network/tcpip/include/irp.h [deleted file]
reactos/drivers/network/tcpip/include/memtrack.h [deleted file]
reactos/drivers/network/tcpip/include/neighbor.h
reactos/drivers/network/tcpip/include/precomp.h
reactos/drivers/network/tcpip/include/routines.h
reactos/drivers/network/tcpip/include/tags.h [new file with mode: 0644]
reactos/drivers/network/tcpip/include/titypes.h
reactos/drivers/network/tcpip/tcpip.rbuild
reactos/drivers/network/tcpip/tcpip/buffer.c
reactos/drivers/network/tcpip/tcpip/dispatch.c
reactos/drivers/network/tcpip/tcpip/fileobjs.c
reactos/drivers/network/tcpip/tcpip/iinfo.c
reactos/drivers/network/tcpip/tcpip/irp.c [deleted file]
reactos/drivers/network/tcpip/tcpip/main.c
reactos/drivers/network/tcpip/tcpip/ninfo.c
reactos/lib/drivers/ip/ip.rbuild
reactos/lib/drivers/ip/network/address.c
reactos/lib/drivers/ip/network/ip.c
reactos/lib/drivers/ip/network/memtrack.c [deleted file]
reactos/lib/drivers/ip/network/neighbor.c
reactos/lib/drivers/ip/network/ports.c
reactos/lib/drivers/ip/network/receive.c
reactos/lib/drivers/ip/network/router.c
reactos/lib/drivers/ip/network/routines.c
reactos/lib/drivers/ip/network/transmit.c
reactos/lib/drivers/ip/transport/datagram/datagram.c
reactos/lib/drivers/ip/transport/tcp/accept.c
reactos/lib/drivers/ip/transport/tcp/event.c
reactos/lib/drivers/ip/transport/tcp/tcp.c
reactos/lib/drivers/oskittcp/include/memtrack.h [deleted file]

index 2160163..fd0b818 100644 (file)
@@ -108,7 +108,7 @@ VOID FreeAdapter(
  *     Adapter = Pointer to LAN_ADAPTER structure to free
  */
 {
-    exFreePool(Adapter);
+    ExFreePoolWithTag(Adapter, LAN_ADAPTER_TAG);
 }
 
 
@@ -249,7 +249,7 @@ VOID LanReceiveWorker( PVOID Context ) {
     Adapter = WorkItem->Adapter;
     BytesTransferred = WorkItem->BytesTransferred;
 
-    exFreePool(WorkItem);
+    ExFreePoolWithTag(WorkItem, WQ_CONTEXT_TAG);
 
     IPInitializePacket(&IPPacket, 0);
 
@@ -300,7 +300,8 @@ VOID LanSubmitReceiveWork(
     PNDIS_PACKET Packet,
     NDIS_STATUS Status,
     UINT BytesTransferred) {
-    PLAN_WQ_ITEM WQItem = exAllocatePool(NonPagedPool, sizeof(LAN_WQ_ITEM));
+    PLAN_WQ_ITEM WQItem = ExAllocatePoolWithTag(NonPagedPool, sizeof(LAN_WQ_ITEM),
+                                                WQ_CONTEXT_TAG);
     PLAN_ADAPTER Adapter = (PLAN_ADAPTER)BindingContext;
 
     TI_DbgPrint(DEBUG_DATALINK,("called\n"));
@@ -312,7 +313,7 @@ VOID LanSubmitReceiveWork(
     WQItem->BytesTransferred = BytesTransferred;
 
     if (!ChewCreate( LanReceiveWorker, WQItem ))
-        exFreePool(WQItem);
+        ExFreePoolWithTag(WQItem, WQ_CONTEXT_TAG);
 }
 
 VOID NTAPI ProtocolTransferDataComplete(
@@ -768,9 +769,9 @@ NTSTATUS NTAPI AppendUnicodeString(PUNICODE_STRING ResultFirst,
                                   BOOLEAN Deallocate) {
     NTSTATUS Status;
     UNICODE_STRING Ustr = *ResultFirst;
-    PWSTR new_string = ExAllocatePoolWithTag
+    PWSTR new_string = ExAllocatePool
         (PagedPool,
-         (ResultFirst->Length + Second->Length + sizeof(WCHAR)), TAG_STRING);
+         (ResultFirst->Length + Second->Length + sizeof(WCHAR)));
     if( !new_string ) {
        return STATUS_NO_MEMORY;
     }
@@ -1087,7 +1088,7 @@ NDIS_STATUS LANRegisterAdapter(
 
     TI_DbgPrint(DEBUG_DATALINK, ("Called.\n"));
 
-    IF = exAllocatePool(NonPagedPool, sizeof(LAN_ADAPTER));
+    IF = ExAllocatePoolWithTag(NonPagedPool, sizeof(LAN_ADAPTER), LAN_ADAPTER_TAG);
     if (!IF) {
         TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
         return NDIS_STATUS_RESOURCES;
@@ -1125,7 +1126,7 @@ NDIS_STATUS LANRegisterAdapter(
         KeWaitForSingleObject(&IF->Event, UserRequest, KernelMode, FALSE, NULL);
     else if (NdisStatus != NDIS_STATUS_SUCCESS) {
        TI_DbgPrint(DEBUG_DATALINK,("denying adapter %wZ\n", AdapterName));
-       exFreePool(IF);
+       ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
         return NdisStatus;
     }
 
@@ -1150,7 +1151,7 @@ NDIS_STATUS LANRegisterAdapter(
     default:
         /* Unsupported media */
         TI_DbgPrint(MIN_TRACE, ("Unsupported media.\n"));
-        exFreePool(IF);
+        ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
         return NDIS_STATUS_NOT_SUPPORTED;
     }
 
@@ -1162,7 +1163,7 @@ NDIS_STATUS LANRegisterAdapter(
                           sizeof(UINT));
     if (NdisStatus != NDIS_STATUS_SUCCESS) {
        TI_DbgPrint(DEBUG_DATALINK,("denying adapter %wZ (NDISCall)\n", AdapterName));
-        exFreePool(IF);
+        ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
         return NdisStatus;
     }
 
@@ -1174,7 +1175,7 @@ NDIS_STATUS LANRegisterAdapter(
                           sizeof(UINT));
     if (NdisStatus != NDIS_STATUS_SUCCESS) {
         TI_DbgPrint(MIN_TRACE, ("Query for maximum packet size failed.\n"));
-        exFreePool(IF);
+        ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
         return NdisStatus;
     }
 
@@ -1197,7 +1198,7 @@ NDIS_STATUS LANRegisterAdapter(
                           IF->HWAddressLength);
     if (NdisStatus != NDIS_STATUS_SUCCESS) {
         TI_DbgPrint(MIN_TRACE, ("Query for current hardware address failed.\n"));
-        exFreePool(IF);
+        ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
         return NdisStatus;
     }
 
@@ -1209,7 +1210,7 @@ NDIS_STATUS LANRegisterAdapter(
                           sizeof(UINT));
     if (NdisStatus != NDIS_STATUS_SUCCESS) {
         TI_DbgPrint(MIN_TRACE, ("Query for maximum link speed failed.\n"));
-        exFreePool(IF);
+        ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
         return NdisStatus;
     }
 
@@ -1219,7 +1220,7 @@ NDIS_STATUS LANRegisterAdapter(
     /* Bind adapter to IP layer */
     if( !BindAdapter(IF, RegistryPath) ) {
        TI_DbgPrint(DEBUG_DATALINK,("denying adapter %wZ (BindAdapter)\n", AdapterName));
-       exFreePool(IF);
+       ExFreePoolWithTag(IF, LAN_ADAPTER_TAG);
        return NDIS_STATUS_NOT_ACCEPTED;
     }
 
index 71a0f87..1bd1dbd 100644 (file)
@@ -15,7 +15,6 @@
  */
 #define AddrInitIPv4(IPAddress, RawAddress)           \
 {                                                     \
-    INIT_TAG((IPAddress), '4VPI');      \
     (IPAddress)->Type                = IP_ADDRESS_V4; \
     (IPAddress)->Address.IPv4Address = (RawAddress);  \
 }
index 3bf4fb3..7f6d86b 100644 (file)
@@ -71,8 +71,6 @@
 
 #define CP CHECKPOINT
 
-#include <memtrack.h>
-
 #define ASSERT_KM_POINTER(_x) \
    ASSERT(((PVOID)_x) != (PVOID)0xcccccccc); \
    ASSERT(((PVOID)_x) >= (PVOID)0x80000000);
index f934425..6be0f26 100644 (file)
@@ -72,6 +72,8 @@ NTSTATUS DispTdiDeleteIPAddress(
 VOID DispDoDisconnect(
     PVOID Data);
 
+NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status );
+
 #endif /* __DISPATCH_H */
 
 /* EOF */
index 61f8e7a..068992f 100644 (file)
@@ -21,7 +21,6 @@ typedef IPv6_RAW_ADDRESS *PIPv6_RAW_ADDRESS;
 
 /* IP style address */
 typedef struct IP_ADDRESS {
-    DEFINE_TAG
     UCHAR Type;                      /* Type of IP address */
     union {
         IPv4_RAW_ADDRESS IPv4Address;/* IPv4 address (in network byte order) */
@@ -76,7 +75,6 @@ typedef VOID (*PACKET_COMPLETION_ROUTINE)(
 
 /* Structure for an IP packet */
 typedef struct _IP_PACKET {
-    DEFINE_TAG
     OBJECT_FREE_ROUTINE Free;           /* Routine used to free resources for the object */
     UCHAR Type;                         /* Type of IP packet (see IP_ADDRESS_xx above) */
     UCHAR Flags;                        /* Flags for packet (see IP_PACKET_FLAG_xx below)*/
@@ -150,7 +148,6 @@ typedef struct _SEND_RECV_STATS {
 
 /* Information about an IP interface */
 typedef struct _IP_INTERFACE {
-    DEFINE_TAG
     LIST_ENTRY ListEntry;         /* Entry on list */
     OBJECT_FREE_ROUTINE Free;     /* Routine used to free resources used by the object */
     KSPIN_LOCK Lock;              /* Spin lock for this object */
diff --git a/reactos/drivers/network/tcpip/include/irp.h b/reactos/drivers/network/tcpip/include/irp.h
deleted file mode 100644 (file)
index 5322009..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS TCP/IP protocol driver
- * FILE:        include/irp.h
- * PURPOSE:     IRP routines
- */
-#ifndef __IRP_H
-#define __IRP_H
-
-VOID IRPRemember( PIRP Irp, PCHAR File, UINT Line );
-NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status );
-
-#endif/*__IRP_H*/
diff --git a/reactos/drivers/network/tcpip/include/memtrack.h b/reactos/drivers/network/tcpip/include/memtrack.h
deleted file mode 100644 (file)
index 778d7b7..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef MEMTRACK_H
-#define MEMTRACK_H
-
-#include <pool.h>
-
-#ifndef FOURCC
-#define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#endif
-
-#define FBSD_MALLOC FOURCC('d','s','b','f')
-#define EXALLOC_TAG FOURCC('E','x','A','l')
-#define IRP_TAG     FOURCC('P','I','R','P')
-#define NPLOOK_TAG  FOURCC('N','P','L','A')
-
-#define AllocatePacketWithBuffer(x,y,z) AllocatePacketWithBufferX(x,y,z,__FILE__,__LINE__)
-#define FreeNdisPacket(x) FreeNdisPacketX(x,__FILE__,__LINE__)
-
-#if DBG
-#define MTMARK() TrackDumpFL(__FILE__, __LINE__)
-#define exAllocatePool(x,y) ExAllocatePoolX(x,y,__FILE__,__LINE__)
-#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolX(x,y,__FILE__,__LINE__)
-#define exFreePool(x) ExFreePoolX(x,__FILE__,__LINE__)
-#define exAllocateFromNPagedLookasideList(x) ExAllocateFromNPagedLookasideListX(x,__FILE__,__LINE__)
-#define exFreeToNPagedLookasideList(x,y) ExFreeToNPagedLookasideListX(x,y,__FILE__,__LINE__)
-
-typedef struct _ALLOCATION_TRACKER {
-    LIST_ENTRY Entry;
-    ULONG Tag;
-    PVOID Thing;
-    PCHAR FileName;
-    ULONG LineNo;
-} ALLOCATION_TRACKER, *PALLOCATION_TRACKER;
-
-VOID TrackingInit();
-VOID TrackWithTag( ULONG Tag, PVOID Thing, PCHAR File, ULONG Line );
-#define Track(Tag,Thing) TrackWithTag(Tag,Thing,__FILE__,__LINE__)
-VOID UntrackFL( PCHAR File, ULONG Line, PVOID Thing, ULONG Tag );
-#define Untrack(Thing) UntrackFL(__FILE__,__LINE__,Thing)
-VOID TrackDumpFL( PCHAR File, ULONG Line );
-#define TrackDump() TrackDumpFL(__FILE__,__LINE__)
-
-static __inline PVOID ExAllocateFromNPagedLookasideListX( PNPAGED_LOOKASIDE_LIST List, PCHAR File, ULONG Line ) {
-    PVOID Out = ExAllocateFromNPagedLookasideList( List );
-    if( Out ) TrackWithTag( NPLOOK_TAG, Out, File, Line );
-    return Out;
-}
-
-static __inline VOID ExFreeToNPagedLookasideListX( PNPAGED_LOOKASIDE_LIST List, PVOID Thing, PCHAR File, ULONG Line ) {
-    UntrackFL(File, Line, Thing, NPLOOK_TAG);
-    ExFreeToNPagedLookasideList( List, Thing );
-}
-
-static __inline PVOID ExAllocatePoolX( POOL_TYPE type, SIZE_T size, PCHAR File, ULONG Line ) {
-    PVOID Out = ExAllocatePool( type, size );
-    if( Out ) TrackWithTag( EXALLOC_TAG, Out, File, Line );
-    return Out;
-}
-
-static __inline VOID ExFreePoolX( PVOID Data, PCHAR File, ULONG Line ) {
-    UntrackFL(File, Line, Data, EXALLOC_TAG);
-    ExFreePool( Data );
-}
-
-#else
-#define MTMARK()
-#define Track(x,y)
-#define TrackingInit()
-#define TrackDump()
-#define Untrack(x)
-#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolWithTag(x,y,z)
-#define exAllocatePool(x,y) ExAllocatePool(x,y)
-#define exFreePool(x) ExFreePool(x)
-#define exAllocateFromNPagedLookasideList(x) ExAllocateFromNPagedLookasideList(x)
-#define exFreeToNPagedLookasideList(x,y) ExFreeToNPagedLookasideList(x,y)
-#define TrackWithTag(w,x,y,z)
-#define UntrackFL(w,x,y,z)
-#endif
-
-#endif/*MEMMTRAC_H*/
index 95ea1f9..6f125f0 100644 (file)
@@ -27,7 +27,6 @@ typedef struct NEIGHBOR_CACHE_TABLE {
 
 /* Information about a neighbor */
 typedef struct NEIGHBOR_CACHE_ENTRY {
-    DEFINE_TAG
     struct NEIGHBOR_CACHE_ENTRY *Next;  /* Pointer to next entry */
     UCHAR State;                        /* State of NCE */
     UINT EventTimer;                    /* Ticks since last event */
index a7b2c88..f37046d 100644 (file)
@@ -1,6 +1,7 @@
 #include <limits.h>
 #include <ntddk.h>
 #include <ntifs.h>
+#include <tags.h>
 #include <tdi.h>
 #include <tdistat.h>
 #include <tcpip.h>
 #include <udp.h>
 #include <tcp.h>
 #include <arp.h>
-#include <irp.h>
 #include <tilists.h>
 #include <dispatch.h>
 #include <fileobjs.h>
 #include <lock.h>
 #include <wait.h>
-#include <memtrack.h>
 #include <oskittcp.h>
 #include <interface.h>
 #include <ports.h>
index 31d7075..1fda0e5 100644 (file)
@@ -49,9 +49,10 @@ UINT ResizePacket(
     PNDIS_PACKET Packet,
     UINT Size);
 
-NDIS_STATUS AllocatePacketWithBufferX( PNDIS_PACKET *NdisPacket,
-                                      PCHAR Data, UINT Len,
-                                      PCHAR File, UINT Line );
+NDIS_STATUS AllocatePacketWithBuffer( PNDIS_PACKET *NdisPacket,
+                                      PCHAR Data, UINT Len );
+
+VOID FreeNdisPacket( PNDIS_PACKET Packet );
 
 void GetDataPtr( PNDIS_PACKET Packet,
                 UINT Offset,
diff --git a/reactos/drivers/network/tcpip/include/tags.h b/reactos/drivers/network/tcpip/include/tags.h
new file mode 100644 (file)
index 0000000..52c16a4
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS TCP/IP protocol driver
+ * FILE:        include/tags.h
+ * PURPOSE:     Memory tags
+ */
+#ifndef __TAGS_H
+#define __TAGS_H
+
+#define CONN_ENDPT_TAG 'pEnC'
+#define ADDR_FILE_TAG 'FrdA'
+#define CONTROL_CHANNEL_TAG 'CnoC'
+#define TRANS_CONTEXT_TAG 'noCT'
+#define TDI_ENTITY_TAG 'EidT'
+#define DATAGRAM_SEND_TAG 'StaD'
+#define DATAGRAM_RECV_TAG 'RtaD'
+#define QUERY_CONTEXT_TAG 'noCQ'
+#define IP_ADDRESS_TAG 'dAPI'
+#define IP_INTERFACE_TAG 'FIPI'
+#define DATAGRAM_REASSEMBLY_TAG 'RDPI'
+#define DATAGRAM_FRAGMENT_TAG 'GFPI'
+#define DATAGRAM_HOLE_TAG 'LHPI'
+#define OSKITTCP_CONTEXT_TAG 'TKSO'
+#define NEIGHBOR_PACKET_TAG 'kPbN'
+#define NCE_TAG ' ECN'
+#define PORT_SET_TAG 'teSP'
+#define PACKET_BUFFER_TAG 'fuBP'
+#define FRAGMENT_DATA_TAG 'taDF'
+#define FIB_TAG ' BIF'
+#define IFC_TAG ' CFI'
+#define TDI_BUCKET_TAG 'BidT'
+#define FBSD_TAG 'DSBF'
+#define OSK_OTHER_TAG 'OKSO'
+#define OSK_LARGE_TAG 'LKSO'
+#define OSK_SMALL_TAG 'SKSO'
+#define LAN_ADAPTER_TAG ' NAL'
+#define WQ_CONTEXT_TAG 'noCW'
+
+#endif
index 88a02bb..78584fb 100644 (file)
 
 #if DBG
 
-#define DEFINE_TAG ULONG Tag;
-#define INIT_TAG(_Object, _Tag) \
-  ((_Object)->Tag = (_Tag))
-
 #define DEBUG_REFCHECK(Object) {        \
    if ((Object)->RefCount <= 0) {       \
       TI_DbgPrint(MIN_TRACE, ("Object at (0x%X) has invalid reference count (%d).\n", \
@@ -64,9 +60,6 @@
 
 #else /* DBG */
 
-#define DEFINE_TAG
-#define INIT_TAG(Object, Tag)
-
 /*
  * VOID ReferenceObject(
  *     PVOID Object)
@@ -149,7 +142,6 @@ typedef struct _DATAGRAM_SEND_REQUEST {
 /* Transport address file context structure. The FileObject->FsContext2
    field holds a pointer to this structure */
 typedef struct _ADDRESS_FILE {
-    DEFINE_TAG
     LIST_ENTRY ListEntry;                 /* Entry on list */
     KSPIN_LOCK Lock;                      /* Spin lock to manipulate this structure */
     OBJECT_FREE_ROUTINE Free;             /* Routine to use to free resources for the object */
index 4dd14d3..ea9d3a6 100644 (file)
@@ -28,7 +28,6 @@
                <file>fileobjs.c</file>
                <file>iinfo.c</file>
                <file>info.c</file>
-               <file>irp.c</file>
                <file>lock.c</file>
                <file>main.c</file>
                <file>ninfo.c</file>
index e604c7b..6858dde 100644 (file)
@@ -318,13 +318,16 @@ NDIS_STATUS PrependPacket( PNDIS_PACKET Packet, PCHAR Data, UINT Length,
     PCHAR NewBuf;
 
     if( Copy ) {
-       NewBuf = exAllocatePool( NonPagedPool, Length );
+       NewBuf = ExAllocatePoolWithTag( NonPagedPool, Length, PACKET_BUFFER_TAG );
        if( !NewBuf ) return NDIS_STATUS_RESOURCES;
        RtlCopyMemory( NewBuf, Data, Length );
     } else NewBuf = Data;
 
     NdisAllocateBuffer( &Status, &Buffer, GlobalBufferPool, NewBuf, Length );
-    if( Status != NDIS_STATUS_SUCCESS ) return Status;
+    if( Status != NDIS_STATUS_SUCCESS ) {
+        if (Copy) ExFreePoolWithTag(NewBuf, PACKET_BUFFER_TAG);
+        return Status;
+    }
 
     NdisChainBufferAtFront( Packet, Buffer );
 
@@ -342,33 +345,30 @@ void GetDataPtr( PNDIS_PACKET Packet,
     SkipToOffset( Buffer, Offset, DataOut, Size );
 }
 
-NDIS_STATUS AllocatePacketWithBufferX( PNDIS_PACKET *NdisPacket,
-                                      PCHAR Data, UINT Len,
-                                      PCHAR File, UINT Line ) {
+NDIS_STATUS AllocatePacketWithBuffer( PNDIS_PACKET *NdisPacket,
+                                     PCHAR Data, UINT Len ) {
     PNDIS_PACKET Packet;
     PNDIS_BUFFER Buffer;
     NDIS_STATUS Status;
     PCHAR NewData;
 
-    NewData = exAllocatePool( NonPagedPool, Len );
+    NewData = ExAllocatePoolWithTag( NonPagedPool, Len, PACKET_BUFFER_TAG );
     if( !NewData ) return NDIS_STATUS_RESOURCES;
 
     if( Data ) RtlCopyMemory(NewData, Data, Len);
 
     NdisAllocatePacket( &Status, &Packet, GlobalPacketPool );
     if( Status != NDIS_STATUS_SUCCESS ) {
-       exFreePool( NewData );
+       ExFreePoolWithTag( NewData, PACKET_BUFFER_TAG );
        return Status;
     }
-    TrackWithTag(NDIS_PACKET_TAG, Packet, File, Line);
 
     NdisAllocateBuffer( &Status, &Buffer, GlobalBufferPool, NewData, Len );
     if( Status != NDIS_STATUS_SUCCESS ) {
-       exFreePool( NewData );
+       ExFreePoolWithTag( NewData, PACKET_BUFFER_TAG );
        FreeNdisPacket( Packet );
        return Status;
     }
-    TrackWithTag(NDIS_BUFFER_TAG, Buffer, File, Line);
 
     NdisChainBufferAtFront( Packet, Buffer );
     *NdisPacket = Packet;
@@ -377,10 +377,8 @@ NDIS_STATUS AllocatePacketWithBufferX( PNDIS_PACKET *NdisPacket,
 }
 
 
-VOID FreeNdisPacketX
-( PNDIS_PACKET Packet,
-  PCHAR File,
-  UINT Line )
+VOID FreeNdisPacket
+( PNDIS_PACKET Packet )
 /*
  * FUNCTION: Frees an NDIS packet
  * ARGUMENTS:
@@ -400,13 +398,11 @@ VOID FreeNdisPacketX
         NdisGetNextBuffer(Buffer, &NextBuffer);
         NdisQueryBuffer(Buffer, &Data, &Length);
        TI_DbgPrint(DEBUG_PBUFFER, ("Freeing ndis buffer (0x%X)\n", Buffer));
-       UntrackFL(File,Line,Buffer,NDIS_BUFFER_TAG);
         NdisFreeBuffer(Buffer);
        TI_DbgPrint(DEBUG_PBUFFER, ("Freeing exal buffer (0x%X)\n", Data));
-        exFreePool(Data);
+        ExFreePoolWithTag(Data, PACKET_BUFFER_TAG);
     }
 
     /* Finally free the NDIS packet discriptor */
-    UntrackFL(File,Line,Packet,NDIS_PACKET_TAG);
     NdisFreePacket(Packet);
 }
index d08ef8a..c78aece 100644 (file)
 #include "precomp.h"
 #include <pseh/pseh2.h>
 
+
+NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status ) {
+    KIRQL OldIrql;
+
+    Irp->IoStatus.Status = Status;
+
+    if( Status == STATUS_PENDING )
+       IoMarkIrpPending( Irp );
+    else {
+        IoAcquireCancelSpinLock(&OldIrql);
+       (void)IoSetCancelRoutine( Irp, NULL );
+        IoReleaseCancelSpinLock(OldIrql);
+
+       IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
+    }
+
+    return Status;
+}
+
 NTSTATUS DispPrepareIrpForCancel(
     PTRANSPORT_CONTEXT Context,
     PIRP Irp,
@@ -1253,7 +1272,7 @@ VOID DispTdiQueryInformationExComplete(
     QueryContext->Irp->IoStatus.Information = ByteCount;
     QueryContext->Irp->IoStatus.Status      = Status;
 
-    exFreePool(QueryContext);
+    ExFreePoolWithTag(QueryContext, QUERY_CONTEXT_TAG);
 }
 
 
@@ -1316,7 +1335,7 @@ NTSTATUS DispTdiQueryInformationEx(
             IrpSp->Parameters.DeviceIoControl.Type3InputBuffer;
         OutputBuffer = Irp->UserBuffer;
 
-        QueryContext = exAllocatePool(NonPagedPool, sizeof(TI_QUERY_CONTEXT));
+        QueryContext = ExAllocatePoolWithTag(NonPagedPool, sizeof(TI_QUERY_CONTEXT), QUERY_CONTEXT_TAG);
         if (QueryContext) {
            _SEH2_TRY {
                 InputMdl = IoAllocateMdl(InputBuffer,
@@ -1379,7 +1398,7 @@ NTSTATUS DispTdiQueryInformationEx(
                 IoFreeMdl(OutputMdl);
             }
 
-            exFreePool(QueryContext);
+            ExFreePoolWithTag(QueryContext, QUERY_CONTEXT_TAG);
         } else
             Status = STATUS_INSUFFICIENT_RESOURCES;
     } else if( InputBufferLength ==
@@ -1392,7 +1411,7 @@ NTSTATUS DispTdiQueryInformationEx(
 
        Size = 0;
 
-        QueryContext = exAllocatePool(NonPagedPool, sizeof(TI_QUERY_CONTEXT));
+        QueryContext = ExAllocatePoolWithTag(NonPagedPool, sizeof(TI_QUERY_CONTEXT), QUERY_CONTEXT_TAG);
         if (!QueryContext) return STATUS_INSUFFICIENT_RESOURCES;
 
        _SEH2_TRY {
@@ -1412,7 +1431,7 @@ NTSTATUS DispTdiQueryInformationEx(
 
        if( !NT_SUCCESS(Status) || !InputMdl ) {
            if( InputMdl ) IoFreeMdl( InputMdl );
-           exFreePool(QueryContext);
+           ExFreePoolWithTag(QueryContext, QUERY_CONTEXT_TAG);
            return Status;
        }
 
index dec7a0c..88ac185 100644 (file)
@@ -153,7 +153,7 @@ VOID AddrFileFree(
  *     Object = Pointer to address file object to free
  */
 {
-    exFreePool(Object);
+    ExFreePoolWithTag(Object, ADDR_FILE_TAG);
 }
 
 
@@ -165,7 +165,7 @@ VOID ControlChannelFree(
  *     Object = Pointer to address file object to free
  */
 {
-    exFreePool(Object);
+    ExFreePoolWithTag(Object, CONTROL_CHANNEL_TAG);
 }
 
 
@@ -189,7 +189,8 @@ NTSTATUS FileOpenAddress(
 
   TI_DbgPrint(MID_TRACE, ("Called (Proto %d).\n", Protocol));
 
-  AddrFile = exAllocatePool(NonPagedPool, sizeof(ADDRESS_FILE));
+  AddrFile = ExAllocatePoolWithTag(NonPagedPool, sizeof(ADDRESS_FILE),
+                                   ADDR_FILE_TAG);
   if (!AddrFile) {
     TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
     return STATUS_INSUFFICIENT_RESOURCES;
@@ -212,7 +213,7 @@ NTSTATUS FileOpenAddress(
 
   if (!AddrIsUnspecified(&AddrFile->Address) &&
       !AddrLocateInterface(&AddrFile->Address)) {
-         exFreePool(AddrFile);
+         ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
          TI_DbgPrint(MIN_TRACE, ("Non-local address given (0x%X).\n", A2S(&AddrFile->Address)));
          return STATUS_INVALID_PARAMETER;
   }
@@ -230,7 +231,7 @@ NTSTATUS FileOpenAddress(
            AddrFile->Port != Address->Address[0].Address[0].sin_port) ||
            AddrFile->Port == 0xffff)
       {
-          exFreePool(AddrFile);
+          ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
           return STATUS_INVALID_PARAMETER;
       }
 
@@ -248,7 +249,7 @@ NTSTATUS FileOpenAddress(
            AddrFile->Port != Address->Address[0].Address[0].sin_port) ||
            AddrFile->Port == 0xffff)
       {
-          exFreePool(AddrFile);
+          ExFreePoolWithTag(AddrFile, ADDR_FILE_TAG);
           return STATUS_INVALID_PARAMETER;
       }
 
@@ -346,7 +347,7 @@ NTSTATUS FileCloseAddress(
   while ((CurrentEntry = ExInterlockedRemoveHeadList(&AddrFile->ReceiveQueue, &AddrFile->Lock))) {
     ReceiveRequest = CONTAINING_RECORD(CurrentEntry, DATAGRAM_RECEIVE_REQUEST, ListEntry);
     (*ReceiveRequest->Complete)(ReceiveRequest->Context, STATUS_CANCELLED, 0);
-    /* exFreePool(ReceiveRequest); FIXME: WTF? */
+    /* ExFreePoolWithTag(ReceiveRequest, DATAGRAM_RECV_TAG); FIXME: WTF? */
   }
 
   TI_DbgPrint(DEBUG_ADDRFILE, ("Aborting send requests on address file at (0x%X).\n", AddrFile));
@@ -355,7 +356,7 @@ NTSTATUS FileCloseAddress(
   while ((CurrentEntry = ExInterlockedRemoveHeadList(&AddrFile->ReceiveQueue, &AddrFile->Lock))) {
     SendRequest = CONTAINING_RECORD(CurrentEntry, DATAGRAM_SEND_REQUEST, ListEntry);
     (*SendRequest->Complete)(SendRequest->Context, STATUS_CANCELLED, 0);
-    exFreePool(SendRequest);
+    ExFreePoolWithTag(SendRequest, DATAGRAM_SEND_TAG);
   }
 
   /* Protocol specific handling */
@@ -454,7 +455,8 @@ NTSTATUS FileOpenControlChannel(
   PCONTROL_CHANNEL ControlChannel;
   TI_DbgPrint(MID_TRACE, ("Called.\n"));
 
-  ControlChannel = exAllocatePool(NonPagedPool, sizeof(*ControlChannel));
+  ControlChannel = ExAllocatePoolWithTag(NonPagedPool, sizeof(*ControlChannel),
+                                         CONTROL_CHANNEL_TAG);
 
   if (!ControlChannel) {
     TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
@@ -494,7 +496,7 @@ NTSTATUS FileCloseControlChannel(
   PCONTROL_CHANNEL ControlChannel = Request->Handle.ControlChannel;
   NTSTATUS Status = STATUS_SUCCESS;
 
-  exFreePool(ControlChannel);
+  ExFreePoolWithTag(ControlChannel, CONTROL_CHANNEL_TAG);
   Request->Handle.ControlChannel = NULL;
 
   return Status;
index 7494d0a..7a9f35c 100644 (file)
@@ -32,7 +32,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
                 Interface, IF, ID.tei_entity, ID.tei_instance));
 
     OutData =
-       (PIFENTRY)exAllocatePool( NonPagedPool,
+       (PIFENTRY)ExAllocatePool( NonPagedPool,
                                  sizeof(IFENTRY) + MAX_IFDESCR_LEN );
 
     if( !OutData ) return TDI_NO_RESOURCES; /* Out of memory */
@@ -99,7 +99,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
                            ID.tei_entity, ID.tei_instance, Size));
 
     Status = InfoCopyOut( (PCHAR)OutData, Size, Buffer, BufferSize );
-    exFreePool( OutData );
+    ExFreePool( OutData );
 
     TI_DbgPrint(DEBUG_INFO,("Returning %x\n", Status));
 
@@ -117,14 +117,14 @@ TDI_STATUS InfoTdiQueryGetArptableMIB(TDIEntityID ID,
 
     if (MemSize != 0)
     {
-        ArpEntries = exAllocatePoolWithTag( NonPagedPool, MemSize, FOURCC('A','R','P','t') );
+        ArpEntries = ExAllocatePool( NonPagedPool, MemSize );
         if( !ArpEntries ) return STATUS_NO_MEMORY;
 
         NBCopyNeighbors( Interface, ArpEntries );
 
         Status = InfoCopyOut( (PVOID)ArpEntries, MemSize, Buffer, BufferSize );
 
-        exFreePool( ArpEntries );
+        ExFreePool( ArpEntries );
     }
     else
     {
diff --git a/reactos/drivers/network/tcpip/tcpip/irp.c b/reactos/drivers/network/tcpip/tcpip/irp.c
deleted file mode 100644 (file)
index f2fc589..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS TCP/IP protocol driver
- * FILE:        tcpip/dispatch.h
- * PURPOSE:     TDI dispatch routines
- * PROGRAMMERS: arty
- * REVISIONS:
- *   CSH 01/08-2000 Created
- * TODO:        Validate device object in all dispatch routines
- */
-
-#include "precomp.h"
-
-VOID IRPRemember( PIRP Irp, PCHAR File, UINT Line ) {
-    TrackWithTag( IRP_TAG, Irp, File, Line );
-}
-
-NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status ) {
-    KIRQL OldIrql;
-
-    UntrackFL( __FILE__, __LINE__, Irp, IRP_TAG );
-
-    Irp->IoStatus.Status = Status;
-
-    if( Status == STATUS_PENDING )
-       IoMarkIrpPending( Irp );
-    else {
-        IoAcquireCancelSpinLock(&OldIrql);
-       (void)IoSetCancelRoutine( Irp, NULL );
-        IoReleaseCancelSpinLock(OldIrql);
-
-       IoCompleteRequest( Irp, IO_NETWORK_INCREMENT );
-    }
-
-    return Status;
-}
-
index 7e45ccc..d1ce6c7 100644 (file)
@@ -119,30 +119,25 @@ NTSTATUS TiCreateFileObject(
   TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp));
 
   EaInfo = Irp->AssociatedIrp.SystemBuffer;
-CP
+
   /* Parameter check */
   /* No EA information means that we're opening for SET/QUERY_INFORMATION
    * style calls. */
-#if 0
-  if (!EaInfo) {
-    TI_DbgPrint(MIN_TRACE, ("No EA information in IRP.\n"));
-    return STATUS_INVALID_PARAMETER;
-  }
-#endif
-CP
+
   /* Allocate resources here. We release them again if something failed */
-  Context = exAllocatePool(NonPagedPool, sizeof(TRANSPORT_CONTEXT));
+  Context = ExAllocatePoolWithTag(NonPagedPool, sizeof(TRANSPORT_CONTEXT),
+                                  TRANS_CONTEXT_TAG);
   if (!Context) {
     TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
     return STATUS_INSUFFICIENT_RESOURCES;
   }
-CP
+
   Context->CancelIrps = FALSE;
-CP
+
   IrpSp = IoGetCurrentIrpStackLocation(Irp);
   IrpSp->FileObject->FsContext = Context;
   Request.RequestContext       = Irp;
-CP
+
   /* Branch to the right handler */
   if (EaInfo &&
       (EaInfo->EaNameLength == TDI_TRANSPORT_ADDRESS_LENGTH) &&
@@ -150,7 +145,7 @@ CP
        (&EaInfo->EaName, TdiTransportAddress,
        TDI_TRANSPORT_ADDRESS_LENGTH) == TDI_TRANSPORT_ADDRESS_LENGTH)) {
     /* This is a request to open an address */
-CP
+
 
        /* XXX This should probably be done in IoCreateFile() */
     /* Parameter checks */
@@ -169,10 +164,10 @@ CP
          TI_DbgPrint(MIN_TRACE, ("AddressType: %\n",
                                  Address->Address[0].AddressType));
       }
-      exFreePool(Context);
+      ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
       return STATUS_INVALID_PARAMETER;
     }
-CP
+
     /* Open address file object */
 
     /* Protocol depends on device object so find the protocol */
@@ -186,21 +181,21 @@ CP
       Status = TiGetProtocolNumber(&IrpSp->FileObject->FileName, &Protocol);
       if (!NT_SUCCESS(Status)) {
         TI_DbgPrint(MIN_TRACE, ("Raw IP protocol number is invalid.\n"));
-        exFreePool(Context);
+        ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
         return STATUS_INVALID_PARAMETER;
       }
     } else {
       TI_DbgPrint(MIN_TRACE, ("Invalid device object at (0x%X).\n", DeviceObject));
-      exFreePool(Context);
+      ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
       return STATUS_INVALID_PARAMETER;
     }
-CP
+
     Status = FileOpenAddress(&Request, Address, Protocol, NULL);
     if (NT_SUCCESS(Status)) {
       IrpSp->FileObject->FsContext2 = (PVOID)TDI_TRANSPORT_ADDRESS_FILE;
       Context->Handle.AddressHandle = Request.Handle.AddressHandle;
     }
-CP
+
   } else if (EaInfo &&
             (EaInfo->EaNameLength == TDI_CONNECTION_CONTEXT_LENGTH) &&
             (RtlCompareMemory
@@ -208,12 +203,12 @@ CP
               TDI_CONNECTION_CONTEXT_LENGTH) ==
              TDI_CONNECTION_CONTEXT_LENGTH)) {
     /* This is a request to open a connection endpoint */
-CP
+
     /* Parameter checks */
 
     if (EaInfo->EaValueLength < sizeof(PVOID)) {
       TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
-      exFreePool(Context);
+      ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
       return STATUS_INVALID_PARAMETER;
     }
 
@@ -221,7 +216,7 @@ CP
 
     if (DeviceObject != TCPDeviceObject) {
       TI_DbgPrint(MIN_TRACE, ("Bad device object.\n"));
-      exFreePool(Context);
+      ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
       return STATUS_INVALID_PARAMETER;
     }
 
@@ -244,7 +239,7 @@ CP
   }
 
   if (!NT_SUCCESS(Status))
-    exFreePool(Context);
+    ExFreePoolWithTag(Context, TRANS_CONTEXT_TAG);
 
   TI_DbgPrint(DEBUG_IRP, ("Leaving. Status = (0x%X).\n", Status));
 
@@ -323,8 +318,6 @@ TiDispatchOpenClose(
   PIO_STACK_LOCATION IrpSp;
   NTSTATUS Status;
 
-  IRPRemember(Irp, __FILE__, __LINE__);
-
 //  DbgPrint("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp);
 
   IrpSp = IoGetCurrentIrpStackLocation(Irp);
@@ -367,8 +360,6 @@ TiDispatchInternal(
   BOOLEAN Complete = TRUE;
   PIO_STACK_LOCATION IrpSp;
 
-  IRPRemember(Irp, __FILE__, __LINE__);
-
   IrpSp = IoGetCurrentIrpStackLocation(Irp);
 
   TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X) MN (%d).\n",
@@ -471,8 +462,6 @@ TiDispatch(
   NTSTATUS Status;
   PIO_STACK_LOCATION IrpSp;
 
-  IRPRemember(Irp, __FILE__, __LINE__);
-
   IrpSp  = IoGetCurrentIrpStackLocation(Irp);
 
   TI_DbgPrint(DEBUG_IRP, ("Called. IRP is at (0x%X).\n", Irp));
@@ -541,8 +530,6 @@ VOID NTAPI TiUnload(
   }
   TcpipReleaseSpinLock(&AddressFileListLock, OldIrql);
 #endif
-  ChewShutdown();
-
   /* Cancel timer */
   KeCancelTimer(&IPTimer);
 
@@ -580,11 +567,13 @@ VOID NTAPI TiUnload(
   if (RawIPDeviceObject)
     IoDeleteDevice(RawIPDeviceObject);
 
-  if (IPDeviceObject)
-    IoDeleteDevice(IPDeviceObject);
+  if (IPDeviceObject) {
+     ChewShutdown();
+     IoDeleteDevice(IPDeviceObject);
+  }
 
   if (EntityList)
-    exFreePool(EntityList);
+    ExFreePoolWithTag(EntityList, TDI_ENTITY_TAG);
 
   TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));
 }
@@ -635,17 +624,22 @@ DriverEntry(
 
   TI_DbgPrint(MAX_TRACE, ("Called.\n"));
 
-  TrackingInit();
-
   /* TdiInitialize() ? */
 
   /* FIXME: Create symbolic links in Win32 namespace */
 
+  /* Initialize our periodic timer and its associated DPC object. When the
+     timer expires, the IPTimeout deferred procedure call (DPC) is queued */
+  ExInitializeWorkItem( &IpWorkItem, IPTimeout, NULL );
+  KeInitializeDpc(&IPTimeoutDpc, IPTimeoutDpcFn, NULL);
+  KeInitializeTimer(&IPTimer);
+
   /* Create IP device object */
   Status = IoCreateDevice(DriverObject, 0, &strIpDeviceName,
     FILE_DEVICE_NETWORK, 0, FALSE, &IPDeviceObject);
   if (!NT_SUCCESS(Status)) {
     TI_DbgPrint(MIN_TRACE, ("Failed to create IP device object. Status (0x%X).\n", Status));
+    TiUnload(DriverObject);
     return Status;
   }
 
@@ -656,8 +650,7 @@ DriverEntry(
     FILE_DEVICE_NETWORK, 0, FALSE, &RawIPDeviceObject);
   if (!NT_SUCCESS(Status)) {
     TI_DbgPrint(MIN_TRACE, ("Failed to create RawIP device object. Status (0x%X).\n", Status));
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
+    TiUnload(DriverObject);
     return Status;
   }
 
@@ -666,9 +659,7 @@ DriverEntry(
     FILE_DEVICE_NETWORK, 0, FALSE, &UDPDeviceObject);
   if (!NT_SUCCESS(Status)) {
     TI_DbgPrint(MIN_TRACE, ("Failed to create UDP device object. Status (0x%X).\n", Status));
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
+    TiUnload(DriverObject);
     return Status;
   }
 
@@ -677,23 +668,18 @@ DriverEntry(
     FILE_DEVICE_NETWORK, 0, FALSE, &TCPDeviceObject);
   if (!NT_SUCCESS(Status)) {
     TI_DbgPrint(MIN_TRACE, ("Failed to create TCP device object. Status (0x%X).\n", Status));
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
-    IoDeleteDevice(UDPDeviceObject);
+    TiUnload(DriverObject);
     return Status;
   }
 
   /* Setup network layer and transport layer entities */
   KeInitializeSpinLock(&EntityListLock);
-  EntityList = exAllocatePool(NonPagedPool, sizeof(TDIEntityID) * MAX_TDI_ENTITIES );
+  EntityList = ExAllocatePoolWithTag(NonPagedPool,
+                                     sizeof(TDIEntityID) * MAX_TDI_ENTITIES,
+                                     TDI_ENTITY_TAG );
   if (!EntityList) {
     TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
-    IoDeleteDevice(UDPDeviceObject);
-    IoDeleteDevice(TCPDeviceObject);
+    TiUnload(DriverObject);
     return STATUS_INSUFFICIENT_RESOURCES;
   }
 
@@ -703,25 +689,14 @@ DriverEntry(
   /* Allocate NDIS packet descriptors */
   NdisAllocatePacketPool(&NdisStatus, &GlobalPacketPool, 100, sizeof(PACKET_CONTEXT));
   if (NdisStatus != NDIS_STATUS_SUCCESS) {
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
-    IoDeleteDevice(UDPDeviceObject);
-    IoDeleteDevice(TCPDeviceObject);
-    exFreePool(EntityList);
+    TiUnload(DriverObject);
     return STATUS_INSUFFICIENT_RESOURCES;
   }
 
   /* Allocate NDIS buffer descriptors */
   NdisAllocateBufferPool(&NdisStatus, &GlobalBufferPool, 100);
   if (NdisStatus != NDIS_STATUS_SUCCESS) {
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
-    IoDeleteDevice(UDPDeviceObject);
-    IoDeleteDevice(TCPDeviceObject);
-    exFreePool(EntityList);
-    NdisFreePacketPool(GlobalPacketPool);
+    TiUnload(DriverObject);
     return STATUS_INSUFFICIENT_RESOURCES;
   }
 
@@ -743,64 +718,26 @@ DriverEntry(
   /* Initialize transport level protocol subsystems */
   Status = RawIPStartup();
   if( !NT_SUCCESS(Status) ) {
-        IPShutdown();
-        ChewShutdown();
-        IoDeleteDevice(IPDeviceObject);
-        IoDeleteDevice(RawIPDeviceObject);
-        IoDeleteDevice(UDPDeviceObject);
-        IoDeleteDevice(TCPDeviceObject);
-        exFreePool(EntityList);
-        NdisFreePacketPool(GlobalPacketPool);
-        NdisFreeBufferPool(GlobalBufferPool);
-       return Status;
+      TiUnload(DriverObject);
+      return Status;
   }
 
   Status = UDPStartup();
   if( !NT_SUCCESS(Status) ) {
-        RawIPShutdown();
-        IPShutdown();
-        ChewShutdown();
-        IoDeleteDevice(IPDeviceObject);
-        IoDeleteDevice(RawIPDeviceObject);
-        IoDeleteDevice(UDPDeviceObject);
-        IoDeleteDevice(TCPDeviceObject);
-        exFreePool(EntityList);
-        NdisFreePacketPool(GlobalPacketPool);
-        NdisFreeBufferPool(GlobalBufferPool);
-       return Status;
+      TiUnload(DriverObject);
+      return Status;
   }
 
   Status = TCPStartup();
   if( !NT_SUCCESS(Status) ) {
-        UDPShutdown();
-        RawIPShutdown();
-        IPShutdown();
-        ChewShutdown();
-        IoDeleteDevice(IPDeviceObject);
-        IoDeleteDevice(RawIPDeviceObject);
-        IoDeleteDevice(UDPDeviceObject);
-        IoDeleteDevice(TCPDeviceObject);
-        exFreePool(EntityList);
-        NdisFreePacketPool(GlobalPacketPool);
-        NdisFreeBufferPool(GlobalBufferPool);
-       return Status;
+      TiUnload(DriverObject);
+      return Status;
   }
 
   Status = ICMPStartup();
   if( !NT_SUCCESS(Status) ) {
-        TCPShutdown();
-        UDPShutdown();
-        RawIPShutdown();
-        IPShutdown();
-        ChewShutdown();
-        IoDeleteDevice(IPDeviceObject);
-        IoDeleteDevice(RawIPDeviceObject);
-        IoDeleteDevice(UDPDeviceObject);
-        IoDeleteDevice(TCPDeviceObject);
-        exFreePool(EntityList);
-        NdisFreePacketPool(GlobalPacketPool);
-        NdisFreeBufferPool(GlobalBufferPool);
-       return Status;
+      TiUnload(DriverObject);
+      return Status;
   }
 
   /* Use direct I/O */
@@ -817,33 +754,11 @@ DriverEntry(
 
   DriverObject->DriverUnload = TiUnload;
 
-  /* Initialize our periodic timer and its associated DPC object. When the
-     timer expires, the IPTimeout deferred procedure call (DPC) is queued */
-  ExInitializeWorkItem( &IpWorkItem, IPTimeout, NULL );
-  KeInitializeDpc(&IPTimeoutDpc, IPTimeoutDpcFn, NULL);
-  KeInitializeTimer(&IPTimer);
-
-  /* Start the periodic timer with an initial and periodic
-     relative expiration time of IP_TIMEOUT milliseconds */
-  DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
-  KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc);
-
   /* Open loopback adapter */
   Status = LoopRegisterAdapter(NULL, NULL);
   if (!NT_SUCCESS(Status)) {
     TI_DbgPrint(MIN_TRACE, ("Failed to create loopback adapter. Status (0x%X).\n", Status));
-    TCPShutdown();
-    UDPShutdown();
-    RawIPShutdown();
-    IPShutdown();
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
-    IoDeleteDevice(UDPDeviceObject);
-    IoDeleteDevice(TCPDeviceObject);
-    exFreePool(EntityList);
-    NdisFreePacketPool(GlobalPacketPool);
-    NdisFreeBufferPool(GlobalBufferPool);
+    TiUnload(DriverObject);
     return Status;
   }
 
@@ -860,25 +775,18 @@ DriverEntry(
       NULL,
       0,
       NULL);
-    TCPShutdown();
-    UDPShutdown();
-    RawIPShutdown();
-    IPShutdown();
-    ChewShutdown();
-    IoDeleteDevice(IPDeviceObject);
-    IoDeleteDevice(RawIPDeviceObject);
-    IoDeleteDevice(UDPDeviceObject);
-    IoDeleteDevice(TCPDeviceObject);
-    exFreePool(EntityList);
-    NdisFreePacketPool(GlobalPacketPool);
-    NdisFreeBufferPool(GlobalBufferPool);
-    return Status;
+      TiUnload(DriverObject);
+      return Status;
   }
 
+  /* Start the periodic timer with an initial and periodic
+     relative expiration time of IP_TIMEOUT milliseconds */
+  DueTime.QuadPart = -(LONGLONG)IP_TIMEOUT * 10000;
+  KeSetTimerEx(&IPTimer, DueTime, IP_TIMEOUT, &IPTimeoutDpc);
+
   return STATUS_SUCCESS;
 }
 
-
 VOID NTAPI
 IPAddInterface(
        ULONG   Unknown0,
index af4fb99..293eb19 100644 (file)
@@ -22,9 +22,9 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI
     UINT RtCount = CountFIBs(IF);
     UINT Size = sizeof( IPROUTE_ENTRY ) * RtCount;
     PFIB_ENTRY RCache =
-       exAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ),
+       ExAllocatePool( NonPagedPool, sizeof( FIB_ENTRY ) * RtCount ),
        RCacheCur = RCache;
-    PIPROUTE_ENTRY RouteEntries = exAllocatePool( NonPagedPool, Size ),
+    PIPROUTE_ENTRY RouteEntries = ExAllocatePool( NonPagedPool, Size ),
        RtCurrent = RouteEntries;
     UINT i;
 
@@ -32,8 +32,8 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI
                            RtCount, RCache));
 
     if( !RCache || !RouteEntries ) {
-       if( RCache ) exFreePool( RCache );
-       if( RouteEntries ) exFreePool( RouteEntries );
+       if( RCache ) ExFreePool( RCache );
+       if( RouteEntries ) ExFreePool( RouteEntries );
        return TDI_NO_RESOURCES;
     }
 
@@ -83,8 +83,8 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PIP_INTERFACE IF, PNDIS_BUFFER Buffer, PUI
 
     Status = InfoCopyOut( (PCHAR)RouteEntries, Size, Buffer, BufferSize );
 
-    exFreePool( RouteEntries );
-    exFreePool( RCache );
+    ExFreePool( RouteEntries );
+    ExFreePool( RCache );
 
     TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));
 
@@ -118,7 +118,7 @@ TDI_STATUS InfoTdiQueryGetAddrTable(TDIEntityID ID,
         return TDI_INVALID_PARAMETER;
     }
 
-    IPEntry = exAllocatePool(NonPagedPool, sizeof(IPADDR_ENTRY));
+    IPEntry = ExAllocatePool(NonPagedPool, sizeof(IPADDR_ENTRY));
     if (!IPEntry)
     {
         TcpipReleaseSpinLock(&EntityListLock, OldIrql);
@@ -143,7 +143,7 @@ TDI_STATUS InfoTdiQueryGetAddrTable(TDIEntityID ID,
     InfoCopyOut((PCHAR)IPEntry, sizeof(IPADDR_ENTRY),
                Buffer, BufferSize);
 
-    exFreePool(IPEntry);
+    ExFreePool(IPEntry);
 
     return TDI_SUCCESS;
 }
index d6ee690..6a3e550 100644 (file)
@@ -17,7 +17,6 @@
                <file>interface.c</file>
                <file>ip.c</file>
                <file>loopback.c</file>
-               <file>memtrack.c</file>
                <file>neighbor.c</file>
                <file>ports.c</file>
                <file>receive.c</file>
index 974dc71..6ddbfd9 100644 (file)
@@ -106,7 +106,7 @@ VOID IPAddressFree(
  *     Nothing
  */
 {
-    exFreePool(Object);
+    ExFreePoolWithTag(Object, IP_ADDRESS_TAG);
 }
 
 
index 9709ce4..2d3621b 100644 (file)
@@ -39,7 +39,7 @@ VOID FreeIF(
  *     Object = Pointer to an interface structure
  */
 {
-    exFreePool(Object);
+    ExFreePoolWithTag(Object, IP_INTERFACE_TAG);
 }
 
 PIP_PACKET IPInitializePacket(
@@ -56,8 +56,6 @@ PIP_PACKET IPInitializePacket(
     /* FIXME: Is this needed? */
     RtlZeroMemory(IPPacket, sizeof(IP_PACKET));
 
-    INIT_TAG(IPPacket, 'TKPI');
-
     IPPacket->Free     = DontFreePacket;
     IPPacket->Type     = Type;
 
@@ -139,14 +137,13 @@ PIP_INTERFACE IPCreateInterface(
     }
 #endif
 
-    IF = exAllocatePool(NonPagedPool, sizeof(IP_INTERFACE));
+    IF = ExAllocatePoolWithTag(NonPagedPool, sizeof(IP_INTERFACE),
+                               IP_INTERFACE_TAG);
     if (!IF) {
         TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
         return NULL;
     }
 
-    INIT_TAG(IF, 'ECAF');
-
        RtlZeroMemory(IF, sizeof(IP_INTERFACE));
 
     IF->Free       = FreeIF;
@@ -165,10 +162,11 @@ PIP_INTERFACE IPCreateInterface(
 
     TcpipInitializeSpinLock(&IF->Lock);
 
-    IF->TCPContext = exAllocatePool
-       ( NonPagedPool, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ) );
+    IF->TCPContext = ExAllocatePoolWithTag
+       ( NonPagedPool, sizeof(OSK_IFADDR) + 2 * sizeof( struct sockaddr_in ),
+          OSKITTCP_CONTEXT_TAG );
     if (!IF->TCPContext) {
-        exFreePool(IF);
+        ExFreePoolWithTag(IF, IP_INTERFACE_TAG);
         return NULL;
     }
 
@@ -194,8 +192,8 @@ VOID IPDestroyInterface(
     RemoveTDIInterfaceEntity( IF );
 #endif
 
-    exFreePool(IF->TCPContext);
-    exFreePool(IF);
+    ExFreePoolWithTag(IF->TCPContext, OSKITTCP_CONTEXT_TAG);
+    ExFreePoolWithTag(IF, IP_INTERFACE_TAG);
 }
 
 VOID IPAddInterfaceRoute( PIP_INTERFACE IF ) {
@@ -361,7 +359,7 @@ NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
            NULL,                           /* Free routine */
            0,                              /* Flags */
            sizeof(IPDATAGRAM_REASSEMBLY),  /* Size of each entry */
-           'RDPI',                         /* Tag */
+           DATAGRAM_REASSEMBLY_TAG,        /* Tag */
            0);                             /* Depth */
 
     ExInitializeNPagedLookasideList(
@@ -370,7 +368,7 @@ NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
            NULL,                           /* Free routine */
            0,                              /* Flags */
            sizeof(IP_FRAGMENT),            /* Size of each entry */
-           'GFPI',                         /* Tag */
+           DATAGRAM_FRAGMENT_TAG,          /* Tag */
            0);                             /* Depth */
 
     ExInitializeNPagedLookasideList(
@@ -379,7 +377,7 @@ NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
            NULL,                           /* Free routine */
            0,                              /* Flags */
            sizeof(IPDATAGRAM_HOLE),        /* Size of each entry */
-           'LHPI',                         /* Tag */
+           DATAGRAM_HOLE_TAG,              /* Tag */
            0);                             /* Depth */
 
     /* Start routing subsystem */
diff --git a/reactos/lib/drivers/ip/network/memtrack.c b/reactos/lib/drivers/ip/network/memtrack.c
deleted file mode 100644 (file)
index 5e8304f..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#define MEMTRACK_NO_POOL
-#include "precomp.h"
-
-
-#if DBG
-#define TRACK_TAG 'KCrT'
-
-static LIST_ENTRY AllocatedObjectsList;
-static KSPIN_LOCK AllocatedObjectsLock;
-static NPAGED_LOOKASIDE_LIST AllocatedObjectsLookasideList;
-
-VOID TrackingInit() {
-    TcpipInitializeSpinLock( &AllocatedObjectsLock );
-    InitializeListHead( &AllocatedObjectsList );
-    ExInitializeNPagedLookasideList(&AllocatedObjectsLookasideList,
-                                   NULL,
-                                   NULL,
-                                   0,
-                                   sizeof(ALLOCATION_TRACKER),
-                                   TRACK_TAG,
-                                   0 );
-}
-
-VOID ShowTrackedThing( PCHAR What, PALLOCATION_TRACKER Thing, BOOLEAN ForceShow ) {
-
-    if (ForceShow)
-    {
-        DbgPrint("[%s] Thing %08x %c%c%c%c (%s:%d)\n",
-                 What,
-                 Thing->Thing,
-                 ((PCHAR)&Thing->Tag)[3],
-                 ((PCHAR)&Thing->Tag)[2],
-                 ((PCHAR)&Thing->Tag)[1],
-                 ((PCHAR)&Thing->Tag)[0],
-                 Thing->FileName,
-                 Thing->LineNo);
-    }
-    else
-    {
-       TI_DbgPrint(MAX_TRACE,
-                   ("[%s] Thing %08x %c%c%c%c (%s:%d)\n",
-                    What,
-                    Thing->Thing,
-                    ((PCHAR)&Thing->Tag)[3],
-                    ((PCHAR)&Thing->Tag)[2],
-                    ((PCHAR)&Thing->Tag)[1],
-                    ((PCHAR)&Thing->Tag)[0],
-                    Thing->FileName,
-                    Thing->LineNo));
-    }
-}
-
-VOID TrackWithTag( ULONG Tag, PVOID Thing, PCHAR FileName, ULONG LineNo ) {
-    PALLOCATION_TRACKER TrackedThing =
-        ExAllocateFromNPagedLookasideList( &AllocatedObjectsLookasideList );
-
-    KIRQL OldIrql;
-    PLIST_ENTRY Entry;
-    PALLOCATION_TRACKER ThingInList;
-
-    if (!TrackedThing) return;
-
-    TrackedThing->Tag      = Tag;
-    TrackedThing->Thing    = Thing;
-    TrackedThing->FileName = FileName;
-    TrackedThing->LineNo   = LineNo;
-
-    ShowTrackedThing( "Alloc", TrackedThing, FALSE );
-
-    TcpipAcquireSpinLock( &AllocatedObjectsLock, &OldIrql );
-    Entry = AllocatedObjectsList.Flink;
-    while( Entry != &AllocatedObjectsList ) {
-       ThingInList = CONTAINING_RECORD(Entry, ALLOCATION_TRACKER, Entry);
-       if( ThingInList->Thing == Thing ) {
-           RemoveEntryList(Entry);
-
-            ShowTrackedThing( "Double Alloc (Item in list)", ThingInList, TRUE );
-            ShowTrackedThing( "Double Alloc (Item not in list)", TrackedThing, TRUE );
-
-            ExFreeToNPagedLookasideList( &AllocatedObjectsLookasideList,
-                                        ThingInList );
-
-            break;
-       }
-       Entry = Entry->Flink;
-    }
-
-    InsertHeadList( &AllocatedObjectsList, &TrackedThing->Entry );
-
-    TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
-}
-
-VOID UntrackFL( PCHAR File, ULONG Line, PVOID Thing, ULONG Tag ) {
-    KIRQL OldIrql;
-    PLIST_ENTRY Entry;
-    PALLOCATION_TRACKER ThingInList;
-
-    TcpipAcquireSpinLock( &AllocatedObjectsLock, &OldIrql );
-    Entry = AllocatedObjectsList.Flink;
-    while( Entry != &AllocatedObjectsList ) {
-       ThingInList = CONTAINING_RECORD(Entry, ALLOCATION_TRACKER, Entry);
-       if( ThingInList->Thing == Thing ) {
-           RemoveEntryList(Entry);
-
-           ShowTrackedThing( "Free ", ThingInList, FALSE );
-
-            if ( ThingInList->Tag != Tag ) {
-                 DbgPrint("UNTRACK: TAG DOES NOT MATCH (%x)\n", Thing);
-                 ShowTrackedThing("Tag Mismatch (Item in list)", ThingInList, TRUE);
-                 ASSERT( FALSE );
-            }
-
-           ExFreeToNPagedLookasideList( &AllocatedObjectsLookasideList,
-                                       ThingInList );
-
-           TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
-
-           return;
-       }
-       Entry = Entry->Flink;
-    }
-    TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
-
-    DbgPrint("[Double Free] Thing %08x %c%c%c%c (%s:%d)\n",
-             Thing,
-             ((PCHAR)&Tag)[3],
-             ((PCHAR)&Tag)[2],
-             ((PCHAR)&Tag)[1],
-             ((PCHAR)&Tag)[0],
-             File,
-             Line);
-
-    ASSERT( FALSE );
-}
-
-VOID TrackDumpFL( PCHAR File, ULONG Line ) {
-    KIRQL OldIrql;
-    PLIST_ENTRY Entry;
-    PALLOCATION_TRACKER Thing;
-
-    TI_DbgPrint(MAX_TRACE,("Dump: %s:%d\n", File, Line));
-
-    TcpipAcquireSpinLock( &AllocatedObjectsLock, &OldIrql );
-    Entry = AllocatedObjectsList.Flink;
-    while( Entry != &AllocatedObjectsList ) {
-       Thing = CONTAINING_RECORD(Entry, ALLOCATION_TRACKER, Entry);
-       ShowTrackedThing( "Dump ", Thing, FALSE );
-       Entry = Entry->Flink;
-    }
-    TcpipReleaseSpinLock( &AllocatedObjectsLock, OldIrql );
-}
-
-#endif /* DBG */
index 375aac1..ae5e3a5 100644 (file)
@@ -21,7 +21,7 @@ VOID NBCompleteSend( PVOID Context,
     ASSERT_KM_POINTER(Packet->Complete);
     Packet->Complete( Packet->Context, Packet->Packet, Status );
     TI_DbgPrint(MID_TRACE, ("Completed\n"));
-    exFreePool( Packet );
+    ExFreePoolWithTag( Packet, NEIGHBOR_PACKET_TAG );
     TI_DbgPrint(MID_TRACE, ("Freed\n"));
 }
 
@@ -84,7 +84,7 @@ VOID NBFlushPacketQueue( PNEIGHBOR_CACHE_ENTRY NCE,
                           Packet->Packet,
                           ErrorCode );
 
-       exFreePool( Packet );
+       ExFreePoolWithTag( Packet, NEIGHBOR_PACKET_TAG );
     }
 }
 
@@ -128,7 +128,7 @@ VOID NBTimeout(VOID)
                     *PrevNCE = NCE->Next;
 
                     NBFlushPacketQueue(NCE, NDIS_STATUS_REQUEST_ABORTED);
-                    exFreePool(NCE);
+                    ExFreePoolWithTag(NCE, NCE_TAG);
 
                     continue;
                 }
@@ -179,7 +179,7 @@ VOID NBShutdown(VOID)
           /* Flush wait queue */
          NBFlushPacketQueue( CurNCE, NDIS_STATUS_NOT_ACCEPTED );
 
-          exFreePool(CurNCE);
+          ExFreePoolWithTag(CurNCE, NCE_TAG);
 
          CurNCE = NextNCE;
       }
@@ -241,16 +241,15 @@ PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
        "LinkAddress (0x%X)  LinkAddressLength (%d)  State (0x%X)\n",
        Interface, Address, LinkAddress, LinkAddressLength, State));
 
-  NCE = exAllocatePool
-      (NonPagedPool, sizeof(NEIGHBOR_CACHE_ENTRY) + LinkAddressLength);
+  NCE = ExAllocatePoolWithTag
+      (NonPagedPool, sizeof(NEIGHBOR_CACHE_ENTRY) + LinkAddressLength,
+       NCE_TAG);
   if (NCE == NULL)
     {
       TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
       return NULL;
     }
 
-  INIT_TAG(NCE, ' ECN');
-
   NCE->Interface = Interface;
   NCE->Address = *Address;
   NCE->LinkAddressLength = LinkAddressLength;
@@ -452,7 +451,8 @@ BOOLEAN NBQueuePacket(
       (DEBUG_NCACHE,
        ("Called. NCE (0x%X)  NdisPacket (0x%X).\n", NCE, NdisPacket));
 
-  Packet = exAllocatePool( NonPagedPool, sizeof(NEIGHBOR_PACKET) );
+  Packet = ExAllocatePoolWithTag( NonPagedPool, sizeof(NEIGHBOR_PACKET),
+                                  NEIGHBOR_PACKET_TAG );
   if( !Packet ) return FALSE;
 
   /* FIXME: Should we limit the number of queued packets? */
@@ -514,7 +514,7 @@ VOID NBRemoveNeighbor(
           *PrevNCE = CurNCE->Next;
 
          NBFlushPacketQueue( CurNCE, NDIS_STATUS_REQUEST_ABORTED );
-          exFreePool(CurNCE);
+          ExFreePoolWithTag(CurNCE, NCE_TAG);
 
          break;
         }
index c8b0835..cd9dbd2 100644 (file)
@@ -17,7 +17,8 @@ NTSTATUS PortsStartup( PPORT_SET PortSet,
     PortSet->PortsToOversee = PortsToManage;
 
     PortSet->ProtoBitBuffer =
-       exAllocatePool( NonPagedPool, (PortSet->PortsToOversee + 7) / 8 );
+       ExAllocatePoolWithTag( NonPagedPool, (PortSet->PortsToOversee + 7) / 8,
+                               PORT_SET_TAG );
     if(!PortSet->ProtoBitBuffer) return STATUS_INSUFFICIENT_RESOURCES;
     RtlInitializeBitMap( &PortSet->ProtoBitmap,
                         PortSet->ProtoBitBuffer,
@@ -28,7 +29,7 @@ NTSTATUS PortsStartup( PPORT_SET PortSet,
 }
 
 VOID PortsShutdown( PPORT_SET PortSet ) {
-    exFreePool( PortSet->ProtoBitBuffer );
+    ExFreePoolWithTag( PortSet->ProtoBitBuffer, PORT_SET_TAG );
 }
 
 VOID DeallocatePort( PPORT_SET PortSet, ULONG Port ) {
index 174b647..afdca21 100644 (file)
@@ -35,7 +35,7 @@ PIPDATAGRAM_HOLE CreateHoleDescriptor(
 
        TI_DbgPrint(DEBUG_IP, ("Called. First (%d)  Last (%d).\n", First, Last));
 
-       Hole = exAllocateFromNPagedLookasideList(&IPHoleList);
+       Hole = ExAllocateFromNPagedLookasideList(&IPHoleList);
        if (!Hole) {
            TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
            return NULL;
@@ -76,7 +76,7 @@ VOID FreeIPDR(
     TI_DbgPrint(DEBUG_IP, ("Freeing hole descriptor at (0x%X).\n", CurrentH));
 
     /* And free the hole descriptor */
-    exFreeToNPagedLookasideList(&IPHoleList, CurrentH);
+    ExFreeToNPagedLookasideList(&IPHoleList, CurrentH);
 
     CurrentEntry = NextEntry;
   }
@@ -92,18 +92,18 @@ VOID FreeIPDR(
     TI_DbgPrint(DEBUG_IP, ("Freeing fragment data at (0x%X).\n", CurrentF->Data));
 
     /* Free the fragment data buffer */
-    exFreePool(CurrentF->Data);
+    ExFreePoolWithTag(CurrentF->Data, FRAGMENT_DATA_TAG);
 
     TI_DbgPrint(DEBUG_IP, ("Freeing fragment at (0x%X).\n", CurrentF));
 
     /* And free the fragment descriptor */
-    exFreeToNPagedLookasideList(&IPFragmentList, CurrentF);
+    ExFreeToNPagedLookasideList(&IPFragmentList, CurrentF);
     CurrentEntry = NextEntry;
   }
 
   TI_DbgPrint(DEBUG_IP, ("Freeing IPDR data at (0x%X).\n", IPDR));
 
-  exFreeToNPagedLookasideList(&IPDRList, IPDR);
+  ExFreeToNPagedLookasideList(&IPDRList, IPDR);
 }
 
 
@@ -205,7 +205,7 @@ ReassembleDatagram(
   RtlCopyMemory(&IPPacket->DstAddr, &IPDR->DstAddr, sizeof(IP_ADDRESS));
 
   /* Allocate space for full IP datagram */
-  IPPacket->Header = exAllocatePool(NonPagedPool, IPPacket->TotalSize);
+  IPPacket->Header = ExAllocatePoolWithTag(NonPagedPool, IPPacket->TotalSize, PACKET_BUFFER_TAG);
   if (!IPPacket->Header) {
     TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
     (*IPPacket->Free)(IPPacket);
@@ -297,7 +297,7 @@ VOID ProcessFragment(
     TI_DbgPrint(DEBUG_IP, ("Starting new assembly.\n"));
 
     /* We don't have a reassembly structure, create one */
-    IPDR = exAllocateFromNPagedLookasideList(&IPDRList);
+    IPDR = ExAllocateFromNPagedLookasideList(&IPDRList);
     if (!IPDR)
       /* We don't have the resources to process this packet, discard it */
       return;
@@ -308,7 +308,7 @@ VOID ProcessFragment(
     Hole = CreateHoleDescriptor(0, 65536);
     if (!Hole) {
       /* We don't have the resources to process this packet, discard it */
-      exFreeToNPagedLookasideList(&IPDRList, IPDR);
+      ExFreeToNPagedLookasideList(&IPDRList, IPDR);
       return;
     }
     AddrInitIPv4(&IPDR->SrcAddr, IPv4Header->SrcAddr);
@@ -361,7 +361,7 @@ VOID ProcessFragment(
       NewHole = CreateHoleDescriptor(Hole->First, FragFirst - 1);
       if (!NewHole) {
         /* We don't have the resources to process this packet, discard it */
-        exFreeToNPagedLookasideList(&IPHoleList, Hole);
+        ExFreeToNPagedLookasideList(&IPHoleList, Hole);
         Cleanup(&IPDR->Lock, OldIrql, IPDR);
         return;
       }
@@ -374,7 +374,7 @@ VOID ProcessFragment(
       NewHole = CreateHoleDescriptor(FragLast + 1, Hole->Last);
       if (!NewHole) {
         /* We don't have the resources to process this packet, discard it */
-        exFreeToNPagedLookasideList(&IPHoleList, Hole);
+        ExFreeToNPagedLookasideList(&IPHoleList, Hole);
         Cleanup(&IPDR->Lock, OldIrql, IPDR);
         return;
       }
@@ -383,7 +383,7 @@ VOID ProcessFragment(
       InsertTailList(&IPDR->HoleListHead, &NewHole->ListEntry);
     }
 
-    exFreeToNPagedLookasideList(&IPHoleList, Hole);
+    ExFreeToNPagedLookasideList(&IPHoleList, Hole);
 
     /* If this is the first fragment, save the IP header */
     if (FragFirst == 0) {
@@ -397,7 +397,7 @@ VOID ProcessFragment(
     /* Create a buffer, copy the data into it and put it
        in the fragment list */
 
-    Fragment = exAllocateFromNPagedLookasideList(&IPFragmentList);
+    Fragment = ExAllocateFromNPagedLookasideList(&IPFragmentList);
     if (!Fragment) {
       /* We don't have the resources to process this packet, discard it */
       Cleanup(&IPDR->Lock, OldIrql, IPDR);
@@ -407,10 +407,10 @@ VOID ProcessFragment(
     TI_DbgPrint(DEBUG_IP, ("Fragment descriptor allocated at (0x%X).\n", Fragment));
 
     Fragment->Size = IPPacket->TotalSize - IPPacket->HeaderSize;
-    Fragment->Data = exAllocatePool(NonPagedPool, Fragment->Size);
+    Fragment->Data = ExAllocatePoolWithTag(NonPagedPool, Fragment->Size, FRAGMENT_DATA_TAG);
     if (!Fragment->Data) {
       /* We don't have the resources to process this packet, discard it */
-      exFreeToNPagedLookasideList(&IPFragmentList, Fragment);
+      ExFreeToNPagedLookasideList(&IPFragmentList, Fragment);
       Cleanup(&IPDR->Lock, OldIrql, IPDR);
       return;
     }
@@ -465,7 +465,7 @@ VOID ProcessFragment(
     IF->Stats.InBytes += Datagram.TotalSize;
 
     /* We're done with this datagram */
-    exFreePool(Datagram.Header);
+    ExFreePoolWithTag(Datagram.Header, PACKET_BUFFER_TAG);
     TI_DbgPrint(MAX_TRACE, ("Freeing datagram at (0x%X).\n", Datagram));
     (*Datagram.Free)(&Datagram);
   } else
index c2b79a2..d541124 100644 (file)
@@ -51,7 +51,7 @@ VOID FreeFIB(
  *     Object = Pointer to an forward information base structure
  */
 {
-    exFreePool(Object);
+    ExFreePoolWithTag(Object, FIB_TAG);
 }
 
 
@@ -217,14 +217,12 @@ PFIB_ENTRY RouterAddRoute(
                               A2S(Netmask),
                               A2S(&Router->Address)));
 
-    FIBE = exAllocatePool(NonPagedPool, sizeof(FIB_ENTRY));
+    FIBE = ExAllocatePoolWithTag(NonPagedPool, sizeof(FIB_ENTRY), FIB_TAG);
     if (!FIBE) {
         TI_DbgPrint(MIN_TRACE, ("Insufficient resources.\n"));
         return NULL;
     }
 
-    INIT_TAG(Router, 'TUOR');
-
     RtlCopyMemory( &FIBE->NetworkAddress, NetworkAddress,
                   sizeof(FIBE->NetworkAddress) );
     RtlCopyMemory( &FIBE->Netmask, Netmask,
index 6407ecb..44aa276 100644 (file)
@@ -115,11 +115,11 @@ VOID DisplayTCPPacket(
 
     if (IPPacket->NdisPacket) {
         NdisQueryPacket(IPPacket->NdisPacket, NULL, NULL, NULL, &Length);
-        Buffer = exAllocatePool(NonPagedPool, Length);
+        Buffer = ExAllocatePool(NonPagedPool, Length);
         if (Buffer) {
             Length = CopyPacketToBuffer(Buffer, IPPacket->NdisPacket, 0, Length);
             DisplayTCPHeader(Buffer, Length);
-            exFreePool(Buffer);
+            ExFreePool(Buffer);
         }
     } else {
         Buffer = IPPacket->Header;
index 554f577..b973182 100644 (file)
@@ -42,7 +42,7 @@ VOID IPSendComplete
         {
             FreeNdisPacket(IFC->NdisPacket);
             IFC->Complete(IFC->Context, IFC->Datagram, Status);
-            exFreePool(IFC);
+            ExFreePoolWithTag(IFC, IFC_TAG);
         }
     } else {
        TI_DbgPrint(MAX_TRACE, ("Calling completion handler.\n"));
@@ -50,7 +50,7 @@ VOID IPSendComplete
        /* There are no more fragments to transmit, so call completion handler */
        FreeNdisPacket(IFC->NdisPacket);
        IFC->Complete(IFC->Context, IFC->Datagram, NdisStatus);
-       exFreePool(IFC);
+       ExFreePoolWithTag(IFC, IFC_TAG);
     }
 }
 
@@ -178,7 +178,7 @@ NTSTATUS SendFragments(
 
     TI_DbgPrint(MAX_TRACE, ("Fragment buffer is %d bytes\n", BufferSize));
 
-    IFC = exAllocatePool(NonPagedPool, sizeof(IPFRAGMENT_CONTEXT));
+    IFC = ExAllocatePoolWithTag(NonPagedPool, sizeof(IPFRAGMENT_CONTEXT), IFC_TAG);
     if (IFC == NULL)
         return STATUS_INSUFFICIENT_RESOURCES;
 
@@ -187,7 +187,7 @@ NTSTATUS SendFragments(
        ( &IFC->NdisPacket, NULL, BufferSize );
 
     if( !NT_SUCCESS(NdisStatus) ) {
-       exFreePool( IFC );
+       ExFreePoolWithTag( IFC, IFC_TAG );
        return NdisStatus;
     }
 
@@ -215,14 +215,14 @@ NTSTATUS SendFragments(
 
     if (!PrepareNextFragment(IFC)) {
         FreeNdisPacket(IFC->NdisPacket);
-        exFreePool(IFC);
+        ExFreePoolWithTag(IFC, IFC_TAG);
         return NDIS_STATUS_FAILURE;
     }
 
     if (!NT_SUCCESS((NdisStatus = IPSendFragment(IFC->NdisPacket, NCE, IFC))))
     {
         FreeNdisPacket(IFC->NdisPacket);
-        exFreePool(IFC);
+        ExFreePoolWithTag(IFC, IFC_TAG);
     }
 
     return NdisStatus;
index fafea75..14562e4 100644 (file)
@@ -35,7 +35,7 @@ VOID DGRemoveIRP(
         if (ReceiveRequest->Irp == Irp)
         {
             RemoveEntryList(&ReceiveRequest->ListEntry);
-            exFreePool(ReceiveRequest);
+            ExFreePoolWithTag(ReceiveRequest, DATAGRAM_RECV_TAG);
             break;
         }
     }
@@ -197,7 +197,7 @@ VOID DGReceiveComplete(PVOID Context, NTSTATUS Status, ULONG Count) {
        (PDATAGRAM_RECEIVE_REQUEST)Context;
     TI_DbgPrint(MAX_TRACE,("Called (%08x:%08x)\n", Status, Count));
     ReceiveRequest->UserComplete( ReceiveRequest->UserContext, Status, Count );
-    exFreePool( ReceiveRequest );
+    ExFreePoolWithTag( ReceiveRequest, DATAGRAM_RECV_TAG );
     TI_DbgPrint(MAX_TRACE,("Done\n"));
 }
 
@@ -236,7 +236,8 @@ NTSTATUS DGReceiveDatagram(
 
     KeAcquireSpinLock(&AddrFile->Lock, &OldIrql);
 
-    ReceiveRequest = exAllocatePool(NonPagedPool, sizeof(DATAGRAM_RECEIVE_REQUEST));
+    ReceiveRequest = ExAllocatePoolWithTag(NonPagedPool, sizeof(DATAGRAM_RECEIVE_REQUEST),
+                                           DATAGRAM_RECV_TAG);
     if (ReceiveRequest)
     {
        /* Initialize a receive request */
@@ -250,7 +251,7 @@ NTSTATUS DGReceiveDatagram(
                                    &ReceiveRequest->RemotePort);
            if (!NT_SUCCESS(Status))
             {
-               exFreePool(ReceiveRequest);
+               ExFreePoolWithTag(ReceiveRequest, DATAGRAM_RECV_TAG);
                KeReleaseSpinLock(&AddrFile->Lock, OldIrql);
                return Status;
             }
index b99c03b..0bdefb3 100644 (file)
@@ -118,7 +118,7 @@ VOID TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
 
     if( Bucket->AssociatedEndpoint == Connection ) {
         RemoveEntryList( &Bucket->Entry );
-        exFreePool( Bucket );
+        ExFreePoolWithTag( Bucket, TDI_BUCKET_TAG );
         break;
     }
 
@@ -148,7 +148,8 @@ NTSTATUS TCPAccept ( PTDI_REQUEST Request,
     KeReleaseSpinLock(&Listener->Lock, OldIrql);
 
     if( Status == STATUS_PENDING ) {
-        Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
+        Bucket = ExAllocatePoolWithTag( NonPagedPool, sizeof(*Bucket),
+                                        TDI_BUCKET_TAG );
 
         if( Bucket ) {
             Bucket->AssociatedEndpoint = Connection;
index 6d062dc..f3d5a14 100644 (file)
@@ -126,8 +126,6 @@ int TCPPacketSend(void *ClientData, OSK_PCHAR data, OSK_UINT len ) {
 #define SIGNATURE_LARGE 'LLLL'
 #define SIGNATURE_SMALL 'SSSS'
 #define SIGNATURE_OTHER 'OOOO'
-#define TCP_TAG ' PCT'
-
 static NPAGED_LOOKASIDE_LIST LargeLookasideList;
 static NPAGED_LOOKASIDE_LIST SmallLookasideList;
 
@@ -139,14 +137,14 @@ TCPMemStartup( void )
                                      NULL,
                                      0,
                                      LARGE_SIZE + sizeof( ULONG ),
-                                     TCP_TAG,
+                                     OSK_LARGE_TAG,
                                      0 );
     ExInitializeNPagedLookasideList( &SmallLookasideList,
                                      NULL,
                                      NULL,
                                      0,
                                      SMALL_SIZE + sizeof( ULONG ),
-                                     TCP_TAG,
+                                     OSK_SMALL_TAG,
                                      0 );
 
     return STATUS_SUCCESS;
@@ -216,13 +214,13 @@ void *TCPMalloc( void *ClientData,
     v = ExAllocateFromNPagedLookasideList( &LargeLookasideList );
     Signature = SIGNATURE_LARGE;
     } else {
-    v = ExAllocatePool( NonPagedPool, Bytes + sizeof(ULONG) );
+    v = ExAllocatePoolWithTag( NonPagedPool, Bytes + sizeof(ULONG),
+                               OSK_OTHER_TAG );
     Signature = SIGNATURE_OTHER;
     }
     if( v ) {
     *((ULONG *) v) = Signature;
     v = (void *)((char *) v + sizeof(ULONG));
-    TrackWithTag( FOURCC('f','b','s','d'), v, (PCHAR)File, Line );
     }
 
     return v;
@@ -232,7 +230,6 @@ void TCPFree( void *ClientData,
           void *data, OSK_PCHAR File, OSK_UINT Line ) {
     ULONG Signature;
 
-    UntrackFL( (PCHAR)File, Line, data, FOURCC('f','b','s','d') );
     data = (void *)((char *) data - sizeof(ULONG));
     Signature = *((ULONG *) data);
     if ( SIGNATURE_SMALL == Signature ) {
@@ -240,7 +237,7 @@ void TCPFree( void *ClientData,
     } else if ( SIGNATURE_LARGE == Signature ) {
     ExFreeToNPagedLookasideList( &LargeLookasideList, data );
     } else if ( SIGNATURE_OTHER == Signature ) {
-    ExFreePool( data );
+    ExFreePoolWithTag( data, OSK_OTHER_TAG );
     } else {
     ASSERT( FALSE );
     }
index 6f9f38c..f0e104e 100644 (file)
@@ -33,7 +33,7 @@ ProcessCompletions(PCONNECTION_ENDPOINT Connection)
 
          Complete(Bucket->Request.RequestContext, Bucket->Status, Bucket->Information);
 
-         exFreePool(Bucket);
+         ExFreePoolWithTag(Bucket, TDI_BUCKET_TAG);
     }
 
     if (!Connection->SocketContext)
@@ -315,7 +315,8 @@ VOID DrainSignals(VOID) {
 
 PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext ) {
     PCONNECTION_ENDPOINT Connection =
-        exAllocatePool(NonPagedPool, sizeof(CONNECTION_ENDPOINT));
+        ExAllocatePoolWithTag(NonPagedPool, sizeof(CONNECTION_ENDPOINT),
+                              CONN_ENDPT_TAG);
     if (!Connection)
         return Connection;
 
@@ -351,7 +352,7 @@ VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection ) {
     RemoveEntryList(&Connection->ListEntry);
     TcpipReleaseSpinLock(&ConnectionEndpointListLock, OldIrql);
 
-    exFreePool( Connection );
+    ExFreePoolWithTag( Connection, CONN_ENDPT_TAG );
 }
 
 NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
@@ -667,7 +668,7 @@ NTSTATUS TCPConnect
 
         if (Status == STATUS_PENDING)
         {
-            Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
+            Bucket = ExAllocatePoolWithTag( NonPagedPool, sizeof(*Bucket), TDI_BUCKET_TAG );
             if( !Bucket )
             {
                return STATUS_NO_MEMORY;
@@ -776,7 +777,7 @@ NTSTATUS TCPReceiveData
     /* Keep this request around ... there was no data yet */
     if( Status == STATUS_PENDING ) {
         /* Freed in TCPSocketState */
-        Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
+        Bucket = ExAllocatePoolWithTag( NonPagedPool, sizeof(*Bucket), TDI_BUCKET_TAG );
         if( !Bucket ) {
             TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
             return STATUS_NO_MEMORY;
@@ -835,7 +836,7 @@ NTSTATUS TCPSendData
     /* Keep this request around ... there was no data yet */
     if( Status == STATUS_PENDING ) {
         /* Freed in TCPSocketState */
-        Bucket = exAllocatePool( NonPagedPool, sizeof(*Bucket) );
+        Bucket = ExAllocatePoolWithTag( NonPagedPool, sizeof(*Bucket), TDI_BUCKET_TAG );
         if( !Bucket ) {
             TI_DbgPrint(DEBUG_TCP,("Failed to allocate bucket\n"));
             return STATUS_NO_MEMORY;
@@ -927,7 +928,7 @@ VOID TCPRemoveIRP( PCONNECTION_ENDPOINT Endpoint, PIRP Irp ) {
             if( Bucket->Request.RequestContext == Irp )
             {
                 RemoveEntryList( &Bucket->Entry );
-                exFreePool( Bucket );
+                ExFreePoolWithTag( Bucket, TDI_BUCKET_TAG );
                 break;
             }
         }
diff --git a/reactos/lib/drivers/oskittcp/include/memtrack.h b/reactos/lib/drivers/oskittcp/include/memtrack.h
deleted file mode 100644 (file)
index 802ed74..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef MEMTRACK_H
-#define MEMTRACK_H
-
-#ifndef FOURCC
-#define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#endif
-
-#define FBSD_MALLOC FOURCC('d','s','b','f')
-#define EXALLOC_TAG FOURCC('E','x','A','l')
-
-#if DBG
-#define MTMARK() TrackDumpFL(__FILE__, __LINE__)
-#define NdisAllocateBuffer(x,y,z,a,b) { \
-    NdisAllocateBuffer(x,y,z,a,b); \
-    if( *x == NDIS_STATUS_SUCCESS ) { \
-        Track(NDIS_BUFFER_TAG, *y); \
-    } \
-}
-#define NdisAllocatePacket(x,y,z) { \
-    NdisAllocatePacket(x,y,z); \
-    if( *x == NDIS_STATUS_SUCCESS ) { \
-        Track(NDIS_PACKET_TAG, *y); \
-    } \
-}
-#define FreeNdisPacket(x) { TI_DbgPrint(MID_TRACE,("Deleting Packet %x\n", x)); FreeNdisPacketX(x); }
-#define NdisFreePacket(x) { Untrack(x); NdisFreePacket(x); }
-#define NdisFreeBuffer(x) { Untrack(x); NdisFreeBuffer(x); }
-#define exAllocatePool(x,y) ExAllocatePoolX(x,y,__FILE__,__LINE__)
-#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolX(x,y,__FILE__,__LINE__)
-#define exFreePool(x) ExFreePoolX(x,__FILE__,__LINE__)
-
-extern LIST_ENTRY AllocatedObjectsHead;
-extern KSPIN_LOCK AllocatedObjectsLock;
-
-typedef struct _ALLOCATION_TRACKER {
-    LIST_ENTRY Entry;
-    DWORD Tag;
-    PVOID Thing;
-    PCHAR FileName;
-    DWORD LineNo;
-} ALLOCATION_TRACKER, *PALLOCATION_TRACKER;
-
-VOID TrackingInit();
-VOID TrackWithTag( DWORD Tag, PVOID Thing, PCHAR File, DWORD Line );
-#define Track(Tag,Thing) TrackWithTag(Tag,Thing,__FILE__,__LINE__)
-VOID UntrackFL( PCHAR File, DWORD Line, PVOID Thing );
-#define Untrack(Thing) UntrackFL(__FILE__,__LINE__,Thing)
-VOID TrackDumpFL( PCHAR File, DWORD Line );
-#define TrackDump() TrackDumpFL(__FILE__,__LINE__)
-VOID TrackTag( DWORD Tag );
-
-static __inline PVOID ExAllocatePoolX( POOL_TYPE type, SIZE_T size, PCHAR File, ULONG Line ) {
-    PVOID Out = ExAllocatePool( type, size );
-    if( Out ) TrackWithTag( EXALLOC_TAG, Out, File, Line );
-    return Out;
-}
-static __inline VOID ExFreePoolX( PVOID Data, PCHAR File, ULONG Line ) {
-    UntrackFL(File, Line, Data);
-    ExFreePool(Data);
-}
-
-#define MEMTRACK_MAX_TAGS_TO_TRACK 64
-#else
-#define MTMARK()
-#define Track(x,y)
-#define TrackingInit()
-#define TrackDump()
-#define Untrack(x)
-#define TrackTag(x)
-#define FreeNdisPacket FreeNdisPacketX
-#define exFreePool(x) ExFreePool(x)
-#define exAllocatePool(x,y) ExAllocatePool(x,y)
-#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolWithTag(x,y,z)
-#define exAllocateFromNPagedLookasideList(x) ExAllocateFromNPagedLookasideList(x)
-#define exFreeToNPagedLookasideList(x,y) ExFreeToNPagedLookasideList(x,y)
-#define TrackWithTag(w,x,y,z)
-#define UntrackFL(w,x,y,z)
-#endif
-
-#endif/*MEMMTRAC_H*/