Below is the code which is calling Windows SetupDiSetClassInstallParamsW method --
bool
Util::SvmDisableNic(HDEVINFO devInfoSet, SP_DEVINFO_DATA deviceInfo)
{
SP_PROPCHANGE_PARAMS params = {0};
SP_DEVINSTALL_PARAMS_W installParams = {0};
//
// Disable device
//
params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
params.StateChange = DICS_DISABLE;
params.Scope = DICS_FLAG_GLOBAL;
params.HwProfile = 0;
if (!SetupDiSetClassInstallParamsW(devInfoSet, &deviceInfo,
&(params.ClassInstallHeader),
sizeof params)) {
DWORD err = GetLastError();
SYSMSG_FUNC(
Debug, _T("Failed setting device params to disable: Err: 0x%X"), err);
return false;
}
This code is running successfully, however, in a couple of VMs, the SetupDiSetClassInstallParamsW is failing, and GetLastError is returning an error code of 0xD. From microsoft doc, looks like this corresponds to ERROR_INVALID_DATA. The VMs in which this code is running successfully and in those in which it is failing, are identical in terms of hardware/software configuration. Any idea how we can debug why this windows API is failing?