c++cwindowsvisual-studio-2019etw

Errors linking to tdh.lib


I'm trying to use functions from the Microsoft TDH library building with Visual Studio 2019. The project is using WindowsApplicationForDrivers10.0 Platform Toolset and the program is very simple:

#include <windows.h>
#include <tdh.h>
#pragma comment(lib, "tdh.lib")
int __cdecl wmain(_In_ int argc, _In_ wchar_t* argv[]) {
    ::TdhCloseDecodingHandle(nullptr);
    return 0;
}

When building the program I'm getting the following error:

Build started...

1>------ Build started: Project: main, Configuration: Debug x64 ------

1>Building 'main' with toolset 'WindowsApplicationForDrivers10.0' and the 'Universal' target platform.

1>main.cpp

1>main.vcxproj -> C:\Play\wpp\cpp\x64\Debug\main.exe

1>ApiValidation : error : main.exe has unsupported API call to "tdh.dll!TdhCloseDecodingHandle"

1>C:\Program Files (x86)\Windows Kits\10\build\WindowsDriver.common.targets(1794,5): error MSB3721: The command ""C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\ApiValidator.exe" -DriverPackagePath:C:\Play\wpp\cpp\ctrl..\x64\Debug\main.exe -SupportedApiXmlFiles:"C:\Program Files (x86)\Windows Kits\10\build\universalDDIs\x64\UniversalDDIs.xml" -ModuleWhiteListXmlFiles:"C:\Program Files (x86)\Windows Kits\10\build\universalDDIs\x64\ModuleWhiteList.xml" -ApiExtractorExePath:"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64"" exited with code -1.

1>Done building project "main.vcxproj" -- FAILED.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Does anyone know what the problem is, or how to prevent ApiValidator.exe from running as part of the build?

Thanks in advance,

-Uri


Solution

  • Finally found the Visual Studio settings:ApiValidator