api: avoid call to CM_Get_DevNode_Status
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
dfa53185d0
commit
99097022fe
@ -1295,46 +1295,35 @@ CreateAdapter(
|
|||||||
goto cleanupTcpipInterfaceRegKey;
|
goto cleanupTcpipInterfaceRegKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG Status, ProblemCode;
|
/* TODO: This GUIDs is in devpkey.h, but we can't link to it? Which dll? */
|
||||||
Result = CM_MapCrToWin32Err(
|
static const DEVPROPKEY DEVPKEY_Device_ProblemStatus = {
|
||||||
CM_Get_DevNode_Status(&Status, &ProblemCode, DevInfoData.DevInst, 0), ERROR_DEVICE_NOT_AVAILABLE);
|
{ 0x4340a6c5, 0x93fa, 0x4706, { 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7 } }, 12
|
||||||
if (Result != ERROR_SUCCESS)
|
};
|
||||||
|
DEVPROPTYPE PropertyType;
|
||||||
|
for (int Tries = 0; Tries < 1000; ++Tries)
|
||||||
{
|
{
|
||||||
LOG_ERROR(L"Failed to get status of adapter", Result);
|
NTSTATUS ProblemStatus;
|
||||||
goto cleanupTcpipInterfaceRegKey;
|
if (SetupDiGetDevicePropertyW(
|
||||||
}
|
DevInfo,
|
||||||
if (Status & DN_HAS_PROBLEM)
|
&DevInfoData,
|
||||||
{
|
&DEVPKEY_Device_ProblemStatus,
|
||||||
/* TODO: This GUIDs is in devpkey.h, but we can't link to it? Which dll? */
|
&PropertyType,
|
||||||
static const DEVPROPKEY DEVPKEY_Device_ProblemStatus = {
|
(PBYTE)&ProblemStatus,
|
||||||
{ 0x4340a6c5, 0x93fa, 0x4706, { 0x97, 0x2c, 0x7b, 0x64, 0x80, 0x08, 0xa5, 0xa7 } }, 12
|
sizeof(ProblemStatus),
|
||||||
};
|
NULL,
|
||||||
DEVPROPTYPE PropertyType;
|
0) &&
|
||||||
for (int Tries = 0; Tries < 1000; Sleep(10), ++Tries)
|
PropertyType == DEVPROP_TYPE_NTSTATUS)
|
||||||
{
|
{
|
||||||
NTSTATUS ProblemStatus;
|
Result = RtlNtStatusToDosError(ProblemStatus);
|
||||||
if (SetupDiGetDevicePropertyW(
|
if (ProblemStatus != STATUS_PNP_DEVICE_CONFIGURATION_PENDING || Tries == 999)
|
||||||
DevInfo,
|
|
||||||
&DevInfoData,
|
|
||||||
&DEVPKEY_Device_ProblemStatus,
|
|
||||||
&PropertyType,
|
|
||||||
(PBYTE)&ProblemStatus,
|
|
||||||
sizeof(ProblemStatus),
|
|
||||||
NULL,
|
|
||||||
0) &&
|
|
||||||
PropertyType == DEVPROP_TYPE_NTSTATUS)
|
|
||||||
{
|
{
|
||||||
Result = RtlNtStatusToDosError(ProblemStatus);
|
LOG_ERROR(L"Failed to setup adapter", Result);
|
||||||
if (ProblemStatus != STATUS_PNP_DEVICE_CONFIGURATION_PENDING || Tries == 999)
|
goto cleanupTcpipInterfaceRegKey;
|
||||||
{
|
|
||||||
LOG_ERROR(L"Failed to setup adapter", Result);
|
|
||||||
goto cleanupTcpipInterfaceRegKey;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
Sleep(10);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
LOG(WINTUN_LOG_WARN, L"Adapter setup error code vanished after initially there");
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Adapter = a;
|
*Adapter = a;
|
||||||
|
Loading…
Reference in New Issue
Block a user