-
Notifications
You must be signed in to change notification settings - Fork 467
Usage
This section documents the use of the libwdi API.
For those in a hurry, below is a basic example in C of how one would use libwdi to automatically install a driver, for all driverless USB devices present on a system.
struct wdi_device_info *device, *list; if (wdi_create_list(&list, NULL) == WDI_SUCCESS) { for (device = list; device != NULL; device = device->next) { printf("Installing driver for USB device: \"%s\" (%04X:%04X)\n", device->desc, device->vid, device->pid); if (wdi_prepare_driver(device, DEFAULT_DIR, INF_NAME, NULL) == WDI_SUCCESS) { wdi_install_driver(device, DEFAULT_DIR, INF_NAME, NULL); } } wdi_destroy_list(list); }
In the program excerpt above, first we start by creating a list of all the driverless USB devices on the system using wdi_create_list. If any are found, the call returns success with a chained list of wdi_device_info elements containing, among other things, the system description of each device, as well as its USB VID & PID.
Using these properties, we then extract the driver files and generate an inf through wdi_prepare_driver, and finally call wdi_install_driver, which starts the Operating System driver installation procedure.
All of the liwdi API function, apart from wdi_strerror, wdi_is_driver_supported and wdi_is_file_embedded, return one of the error codes below.
The wdi_strerror function, documented further down, is used to convert an error code to a human readable string.
Success is always indicated by a return value zero (WDI_SUCCESS
) while any error will be a negative value.
-
WDI_SUCCESS:
This code is used to indicate that the function completed successfully. Its value is hardcoded to 0. -
WDI_ERROR_IO:
This code indicates that the function call was unable to read or write the data it needs to perform a successful operation. -
WDI_ERROR_INVALID_PARAM:
This code is returned when one of the parameters provided by the user is not valid within the scope of the function usage. -
WDI_ERROR_ACCESS:
This code indicates that the system explicitly refused access to a resource needed to perform a successful operation. -
WDI_ERROR_NO_DEVICE:
This code is returned when either the user is trying to access a USB device that is unavailable, or when a request to enumerate a set of devices finds that none are available. -
WDI_ERROR_NOT_FOUND:
This code is returned when a non device element, required for the function to perform a successful operation, is unavailable. -
WDI_ERROR_BUSY:
This code is returned when a resource (device, I/O channel, etc) or a function that does not support concurrent is already in use. -
WDI_ERROR_TIMEOUT:
This code reports that an operation that has a time limit expired before it could be completed. -
WDI_ERROR_OVERFLOW:
This code indicates that an operation or API call returned more data than was requested. -
WDI_ERROR_PENDING_INSTALLATION:
This code indicates that the system is waiting for a previous driver installation operation to complete. -
WDI_ERROR_INTERRUPTED:
This code indicates that a system call was interrupted by another process. -
WDI_ERROR_RESOURCE:
This code indicates that a system resource required for the function to perform a successful operation, could not be allocated. This can occur if the system is running low on memory or disk, etc. -
WDI_ERROR_NOT_SUPPORTED:
This code indicates that the user requested an operation, or combination of operations, that the system does not currently support. -
WDI_ERROR_EXISTS:
This code is returned when an operation tried to create an entity (device, resource, etc.) that already exists and can only be unique. -
WDI_ERROR_USER_CANCEL:
This code indicates that the end user explicitly cancelled an operation, either when prompted or by forcefully interrupting an operation. -
WDI_ERROR_NEEDS_ADMIN:
This code is returned when a process does not have sufficient privileges to perform the administrative operations it requires. -
WDI_ERROR_WOW64:
This code is returned when a 32 bit process or operation is being run on in an incompatible 64 bit environment. -
WDI_ERROR_INF_SYNTAX:
This code is returned when the driver installation detects either a corrupted or improper inf file. -
WDI_ERROR_CAT_MISSING:
This code indicates that the driver installation required the presence of a cat file to match the inf, and could not find it. -
WDI_ERROR_UNSIGNED:
This code is returned when the system policy prevents the installation of unsigned drivers. -
WDI_ERROR_OTHER:
This code is returned for any error that does not fit in the categories above.
This structure provides all the information related to the device installation
|
This structure is used by wdi_create_list to set optional parameters
|
This structure is used by wdi_prepare_driver to set optional parameters
|
This structure is used by wdi_install_driver to set optional parameters.
|
This structure is used by wdi_install_trusted_certificate to set optional parameters.
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|
Synopsis:
|