Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query
The error you're encountering is because when you call IoAllocateMdl with a Length argument of 0, you are allocating an MDL (Memory Descriptor List) that describes an invalid memory region.
MmMapLockedPagesSpecifyCache maps the locked pages described by the MDL into a virtually contiguous region of system address space. In this case, the MDL describes a region of 0 length, which means there are no pages to map. This leads to an error when trying to unmap the pages using MmUnmapLockedPages.
To avoid this error, you should ensure that the Length argument passed to IoAllocateMdl is non-zero and that it represents a valid memory region before calling MmMapLockedPagesSpecifyCache.
If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.