CmDeleteDevicePanelRegKeyWorker
__int64 __fastcall CmDeleteDevicePanelRegKeyWorker(__int64 a1, const wchar_t *a2, int a3, __int64 a4, char a5){
wchar_t *pszDest;
unsigned __int64 v9;
UINT64 i;
int v11;
int inited;
__int64 v13;
unsigned __int16 Length;
char v15;
const WCHAR *v16;
char *v17;
_QWORD *v18;
__int64 v19;
__int64 v20;
int v21;
__int64 v22;
__int64 v23;
WCHAR *v24;
__int64 v25;
__int64 v26;
WCHAR *v27;
__int64 v28;
__int64 v29;
int v31;
size_t cchDest;
HANDLE Handle;
char *v34;
struct _UNICODE_STRING DestinationString;
__int64 v36;
LODWORD(v36) = 0;
v34 = 0i64;
Handle = 0i64;
pszDest = 0i64;
DestinationString = 0i64;
if( !a3 || (a3 & 0xFFFFFE9F) != 0 )
goto LABEL_54;
LODWORD(v9) = 317;
for( i = 317i64; ; i = (unsigned int)v9 )
{
pszDest = (wchar_t *)ExAllocatePoolWithTag(PagedPool, i, 0x52504E50ui64);
if( !pszDest )
break;
LODWORD(cchDest) = (unsigned int)v9 >> 1;
CmGetDevicePanelRegKeyPath((unsigned int)v9 >> 1, a2, a3, v13, v31, pszDest, cchDest, (__int64)&v36);
inited = v11;
if( v11 != -1073741789 )
goto LABEL_9;
ExFreePoolWithTag(pszDest, 0);
v9 = 2i64 * (unsigned int)v36;
pszDest = 0i64;
if( v9 > 0xFFFFFFFF )
{
inited = -1073741675;
goto LABEL_55;
}
}
inited = -1073741801;
LABEL_9:
if( inited < 0 )
goto LABEL_55;
if( (a3 & 0x100) == 0 )
{
inited = RtlInitUnicodeStringEx(&DestinationString, pszDest);
if( inited < 0 )
goto LABEL_55;
Length = DestinationString.Length;
if( DestinationString.Length < (unsigned int)v9
&& DestinationString.Length > 0x32u
&& (unsigned __int8)RtlPrefixUnicodeString(
(PVOID)&`_CmOpenDevicePanelRegKeyWorker'::`2'::ObjectPathRootPrefix,
(INT64 *)&DestinationString) )
{
DestinationString.MaximumLength -= 50;
DestinationString.Buffer = pszDest + 25;
DestinationString.Length = Length - 50;
v15 = RtlPrefixUnicodeString(
(PVOID)&`_CmDeleteDevicePanelRegKeyWorker'::`2'::DevicePanelsKeyPrefix,
(INT64 *)&DestinationString);
inited = PnpCtxGetCachedContextBaseKey(a1, v15 != 0 ? 11 : 4, (__int64 *)&v34);
if( inited < 0 )
goto LABEL_55;
v16 = pszDest + 46;
if( !v15 )
v16 = pszDest + 25;
v17 = v34;
goto LABEL_24;
}
LABEL_54:
inited = -1073741811;
goto LABEL_55;
}
v16 = pszDest;
v18 = 0i64;
if( a1 )
v18 = *(_QWORD **)(a1 + 224);
inited = SysCtxRegOpenCurrentUserKey(v18, 0, 0x2000000u, &Handle);
if( inited < 0 )
goto LABEL_55;
v17 = (char *)Handle;
LABEL_24:
if( a5 )
{
if( a1 && (v19 = *(_QWORD *)(a1 + 224)) != 0 )
v20 = *(_QWORD *)(v19 + 8);
else
v20 = 0i64;
v21 = RegRtlDeleteTreeInternal(v17, v16, v20, 0);
}
else
{
if( a1 && (v22 = *(_QWORD *)(a1 + 224)) != 0 )
v23 = *(_QWORD *)(v22 + 8);
else
v23 = 0i64;
v21 = RegRtlDeleteKeyTransacted(v17, v16, v23);
}
if( v21 == -1073741444 )
goto LABEL_55;
if( v21 < 0 )
goto LABEL_37;
v24 = wcsrchr(v16, 0x5Cu);
if( !v24 )
goto LABEL_39;
*v24 = 0;
if( a1 && (v25 = *(_QWORD *)(a1 + 224)) != 0 )
v26 = *(_QWORD *)(v25 + 8);
else
v26 = 0i64;
v21 = RegRtlDeleteKeyTransacted(v17, v16, v26);
if( v21 != -1073741535 )
{
if( v21 < 0 )
goto LABEL_37;
v27 = wcsrchr(v16, 0x5Cu);
if( !v27 )
{
LABEL_39:
inited = -1073741595;
goto LABEL_55;
}
*v27 = 0;
if( a1 && (v28 = *(_QWORD *)(a1 + 224)) != 0 )
v29 = *(_QWORD *)(v28 + 8);
else
v29 = 0i64;
v21 = RegRtlDeleteKeyTransacted(v17, v16, v29);
if( (int)(v21 + 0x80000000) >= 0 && v21 != -1073741535 )
LABEL_37:
inited = v21;
}
LABEL_55:
if( Handle )
ZwClose(Handle);
if( pszDest )
ExFreePoolWithTag(pszDest, 0);
return(unsigned int)inited;
}Referenced by:
CmDeleteDevicePanelRegKey