CmGetDeviceInterfaceRegKeyPath
NTSTATUS __stdcall CmGetDeviceInterfaceRegKeyPath(
HPNPCTX *hPnpCtx,
const WCHAR *DeviceInterfaceName,
_CM_KEY_TYPE CmKeyTypeFlags,
UINT64 HardwareProfileId,
UINT8 Create,
WCHAR *BaseKeyPath,
UINT64 BaseKeyLength,
UINT64 *RequiredLength){
int v8;
__int16 v9;
UINT8 v10;
VOID **v11;
unsigned int v12;
char v13;
__int64 v14;
__int64 v15;
unsigned __int64 v16;
VOID **PoolWithTag;
WCHAR *v18;
WCHAR *v19;
int DeviceInterfaceSubkeyPath;
WCHAR **v21;
int v22;
__int64 v23;
__int64 v24;
unsigned __int64 v25;
NTSTATUS v26;
__int64 v28;
WCHAR **v29;
__int64 v30;
UINT64 *SubkeyPathLength;
UINT64 *SubkeyPathLengtha;
UINT64 pszFormat;
UINT64 pszFormata;
__int16 SubkeyPath[40];
v8 = HardwareProfileId;
v9 = CmKeyTypeFlags;
v10 = (unsigned __int8)DeviceInterfaceName;
v11 = 0i64;
if( CmKeyTypeFlags == CM_KEY_TYPE_NONE || (CmKeyTypeFlags & 0xFFFFFCCC) != 0 )
goto LABEL_54;
v12 = (unsigned __int8)CmKeyTypeFlags;
if( (((unsigned __int8)CmKeyTypeFlags - 48) & 0xFFFFFFFD) != 0 )
{
if( (unsigned __int8)CmKeyTypeFlags != CM_KEY_TYPE_DEVICE_INTERFACE_SYMLINK )
return -1073741811;
v13 = 0;
}
else
{
v13 = 1;
}
v14 = -1i64;
v15 = -1i64;
do
++v15;
while( DeviceInterfaceName[v15] );
v16 = 2 * v15 + 6;
if( v16 > 0xFFFFFFFF )
return -1073741675;
PoolWithTag = ExAllocatePoolWithTag(1ui64, (unsigned int)v16, 1380994640i64);
v11 = PoolWithTag;
if( !PoolWithTag )
return -1073741801;
LODWORD(pszFormat) = (unsigned int)v16 >> 1;
LOBYTE(v19) = v13;
DeviceInterfaceSubkeyPath = CmGetDeviceInterfaceSubkeyPath(v18, v10, v19, (WCHAR *)SubkeyPath, (UINT64)PoolWithTag);
if( DeviceInterfaceSubkeyPath < 0 )
goto LABEL_27;
v22 = v9 & 0x200;
if( !v22 )
{
v23 = -1i64;
do
++v23;
while( SubkeyPath[v23] );
v24 = v23 + 48;
goto LABEL_14;
}
if( !v8 )
{
v28 = -1i64;
do
++v28;
while( SubkeyPath[v28] );
v24 = v28 + 99;
goto LABEL_14;
}
if( v8 == -1 )
{
LABEL_54:
DeviceInterfaceSubkeyPath = -1073741811;
goto LABEL_27;
}
v30 = -1i64;
do
++v30;
while( SubkeyPath[v30] );
v24 = v30 + 96;
do
LABEL_14:
++v14;
while( *((_WORD *)v11 + v14) );
v25 = v24 + v14 + 1;
if( v12 < 0x30 )
goto LABEL_51;
if( v12 <= 0x31 )
goto LABEL_17;
if( v12 == 50 )
v25 += 18i64;
else
LABEL_51:
DeviceInterfaceSubkeyPath = -1073741811;
LABEL_17:
if( DeviceInterfaceSubkeyPath >= 0 )
{
if( v25 > 0xFFFFFFFF )
{
DeviceInterfaceSubkeyPath = -1073741675;
}
else
{
DeviceInterfaceSubkeyPath = 0;
if( RequiredLength )
*(_DWORD *)RequiredLength = v25;
if( (unsigned int)v25 <= (unsigned int)BaseKeyLength )
{
if( v22 )
{
if( v8 )
{
if( v8 == -1 )
goto LABEL_25;
LODWORD(SubkeyPathLength) = 2048;
v26 = RtlStringCchPrintfExW(
BaseKeyPath,
(unsigned int)BaseKeyLength,
0i64,
0i64,
(UINT64)SubkeyPathLength,
(WCHAR *)L"%s\\%04u\\%s\\%s\\%s");
}
else
{
LODWORD(SubkeyPathLength) = 2048;
v26 = RtlStringCchPrintfExW(
BaseKeyPath,
(unsigned int)BaseKeyLength,
0i64,
0i64,
(UINT64)SubkeyPathLength,
(WCHAR *)L"%s\\%s\\%s\\%s");
}
}
else
{
LODWORD(SubkeyPathLength) = 2048;
v26 = RtlStringCchPrintfExW(
BaseKeyPath,
(unsigned int)BaseKeyLength,
0i64,
0i64,
(UINT64)SubkeyPathLength,
(WCHAR *)L"%s\\%s\\%s");
}
DeviceInterfaceSubkeyPath = v26;
LABEL_25:
if( DeviceInterfaceSubkeyPath >= 0 && v12 == 50 )
{
DeviceInterfaceSubkeyPath = RtlStringCchCatExW(
BaseKeyPath,
(unsigned int)BaseKeyLength,
(WCHAR *)L"\\",
v21,
SubkeyPathLength,
pszFormat);
if( DeviceInterfaceSubkeyPath >= 0 )
DeviceInterfaceSubkeyPath = RtlStringCchCatExW(
BaseKeyPath,
(unsigned int)BaseKeyLength,
(WCHAR *)L"Device Parameters",
v29,
SubkeyPathLengtha,
pszFormata);
}
goto LABEL_27;
}
DeviceInterfaceSubkeyPath = -1073741789;
}
}
LABEL_27:
if( v11 )
ExFreePoolWithTag(v11, 0);
return DeviceInterfaceSubkeyPath;
}Referenced by:
CmDeleteDeviceInterfaceRegKeyWorker
CmOpenDeviceInterfaceRegKeyWorker
PiDqGetRelativeObjectRegPath