Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wrote a virtual USB bus driver in Windows, after it enumerate the USBSTOR driver, in the usb bulk or interrupt transfer phase, the USBSTOR driver will send some IRPs with MDL pointer. It means that using direct I/O method (but strangely, the "Method" in the IRP is "Neither"). When I use the MDL to copy data, it cause a crash. The code to deal with the mdl is below:
if(Irp->MdlAddress != NULL)
{
    buf = MmGetSystemAddressForMdlSafe(Irp->MdlAddress, NormalPagePriority);

    //It will not crash without this sentence
    RtlMoveMemory(buf, data, dataLength);
}

Without copying data, it will not crash. But when crash happen, there always be some delay from copying, and the point it crash down, not always at one place.
When I print out the data from the buf before copying to it, I saw some times it's not all zero. It should be all zero. It means the but dosn't point to the right buffer the data shall be copied to. The data was copied to an unknow place in the kernel, it cause a crash.

The question is why would I get a wrong virtual address by using MmGetSystemAddressForMdlSafe(), is this a bug of USBSTOR driver or what? Should I do something else before copying data?
Posted
Updated 13-Dec-10 6:35am
v3
Comments
Toniyo Jackson 13-Dec-10 7:36am    
Always put code inside code block.
Abdul Quader Mamun 13-Dec-10 12:35pm    
Spelling check.

1 solution

I know the reason now. Before getting the virtual address here, I did a wrong thing. I lower the IRQL, this is a fatal error.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900