(C++) CloseHandle, NtClose by External

Created the Wednesday 22 June 2022. Updated 3 months, 2 weeks ago.

Description:

Original source code is available here: https://anti-debug.checkpoint.com/techniques/object-handles.html#closehandle

Code

            bool Check()
{
    __try
    {
        CloseHandle((HANDLE)0xDEADBEEF);
        return false;
    }
    __except (EXCEPTION_INVALID_HANDLE == GetExceptionCode()
                ? EXCEPTION_EXECUTE_HANDLER 
                : EXCEPTION_CONTINUE_SEARCH)
    {
        return true;
    }
}