CmGetDeviceInterfaceMappedPropertyFromRegValue
NTSTATUS __stdcall CmGetDeviceInterfaceMappedPropertyFromRegValue(
HPNPCTX *hPnpCtx,
const WCHAR *DeviceInterfaceName,
VOID *ObjectBaseKey,
const _DEVPROPKEY *PropertyKey,
UINT64 *PropertyType,
UINT8 *PropertyBuffer,
INT64 BufferSize,
UINT64 *PropertySize){
UINT64 *v8;
UINT64 *v10;
UINT64 *Disposition;
unsigned __int64 v12;
int IsDeviceInterfaceEnabled;
int v16;
unsigned int pid;
unsigned int v18;
DEVPROPKEY **v19;
DEVPROPKEY *v20;
DEVPROPKEY **v21;
NTSTATUS v22;
unsigned int v23;
__int64 v24;
int Value;
__int64 v27;
__int64 v28;
VOID *v29;
NTSTATUS v30;
UINT64 *v31;
INT64 DesiredAccess;
INT64 Create;
char Enabled[4];
UINT64 DataSize;
INT64 v36;
VOID *Handle;
UINT64 DeviceInterfaceKey;
UINT8 Indirected;
v8 = PropertyType;
v10 = PropertySize;
Disposition = 0i64;
v12 = (unsigned __int64)PropertyBuffer;
DeviceInterfaceKey = 0i64;
*(_DWORD *)PropertyType = 0;
IsDeviceInterfaceEnabled = 0;
*(_DWORD *)v10 = 0;
Handle = 0i64;
v36 = 0i64;
DataSize = 0i64;
Indirected = 0;
Enabled[0] = 0;
if( v12 )
{
v16 = BufferSize;
v12 &= -(__int64)((_DWORD)BufferSize != 0);
Disposition = 0i64;
}
else
{
v16 = 0;
}
pid = PropertyKey->pid;
if( pid < 2 )
return -1073741264;
v18 = 0;
v19 = &off_140983A68;
while( 1 )
{
v20 = *v19;
v21 = v19;
if( pid == (*v19)->pid )
break;
LABEL_6:
++v18;
v19 += 2;
v21 = 0i64;
if( v18 >= 3 )
goto LABEL_11;
}
Disposition = (UINT64 *)(*(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&v20->fmtid.Data1);
if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&v20->fmtid.Data1 )
Disposition = (UINT64 *)(*(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)v20->fmtid.Data4);
if( Disposition )
{
Disposition = 0i64;
goto LABEL_6;
}
LABEL_11:
if( !v21 )
return -1073741264;
if( ObjectBaseKey )
goto LABEL_15;
LOBYTE(Create) = (_BYTE)Disposition;
LODWORD(DesiredAccess) = 1;
v22 = CmOpenDeviceInterfaceRegKey(
hPnpCtx,
DeviceInterfaceName,
48i64,
(UINT64)v20,
DesiredAccess,
Create,
(VOID **)&DeviceInterfaceKey,
Disposition);
Disposition = 0i64;
IsDeviceInterfaceEnabled = v22;
if( v22 >= 0 )
{
v8 = PropertyType;
LABEL_15:
v23 = PropertyKey->pid;
if( v23 == 2 )
{
v28 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceInterface_FriendlyName.fmtid.Data1;
if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceInterface_FriendlyName.fmtid.Data1 )
v28 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceInterface_FriendlyName.fmtid.Data4;
if( v28 )
goto LABEL_66;
v29 = (VOID *)DeviceInterfaceKey;
if( ObjectBaseKey )
v29 = ObjectBaseKey;
if( hPnpCtx )
Disposition = (UINT64 *)*((_QWORD *)hPnpCtx + 28);
v30 = SysCtxRegOpenKey((__int64)Disposition, v29, (const WCHAR *)L"Device Parameters", 0, 1u, (VOID **)&v36);
if( v30 == -1073741772 || v30 == -1073741444 )
goto LABEL_53;
if( v30 < 0 )
{
IsDeviceInterfaceEnabled = v30;
goto LABEL_27;
}
LODWORD(DataSize) = v16;
Value = PnpCtxRegQueryValueIndirect(
hPnpCtx,
(VOID *)v36,
(WCHAR *)L"FriendlyName",
(UINT64 *)((char *)&DataSize + 4),
(VOID *)v12,
&DataSize,
&Indirected);
ZwClose(v36);
if( Value == -1073741772 || Value == -1073741444 )
goto LABEL_53;
if( Value && Value != -1073741789 )
goto LABEL_61;
*(_DWORD *)PropertySize = DataSize;
v31 = PropertyType;
*(_DWORD *)PropertyType = 18;
if( Value || !v16 )
IsDeviceInterfaceEnabled = -1073741789;
if( Indirected )
*(_DWORD *)v31 = 25;
}
else
{
if( v23 != 3 )
{
if( v23 == 256 )
{
v24 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_Device_InstanceId.fmtid.Data1;
if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_Device_InstanceId.fmtid.Data1 )
v24 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_Device_InstanceId.fmtid.Data4;
if( !v24 )
{
LOBYTE(Create) = (_BYTE)Disposition;
LODWORD(DesiredAccess) = 1;
IsDeviceInterfaceEnabled = CmOpenDeviceInterfaceRegKey(
hPnpCtx,
DeviceInterfaceName,
49i64,
(UINT64)v20,
DesiredAccess,
Create,
&Handle,
Disposition);
if( IsDeviceInterfaceEnabled < 0 )
goto LABEL_27;
LODWORD(DataSize) = v16;
Value = RegRtlQueryValue(
Handle,
L"DeviceInstance",
(_DWORD *)&DataSize + 1,
(VOID *)v12,
(__int64)&DataSize);
ZwClose((_HANDLE)Handle);
if( Value != -1073741772 && Value != -1073741444 )
{
if( !Value || Value == -1073741789 )
{
*(_DWORD *)PropertySize = DataSize;
*(_DWORD *)PropertyType = 18;
if( Value || !v16 )
IsDeviceInterfaceEnabled = -1073741789;
goto LABEL_27;
}
LABEL_61:
IsDeviceInterfaceEnabled = Value;
goto LABEL_27;
}
LABEL_53:
IsDeviceInterfaceEnabled = -1073741275;
goto LABEL_27;
}
}
LABEL_66:
IsDeviceInterfaceEnabled = -1073741264;
goto LABEL_27;
}
v27 = *(_QWORD *)&PropertyKey->fmtid.Data1 - *(_QWORD *)&DEVPKEY_DeviceInterface_Enabled.fmtid.Data1;
if( *(_QWORD *)&PropertyKey->fmtid.Data1 == *(_QWORD *)&DEVPKEY_DeviceInterface_Enabled.fmtid.Data1 )
v27 = *(_QWORD *)PropertyKey->fmtid.Data4 - *(_QWORD *)DEVPKEY_DeviceInterface_Enabled.fmtid.Data4;
if( v27 )
goto LABEL_66;
*(_DWORD *)PropertySize = 1;
*(_DWORD *)v8 = 17;
if( v16 )
{
IsDeviceInterfaceEnabled = CmIsDeviceInterfaceEnabled(hPnpCtx, DeviceInterfaceName, v19, (UINT8 *)Enabled);
if( IsDeviceInterfaceEnabled >= 0 )
*(_BYTE *)v12 = -(Enabled[0] != 0);
}
else
{
IsDeviceInterfaceEnabled = -1073741789;
}
}
}
LABEL_27:
if( DeviceInterfaceKey )
ZwClose(DeviceInterfaceKey);
return IsDeviceInterfaceEnabled;
}Referenced by:
CmGetDeviceInterfaceMappedProperty
CmGetDeviceInterfaceMappedPropertyKeys