ZwClose() for file handle in another thread

Hello!

I create file in thread ‘A’ and then I trying to close handle of file in another thread ‘B’.
It’s wrong, because handle - process/thread dependent variable?

And if I use ZwDuplicateObject() it’s safety and it’s solved possible problem with handles?

Hi Nick,

You must use OBJ_KERNEL_HANDLE on filling up the object attributes, so that the returned handle will be valid on any process/thread but only in kernel mode.

Take a look at the link bellow:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff557749(v=vs.85).aspx

Regards,

Fernando Roberto da Silva
DriverEntry Kernel Development
http://www.driverentry.com.br

Handles in user space are process-relative and therefore any thread in the
process can do anything permitted by the handle creation to any handle
opened by the process. I do not know who “owns” a handle created in the
kernel, and it may depend on whether you specify the UserMode or
KernelMode flag.
joe

Hello!

I create file in thread ‘A’ and then I trying to close handle of file in
another thread ‘B’.
It’s wrong, because handle - process/thread dependent variable?

And if I use ZwDuplicateObject() it’s safety and it’s solved possible
problem with handles?


NTFSD is sponsored by OSR

For our schedule of debugging and file system seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Thank you guys!