Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


NdisAllocateNetBufferListContext

ArsenArsen Member Posts: 189

Hi all.
I'm using NdisAllocateNetBufferListContext to allocate a NET_BUFFER_LIST_CONTEXT for a newly cloned NET_BUFFER_LIST. But this coused a deadlock (IRQL not less than or equal to). For this alocation, I use the NET_BUFFER_LIST_CONTEXT size of the source NET_BUFFER_LIST. I think this function (NdisAllocateNetBufferListContext) is being called at (IRQL>=Dispatchlevel) and the original NET_BUFFER has been unloaded (or part of that structure). So, if I'm right, what should I do? How to temporarily reduce IRQL, and then increase it.

... FilterSendNetBufferList(...., PNET_BUFFER_LIST pNBL, ...)
{
...
...
cloneNBL = NdisAllocateCloneNetBufferList(pNBL, ...);
NdisAllocateNetBufferListContext(cloneNBL, NET_BUFFER_LIST_CONTEXT_DATA_SIZE(pNBL),...);

 RtlCopy (cloneNBL->Context->ContextData, NET_BUFFER_LIST_CONTEXT_DATA_START(pNBL),
                                                             NET_BUFFER_LIST_CONTEXT_DATA_SIZE(pNBL),

}

And the second question.
So far I was cloning NET_BUFFER_LIST without any context structure and was sending that newly cloned NBL over the network, insteed of original NBL. As a result, I was able to ping from one host to another. But other more complex protocols didn't work properly. In particular, I couldn't see the shared directory on the other host when my driver was loaded. Is it due to missing NET_BUFFER_LIST_CONTEXT data?
Thank you.

Comments

  • ArsenArsen Member Posts: 189

    Thanks everybody. Problem was in NULL pointer;

  • ArsenArsen Member Posts: 189

    Hello everybody.
    Who can help me.
    Thes couses blue screen DRIVER IRQL NOT less OR equal

    VOID FilterSendNetBufferLists(NDIS_HANDLE FilterModuleContext, PNET_BUFFER_LIST NetBufferLists, NDIS_PORT_NUMBER PortNumber, ULONG SendFlags)

    {

    ---

                    RtlCopyMemory((PUCHAR)pFilter->pIrpSend[nSend]->AssociatedIrp.SystemBuffer + 1, (PUCHAR)MmGetMdlVirtualAddress(NET_BUFFER_FIRST_MDL(pNB)) + NET_BUFFER_DATA_OFFSET(pNB), NET_BUFFER_DATA_LENGTH(pNB));
                    if (pNB == NET_BUFFER_LIST_FIRST_NB(pNBL)) {
                        PNET_BUFFER_LIST cloneOfpNBL = NdisAllocateCloneNetBufferList(pNBL, pFilter->NBLPoolHandle, pFilter->NBPoolHandle, NDIS_CLONE_FLAGS_USE_ORIGINAL_MDLS);//osr how_to_send_cloned_nbl
                        if (!cloneOfpNBL) { KdPrint(("Error NdisAllocateCloneNetBufferList")); FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel); break; }  //????
                        pNBL->ChildRefCount = 0;                              //new from community "How-to-send-cloned-nbl"
                        cloneOfpNBL->ParentNetBufferList = NULL;   //pNBL;            //new from community "How-to-send-cloned-nbl"
    
                        NET_BUFFER* pCloneNB = NET_BUFFER_LIST_FIRST_NB(cloneOfpNBL);
                        while (pCloneNB) {
    
                            pCloneNB->MdlChain = NULL;
                            pCloneNB = NET_BUFFER_NEXT_NB(pCloneNB);
                        }
    
                      **  if (pNBL->Context) {
                            NDIS_STATUS resContext = NdisAllocateNetBufferListContext(cloneOfpNBL,
                                NET_BUFFER_LIST_CONTEXT_DATA_SIZE(pNBL),
                                0, FILTER_TAG/*'2gaT'*/);
                            if (resContext != NDIS_STATUS_SUCCESS) {
                                FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel);
                                if (resContext == NDIS_STATUS_RESOURCES) { KdPrint(("NdisAllocateNetBufferListContext error NDIS_STATUS_RESOURCES\n")); }
                                else { KdPrint(("NdisAllocateNetBufferListContext error\n")); }
                                break;
                            }
    
                            cloneOfpNBL->Context->Next = 0;
                            cloneOfpNBL->Context->Offset = pNBL->Context->Offset;
                            cloneOfpNBL->Context->Size = pNBL->Context->Size;
                            RtlCopyMemory(NET_BUFFER_LIST_CONTEXT_DATA_START(cloneOfpNBL), NET_BUFFER_LIST_CONTEXT_DATA_START(pNBL), NET_BUFFER_LIST_CONTEXT_DATA_SIZE(pNBL));
    

    }**


    }

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 26 Feb - 1 Mar 2024 Live, Online