static void performKernelAttachOperation(char line[])
{
    char* linePtr = line + 1;

    // Parse the device index
    DWORD devIdx = 0;
    linePtr = parseNumber(linePtr, devIdx);
    if (!linePtr) {
        printf("Please provide a decimal device number following the command\n");
        return;
    }
    if (devIdx >= gDeviceListSize || devIdx < 0) {
        printf("Invalid device index '%d' provided\n", devIdx);
        return;
    }

    // Parse the interface number
    DWORD ifnum = 0;
    linePtr = parseNumber(linePtr, ifnum);
    if (!linePtr) {
        printf("Please provide a decimal interface number\n");
        return;
    }

    UKW_DEVICE device = gDeviceList[devIdx];
    BOOL result = FALSE;
    switch (line[0]) {
    case 't':
    {
        BOOL active = FALSE;
        result = UkwKernelDriverActive(device, ifnum, &active);
        if (result) {
            printf("Kernel driver active on interface %d = %d\n", ifnum, active);
        }
        break;
    }
    case 'a':
    {
        result = UkwAttachKernelDriver(device, ifnum);
        break;
    }
    case 'd':
    {
        result = UkwDetachKernelDriver(device, ifnum);
        break;
    }
    default:
    {
        printf("Unknown operation '%c'\n", line[0]);
        return;
    }
    }

    if (result) {
        printf("Kernel attach operation on interface %d successful.\n", ifnum);
    } else {
        printf("Kernel attach operation on interface %d failed: %d\n", ifnum, GetLastError());
    }
}
static int wince_attach_kernel_driver(
	struct libusb_device_handle *handle,
	int interface_number)
{
	struct wince_device_priv *priv = _device_priv(handle->dev);
	if (!UkwAttachKernelDriver(priv->dev, interface_number)) {
		return translate_driver_error(GetLastError());
	}	
	return LIBUSB_SUCCESS;
}