CmDeleteDeviceContainerRegKeyWorker
NTSTATUS __stdcall CmDeleteDeviceContainerRegKeyWorker(
HPNPCTX *hPnpCtx,
WCHAR *DeviceContainerId,
WCHAR *CmKeyTypeFlags,
INT64 HardwareProfileId,
CHAR DeleteTree,
INT64 a6,
INT64 a8,
INT64 C8,
UINT64 *a9){
WCHAR *PoolWithTag;
_CM_KEY_TYPE v10;
unsigned __int64 v13;
UINT64 i;
WCHAR *v15;
int DeviceContainerRegKeyPath;
WCHAR *v17;
HSYSCTX *v18;
unsigned __int16 Length;
WCHAR *v21;
unsigned __int8 v22;
VOID *v23;
__int64 v24;
VOID *v25;
int v26;
__int64 v27;
VOID *v28;
UINT64 v29;
WCHAR *BaseKeyPath;
UINT64 BaseKeyLength;
UINT64 *RequiredLength;
VOID *Handle;
INT64 v34;
_UNICODE_STRING DestinationString;
UINT64 v36;
PoolWithTag = 0i64;
LODWORD(v36) = 0;
v10 = (int)CmKeyTypeFlags;
v34 = 0i64;
Handle = 0i64;
DestinationString = 0i64;
if( !(_DWORD)CmKeyTypeFlags || ((unsigned int)CmKeyTypeFlags & 0xFFFFFEAF) != 0 )
goto LABEL_45;
LODWORD(v13) = 260;
for( i = 260i64; ; i = (unsigned int)v13 )
{
PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(1ui64, i, 1380994640i64);
if( !PoolWithTag )
break;
LODWORD(BaseKeyLength) = (unsigned int)v13 >> 1;
DeviceContainerRegKeyPath = CmGetDeviceContainerRegKeyPath(
(HPNPCTX *)((unsigned int)v13 >> 1),
DeviceContainerId,
v10,
v15,
v29,
PoolWithTag,
BaseKeyLength,
&v36);
if( DeviceContainerRegKeyPath != -1073741789 )
goto LABEL_6;
ExFreePoolWithTag(PoolWithTag, 0);
PoolWithTag = 0i64;
v13 = 2i64 * (unsigned int)v36;
if( v13 > 0xFFFFFFFF )
{
DeviceContainerRegKeyPath = -1073741675;
goto LABEL_11;
}
}
DeviceContainerRegKeyPath = -1073741801;
LABEL_6:
if( DeviceContainerRegKeyPath < 0 )
goto LABEL_11;
if( (v10 & 0x100) == 0 )
{
DeviceContainerRegKeyPath = RtlInitUnicodeStringEx(&DestinationString, PoolWithTag);
if( DeviceContainerRegKeyPath < 0 )
goto LABEL_11;
Length = DestinationString.Length;
if( DestinationString.Length < (unsigned int)v13
&& DestinationString.Length > 0x32u
&& (unsigned __int8)RtlPrefixUnicodeString(
&`_CmDeleteDeviceContainerRegKeyWorker'::`2'::ObjectPathRootPrefix,
&DestinationString,
1u) )
{
v21 = PoolWithTag + 25;
DestinationString.MaximumLength -= 50;
DestinationString.Buffer = PoolWithTag + 25;
DestinationString.Length = Length - 50;
v22 = (unsigned __int8)RtlPrefixUnicodeString(
&`_CmDeleteDeviceContainerRegKeyWorker'::`2'::DeviceContainersKeyPrefix,
&DestinationString,
1u);
DeviceContainerRegKeyPath = PnpCtxGetCachedContextBaseKey(
hPnpCtx,
(PNPCTX_BASE_KEY_TYPE)(v22 != 0 ? PNPCTX_BASE_KEY_TYPE_CRITICALDEVICEDATABASE : PNPCTX_BASE_KEY_TYPE_CONTROLSET),
(VOID **)&v34);
if( DeviceContainerRegKeyPath < 0 )
goto LABEL_11;
v23 = (VOID *)v34;
if( !v22 )
v21 = PoolWithTag;
v17 = v21 + 25;
goto LABEL_24;
}
LABEL_45:
DeviceContainerRegKeyPath = -1073741811;
goto LABEL_11;
}
v17 = PoolWithTag;
if( hPnpCtx )
v18 = (HSYSCTX *)*((_QWORD *)hPnpCtx + 28);
else
v18 = 0i64;
DeviceContainerRegKeyPath = SysCtxRegOpenCurrentUserKey(
v18,
0,
0x2000000,
&Handle,
v29,
(INT64)BaseKeyPath,
BaseKeyLength,
(INT64)RequiredLength);
if( DeviceContainerRegKeyPath < 0 )
goto LABEL_11;
v23 = Handle;
LABEL_24:
if( DeleteTree )
{
if( hPnpCtx && (v24 = *((_QWORD *)hPnpCtx + 28)) != 0 )
v25 = *(VOID **)(v24 + 8);
else
v25 = 0i64;
v26 = RegRtlDeleteTreeInternal(v23, v17, v25, 0);
}
else
{
if( hPnpCtx && (v27 = *((_QWORD *)hPnpCtx + 28)) != 0 )
v28 = *(VOID **)(v27 + 8);
else
v28 = 0i64;
v26 = RegRtlDeleteKeyTransacted(v23, v17, v28);
}
if( (int)(v26 + 0x80000000) >= 0 && v26 != -1073741444 )
DeviceContainerRegKeyPath = v26;
LABEL_11:
if( Handle )
ZwClose((_HANDLE)Handle);
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0);
return DeviceContainerRegKeyPath;
}Referenced by:
CmDeleteDeviceContainerRegKey