windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

Implement aligned WDK allocator

Open Zero-Tang opened this issue 8 months ago • 5 comments

Now the WDK allocator can allocate aligned memory according to the layout argument.

Note that this allocator won't waste additional space for alignment if the alignment is normal (e.g.: less than or equal to 16-byte boundary on 64-bit platform). In average scenario, this is better than _aligned_malloc and _aligned_free in msvcrt, in that I guess we rarely need big alignments in drivers for some stuff in the pool. Still, some performance-critical codes might require cache-aligned (e.g.: 64-byte in x86) objects, which is usually bigger than ExAllocatePool2's alignment.

Close #303.

Zero-Tang avatar May 13 '25 16:05 Zero-Tang

related to #303? @gurry could you also take a look at this and provide feedback :)

wmmc88 avatar May 13 '25 18:05 wmmc88

Thanks for the feedback! I did wrote an example, but in a local separate crate, because rust-analyzer marks most parts of wdk-alloc crate as inactive codes for some strange reasons. It won't be marked as inactive if I check it in a separate crate. I will copy'n'paste my validation example here soon.

Zero-Tang avatar May 14 '25 02:05 Zero-Tang

related to #303? @gurry could you also take a look at this and provide feedback :)

Thanks @wmmc88. I will have a look.

gurry avatar May 14 '25 07:05 gurry

Just FYI that I edited the first comment of this PR thread so that this PR will close #303 on merge.

Zero-Tang avatar May 20 '25 16:05 Zero-Tang

Just FYI that I edited the first comment of this PR thread so that this PR will close #303 on merge.

Thanks. Yes, #303 should be closed.

I am done with my review. Will wait for inputs from @wmmc88.

gurry avatar May 21 '25 01:05 gurry