From 3b4ef6a3d109702694435087311258355df1b63a Mon Sep 17 00:00:00 2001 From: Josef Micka Date: Thu, 2 Mar 2023 13:46:17 +0100 Subject: win32: Use ANSI versions for SetupDI and CreateFile API to prevent errors when compiling with unicode support --- src/libirecovery.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libirecovery.c b/src/libirecovery.c index 6741b95..a91a742 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c @@ -791,11 +791,11 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) { _client->DfuPath = NULL; _client->handle = NULL; DWORD requiredSize = 0; - PSP_DEVICE_INTERFACE_DETAIL_DATA details; - SetupDiGetDeviceInterfaceDetail(usbDevices, ¤tInterface, NULL, 0, &requiredSize, NULL); - details = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize); - details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - if(!SetupDiGetDeviceInterfaceDetail(usbDevices, ¤tInterface, details, requiredSize, NULL, NULL)) { + PSP_DEVICE_INTERFACE_DETAIL_DATA_A details; + SetupDiGetDeviceInterfaceDetailA(usbDevices, ¤tInterface, NULL, 0, &requiredSize, NULL); + details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize); + details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); + if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, ¤tInterface, details, requiredSize, NULL, NULL)) { free(details); continue; } else { @@ -884,11 +884,11 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) { _client->iBootPath = NULL; _client->handle = NULL; DWORD requiredSize = 0; - PSP_DEVICE_INTERFACE_DETAIL_DATA details; - SetupDiGetDeviceInterfaceDetail(usbDevices, ¤tInterface, NULL, 0, &requiredSize, NULL); - details = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize); - details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); - if(!SetupDiGetDeviceInterfaceDetail(usbDevices, ¤tInterface, details, requiredSize, NULL, NULL)) { + PSP_DEVICE_INTERFACE_DETAIL_DATA_A details; + SetupDiGetDeviceInterfaceDetailA(usbDevices, ¤tInterface, NULL, 0, &requiredSize, NULL); + details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize); + details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); + if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, ¤tInterface, details, requiredSize, NULL, NULL)) { free(details); continue; } else { @@ -965,12 +965,12 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) { } irecv_error_t mobiledevice_openpipes(irecv_client_t client) { - if (client->iBootPath && !(client->hIB = CreateFile(client->iBootPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL))) { + if (client->iBootPath && !(client->hIB = CreateFileA(client->iBootPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL))) { irecv_close(client); return IRECV_E_UNABLE_TO_CONNECT; } - if (client->DfuPath && !(client->hDFU = CreateFile(client->DfuPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL))) { + if (client->DfuPath && !(client->hDFU = CreateFileA(client->DfuPath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL))) { irecv_close(client); return IRECV_E_UNABLE_TO_CONNECT; } @@ -1860,7 +1860,7 @@ struct irecv_usb_device_info { #ifdef WIN32 struct irecv_win_dev_ctx { - PSP_DEVICE_INTERFACE_DETAIL_DATA details; + PSP_DEVICE_INTERFACE_DETAIL_DATA_A details; uint32_t location; }; #else @@ -1934,7 +1934,7 @@ static void* _irecv_handle_device_add(void *userdata) memset(serial_str, 0, 256); #ifdef WIN32 struct irecv_win_dev_ctx *win_ctx = (struct irecv_win_dev_ctx*)userdata; - PSP_DEVICE_INTERFACE_DETAIL_DATA details = win_ctx->details; + PSP_DEVICE_INTERFACE_DETAIL_DATA_A details = win_ctx->details; LPSTR result = (LPSTR)details->DevicePath; location = win_ctx->location; @@ -2224,13 +2224,13 @@ static void *_irecv_event_handler(void* data) currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, guids[k], i, ¤tInterface); i++) { DWORD requiredSize = 0; - PSP_DEVICE_INTERFACE_DETAIL_DATA details; + PSP_DEVICE_INTERFACE_DETAIL_DATA_A details; SetupDiGetDeviceInterfaceDetail(usbDevices, ¤tInterface, NULL, 0, &requiredSize, NULL); - details = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize); - details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); + details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize); + details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); SP_DEVINFO_DATA devinfodata; devinfodata.cbSize = sizeof(SP_DEVINFO_DATA); - if(!SetupDiGetDeviceInterfaceDetail(usbDevices, ¤tInterface, details, requiredSize, NULL, &devinfodata)) { + if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, ¤tInterface, details, requiredSize, NULL, &devinfodata)) { free(details); continue; } @@ -2238,7 +2238,7 @@ static void *_irecv_event_handler(void* data) DWORD sz = REG_SZ; char driver[256]; driver[0] = '\0'; - if (!SetupDiGetDeviceRegistryProperty(usbDevices, &devinfodata, SPDRP_DRIVER, &sz, (PBYTE)driver, sizeof(driver), NULL)) { + if (!SetupDiGetDeviceRegistryPropertyA(usbDevices, &devinfodata, SPDRP_DRIVER, &sz, (PBYTE)driver, sizeof(driver), NULL)) { debug("%s: ERROR: Failed to get driver key\n", __func__); free(details); continue; -- cgit v1.1-32-gdbae