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/


NET_BUFFER_LIST_CONTEXT for cloned NBL

ArsenArsen Member Posts: 188

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));

}


}

Comments

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,718

    Where, exactly? Which line? Should we really have to guess?

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,718

    You're doing a copy to "SystemBuffer + 1". What do you think that is doing? You don't want to copy something with a one-byte offset.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • ArsenArsen Member Posts: 188

    Tank You mr Tim Roberts.
    Last four lines couse a blue screen. Sorry. That plus 1 is for another purpose. Do not think about it.Problem is in last four lines. That 4 lines couse an error. My driver is working normally without that lines. . Ping is comming normal. But other more complex protocols not working after I install my driver. For example i can not look the shared directories in another computer, So i desided it is becouse i am not copying the NET+BUFFER+LIST+CONTEXT,
    But after i write
    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;
    }
    lines, the driver begun to couse blue screen,
    Thank You mister

                        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));
    
  • ArsenArsen Member Posts: 188

    And second question. Do I need to allocate the pool for NdisAllocateNetBufferListContext, like a allocating memory for net buffers and net buffer list. If no, from where is being allocation for context

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,718

    YOU should not be dinking with the members of the NET_BUFFER_LIST_CONTEXT structure. NdisAllocateNetBufferListContext will set up all those members as needed. You need to copy the data to whatever the CURRENT offset is, not the offset from a buffer list that has had a separate lifetime. I would just delete those three lines.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • ArsenArsen Member Posts: 188

    Thak You. Tomorrow I will do. Thank you.

  • ArsenArsen Member Posts: 188

    Mr. Tim_Roberts. Can you tell me. When I look at the NdisAllocateCloneNetBufferList examples, they don't allocate context for the cloned NET_BUFFER_LIST. How it works without allocating the context. The NdisAllocateCloneNetBufferList documentation says that this function does not allocate a context. We have to make ourselves

  • Tim_RobertsTim_Roberts Member - All Emails Posts: 14,718

    First, I should comment that I am not a network guy. Like 90% of the questions I answer, I get my info from my friend Google.

    But I am not sure what you think you are accomplishing here. Context is private to the entity that allocated it. No one else understands what's in there. If you allocate a net buffer list, then you can allocate context space for YOU, but I don't believe you should have to copy anyone else's context.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • ArsenArsen Member Posts: 188

    Well, I agree with you. Thank you, Mister. Tim Roberts.

  • ArsenArsen Member Posts: 188

    Your advice helped me a lot

  • ArsenArsen Member Posts: 188

    Mr. Tim_Roberts. Thank you very much for giving me multiple help. After 6 months of work, everything worked out for me. My driver intercepts all the outgoing trafic and sends it to the user program to make changes. Then it receives again already altered data and sends it to the network. Thank you again.
    The development time could have been a little shorter if my English was perfect.
    Thank you again.

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