From 90278c538a8fb5fd82aab25ae7f5a9887ca468ce Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 1 Mar 2023 17:22:25 +0000 Subject: [PATCH] libwdi 1.5.0 * Also fix static analysis warnings --- ChangeLog | 10 ++++++++++ README.md | 2 +- examples/wdi-simple.rc | 10 +++++----- examples/zadig.c | 7 ++++--- examples/zadig.h | 2 +- examples/zadig.rc | 14 +++++++------- libwdi/installer.c | 6 +++--- libwdi/libwdi.c | 4 ++-- libwdi/libwdi.rc | 10 +++++----- libwdi/msapi_utf8.h | 4 ++-- 10 files changed, 40 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f3a2249..093c39a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,16 @@ For the latest changes, please visit: https://github.com/pbatard/libwdi/commits/master +o v1.5.0 (2023.03.01) + New features: + - ARM64 driver installation support (WinUSB, USBSer with MSVC only) + Bugfixes: + - fix MSVC compilation of the shared library + - fix MinGW compilation when using the shared library (with thanks to Joel Holdsworth) + Improvements: + - avoid symbol conflicts by using library specific prefixes where needed + - improve Zadig network support + o v1.4.1 (2021.11.01) New features: - add a new 'external_inf' boolean option to wdi_options_prepare_driver diff --git a/README.md b/README.md index ad1a06a2..106d8f5e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Main features * Automated inf creation, using reported USB device name * Automated catalog file creation and signing, using autogenerated certificate -* Automated driver files extraction, for both 32 and 64 bit platforms +* Automated driver files extraction, for x86_32 x86_64 and ARM64 platforms * Automated driver installation, including UAC elevation where necessary * Single library embedding all the required files * Supports Windows platform from Windows 7 to Windows 11 diff --git a/examples/wdi-simple.rc b/examples/wdi-simple.rc index 85f5a07d..5e8d4f0b 100644 --- a/examples/wdi-simple.rc +++ b/examples/wdi-simple.rc @@ -7,8 +7,8 @@ #endif VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,1,781 - PRODUCTVERSION 1,4,1,781 + FILEVERSION 1,5,0,782 + PRODUCTVERSION 1,5,0,782 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -25,13 +25,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "WDI-Simple" - VALUE "FileVersion", "1.4.1.781" + VALUE "FileVersion", "1.5.0.782" VALUE "InternalName", "WDI-Simple" - VALUE "LegalCopyright", "© 2010-2021 Pete Batard (LGPL v3)" + VALUE "LegalCopyright", "� 2010-2023 Pete Batard (LGPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/lesser.html" VALUE "OriginalFilename", "wdi-simple.exe" VALUE "ProductName", "WDI-Simple" - VALUE "ProductVersion", "1.4.1.781" + VALUE "ProductVersion", "1.5.0.782" VALUE "Comments", "http://libwdi.akeo.ie" END END diff --git a/examples/zadig.c b/examples/zadig.c index 95bbc324..e236fda4 100644 --- a/examples/zadig.c +++ b/examples/zadig.c @@ -936,11 +936,12 @@ int get_windows_version(char* WindowsVersionStr, size_t WindowsVersionStrSize) char* vptr; size_t vlen; unsigned major, minor; - int nWindowsVersion, nWindowsBuildNumber; + int nWindowsVersion = WINDOWS_UNDEFINED, nWindowsBuildNumber = 0; ULONGLONG major_equal, minor_equal; BOOL ws; - nWindowsVersion = WINDOWS_UNDEFINED; + if (WindowsVersionStr == NULL || WindowsVersionStrSize < 32) + return nWindowsVersion; safe_strcpy(WindowsVersionStr, WindowsVersionStrSize, "Windows Undefined"); memset(&vi, 0, sizeof(vi)); @@ -1282,7 +1283,7 @@ BOOL parse_ini(void) { // Set the log level profile_get_integer(profile, "general", "log_level", NULL, WDI_LOG_LEVEL_INFO, &log_level); - if ((log_level < WDI_LOG_LEVEL_DEBUG) && (log_level > WDI_LOG_LEVEL_NONE)) { + if ((log_level < WDI_LOG_LEVEL_DEBUG) || (log_level > WDI_LOG_LEVEL_NONE)) { log_level = WDI_LOG_LEVEL_INFO; } diff --git a/examples/zadig.h b/examples/zadig.h index 1729a319..20c95525 100644 --- a/examples/zadig.h +++ b/examples/zadig.h @@ -60,7 +60,7 @@ #define FIELD_ORANGE RGB(255,240,200) #define ARROW_GREEN RGB(92,228,65) #define ARROW_ORANGE RGB(253,143,56) -#define APP_VERSION "Zadig 2.7.781" +#define APP_VERSION "Zadig 2.8.782" // These are used to flag end users about the driver they are going to replace enum driver_type { diff --git a/examples/zadig.rc b/examples/zadig.rc index 2d569441..af30ae66 100644 --- a/examples/zadig.rc +++ b/examples/zadig.rc @@ -151,7 +151,7 @@ BEGIN LTEXT "WCID",IDC_STATIC_WCID,14,84,18,9,SS_NOTIFY EDITTEXT IDC_WCID_BOX,40,82,14,14,ES_READONLY | NOT WS_TABSTOP EDITTEXT IDC_WCID,55,82,44,14,ES_READONLY | NOT WS_VISIBLE | NOT WS_TABSTOP,WS_EX_TRANSPARENT - LTEXT "ð",IDC_RARR,142,44,17,14,SS_NOTIFY | SS_CENTERIMAGE | NOT WS_VISIBLE + LTEXT "�",IDC_RARR,142,44,17,14,SS_NOTIFY | SS_CENTERIMAGE | NOT WS_VISIBLE EDITTEXT IDC_TARGET,162,44,98,14,ES_READONLY | NOT WS_TABSTOP CONTROL "",IDC_TARGETSPIN,"msctls_updown32",UDS_ARROWKEYS,260,44,11,14,WS_EX_TRANSPARENT CONTROL IDB_ZADIG,IDC_THIS_SPACE_FOR_RENT,"Static",SS_BITMAP | SS_CENTERIMAGE | SS_REALSIZEIMAGE,278,37,97,66 @@ -246,8 +246,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,7,781,0 - PRODUCTVERSION 2,7,781,0 + FILEVERSION 2,8,782,0 + PRODUCTVERSION 2,8,782,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -264,14 +264,14 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Zadig" - VALUE "FileVersion", "2.7.781" + VALUE "FileVersion", "2.8.782" VALUE "InternalName", "Zadig" - VALUE "LegalCopyright", "© 2010-2021 Pete Batard (GPL v3)" + VALUE "LegalCopyright", "� 2010-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "zadig.exe" VALUE "ProductName", "Zadig" - VALUE "ProductVersion", "2.7.781" - VALUE "Comments", "http://libwdi.akeo.ie" + VALUE "ProductVersion", "2.8.782" + VALUE "Comments", "https://zadig.akeo.ie" END END BLOCK "VarFileInfo" diff --git a/libwdi/installer.c b/libwdi/installer.c index 0f86057b..89599803 100644 --- a/libwdi/installer.c +++ b/libwdi/installer.c @@ -365,12 +365,12 @@ static __inline char* xlocale_to_utf8(const char* str) } // +1 for extra leading byte - if ((ustr = (char*)calloc(size+1, 1)) == NULL) { + if ((ustr = (char*)calloc((size_t)size + 1, 1)) == NULL) { free(wstr); return NULL; } - if (wchar_to_utf8_no_alloc(wstr, ustr+1, size) != size) { + if (wchar_to_utf8_no_alloc(wstr, ustr + 1, size) != size) { free(ustr); free(wstr); return NULL; @@ -480,7 +480,7 @@ void __cdecl syslog_reader_thread(void* param) if (size != 0) { // Read from file and add a zero terminator - buffer = malloc(size+1); + buffer = malloc((size_t)size + 1); if (buffer == NULL) { plog("could not allocate buffer to read syslog"); goto out; diff --git a/libwdi/libwdi.c b/libwdi/libwdi.c index a5dc7286..0bd1296c 100644 --- a/libwdi/libwdi.c +++ b/libwdi/libwdi.c @@ -1693,7 +1693,7 @@ static int install_driver_internal(void* arglist) DWORD err, rd_count, to_read, offset, bufsize = LOGBUF_SIZE; USHORT platform_arch = get_platform_arch(); int r; - char path[MAX_PATH], exename[MAX_PATH], exeargs[MAX_PATH], installer_name[32]; + char path[MAX_PATH], exename[MAX_PATH], exeargs[MAX_PATH], installer_name[32] = { 0 }; char *buffer = NULL, *new_buffer; const char* filter_name = "libusb0"; @@ -1768,7 +1768,7 @@ static int install_driver_internal(void* arglist) static_sprintf(exeargs, "\"%s\"", params->inf_name); } else { // Use libusb-win32's filter driver installer - static_strcat(installer_name, "install-filter.exe"); + static_strcpy(installer_name, "install-filter.exe"); static_strcat(path, (platform_arch == IMAGE_FILE_MACHINE_AMD64) ? "\\amd64" : "\\x86"); if (safe_stricmp(current_device->upper_filter, filter_name) == 0) { // Device already has the libusb-win32 filter => remove diff --git a/libwdi/libwdi.rc b/libwdi/libwdi.rc index aa2a30f9..30fed185 100644 --- a/libwdi/libwdi.rc +++ b/libwdi/libwdi.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,1,781 - PRODUCTVERSION 1,4,1,781 + FILEVERSION 1,5,0,782 + PRODUCTVERSION 1,5,0,782 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -68,13 +68,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "libwdi: Windows Driver Installer Library" - VALUE "FileVersion", "1.4.1.781" + VALUE "FileVersion", "1.5.0.782" VALUE "InternalName", "libwdi" - VALUE "LegalCopyright", "© 2010-2022 Pete Batard (LGPL v3)" + VALUE "LegalCopyright", "� 2010-2023 Pete Batard (LGPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/lesser.html" VALUE "OriginalFilename", "libwdi" VALUE "ProductName", "libwdi" - VALUE "ProductVersion", "1.4.1.781" + VALUE "ProductVersion", "1.5.0.782" VALUE "Comments", "http://libwdi.akeo.ie" END END diff --git a/libwdi/msapi_utf8.h b/libwdi/msapi_utf8.h index 9ace267b..2e020c1e 100644 --- a/libwdi/msapi_utf8.h +++ b/libwdi/msapi_utf8.h @@ -439,11 +439,11 @@ static __inline int ComboBox_GetLBTextU(HWND hCtrl, int index, char* lpString) size = (int)SendMessageW(hCtrl, CB_GETLBTEXTLEN, (WPARAM)index, (LPARAM)0); if (size < 0) return size; - wlpString = (wchar_t*)calloc(size+1, sizeof(wchar_t)); + wlpString = (wchar_t*)calloc((size_t)size + 1, sizeof(wchar_t)); size = (int)SendMessageW(hCtrl, CB_GETLBTEXT, (WPARAM)index, (LPARAM)wlpString); err = GetLastError(); if (size > 0) - wchar_to_utf8_no_alloc(wlpString, lpString, size+1); + wchar_to_utf8_no_alloc(wlpString, lpString, size + 1); wfree(lpString); SetLastError(err); return size;