qemu/target/i386/hax-windows.c
/*
 * return 0 when success, -1 when driver not loaded,
 * other negative value for other failure
 */
return 0 when success, -1 when driver not loaded,
other negative value for other failure
return 0 when success - 1 when driver not loaded other negative value for other failure
static int hax_open_device(hax_fd *fd)
{
    uint32_t errNum = 0;
    HANDLE hDevice;
    if (!fd) {
        return -2;
    }
    hDevice = CreateFile("\\\\.\\HAX",
                         GENERIC_READ | GENERIC_WRITE,
                         0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (hDevice == INVALID_HANDLE_VALUE) {
        fprintf(stderr, "Failed to open the HAX device!\n");
        errNum = GetLastError();
        if (errNum == ERROR_FILE_NOT_FOUND) {
            return -1;
        }
        return -2;
    }
    *fd = hDevice;
    return 0;
}
static int hax_open_device ( hax_fd * fd ) { uint32_t errNum = 0 ; HANDLE hDevice ; if ( ! fd ) { return -2 ; } hDevice = CreateFile ( " \\ \\ \\ " , GENERIC_READ | GENERIC_WRITE , 0 , NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ) ; if ( hDevice == INVALID_HANDLE_VALUE ) { fprintf ( stderr , " \n " ) ; errNum = GetLastError ( ) ; if ( errNum == ERROR_FILE_NOT_FOUND ) { return -1 ; } return -2 ; } * fd = hDevice ; return 0 ; }
return 0 when success, -1 when driver not loaded,
 other negative value for other failure
return 0 when success - 1 when driver not loaded other negative value for other failure