I need to pass a handle/identifier to usermode to be able to track requests. And obviously when a future IOCTL passes back that handle, I need to be sure usermode isn't up to mischief.
Is there an existing API for this, or should I just maintain a freelist of small integers which I can check against an array of known handles when usermode passes it back to me? If the latter, are there any pitfalls I need to watch out for?
The problem I'm solving here is that usermode will request an SRB (obviously not an exact SRB, but enough information for usermode to service the SRB), and then a short time later usermode will complete the SRB (eg passing back a buffer for a read request). I need to pass usermode an identifier when the SRB is requested, and track that identifier when the SRB is completed.
And to further elaborate, usermode will basically only get read and write requests, as well as pass some device dimensions on startup. I'm not going to allow arbitrary mode pages etc to be sent from usermode.