Do you have a problem with ZwQueryVirtualMemory or with ObOpenObjectByPointer (as your code might suggest)?
If you specify UserMode as access mode, the system performs security checks whether you are allowed to do the operation. Additionally, some buffers must point to userspace memory (this is true especially for ZwXxx functions).
If you specify UserMode as access mode, the system performs security checks whether you are allowed to do the operation. Additionally, some buffers must point to userspace memory (this is true especially for ZwXxx functions).