pbatard / libwdi

Windows Driver Installer library for USB devices
GNU General Public License v3.0
1.9k stars 466 forks source link

Failed to build libwdi dll #238

Closed mcuee closed 2 years ago

mcuee commented 3 years ago

It is a bit strange that I can not build latest git (libwdi 1.4.1) using VS2019

Rebuild started...
1>------ Rebuild All started: Project: detect_64build, Configuration: Release Win32 ------
2>------ Rebuild All started: Project: installer_x86, Configuration: Release Win32 ------
3>------ Rebuild All started: Project: installer_x64, Configuration: Release x64 ------
1>detected 32 bit build
4>------ Rebuild All started: Project: embedder, Configuration: Release Win32 ------
3>installer.c
2>installer.c
4>embedder.c
4>Generating code
4>Previous IPDB not found, fall back to full compilation.
2>Generating code
3>Generating code
2>Previous IPDB not found, fall back to full compilation.
3>Previous IPDB not found, fall back to full compilation.
4>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
2>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
2>Finished generating code
4>Finished generating code
3>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Finished generating code
4>embedder.vcxproj -> C:\work\libusb\libwdi\libwdi\libwdi\embedder.exe
2>installer_x86.vcxproj -> C:\work\libusb\libwdi\libwdi\Win32\Release\helper\installer_x86.exe
3>installer_x64.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe
5>------ Rebuild All started: Project: libwdi (dll), Configuration: Release Win32 ------
5>Embedding binary resources
5>detected change for 'C:\work\libusb\libwdi\libwdi\Win32\Release\helper\installer_x86.exe'
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x86\WdfCoInstaller01011.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x86\winusbcoinstaller2.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\WdfCoInstaller01011.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\winusbcoinstaller2.dll (2021.05.27)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\libusb0_x86.dll (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\install-filter.exe (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\libusb0.sys (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\libusb0.dll (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\libusb0.sys (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\install-filter.exe (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\installer_license.txt (2021.10.25)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\x86\libusbK.sys (2021.07.20)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\x86\libusbK.dll (2021.07.20)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\amd64\libusbK.sys (2021.07.20)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\amd64\libusbK.dll (2021.07.20)
5>  EMBED  C:\work\libusb\libwdi\libwdi\Win32\Release\helper\installer_x86.exe (2021.11.02)
5>  EMBED  C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe (2021.11.02)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\winusb.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusb0.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusbk.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\usbser.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\winusb.cat.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusb0.cat.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusbk.cat.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\usbser.cat.in (2021.07.10)
5>libwdi.c
5>libwdi_dlg.c
5>logging.c
5>pki.c
5>tokenizer.c
5>vid_data.c
5>   Creating library C:\work\libusb\libwdi\libwdi\Win32\Release\dll\libwdi.lib and object C:\work\libusb\libwdi\libwdi\Win32\Release\dll\libwdi.exp
5>libwdi.obj : error LNK2001: unresolved external symbol _NtQuerySystemInformation@16
5>C:\work\libusb\libwdi\libwdi\Win32\Release\dll\libwdi.dll : fatal error LNK1120: 1 unresolved externals
5>Done building project "libwdi_dll.vcxproj" -- FAILED.
========== Rebuild All: 4 succeeded, 1 failed, 0 skipped ==========
mcuee commented 3 years ago

My configuration is not the same as default but it should not matter.

C:\work\libusb\libwdi\libwdi [master ≡ +0 ~1 -0 !]> git diff
diff --git a/msvc/config.h b/msvc/config.h
index d4032df..059ab63 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -23,7 +23,7 @@
  * match your WinUSB redist directories.
  */
 #ifndef WDK_DIR
-#define WDK_DIR "C:/Program Files (x86)/Windows Kits/8.0"
+#define WDK_DIR "C:/Program Files (x86)/Windows Kits/10"
 #endif

 /* WDK WDF coinstaller version */
@@ -37,12 +37,12 @@

 /* embed libusb0 driver files from the following location */
 #ifndef LIBUSB0_DIR
-#define LIBUSB0_DIR "D:/libusb-win32"
+#define LIBUSB0_DIR "C:/libusb-win32-1.2.7.2-bin"
 #endif

 /* embed libusbK driver files from the following location */
 #ifndef LIBUSBK_DIR
-#define LIBUSBK_DIR "D:/libusbK/bin"
+#define LIBUSBK_DIR "C:/libusbK-3.1.0.0-bin/bin"
 #endif

 /* embed user defined driver files from the following location */
mcuee commented 3 years ago

Same for x64 only build.

Rebuild started...
1>------ Rebuild All started: Project: detect_64build, Configuration: Release x64 ------
2>------ Skipped Rebuild All: Project: installer_x86, Configuration: Release Win32 ------
2>Project not selected to build for this solution configuration 
3>------ Rebuild All started: Project: installer_x64, Configuration: Release x64 ------
1>detected 64 bit build
4>------ Rebuild All started: Project: embedder, Configuration: Release Win32 ------
3>installer.c
4>embedder.c
4>C:\work\libusb\libwdi\libwdi\libwdi\embedder.h(40): warning : library is compiled as 64 bit - disabling 32 bit support
4>Generating code
3>Generating code
3>Previous IPDB not found, fall back to full compilation.
4>Previous IPDB not found, fall back to full compilation.
4>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
4>Finished generating code
3>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Finished generating code
4>embedder.vcxproj -> C:\work\libusb\libwdi\libwdi\libwdi\embedder.exe
4>Done building project "embedder.vcxproj".
3>installer_x64.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe
5>------ Rebuild All started: Project: libwdi (dll), Configuration: Release x64 ------
5>Embedding binary resources
5>detected change for 'C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe'
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\WdfCoInstaller01011.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\winusbcoinstaller2.dll (2021.05.27)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\libusb0_x86.dll (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\install-filter.exe (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\libusb0.dll (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\libusb0.sys (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\install-filter.exe (2021.10.25)
5>  EMBED  C:\libusb-win32-1.2.7.2-bin\installer_license.txt (2021.10.25)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\amd64\libusbK.sys (2021.07.20)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\amd64\libusbK.dll (2021.07.20)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\x86\libusbK.dll (2021.07.20)
5>  EMBED  C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe (2021.11.02)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\winusb.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusb0.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusbk.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\usbser.inf.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\winusb.cat.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusb0.cat.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusbk.cat.in (2021.07.10)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\usbser.cat.in (2021.07.10)
5>libwdi.c
5>C:\work\libusb\libwdi\libwdi\libwdi\libwdi_i.h(39): warning : library is compiled as 64 bit - disabling 32 bit support
5>C:\work\libusb\libwdi\libwdi\libwdi\libwdi_i.h(47): warning : this library will be INCOMPATIBLE with 32 bit platforms
5>C:\work\libusb\libwdi\libwdi\libwdi\libwdi.c(1723,3): warning C4312: 'type cast': conversion from 'BOOL' to 'char *' of greater size
5>libwdi_dlg.c
5>logging.c
5>pki.c
5>tokenizer.c
5>vid_data.c
5>Generating Code...
5>   Creating library C:\work\libusb\libwdi\libwdi\x64\Release\dll\libwdi.lib and object C:\work\libusb\libwdi\libwdi\x64\Release\dll\libwdi.exp
5>libwdi.obj : error LNK2019: unresolved external symbol NtQuerySystemInformation referenced in function wdi_prepare_driver
5>C:\work\libusb\libwdi\libwdi\x64\Release\dll\libwdi.dll : fatal error LNK1120: 1 unresolved externals
5>Done building project "libwdi_dll.vcxproj" -- FAILED.
========== Rebuild All: 3 succeeded, 1 failed, 1 skipped ==========
mcuee commented 3 years ago

I just did the build libwdi on a week ago on 25 Oct 2021 with the following commits. https://github.com/pbatard/libwdi/commit/99a38ae62ba030d7638526e6fca5e39cf3e5c5c0

mcuee commented 3 years ago

Just upgraded VS2019 to the latest version and it is now okay.

Rebuild started...
1>------ Rebuild All started: Project: detect_64build, Configuration: Release x64 ------
2>------ Skipped Rebuild All: Project: installer_x86, Configuration: Release Win32 ------
2>Project not selected to build for this solution configuration 
3>------ Rebuild All started: Project: installer_x64, Configuration: Release x64 ------
4>------ Rebuild All started: Project: getopt, Configuration: Release x64 ------
1>detected 64 bit build
4>getopt.c
3>installer.c
5>------ Rebuild All started: Project: embedder, Configuration: Release Win32 ------
4>getopt1.c
5>embedder.c
4>getopt.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\lib\getopt.lib
5>C:\work\libusb\libwdi\libwdi\libwdi\embedder.h(40): warning : library is compiled as 64 bit - disabling 32 bit support
3>Generating code
3>Previous IPDB not found, fall back to full compilation.
3>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Finished generating code
3>installer_x64.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe
5>Generating code
5>Previous IPDB not found, fall back to full compilation.
5>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
5>Finished generating code
5>embedder.vcxproj -> C:\work\libusb\libwdi\libwdi\libwdi\embedder.exe
5>Done building project "embedder.vcxproj".
6>------ Rebuild All started: Project: libwdi (static), Configuration: Release x64 ------
7>------ Skipped Rebuild All: Project: libwdi (dll), Configuration: Release x64 ------
7>Project not selected to build for this solution configuration 
6>Embedding binary resources
6>detected change for 'C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe'
6>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\WdfCoInstaller01011.dll (2021.05.27)
6>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\winusbcoinstaller2.dll (2021.05.27)
6>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\libusb0_x86.dll (2021.10.25)
6>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\x86\install-filter.exe (2021.10.25)
6>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\libusb0.dll (2021.10.25)
6>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\libusb0.sys (2021.10.25)
6>  EMBED  C:\libusb-win32-1.2.7.2-bin\bin\amd64\install-filter.exe (2021.10.25)
6>  EMBED  C:\libusb-win32-1.2.7.2-bin\installer_license.txt (2021.10.25)
6>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\amd64\libusbK.sys (2021.07.20)
6>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\amd64\libusbK.dll (2021.07.20)
6>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\x86\libusbK.dll (2021.07.20)
6>  EMBED  C:\work\libusb\libwdi\libwdi\x64\Release\helper\installer_x64.exe (2021.11.02)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\winusb.inf.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusb0.inf.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusbk.inf.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\usbser.inf.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\winusb.cat.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusb0.cat.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\libusbk.cat.in (2021.07.10)
6>  EMBED  C:\work\libusb\libwdi\libwdi\libwdi\usbser.cat.in (2021.07.10)
6>libwdi.c
6>C:\work\libusb\libwdi\libwdi\libwdi\libwdi_i.h(39): warning : library is compiled as 64 bit - disabling 32 bit support
6>C:\work\libusb\libwdi\libwdi\libwdi\libwdi_i.h(47): warning : this library will be INCOMPATIBLE with 32 bit platforms
6>C:\work\libusb\libwdi\libwdi\libwdi\libwdi.c(1723,3): warning C4312: 'type cast': conversion from 'BOOL' to 'char *' of greater size
6>libwdi_dlg.c
6>logging.c
6>pki.c
6>tokenizer.c
6>vid_data.c
6>Generating Code...
6>libwdi_static.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\lib\libwdi.lib
6>Done building project "libwdi_static.vcxproj".
8>------ Rebuild All started: Project: wdi-simple, Configuration: Release x64 ------
9>------ Rebuild All started: Project: zadig, Configuration: Release x64 ------
9>zadig_net.c
8>wdi-simple.c
9>profile.c
8>Generating code
8>Previous IPDB not found, fall back to full compilation.
8>All 12 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
8>Finished generating code
8>wdi-simple.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\examples\wdi-simple.exe
9>zadig.c
9>zadig_parser.c
9>zadig_stdlg.c
9>Generating code
9>Previous IPDB not found, fall back to full compilation.
9>All 170 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
9>Finished generating code
9>zadig.vcxproj -> C:\work\libusb\libwdi\libwdi\x64\Release\examples\zadig.exe
========== Rebuild All: 7 succeeded, 0 failed, 2 skipped ==========
mcuee commented 3 years ago

New version VS2019 16.11.5. I was using 16.11.2 previously.

mcuee commented 3 years ago

FYI libusb-win32 1.2.7.2 is not a formal release but a signed snapshot release, it may not work under Windows 7. It works under Windows 10 and Windows 11.

pbatard commented 3 years ago

Okay. Just FYI, as long as I don't see an official libusb-win32 release in https://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/, I'm not going to upgrade the one I use in Zadig.

Also, if you ever have doubts if the library compilation is broken or if it's your environment, just check for failures in https://github.com/pbatard/libwdi/actions. For every commit, a build is issued for all of the VS2019 and MinGW targets, so unless you see a failure there, it's probably your environment.

mcuee commented 3 years ago

Yes that libusb-1.2.7.2 snapshot release is not a formal release. Therefore it is correct not to include it in Zadig official release.

mcuee commented 3 years ago

As for the VS2019, it is rather strange but anyway it is fixed after I update my VS2019 community edition installation. So it is all good now.

mcuee commented 3 years ago

For those who want to try out libusb0.sys 1.2.7.2 snapshot release, you can try my build of Zadig here. https://github.com/mcuee/libwdi/releases/tag/v1.4.1

Build with VS2019. Tested with Windows 10 and 11. Not so sure if it works under Windows 7/8/8.1. It will not work under Windows XP. Unlikely it will work under Windows Vista either.

C:\work\libusb\libwdi\libwdi [master ≡ +0 ~1 -0 !]> git diff
diff --git a/msvc/config.h b/msvc/config.h
index d4032df..059ab63 100644
--- a/msvc/config.h
+++ b/msvc/config.h
@@ -23,7 +23,7 @@
  * match your WinUSB redist directories.
  */
 #ifndef WDK_DIR
-#define WDK_DIR "C:/Program Files (x86)/Windows Kits/8.0"
+#define WDK_DIR "C:/Program Files (x86)/Windows Kits/10"
 #endif

 /* WDK WDF coinstaller version */
@@ -37,12 +37,12 @@

 /* embed libusb0 driver files from the following location */
 #ifndef LIBUSB0_DIR
-#define LIBUSB0_DIR "D:/libusb-win32"
+#define LIBUSB0_DIR "C:/libusb-win32-1.2.7.2-bin"
 #endif

 /* embed libusbK driver files from the following location */
 #ifndef LIBUSBK_DIR
-#define LIBUSBK_DIR "D:/libusbK/bin"
+#define LIBUSBK_DIR "C:/libusbK-3.1.0.0-bin/bin"
 #endif
njk42 commented 2 years ago

Hello, I am also getting the linker error mentioned above related to the "NtQuerySystemInformation" unresolved symbol. It only occurs when I build the dll, but not the static lib. I'm building with VS 2022, most recent available update (17.0.5) with platform toolset v143. Is there any known fix for this error which involves a change to configuration, or do I need to roll back to VS 2019 or toolset v142?

pbatard commented 2 years ago

@njk42, I am not seeing any issue with VS2022 compilation on the most recent update (2f4186ce2cd0e6d664ed21e47f5610b1a13987de, using toolset v143).

The GitHub Actions build of the VS2022 updated project files also show no issue.

Therefore, we have to conclude that whatever issue you are facing comes from your environment and not the project, as the project does build fine with VS2022.

mcuee commented 2 years ago

@njk42 Try to upgrade your VS2022 installation. The current libwdi git head is targeting VS2022 and it works. I just installed VS2022 and there is no issue building libwdi git head.

Build started...
1>------ Build started: Project: detect_64build, Configuration: Release Win32 ------
2>------ Build started: Project: getopt, Configuration: Release Win32 ------
3>------ Build started: Project: installer_x64, Configuration: Release x64 ------
4>------ Build started: Project: installer_x86, Configuration: Release Win32 ------
1>detected 32 bit build
5>------ Build started: Project: embedder, Configuration: Release Win32 ------
3>installer.c
5>embedder.c
2>getopt.c
4>installer.c
2>getopt1.c
3>Generating code
3>Previous IPDB not found, fall back to full compilation.
3>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Finished generating code
3>installer_x64.vcxproj -> C:\work\libusb\libwdi\x64\Release\helper\installer_x64.exe
2>getopt.vcxproj -> C:\work\libusb\libwdi\Win32\Release\lib\getopt.lib
5>Generating code
5>Previous IPDB not found, fall back to full compilation.
5>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
5>Finished generating code
5>embedder.vcxproj -> C:\work\libusb\libwdi\libwdi\embedder.exe
4>Generating code
4>Previous IPDB not found, fall back to full compilation.
4>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
4>Finished generating code
4>installer_x86.vcxproj -> C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe
6>------ Skipped Build: Project: libwdi (dll), Configuration: Release Win32 ------
6>Project not selected to build for this solution configuration 
7>------ Build started: Project: libwdi (static), Configuration: Release Win32 ------
7>Embedding binary resources
7>detected change for 'C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe'
7>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x86\WdfCoInstaller01011.dll (2021.05.27)
7>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x86\winusbcoinstaller2.dll (2021.05.27)
7>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\WdfCoInstaller01011.dll (2021.05.27)
7>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\winusbcoinstaller2.dll (2021.05.27)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\x86\libusb0_x86.dll (2021.11.13)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\x86\install-filter.exe (2021.11.13)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\x86\libusb0.sys (2021.11.13)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\amd64\libusb0.dll (2021.11.13)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\amd64\libusb0.sys (2021.11.13)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\amd64\install-filter.exe (2021.11.13)
7>  EMBED  C:\libusb-win32-bin-1.2.7.3\installer_license.txt (2021.11.13)
7>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\x86\libusbK.sys (2021.11.14)
7>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\x86\libusbK.dll (2021.11.14)
7>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\amd64\libusbK.sys (2021.11.14)
7>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\amd64\libusbK.dll (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe (2022.01.29)
7>  EMBED  C:\work\libusb\libwdi\x64\Release\helper\installer_x64.exe (2022.01.29)
7>  EMBED  C:\work\libusb\libwdi\libwdi\winusb.inf.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\libusb0.inf.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\libusbk.inf.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\usbser.inf.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\winusb.cat.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\libusb0.cat.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\libusbk.cat.in (2021.11.14)
7>  EMBED  C:\work\libusb\libwdi\libwdi\usbser.cat.in (2021.11.14)
7>libwdi.c
7>libwdi_dlg.c
7>logging.c
7>pki.c
7>tokenizer.c
7>vid_data.c
7>libwdi_static.vcxproj -> C:\work\libusb\libwdi\Win32\Release\lib\libwdi.lib
8>------ Build started: Project: zadig, Configuration: Release Win32 ------
9>------ Build started: Project: wdi-simple, Configuration: Release Win32 ------
8>zadig_net.c
9>wdi-simple.c
8>profile.c
9>Generating code
9>Previous IPDB not found, fall back to full compilation.
8>zadig.c
8>zadig_parser.c
9>All 96 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
9>Finished generating code
8>zadig_stdlg.c
9>wdi-simple.vcxproj -> C:\work\libusb\libwdi\Win32\Release\examples\wdi-simple.exe
8>Generating code
8>Previous IPDB not found, fall back to full compilation.
8>All 256 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
8>Finished generating code
8>zadig.vcxproj -> C:\work\libusb\libwdi\Win32\Release\examples\zadig.exe
========== Build: 8 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========
njk42 commented 2 years ago

@mcuee I don't think the dll is getting included as part of the Solution build. From your output above:

  6>------ Skipped Build: Project: libwdi (dll), Configuration: Release Win32 ------
  6>Project not selected to build for this solution configuration 

The default solution settings have the dll unchecked from the build for both x32 and x64.

It's when I try to explicitly build the dll project that I get the linker error regarding NtQuerySystemInformation.

mcuee commented 2 years ago

@njk42 You are right. I can reproduce the issue when building the dll.

Build started...
1>------ Build started: Project: detect_64build, Configuration: Release Win32 ------
2>------ Build started: Project: installer_x64, Configuration: Release x64 ------
3>------ Build started: Project: installer_x86, Configuration: Release Win32 ------
1>detected 32 bit build
4>------ Build started: Project: embedder, Configuration: Release Win32 ------
2>installer_x64.vcxproj -> C:\work\libusb\libwdi\x64\Release\helper\installer_x64.exe
3>installer_x86.vcxproj -> C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe
4>embedder.c
4>Generating code
4>0 of 14 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
4>  0 functions were new in current compilation
4>  0 functions had inline decision re-evaluated but remain unchanged
4>Finished generating code
4>embedder.vcxproj -> C:\work\libusb\libwdi\libwdi\embedder.exe
5>------ Build started: Project: libwdi (dll), Configuration: Release Win32 ------
5>Embedding binary resources
5>  resources haven't changed - skipping step
5>libwdi.c
5>libwdi_dlg.c
5>logging.c
5>pki.c
5>tokenizer.c
5>vid_data.c
5>   Creating library C:\work\libusb\libwdi\Win32\Release\dll\libwdi.lib and object C:\work\libusb\libwdi\Win32\Release\dll\libwdi.exp
5>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(1087,5): error MSB6006: "link.exe" exited with code 1120.
5>libwdi.obj : error LNK2001: unresolved external symbol _NtQuerySystemInformation@16
5>C:\work\libusb\libwdi\Win32\Release\dll\libwdi.dll : fatal error LNK1120: 1 unresolved externals
5>Done building project "libwdi_dll.vcxproj" -- FAILED.
========== Build: 4 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
mcuee commented 2 years ago

Looking back my original report and it was also because of the dll building. Then I look at the github action output (https://github.com/pbatard/libwdi/runs/4883797960?check_suite_focus=true) and it does not seem to build the dll as well. So I think we can reopen the issue.

mcuee commented 2 years ago

Just try to rebuild 1.4.1 release with the just updated VS2019 and I can see the issue with the DLL build as well.

Build started...
1>------ Build started: Project: detect_64build, Configuration: Release Win32 ------
2>------ Build started: Project: installer_x86, Configuration: Release Win32 ------
3>------ Build started: Project: installer_x64, Configuration: Release x64 ------
1>detected 32 bit build
4>------ Build started: Project: embedder, Configuration: Release Win32 ------
3>installer.c
2>installer.c
4>embedder.c
2>Generating code
4>Generating code
4>Previous IPDB not found, fall back to full compilation.
2>Previous IPDB not found, fall back to full compilation.
4>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
4>Finished generating code
2>Finished generating code
2>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Generating code
3>Previous IPDB not found, fall back to full compilation.
3>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Finished generating code
4>embedder.vcxproj -> C:\work\libusb\libwdi-1.4.1\libwdi\embedder.exe
2>installer_x86.vcxproj -> C:\work\libusb\libwdi-1.4.1\Win32\Release\helper\installer_x86.exe
3>installer_x64.vcxproj -> C:\work\libusb\libwdi-1.4.1\x64\Release\helper\installer_x64.exe
5>------ Build started: Project: libwdi (dll), Configuration: Release Win32 ------
5>Embedding binary resources
5>embedder : error : Could not open file 'C:\Program Files (x86)\Windows Kits\8.0\redist\wdf\x86\WdfCoInstaller01011.dll'.
5>  EMBED  C:\Program Files (x86)\Windows Kits\8.0\redist\wdf\x86\WdfCoInstaller01011.dll
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: The command "cd C:\work\libusb\libwdi-1.4.1\libwdi\.msvc\\..
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: embedder embedded.h
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(145,5): error MSB3073: :VCEnd" exited with code 1.
5>Done building project "libwdi_dll.vcxproj" -- FAILED.
========== Build: 4 succeeded, 1 failed, 0 up-to-date, 0 skip
mcuee commented 2 years ago

Yes this is now fixed.

Rebuild started...
1>------ Rebuild All started: Project: detect_64build, Configuration: Release Win32 ------
2>------ Rebuild All started: Project: installer_x64, Configuration: Release x64 ------
3>------ Rebuild All started: Project: installer_x86, Configuration: Release Win32 ------
1>detected 32 bit build
4>------ Rebuild All started: Project: embedder, Configuration: Release Win32 ------
2>installer.c
3>installer.c
4>embedder.c
4>Generating code
2>Generating code
2>Previous IPDB not found, fall back to full compilation.
4>Previous IPDB not found, fall back to full compilation.
4>All 14 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
4>Finished generating code
2>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Generating code
4>embedder.vcxproj -> C:\work\libusb\libwdi\libwdi\embedder.exe
2>Finished generating code
3>Previous IPDB not found, fall back to full compilation.
2>installer_x64.vcxproj -> C:\work\libusb\libwdi\x64\Release\helper\installer_x64.exe
3>All 31 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
3>Finished generating code
3>installer_x86.vcxproj -> C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe
5>------ Rebuild All started: Project: libwdi (dll), Configuration: Release Win32 ------
5>Embedding binary resources
5>detected change for 'C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe'
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x86\WdfCoInstaller01011.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x86\winusbcoinstaller2.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\WdfCoInstaller01011.dll (2021.05.27)
5>  EMBED  C:\Program Files (x86)\Windows Kits\10\redist\wdf\x64\winusbcoinstaller2.dll (2021.05.27)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\x86\libusb0_x86.dll (2021.11.13)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\x86\install-filter.exe (2021.11.13)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\x86\libusb0.sys (2021.11.13)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\amd64\libusb0.dll (2021.11.13)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\amd64\libusb0.sys (2021.11.13)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\bin\amd64\install-filter.exe (2021.11.13)
5>  EMBED  C:\libusb-win32-bin-1.2.7.3\installer_license.txt (2021.11.13)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\x86\libusbK.sys (2021.11.14)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\x86\libusbK.dll (2021.11.14)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\sys\amd64\libusbK.sys (2021.11.14)
5>  EMBED  C:\libusbK-3.1.0.0-bin\bin\dll\amd64\libusbK.dll (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\Win32\Release\helper\installer_x86.exe (2022.01.30)
5>  EMBED  C:\work\libusb\libwdi\x64\Release\helper\installer_x64.exe (2022.01.30)
5>  EMBED  C:\work\libusb\libwdi\libwdi\winusb.inf.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libusb0.inf.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libusbk.inf.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\usbser.inf.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\winusb.cat.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libusb0.cat.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\libusbk.cat.in (2021.11.14)
5>  EMBED  C:\work\libusb\libwdi\libwdi\usbser.cat.in (2021.11.14)
5>libwdi.c
5>libwdi_dlg.c
5>logging.c
5>pki.c
5>tokenizer.c
5>vid_data.c
5>   Creating library C:\work\libusb\libwdi\Win32\Release\dll\libwdi.lib and object C:\work\libusb\libwdi\Win32\Release\dll\libwdi.exp
5>Generating code
5>Previous IPDB not found, fall back to full compilation.
5>All 94 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
5>Finished generating code
5>libwdi_dll.vcxproj -> C:\work\libusb\libwdi\Win32\Release\dll\libwdi.dll
========== Rebuild All: 5 succeeded, 0 failed, 0 skipped ==========