diff options
Diffstat (limited to 'libusb/os/windows_usb.c')
-rw-r--r-- | libusb/os/windows_usb.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index bced4ee..d6e9f9d 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -250,6 +250,20 @@ static char* sanitize_path(const char* path) } /* + * Cfgmgr32 API functions + */ +static int Cfgmgr32_init(void) +{ + DLL_LOAD(Cfgmgr32.dll, CM_Get_Parent, TRUE); + DLL_LOAD(Cfgmgr32.dll, CM_Get_Child, TRUE); + DLL_LOAD(Cfgmgr32.dll, CM_Get_Sibling, TRUE); + DLL_LOAD(Cfgmgr32.dll, CM_Get_Device_IDA, TRUE); + DLL_LOAD(Cfgmgr32.dll, CM_Get_Device_IDW, TRUE); + + return LIBUSB_SUCCESS; +} + +/* * enumerate interfaces for a specific GUID * * Parameters: @@ -390,6 +404,11 @@ static int windows_init(struct libusb_context *ctx) struct windows_hcd_priv** _hcd_cur; TCHAR sem_name[11+1+8]; // strlen(libusb_init)+'\0'+(32-bit hex PID) + if (Cfgmgr32_init() != LIBUSB_SUCCESS) { + usbi_err(ctx, "could not resolve Cfgmgr32.dll functions"); + return LIBUSB_ERROR_OTHER; + } + sprintf(sem_name, "libusb_init%08X", (unsigned int)GetCurrentProcessId()&0xFFFFFFFF); semaphore = CreateSemaphore(NULL, 1, 1, sem_name); if (semaphore == NULL) { |