summaryrefslogtreecommitdiffstats
path: root/src/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Josef Micka2023-03-02 13:46:17 +0100
committerGravatar Nikias Bassen2023-05-08 13:48:05 +0200
commit3b4ef6a3d109702694435087311258355df1b63a (patch)
tree404fa19f1a1ae58dc0a2f08b52af858ffd95f405 /src/libirecovery.c
parent12ed446fb17b8ea34728641cf4ca836eedab7aeb (diff)
downloadlibirecovery-3b4ef6a3d109702694435087311258355df1b63a.tar.gz
libirecovery-3b4ef6a3d109702694435087311258355df1b63a.tar.bz2
win32: Use ANSI versions for SetupDI and CreateFile API to prevent errors when compiling with unicode support
Diffstat (limited to 'src/libirecovery.c')
-rw-r--r--src/libirecovery.c38
1 files 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) {
791 _client->DfuPath = NULL; 791 _client->DfuPath = NULL;
792 _client->handle = NULL; 792 _client->handle = NULL;
793 DWORD requiredSize = 0; 793 DWORD requiredSize = 0;
794 PSP_DEVICE_INTERFACE_DETAIL_DATA details; 794 PSP_DEVICE_INTERFACE_DETAIL_DATA_A details;
795 SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL); 795 SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL);
796 details = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize); 796 details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize);
797 details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); 797 details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
798 if(!SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) { 798 if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) {
799 free(details); 799 free(details);
800 continue; 800 continue;
801 } else { 801 } else {
@@ -884,11 +884,11 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
884 _client->iBootPath = NULL; 884 _client->iBootPath = NULL;
885 _client->handle = NULL; 885 _client->handle = NULL;
886 DWORD requiredSize = 0; 886 DWORD requiredSize = 0;
887 PSP_DEVICE_INTERFACE_DETAIL_DATA details; 887 PSP_DEVICE_INTERFACE_DETAIL_DATA_A details;
888 SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL); 888 SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL);
889 details = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize); 889 details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize);
890 details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); 890 details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
891 if(!SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) { 891 if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, NULL)) {
892 free(details); 892 free(details);
893 continue; 893 continue;
894 } else { 894 } else {
@@ -965,12 +965,12 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, uint64_t ecid) {
965} 965}
966 966
967irecv_error_t mobiledevice_openpipes(irecv_client_t client) { 967irecv_error_t mobiledevice_openpipes(irecv_client_t client) {
968 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))) { 968 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))) {
969 irecv_close(client); 969 irecv_close(client);
970 return IRECV_E_UNABLE_TO_CONNECT; 970 return IRECV_E_UNABLE_TO_CONNECT;
971 } 971 }
972 972
973 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))) { 973 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))) {
974 irecv_close(client); 974 irecv_close(client);
975 return IRECV_E_UNABLE_TO_CONNECT; 975 return IRECV_E_UNABLE_TO_CONNECT;
976 } 976 }
@@ -1860,7 +1860,7 @@ struct irecv_usb_device_info {
1860 1860
1861#ifdef WIN32 1861#ifdef WIN32
1862struct irecv_win_dev_ctx { 1862struct irecv_win_dev_ctx {
1863 PSP_DEVICE_INTERFACE_DETAIL_DATA details; 1863 PSP_DEVICE_INTERFACE_DETAIL_DATA_A details;
1864 uint32_t location; 1864 uint32_t location;
1865}; 1865};
1866#else 1866#else
@@ -1934,7 +1934,7 @@ static void* _irecv_handle_device_add(void *userdata)
1934 memset(serial_str, 0, 256); 1934 memset(serial_str, 0, 256);
1935#ifdef WIN32 1935#ifdef WIN32
1936 struct irecv_win_dev_ctx *win_ctx = (struct irecv_win_dev_ctx*)userdata; 1936 struct irecv_win_dev_ctx *win_ctx = (struct irecv_win_dev_ctx*)userdata;
1937 PSP_DEVICE_INTERFACE_DETAIL_DATA details = win_ctx->details; 1937 PSP_DEVICE_INTERFACE_DETAIL_DATA_A details = win_ctx->details;
1938 LPSTR result = (LPSTR)details->DevicePath; 1938 LPSTR result = (LPSTR)details->DevicePath;
1939 location = win_ctx->location; 1939 location = win_ctx->location;
1940 1940
@@ -2224,13 +2224,13 @@ static void *_irecv_event_handler(void* data)
2224 currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); 2224 currentInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
2225 for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, guids[k], i, &currentInterface); i++) { 2225 for (i = 0; usbDevices && SetupDiEnumDeviceInterfaces(usbDevices, NULL, guids[k], i, &currentInterface); i++) {
2226 DWORD requiredSize = 0; 2226 DWORD requiredSize = 0;
2227 PSP_DEVICE_INTERFACE_DETAIL_DATA details; 2227 PSP_DEVICE_INTERFACE_DETAIL_DATA_A details;
2228 SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL); 2228 SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, NULL, 0, &requiredSize, NULL);
2229 details = (PSP_DEVICE_INTERFACE_DETAIL_DATA) malloc(requiredSize); 2229 details = (PSP_DEVICE_INTERFACE_DETAIL_DATA_A) malloc(requiredSize);
2230 details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); 2230 details->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A);
2231 SP_DEVINFO_DATA devinfodata; 2231 SP_DEVINFO_DATA devinfodata;
2232 devinfodata.cbSize = sizeof(SP_DEVINFO_DATA); 2232 devinfodata.cbSize = sizeof(SP_DEVINFO_DATA);
2233 if(!SetupDiGetDeviceInterfaceDetail(usbDevices, &currentInterface, details, requiredSize, NULL, &devinfodata)) { 2233 if(!SetupDiGetDeviceInterfaceDetailA(usbDevices, &currentInterface, details, requiredSize, NULL, &devinfodata)) {
2234 free(details); 2234 free(details);
2235 continue; 2235 continue;
2236 } 2236 }
@@ -2238,7 +2238,7 @@ static void *_irecv_event_handler(void* data)
2238 DWORD sz = REG_SZ; 2238 DWORD sz = REG_SZ;
2239 char driver[256]; 2239 char driver[256];
2240 driver[0] = '\0'; 2240 driver[0] = '\0';
2241 if (!SetupDiGetDeviceRegistryProperty(usbDevices, &devinfodata, SPDRP_DRIVER, &sz, (PBYTE)driver, sizeof(driver), NULL)) { 2241 if (!SetupDiGetDeviceRegistryPropertyA(usbDevices, &devinfodata, SPDRP_DRIVER, &sz, (PBYTE)driver, sizeof(driver), NULL)) {
2242 debug("%s: ERROR: Failed to get driver key\n", __func__); 2242 debug("%s: ERROR: Failed to get driver key\n", __func__);
2243 free(details); 2243 free(details);
2244 continue; 2244 continue;