DrvDbDeleteObjectSubKey
__int64 __fastcall DrvDbDeleteObjectSubKey(__int64 *a1, char *a2, const WCHAR *a3, unsigned int a4){
__int64 v4;
unsigned int v5;
void *PoolWithTag;
unsigned int v9;
WCHAR *v10;
__int64 v11;
__int64 v12;
int v13;
int inited;
__int64 v15;
signed int i;
__int64 v17;
int v18;
__int64 v19;
int v20;
__int64 v21;
UINT64 v22;
WCHAR *v23;
char *j;
__int64 v25;
int v26;
__int64 v27;
__int64 v28;
__int64 v29;
int v30;
WCHAR *v31;
bool v32;
__int64 v33;
__int64 v34;
int v35;
__int64 v36;
unsigned int v37;
__int64 v38;
void *v39;
HANDLE v40;
UINT64 dwFlags;
unsigned int v43;
int v44;
int v45;
HANDLE Handle;
struct _UNICODE_STRING DestinationString;
unsigned int v49;
v4 = *a1;
v5 = 0;
Handle = 0i64;
v43 = 0;
v44 = 0;
v49 = 0;
PoolWithTag = 0i64;
v45 = 0;
v9 = 0;
v10 = 0i64;
if( a4 <= 1 )
{
if( v4 && (v11 = *(_QWORD *)(v4 + 224)) != 0 )
v12 = *(_QWORD *)(v11 + 8);
else
v12 = 0i64;
v13 = RegRtlDeleteTreeInternal(a2, a3, v12, 0);
inited = v13;
LABEL_7:
if( v13 == -1073741444 )
inited = 0;
goto LABEL_86;
}
v15 = 0i64;
if( v4 )
v15 = *(_QWORD *)(v4 + 224);
v13 = SysCtxRegOpenKey(v15, a2, a3, 0, 0x3001Fu, &Handle);
inited = v13;
if( v13 < 0 )
goto LABEL_7;
for( i = PnpGetGenericStorePropertyKeys(*a1, (char *)Handle, 0i64, 0, 0i64, 0, &v43);
;
i = PnpGetGenericStorePropertyKeys(*a1, (char *)Handle, 0i64, 0, (__int64)PoolWithTag, v17, &v43) )
{
inited = i;
if( i != -1073741789 )
break;
v17 = v43;
if( v43 <= v9 )
{
inited = -1073741595;
break;
}
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0);
v9 = v17;
PoolWithTag = ExAllocatePoolWithTag(PagedPool, 20 * v17, 0x42444450ui64);
if( !PoolWithTag )
{
inited = -1073741801;
break;
}
}
if( (int)(inited + 0x80000000) >= 0 && inited != -1073741275 )
goto LABEL_84;
if( inited != -1073741275 )
v5 = v9;
v18 = 0;
v19 = 0i64;
if( inited != -1073741275 )
v18 = inited;
inited = v18;
if( v5 )
{
do
{
v20 = PnpDeletePropertyWorker(*a1, (char *)Handle, 0i64, (__int64)PoolWithTag + 20 * v19, 0, dwFlags, 0);
inited = v20;
if( v20 == -1073741275 || v20 == -1073741790 )
{
inited = 0;
}
else if( v20 < 0 )
{
goto LABEL_84;
}
v19 = (unsigned int)(v19 + 1);
}
while( (unsigned int)v19 < v5 );
}
if( inited < 0 )
goto LABEL_84;
if( !wcschr((WCHAR *)a3, 0x5Cu) )
{
if( *a1 && (v33 = *(_QWORD *)(*a1 + 224)) != 0 )
v34 = *(_QWORD *)(v33 + 8);
else
v34 = 0i64;
v35 = RegRtlDeleteKeyTransacted((char *)Handle, 0i64, v34);
inited = v35;
if( v35 == -1073741444 )
{
inited = 0;
goto LABEL_84;
}
if( v35 != -1073741535 )
goto LABEL_84;
inited = PnpCtxRegQueryInfoKey(v36, Handle, 0i64, 0i64, &v49, &v45, 0i64);
if( inited < 0 )
goto LABEL_84;
v37 = v45 + 1;
if( !v49 )
goto LABEL_84;
v39 = ExAllocatePoolWithTag(PagedPool, 2i64 * v37, 0x42444450ui64);
if( v39 )
{
while( 1 )
{
v49 = v37;
inited = PnpCtxRegEnumValue(v38, Handle, 0, v39, &v49, 0i64, 0i64, 0i64);
if( inited < 0 )
break;
v40 = Handle;
DestinationString = 0i64;
inited = RtlInitUnicodeStringEx(&DestinationString, (WCHAR *)v39);
if( inited >= 0 )
inited = ZwDeleteValueKey(v40, &DestinationString);
if( inited != -1073741772 && inited < 0 )
goto LABEL_81;
}
if( inited == -2147483622 )
inited = 0;
LABEL_81:
ExFreePoolWithTag(v39, 0);
goto LABEL_82;
}
LABEL_40:
inited = -1073741801;
goto LABEL_84;
}
v21 = -1i64;
do
++v21;
while( a3[v21] );
v22 = v21 + 1;
v23 = (WCHAR *)ExAllocatePoolWithTag(PagedPool, 2 * v22, 0x42444450ui64);
v10 = v23;
if( !v23 )
goto LABEL_40;
LODWORD(dwFlags) = 2304;
RtlStringCchCopyExW(v23, v22, (WCHAR *)a3, 0i64, 0i64, dwFlags);
for( j = (char *)Handle; ; j = 0i64 )
{
if( !j )
{
v25 = 0i64;
if( *a1 )
v25 = *(_QWORD *)(*a1 + 224);
v26 = SysCtxRegOpenKey(v25, a2, v10, 0, 0x3001Fu, &Handle);
inited = v26;
if( v26 < 0 )
{
v32 = v26 == -1073741444;
goto LABEL_60;
}
inited = PnpCtxRegQueryInfoKey(v27, Handle, &v44, 0i64, &v49, 0i64, 0i64);
if( inited < 0 || v44 || v49 )
goto LABEL_82;
j = (char *)Handle;
}
if( *a1 && (v28 = *(_QWORD *)(*a1 + 224)) != 0 )
v29 = *(_QWORD *)(v28 + 8);
else
v29 = 0i64;
v30 = RegRtlDeleteKeyTransacted(j, 0i64, v29);
inited = v30;
if( v30 == -1073741444 )
{
inited = 0;
goto LABEL_57;
}
if( v30 < 0 )
break;
LABEL_57:
v31 = wcsrchr(v10, 0x5Cu);
if( !v31 )
goto LABEL_82;
*v31 = 0;
ZwClose(Handle);
Handle = 0i64;
}
v32 = v30 == -1073741535;
LABEL_60:
if( v32 )
inited = 0;
LABEL_82:
if( v10 )
ExFreePoolWithTag(v10, 0);
LABEL_84:
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0);
LABEL_86:
if( Handle )
ZwClose(Handle);
return(unsigned int)inited;
}Referenced by:
DrvDbDeleteObjectRegKey