|
Packit Service |
b0a153 |
/*
|
|
Packit Service |
b0a153 |
* Windows backend common header for libusb 1.0
|
|
Packit Service |
b0a153 |
*
|
|
Packit Service |
b0a153 |
* This file brings together header code common between
|
|
Packit Service |
b0a153 |
* the desktop Windows backends.
|
|
Packit Service |
b0a153 |
* Copyright © 2012-2013 RealVNC Ltd.
|
|
Packit Service |
b0a153 |
* Copyright © 2009-2012 Pete Batard <pete@akeo.ie>
|
|
Packit Service |
b0a153 |
* With contributions from Michael Plante, Orin Eman et al.
|
|
Packit Service |
b0a153 |
* Parts of this code adapted from libusb-win32-v1 by Stephan Meyer
|
|
Packit Service |
b0a153 |
* Major code testing contribution by Xiaofan Chen
|
|
Packit Service |
b0a153 |
*
|
|
Packit Service |
b0a153 |
* This library is free software; you can redistribute it and/or
|
|
Packit Service |
b0a153 |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
b0a153 |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
b0a153 |
* version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
b0a153 |
*
|
|
Packit Service |
b0a153 |
* This library is distributed in the hope that it will be useful,
|
|
Packit Service |
b0a153 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
b0a153 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
b0a153 |
* Lesser General Public License for more details.
|
|
Packit Service |
b0a153 |
*
|
|
Packit Service |
b0a153 |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
b0a153 |
* License along with this library; if not, write to the Free Software
|
|
Packit Service |
b0a153 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit Service |
b0a153 |
*/
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
#pragma once
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
#include "windows_nt_shared_types.h"
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
/* Windows versions */
|
|
Packit Service |
b0a153 |
enum windows_version {
|
|
Packit Service |
b0a153 |
WINDOWS_UNDEFINED,
|
|
Packit Service |
b0a153 |
WINDOWS_2000,
|
|
Packit Service |
b0a153 |
WINDOWS_XP,
|
|
Packit Service |
b0a153 |
WINDOWS_2003, // Also XP x64
|
|
Packit Service |
b0a153 |
WINDOWS_VISTA,
|
|
Packit Service |
b0a153 |
WINDOWS_7,
|
|
Packit Service |
b0a153 |
WINDOWS_8,
|
|
Packit Service |
b0a153 |
WINDOWS_8_1,
|
|
Packit Service |
b0a153 |
WINDOWS_10,
|
|
Packit Service |
b0a153 |
WINDOWS_11_OR_LATER
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
extern enum windows_version windows_version;
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
/* This call is only available from Vista */
|
|
Packit Service |
b0a153 |
extern BOOL (WINAPI *pCancelIoEx)(HANDLE, LPOVERLAPPED);
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
struct windows_backend {
|
|
Packit Service |
b0a153 |
int (*init)(struct libusb_context *ctx);
|
|
Packit Service |
b0a153 |
void (*exit)(struct libusb_context *ctx);
|
|
Packit Service |
b0a153 |
int (*get_device_list)(struct libusb_context *ctx,
|
|
Packit Service |
b0a153 |
struct discovered_devs **discdevs);
|
|
Packit Service |
b0a153 |
int (*open)(struct libusb_device_handle *dev_handle);
|
|
Packit Service |
b0a153 |
void (*close)(struct libusb_device_handle *dev_handle);
|
|
Packit Service |
b0a153 |
int (*get_device_descriptor)(struct libusb_device *device, unsigned char *buffer);
|
|
Packit Service |
b0a153 |
int (*get_active_config_descriptor)(struct libusb_device *device,
|
|
Packit Service |
b0a153 |
unsigned char *buffer, size_t len);
|
|
Packit Service |
b0a153 |
int (*get_config_descriptor)(struct libusb_device *device,
|
|
Packit Service |
b0a153 |
uint8_t config_index, unsigned char *buffer, size_t len);
|
|
Packit Service |
b0a153 |
int (*get_config_descriptor_by_value)(struct libusb_device *device,
|
|
Packit Service |
b0a153 |
uint8_t bConfigurationValue, unsigned char **buffer);
|
|
Packit Service |
b0a153 |
int (*get_configuration)(struct libusb_device_handle *dev_handle, int *config);
|
|
Packit Service |
b0a153 |
int (*set_configuration)(struct libusb_device_handle *dev_handle, int config);
|
|
Packit Service |
b0a153 |
int (*claim_interface)(struct libusb_device_handle *dev_handle, int interface_number);
|
|
Packit Service |
b0a153 |
int (*release_interface)(struct libusb_device_handle *dev_handle, int interface_number);
|
|
Packit Service |
b0a153 |
int (*set_interface_altsetting)(struct libusb_device_handle *dev_handle,
|
|
Packit Service |
b0a153 |
int interface_number, int altsetting);
|
|
Packit Service |
b0a153 |
int (*clear_halt)(struct libusb_device_handle *dev_handle,
|
|
Packit Service |
b0a153 |
unsigned char endpoint);
|
|
Packit Service |
b0a153 |
int (*reset_device)(struct libusb_device_handle *dev_handle);
|
|
Packit Service |
b0a153 |
void (*destroy_device)(struct libusb_device *dev);
|
|
Packit Service |
b0a153 |
int (*submit_transfer)(struct usbi_transfer *itransfer);
|
|
Packit Service |
b0a153 |
int (*cancel_transfer)(struct usbi_transfer *itransfer);
|
|
Packit Service |
b0a153 |
void (*clear_transfer_priv)(struct usbi_transfer *itransfer);
|
|
Packit Service |
b0a153 |
int (*copy_transfer_data)(struct usbi_transfer *itransfer, uint32_t io_size);
|
|
Packit Service |
b0a153 |
int (*get_transfer_fd)(struct usbi_transfer *itransfer);
|
|
Packit Service |
b0a153 |
void (*get_overlapped_result)(struct usbi_transfer *itransfer,
|
|
Packit Service |
b0a153 |
DWORD *io_result, DWORD *io_size);
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
struct windows_context_priv {
|
|
Packit Service |
b0a153 |
const struct windows_backend *backend;
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
union windows_device_priv {
|
|
Packit Service |
b0a153 |
struct usbdk_device_priv usbdk_priv;
|
|
Packit Service |
b0a153 |
struct winusb_device_priv winusb_priv;
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
union windows_device_handle_priv {
|
|
Packit Service |
b0a153 |
struct usbdk_device_handle_priv usbdk_priv;
|
|
Packit Service |
b0a153 |
struct winusb_device_handle_priv winusb_priv;
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
union windows_transfer_priv {
|
|
Packit Service |
b0a153 |
struct usbdk_transfer_priv usbdk_priv;
|
|
Packit Service |
b0a153 |
struct winusb_transfer_priv winusb_priv;
|
|
Packit Service |
b0a153 |
};
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
extern const struct windows_backend usbdk_backend;
|
|
Packit Service |
b0a153 |
extern const struct windows_backend winusb_backend;
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
unsigned long htab_hash(const char *str);
|
|
Packit Service |
b0a153 |
void windows_force_sync_completion(OVERLAPPED *overlapped, ULONG size);
|
|
Packit Service |
b0a153 |
|
|
Packit Service |
b0a153 |
#if defined(ENABLE_LOGGING)
|
|
Packit Service |
b0a153 |
const char *windows_error_str(DWORD error_code);
|
|
Packit Service |
b0a153 |
#endif
|