xxandy / USB_UDE_Sample

UDE (USB Device Emulation) Hardware-less sample, with matching Host-Side drivers. Used as a USB study test bed.
52 stars 16 forks source link

Remove support for paging out certain functions - to simplify & fix Code Analysis warning #32

Closed forderud closed 6 months ago

forderud commented 6 months ago

Done to simplify, so that the implementation becomes slightly easier to understand for driver "newbies". Making certain functions pageable is an optimization to reduce RAM usage that does not effect the driver functionality.

Driver binary sizes:

Any RAM consumption growth is therefore guaranteed to be less than 33kb + 26kB = 59kB when both drivers are loaded. This is a negligible amount of RAM on todays computers.

I've already tested the changes with hostudetest.exe -a/hostudetest.exe -c somemission in a clean Win11 VM.

Related documentation

forderud commented 6 months ago

This PR also fixes the following warnings when running "Code Analysis" from Visual Studio:

UDEFX2\Device.c(31): warning C28170: The function 'UDEFX2CreateDevice' has been declared to be in a paged segment, but neither PAGED_CODE nor PAGED_CODE_LOCKED was found:  This warning is not emitted for functions that are __forceinline.
UDEFX_host\driver\ioctl.c(150): warning C28150: The function 'WdfSpinLockAcquire' causes the IRQ Level to be set above the maximum acceptable for the function being analyzed:  The level limits come from being PAGED_CODE or annotations on the current function.