NdisAllocateCloneNetBufferList

Why NdisAllocateCloneNetBufferList is not incrementing ChildRefCount member of source NBL and not changing ParentNetBufferList of destination NBL. It remains 0 after NdisAllocateCloneNetBufferList.
What typically must I do after cloning.
Is there any flag, that specifies MDL as shared between two NBLs (original and cloned) .
Thanks.

PNET_BUFFER_LIST cloneNBL = NdisAllocateCloneNetBufferList(pNBL, pFilter->NBLPoolHandle, pFilter->NBPoolHandle, NDIS_CLONE_FLAGS_USE_ORIGINAL_MDLS);
DEBUGP(DL_WARN, "pNBL->ChildRefCount = %d", pNBL->ChildRefCount);  //remains 0
DEBUGP(DL_WARN, "cloneNBL->ParentNetBufferList = %p", cloneNBL->ParentNetBufferList);  //remains NULL
NdisCopyReceiveNetBufferListInfo(cloneNBL, pNBL);
cloneNBL->SourceHandle = pFilter->FilterHandle;  // pNBL->ChildRefCount++;  cloneNBL->ParentNetBufferList = pNBL;
cloneNBL->Scratch = (PVOID)UlongToPtr(ReceiveFlags);

When I uninstall my driver, its hangs up. When I close the receive and return (doing bypass), its successfully uninstalling. So the problem is in receive path. I think it is because of clone.
freezing occurs in NdisFDeregisterFilterDriver, when I try to uninstall the driver. Some NBLs may not have been sent or received

How can I study this problem with windbg.

Who can say

VOID FilterReceiveNetBufferLists(NDIS_HANDLE FilterModuleContext,PNET_BUFFER_LIST NetBufferLists,NDIS_PORT_NUMBER PortNumber,ULONG NumberOfNetBufferLists,ULONG ReceiveFlags)
{
    PMS_FILTER          pFilter = (PMS_FILTER)FilterModuleContext;
    BOOLEAN             DispatchLevel;
    BOOLEAN             bFalse = FALSE;
    ULONG               Ref; UNREFERENCED_PARAMETER(Ref);
    UNREFERENCED_PARAMETER(PortNumber);
    do {
        DispatchLevel = NDIS_TEST_RECEIVE_AT_DISPATCH_LEVEL(ReceiveFlags);
#if DBG
        ULONG               ReturnFlags;
        FILTER_ACQUIRE_LOCK(&pFilter->Lock, DispatchLevel);
        if (pFilter->State != FilterRunning)
        {
            FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel);
            if (NDIS_TEST_RECEIVE_CAN_PEND(ReceiveFlags))
            {
                ReturnFlags = 0;
                if (NDIS_TEST_RECEIVE_AT_DISPATCH_LEVEL(ReceiveFlags))
                {
                    NDIS_SET_RETURN_FLAG(ReturnFlags, NDIS_RETURN_FLAGS_DISPATCH_LEVEL);
                }
                NdisFReturnNetBufferLists(pFilter->FilterHandle, NetBufferLists, ReturnFlags);
            }
            break;
        }
        FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel);
#endif
        ASSERT(NumberOfNetBufferLists >= 1);

why the code is enclosed in #if DBG - #endif pair
Thanks

When I uninstall my driver, its hangs up … How can I study this problem with windbg.

You attach a debugger and press Ctrl-Break to freeze the system when it hangs. Now you should be about to examine each CPU and see which one is handling shutdown.

Well.