api: map cr errors to win32 errors
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
47a241e5d8
commit
7f35f0dbab
@ -174,26 +174,22 @@ static WINTUN_STATUS
|
|||||||
GetDeviceObject(_In_opt_z_ const WCHAR *InstanceId, _Out_ HANDLE *Handle)
|
GetDeviceObject(_In_opt_z_ const WCHAR *InstanceId, _Out_ HANDLE *Handle)
|
||||||
{
|
{
|
||||||
ULONG InterfacesLen;
|
ULONG InterfacesLen;
|
||||||
DWORD Result = CM_Get_Device_Interface_List_SizeW(
|
DWORD Result = CM_MapCrToWin32Err(CM_Get_Device_Interface_List_SizeW(
|
||||||
&InterfacesLen, (GUID *)&GUID_DEVINTERFACE_NET, (DEVINSTID_W)InstanceId, CM_GET_DEVICE_INTERFACE_LIST_PRESENT);
|
&InterfacesLen, (GUID *)&GUID_DEVINTERFACE_NET, (DEVINSTID_W)InstanceId, CM_GET_DEVICE_INTERFACE_LIST_PRESENT), ERROR_GEN_FAILURE);
|
||||||
if (Result != CR_SUCCESS)
|
if (Result != ERROR_SUCCESS)
|
||||||
{
|
return LOG_ERROR(L"Failed to query associated instances size", Result);
|
||||||
LOG(WINTUN_LOG_ERR, L"Failed to query associated instances size");
|
|
||||||
return ERROR_GEN_FAILURE;
|
|
||||||
}
|
|
||||||
WCHAR *Interfaces = HeapAlloc(ModuleHeap, 0, InterfacesLen * sizeof(WCHAR));
|
WCHAR *Interfaces = HeapAlloc(ModuleHeap, 0, InterfacesLen * sizeof(WCHAR));
|
||||||
if (!Interfaces)
|
if (!Interfaces)
|
||||||
return LOG(WINTUN_LOG_ERR, L"Out of memory"), ERROR_OUTOFMEMORY;
|
return LOG(WINTUN_LOG_ERR, L"Out of memory"), ERROR_OUTOFMEMORY;
|
||||||
Result = CM_Get_Device_Interface_ListW(
|
Result = CM_MapCrToWin32Err(CM_Get_Device_Interface_ListW(
|
||||||
(GUID *)&GUID_DEVINTERFACE_NET,
|
(GUID *)&GUID_DEVINTERFACE_NET,
|
||||||
(DEVINSTID_W)InstanceId,
|
(DEVINSTID_W)InstanceId,
|
||||||
Interfaces,
|
Interfaces,
|
||||||
InterfacesLen,
|
InterfacesLen,
|
||||||
CM_GET_DEVICE_INTERFACE_LIST_PRESENT);
|
CM_GET_DEVICE_INTERFACE_LIST_PRESENT), ERROR_GEN_FAILURE);
|
||||||
if (Result != CR_SUCCESS)
|
if (Result != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
LOG(WINTUN_LOG_ERR, L"Failed to get associated instances");
|
LOG_ERROR(L"Failed to get associated instances", Result);
|
||||||
Result = ERROR_GEN_FAILURE;
|
|
||||||
goto cleanupBuf;
|
goto cleanupBuf;
|
||||||
}
|
}
|
||||||
*Handle = CreateFileW(
|
*Handle = CreateFileW(
|
||||||
|
Loading…
Reference in New Issue
Block a user