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: [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)
  • Re: Webcam
    ... > Invalid argument ... > hardware is recognised (everything works fine in camstream) ... The Philips webcams use the "pwc" kernel driver. ... 288x353, or get "pwcx" working. ...
    (comp.os.linux.hardware)
  • 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. ... The kernel does not have such functionality, ... if we have to have separate code to validate a compressed image, ...
    (Linux-Kernel)