CmOpenCommonClassRegKeyWorker
__int64 __fastcall CmOpenCommonClassRegKeyWorker(
__int64 a1,
const WCHAR *a2,
__int16 a3,
int a4,
ACCESS_MASK a5,
char a6,
void **a7,
_DWORD *a8){
const WCHAR *v8;
int v11;
unsigned __int64 v13;
wchar_t *pszDest;
int v15;
int inited;
unsigned __int16 Length;
const wchar_t *v18;
char *v19;
__int64 v20;
void **v21;
int Tree;
_DWORD *v23;
_QWORD *v25;
int v26;
size_t cchDest;
char *v28;
HANDLE Handle;
struct _UNICODE_STRING DestinationString;
__int64 v32;
v8 = a2;
LODWORD(v32) = 0;
v28 = 0i64;
Handle = 0i64;
v11 = 4;
DestinationString = 0i64;
LODWORD(v13) = (a3 & 0x200) != 0 ? 320 : 200;
pszDest = (wchar_t *)ExAllocatePoolWithTag(PagedPool, (unsigned int)v13, 0x52504E50ui64);
if( pszDest )
{
while( 1 )
{
LODWORD(cchDest) = (unsigned int)v13 >> 1;
CmGetCommonClassRegKeyPath((unsigned int)v13 >> 1, v8, a3, a4, v26, pszDest, cchDest, (__int64)&v32);
inited = v15;
if( v15 != -1073741789 )
break;
ExFreePoolWithTag(pszDest, 0);
pszDest = 0i64;
v13 = 2i64 * (unsigned int)v32;
if( v13 > 0xFFFFFFFF )
{
inited = -1073741675;
goto LABEL_21;
}
pszDest = (wchar_t *)ExAllocatePoolWithTag(PagedPool, (unsigned int)v13, 0x52504E50ui64);
if( !pszDest )
goto LABEL_36;
v8 = a2;
}
}
else
{
LABEL_36:
inited = -1073741801;
}
if( inited < 0 )
goto LABEL_21;
if( (a3 & 0x100) != 0 )
{
v18 = pszDest;
if( a1 )
v25 = *(_QWORD **)(a1 + 224);
else
v25 = 0i64;
inited = SysCtxRegOpenCurrentUserKey(v25, 0, 0x2000000u, &Handle);
if( inited < 0 )
goto LABEL_21;
v19 = (char *)Handle;
v28 = (char *)Handle;
}
else
{
inited = RtlInitUnicodeStringEx(&DestinationString, pszDest);
if( inited < 0 )
goto LABEL_21;
Length = DestinationString.Length;
if( DestinationString.Length >= (unsigned int)v13
|| DestinationString.Length <= 0x32u
|| !(unsigned __int8)RtlPrefixUnicodeString(
(PVOID)&`_CmDeleteDeviceContainerRegKeyWorker'::`2'::ObjectPathRootPrefix,
(INT64 *)&DestinationString) )
{
inited = -1073741811;
goto LABEL_21;
}
v18 = pszDest + 25;
DestinationString.MaximumLength -= 50;
DestinationString.Buffer = pszDest + 25;
DestinationString.Length = Length - 50;
if( (unsigned __int8)RtlPrefixUnicodeString(
(PVOID)&`_CmOpenCommonClassRegKeyWorker'::`2'::ClassKeyPrefix,
(INT64 *)&DestinationString) )
{
v11 = 7;
v18 = pszDest + 39;
}
else if( (unsigned __int8)RtlPrefixUnicodeString(
(PVOID)&`_CmDeleteDeviceInterfaceRegKeyWorker'::`2'::DeviceClassesKeyPrefix,
(INT64 *)&DestinationString) )
{
v11 = 8;
v18 = pszDest + 47;
}
else if( (unsigned __int8)RtlPrefixUnicodeString(
(PVOID)&`_CmOpenDeviceInterfaceRegKeyWorker'::`2'::HardwareProfilesKeyPrefix,
(INT64 *)&DestinationString) )
{
v11 = 14;
v18 = pszDest + 43;
}
inited = PnpCtxGetCachedContextBaseKey(a1, v11, (__int64 *)&v28);
if( inited < 0 )
goto LABEL_21;
v19 = v28;
}
if( a6 )
{
Tree = PnpCtxRegCreateTree(a1, v19, v18, 0, a5, 0i64, (__int64)a7, (__int64)a8);
LABEL_19:
if( Tree != -1073741444 )
{
if( Tree >= 0 )
goto LABEL_21;
goto LABEL_30;
}
inited = -1073741595;
goto LABEL_21;
}
if( a1 )
v20 = *(_QWORD *)(a1 + 224);
else
v20 = 0i64;
v21 = a7;
Tree = SysCtxRegOpenKey(v20, v19, v18, 0, a5, a7);
v23 = a8;
if( Tree >= 0 )
*a8 = 2;
if( Tree != -1073741772 )
goto LABEL_19;
if( v11 != 8 || !*(_BYTE *)(a1 + 4) )
{
LABEL_30:
inited = Tree;
goto LABEL_21;
}
inited = PnpCtxGetCachedContextBaseKey(a1, 9, (__int64 *)&v28);
if( inited >= 0 )
{
Tree = SysCtxRegOpenKey(*(_QWORD *)(a1 + 224), v28, v18, 0, a5, v21);
if( Tree >= 0 )
*v23 = 2;
goto LABEL_19;
}
LABEL_21:
if( Handle )
ZwClose(Handle);
if( pszDest )
ExFreePoolWithTag(pszDest, 0);
return(unsigned int)inited;
}Referenced by:
CmOpenCommonClassRegKey