Windows C++ / CloseHandle, NtClose

Author External
Platform Windows
Language C++
Technique CloseHandle, NtClose

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;
    }
}

Created

June 22, 2022

Last Revised

April 22, 2024