virtio-win / kvm-guest-drivers-windows

Windows paravirtualized drivers for QEMU\KVM
https://www.linux-kvm.org/page/WindowsGuestDrivers
BSD 3-Clause "New" or "Revised" License
2.01k stars 385 forks source link

WSK: Simplify and fix WskSend/WskReceive #1053

Closed MartinDrab closed 7 months ago

MartinDrab commented 7 months ago

Buffers for WskSend/WskReceive calls are represented by WSK_BUF structures as memory descriptor lists (MDLs). Since the caller is responsible for making them fully initialized, there is no need to use MmProbeAndLockPages to lock the buffer memory in place (IoBuildAsynchronousFsdRequest does that under the hood). Since, the Socket Driver device object works in so-called direct mode, we just need to copy buffer MDLs through IoBuildPartialMdl and pass these copies to the Socket Driver within corresponding IRP_MJ_READ/IRP_MJ_WRITE IRPs. Such approach simplifies the code and also makes WskSend/WskReceive usable at IRQL = DISPATCH_LEVEL (which they should be from the beginning).