Re: INVALID_KERNEL_HANDLE when call ZwClose( )



Jia wrote:
Hi all,
I met a problem when I call ZwClose( ) in kernel driver. If the
parameter is an invalid handle, it will BSOD, that is Bug Check 0x93:
INVALID_KERNEL_HANDLE, with parameter2 is "1". According to MSDN, this
means "the caller tried to close an invalid handle".
Howerver, also in MSDN, ZwClose( ) is said to return
STATUS_INVALID_HANDLE "if Handle is not a valid handle".

Is it inconsistency? How can I avoid this BSOD except to maintain a
handle list?
I used try and except, but it cannot grasp the problem. Is there any
function to check the handle validity?

Don't supply invalid handles to ZwClose or any other kernel routine that requires handles. This is not user mode code, you really are expected to use valid handles, objects, pointers etc. and when you don't it is almost certain that Bad Things Will Happen. This bugcheck may only occur if a debugger is attached and you are closing a handle from a kernel system thread.
.



Relevant Pages

  • Re: INVALID_KERNEL_HANDLE when call ZwClose( )
    ... I met a problem when I call ZwClose() in kernel driver. ... parameter is an invalid handle, it will BSOD, that is Bug Check 0x93: ... means "the caller tried to close an invalid handle". ...
    (microsoft.public.development.device.drivers)
  • INVALID_KERNEL_HANDLE when call ZwClose( )
    ... I met a problem when I call ZwClose() in kernel driver. ... parameter is an invalid handle, it will BSOD, that is Bug Check 0x93: ... means "the caller tried to close an invalid handle". ...
    (microsoft.public.development.device.drivers)
  • Re: weeding out c++ keywords from sys/sys
    ... Can you mention exactly which links were invalid for you? ... any movement within the Linux community to bring C++ support into the kernel. ... should be used as a framenwork for C-like processing segments. ... I would like to go even further and make the framework actually ...
    (freebsd-current)
  • Re: weeding out c++ keywords from sys/sys
    ... Can you mention exactly which links were invalid for you? ... any movement within the Linux community to bring C++ support into the kernel. ... It's time to get real, and admit that C++ is a very powerful tool that, whilst it can be misused in untrained hands, can be very powerful in skillful hands. ...
    (freebsd-current)
  • Re: [PATCH 3/7] inflate pt1: clean up input logic
    ... invalid initrd to kernel" would have been a simpler description. ... Boot firmware passes invalid arguments. ...
    (Linux-Kernel)