There is a long, sometime torturous, thread on the topic of common buffer alignment here. I strongly recommend you get a cup of coffee and read through the entire thing. Mr. Roberts does some excellent investigation.
Among the findings:
-
It appears you have to use a scatter/gather profile for your alignment to be respected.
-
Use WdfCommonBufferCreateWithConfig instead of relying on the device alignment to be respected.
I’ll be waiting to hear the result of your experiments!
Peter
3 Likes
The result of “WdfCommonBufferCreateWithConfig” is that it is looking that all my problems have apparently vanished, for now.
I will give that thread a read.
Thank you.
Even absent a “correct” fix, it’s always trivially easy to generate whatever arbitrary alignment you need. If you need a 64k buffer with 16k alignment, just allocate an 80k buffer (64+16), and adjust your starting address to the first 16k aligned address.
void * myptr = allocate_common_buffer( 65536 + 16384);
void * aligned = (void *)((UINT_PTR)myptr) + 16384 - ((UINT_PTR)myptr) & 16383));
Wow, did anyone formally report this bug to MSFT?
I didn’t report it either formally or informally. Mr. Roberts should get the glory 
Peter
Anyhow everything is working great. Thank you all. And if you think that is a bug I should not mention… I think driver writers should learn how to create actual devices…and the other way around. I am sooooo tired. But thank you.