Spin Lock

Somewhere I red that it is possible to add new mdl to the already existing one(to build mdl chain). But I cant imagine, how I/O manager will convert it to user mode buffer, when it returns to user.

Yes. I can split to many NBs and return them via the many IRPs but it is not very good solution for me.

Sometimes I need to increase this space.

Well, that’s simply impossible. Surely that must be obvious. The UM app allocated that space from its heap and has the address stored in its own pointers. You can’t arbitrarily extend that space, because there is almost certainly no room in his heap, and you can’t allocate your own space at a new address, because you don’t know where they might have stored the pointer. The IRP is merely telling you where the buffer is. Changes to the IRP are not reflected back to UM.

If there’s not enough room, you need to fail the IRP and have the app send you a larger buffer. There are NTSTATUS codes specifically for this condition.

Yes, you can allocate a new MDL and replace the one in the IRP, but that’s only for requests that are travelling DOWN the stack towards the hardware. In that case, YOU become the client, so you are in control. You do not have the option of modifying the request on the way back up. No one is looking at that.

Thank you Mr. Tim_Roberts. I now will split it into many NBs and return from driver with multiple IRPs. Thanks for your many helpful tips.