Skip to content

Commit 367ef15

Browse files
committed
[zadig] prevent DLL side-load from current directory
* Also add platform version to User Agent info and fix warnings
1 parent ae8feb3 commit 367ef15

File tree

8 files changed

+33
-27
lines changed

8 files changed

+33
-27
lines changed

examples/wdi-simple.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#endif
88

99
VS_VERSION_INFO VERSIONINFO
10-
FILEVERSION 1,2,5,691
11-
PRODUCTVERSION 1,2,5,691
10+
FILEVERSION 1,2,5,692
11+
PRODUCTVERSION 1,2,5,692
1212
FILEFLAGSMASK 0x17L
1313
#ifdef _DEBUG
1414
FILEFLAGS 0x1L
@@ -25,13 +25,13 @@ BEGIN
2525
BEGIN
2626
VALUE "CompanyName", "akeo.ie"
2727
VALUE "FileDescription", "WDI-Simple"
28-
VALUE "FileVersion", "1.2.5.691"
28+
VALUE "FileVersion", "1.2.5.692"
2929
VALUE "InternalName", "WDI-Simple"
3030
VALUE "LegalCopyright", "� 2010-2014 Pete Batard (LGPL v3)"
3131
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
3232
VALUE "OriginalFilename", "wdi-simple.exe"
3333
VALUE "ProductName", "WDI-Simple"
34-
VALUE "ProductVersion", "1.2.5.691"
34+
VALUE "ProductVersion", "1.2.5.692"
3535
VALUE "Comments", "http://libwdi.akeo.ie"
3636
END
3737
END

examples/zadic.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ END
5656
//
5757

5858
VS_VERSION_INFO VERSIONINFO
59-
FILEVERSION 1,2,5,691
60-
PRODUCTVERSION 1,2,5,691
59+
FILEVERSION 1,2,5,692
60+
PRODUCTVERSION 1,2,5,692
6161
FILEFLAGSMASK 0x17L
6262
#ifdef _DEBUG
6363
FILEFLAGS 0x1L
@@ -74,13 +74,13 @@ BEGIN
7474
BEGIN
7575
VALUE "CompanyName", "akeo.ie"
7676
VALUE "FileDescription", "Zadic"
77-
VALUE "FileVersion", "1.2.5.691"
77+
VALUE "FileVersion", "1.2.5.692"
7878
VALUE "InternalName", "Zadic"
7979
VALUE "LegalCopyright", "� 2010-2014 Pete Batard (LGPL v3)"
8080
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
8181
VALUE "OriginalFilename", "zadic.exe"
8282
VALUE "ProductName", "Zadic"
83-
VALUE "ProductVersion", "1.2.5.691"
83+
VALUE "ProductVersion", "1.2.5.692"
8484
VALUE "Comments", "http://libwdi.akeo.ie"
8585
END
8686
END

examples/zadig.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
17551755
int i, wait_for_mutex = 0;
17561756
BOOL r;
17571757

1758+
// Disable loading system DLLs from the current directory (DLL sideloading mitigation)
1759+
SetDllDirectoryA("");
1760+
17581761
// Retrieve the current application directory
17591762
GetCurrentDirectoryU(MAX_PATH, app_dir);
17601763

examples/zadig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#define FIELD_ORANGE RGB(255,240,200)
6060
#define ARROW_GREEN RGB(92,228,65)
6161
#define ARROW_ORANGE RGB(253,143,56)
62-
#define APP_VERSION "Zadig 2.2.691"
62+
#define APP_VERSION "Zadig 2.2.692"
6363

6464
// These are used to flag end users about the driver they are going to replace
6565
enum driver_type {

examples/zadig.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ END
248248
//
249249

250250
VS_VERSION_INFO VERSIONINFO
251-
FILEVERSION 2,2,682,691
252-
PRODUCTVERSION 2,2,682,691
251+
FILEVERSION 2,2,682,692
252+
PRODUCTVERSION 2,2,682,692
253253
FILEFLAGSMASK 0x17L
254254
#ifdef _DEBUG
255255
FILEFLAGS 0x1L
@@ -266,13 +266,13 @@ BEGIN
266266
BEGIN
267267
VALUE "CompanyName", "akeo.ie"
268268
VALUE "FileDescription", "Zadig"
269-
VALUE "FileVersion", "2.2.691"
269+
VALUE "FileVersion", "2.2.692"
270270
VALUE "InternalName", "Zadig"
271271
VALUE "LegalCopyright", "� 2010-2016 Pete Batard (GPL v3)"
272272
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
273273
VALUE "OriginalFilename", "zadig.exe"
274274
VALUE "ProductName", "Zadig"
275-
VALUE "ProductVersion", "2.2.691"
275+
VALUE "ProductVersion", "2.2.692"
276276
VALUE "Comments", "http://libwdi.akeo.ie"
277277
END
278278
END

examples/zadig_net.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Zadig: Automated Driver Installer for USB devices (GUI version)
33
* Networking functionality (web file download, check for update, etc.)
4-
* Copyright © 2012-2014 Pete Batard <[email protected]>
4+
* Copyright © 2012-2016 Pete Batard <[email protected]>
55
*
66
* This program is free software: you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -31,6 +31,7 @@
3131
#include <inttypes.h>
3232

3333
#include "msapi_utf8.h"
34+
#include "stdfn.h"
3435
#include "zadig.h"
3536
#include "zadig_registry.h"
3637
#include "zadig_resource.h"
@@ -286,8 +287,9 @@ BOOL DownloadFile(const char* url, const char* file, HWND hProgressDialog)
286287
dprintf("Network is unavailable: %s\n", WinInetErrorString());
287288
goto out;
288289
}
289-
_snprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d.%d",
290-
application_version[0], application_version[1], application_version[2], application_version[3]);
290+
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)",
291+
application_version[0], application_version[1], application_version[2],
292+
nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : "");
291293
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
292294
if (hSession == NULL) {
293295
dprintf("Could not open internet session: %s\n", WinInetErrorString());
@@ -472,8 +474,9 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
472474
goto out;
473475
hostname[sizeof(hostname)-1] = 0;
474476

475-
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d.%d",
476-
application_version[0], application_version[1], application_version[2], application_version[3]);
477+
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)",
478+
application_version[0], application_version[1], application_version[2],
479+
nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : "");
477480
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
478481
if (hSession == NULL)
479482
goto out;
@@ -518,7 +521,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
518521
dwSize = sizeof(dwStatus);
519522
dwStatus = 404;
520523
HttpQueryInfoA(hRequest, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwStatus, &dwSize, NULL);
521-
if (dwStatus == 200)
524+
if (dwStatus == 200)
522525
break;
523526
InternetCloseHandle(hRequest);
524527
hRequest = NULL;
@@ -553,7 +556,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
553556
if (!force_update_check) {
554557
if ((local_time > server_time + 600) || (local_time < server_time - 600)) {
555558
dprintf("IMPORTANT: Your local clock is more than 10 minutes in the %s. Unless you fix this, "
556-
APPLICATION_NAME " may not be able to check for updates...",
559+
APPLICATION_NAME " may not be able to check for updates...",
557560
(local_time > server_time + 600)?"future":"past");
558561
}
559562
}
@@ -576,7 +579,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
576579
parse_update(buf, dwTotalSize+1);
577580

578581
vuprintf("UPDATE DATA:\n");
579-
vuprintf(" version: %d.%d.%d.%d (%s)\n", update.version[0], update.version[1],
582+
vuprintf(" version: %d.%d.%d.%d (%s)\n", update.version[0], update.version[1],
580583
update.version[2], update.version[3], channel[k]);
581584
vuprintf(" platform_min: %d.%d\n", update.platform_min[0], update.platform_min[1]);
582585
vuprintf(" url: %s\n", update.download_url);

libwdi/libwdi.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ END
5050
//
5151

5252
VS_VERSION_INFO VERSIONINFO
53-
FILEVERSION 1,2,5,691
54-
PRODUCTVERSION 1,2,5,691
53+
FILEVERSION 1,2,5,692
54+
PRODUCTVERSION 1,2,5,692
5555
FILEFLAGSMASK 0x17L
5656
#ifdef _DEBUG
5757
FILEFLAGS 0x1L
@@ -68,13 +68,13 @@ BEGIN
6868
BEGIN
6969
VALUE "CompanyName", "akeo.ie"
7070
VALUE "FileDescription", "libwdi: Windows Driver Installer Library"
71-
VALUE "FileVersion", "1.2.5.691"
71+
VALUE "FileVersion", "1.2.5.692"
7272
VALUE "InternalName", "libwdi"
7373
VALUE "LegalCopyright", "� 2010-2014 Pete Batard (LGPL v3)"
7474
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
7575
VALUE "OriginalFilename", "libwdi"
7676
VALUE "ProductName", "libwdi"
77-
VALUE "ProductVersion", "1.2.5.691"
77+
VALUE "ProductVersion", "1.2.5.692"
7878
VALUE "Comments", "http://libwdi.akeo.ie"
7979
END
8080
END

libwdi/stdfn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ static __inline BOOL ReadRegistryStr(HKEY key_root, const char* key_name, char*
6464
if (key_name == NULL)
6565
return FALSE;
6666

67-
for (i = safe_strlen(key_name); i>0; i--) {
67+
for (i = strlen(key_name); i>0; i--) {
6868
if (key_name[i] == '\\')
6969
break;
7070
}
7171

7272
if (i != 0) {
7373
strcpy(long_key_name, "SOFTWARE\\");
74-
safe_strcat(long_key_name, sizeof(long_key_name), key_name);
74+
strncat(long_key_name, key_name, sizeof(long_key_name));
7575
long_key_name[sizeof("SOFTWARE\\") + i - 1] = 0;
7676
i++;
7777
if (RegOpenKeyExA(key_root, long_key_name, 0, KEY_READ, &hApp) != ERROR_SUCCESS) {

0 commit comments

Comments
 (0)