CmGetDeviceSoftwareKey
__int64 __fastcall CmGetDeviceSoftwareKey(__int64 a1, const WCHAR *a2, wchar_t *a3, __int64 a4, char a5){
int DeviceRegProp;
_ETHREAD *CurrentThread;
int v11;
__int64 v12;
__int64 v13;
__int64 v14;
int v15;
__int64 v16;
__int64 v17;
__int64 dwFlags;
UINT64 dwFlagsa;
int v20;
int v21;
HANDLE v22;
HANDLE Handle;
struct _UNICODE_STRING DestinationString;
__int16 v25[12];
WCHAR v26[40];
v20 = 88;
v22 = 0i64;
Handle = 0i64;
v21 = 0;
DestinationString = 0i64;
DeviceRegProp = CmGetDeviceRegProp(a1, a2, 0i64, 10, (__int64)&v21, (__int64)a3, (__int64)&v20, 0);
if( DeviceRegProp == -1073741275 )
{
if( a5 == 1 )
{
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--*((_WORD *)CurrentThread + 242);
ExAcquireResourceExclusiveLite(*(ERESOURCE **)(a1 + 240), 1u);
v21 = 0;
v20 = 88;
DeviceRegProp = CmGetDeviceRegProp(a1, a2, 0i64, 10, (__int64)&v21, (__int64)a3, (__int64)&v20, 0);
if( DeviceRegProp == -1073741275 )
{
v20 = 78;
v21 = 0;
v11 = CmGetDeviceRegProp(a1, a2, 0i64, 9, (__int64)&v21, (__int64)v26, (__int64)&v20, 0);
DeviceRegProp = v11;
if( v11 == -1073741275 )
{
DeviceRegProp = -1073741772;
}
else if( v11 >= 0 )
{
v26[38] = 0;
DeviceRegProp = CmOpenInstallerClassRegKey(a1, v26, v12, v13, 131103, 0, (__int64)&v22, 0i64);
if( DeviceRegProp >= 0 )
{
DeviceRegProp = CmCreateOrdinalInstanceKey(a1, (__int64)v22, (wchar_t *)v25, v14, dwFlags, &Handle);
if( DeviceRegProp >= 0 )
{
LODWORD(dwFlagsa) = 2048;
RtlStringCchPrintfExW(a3, 0x2Cui64, 0i64, 0i64, dwFlagsa, L"%s\\%s", v26, v25);
DeviceRegProp = v15;
if( v15 >= 0 )
{
DeviceRegProp = RtlInitUnicodeStringEx(&DestinationString, a3);
if( DeviceRegProp >= 0 )
{
DeviceRegProp = CmSetDeviceRegProp(
a1,
a2,
0i64,
0xAu,
1u,
(__int64)DestinationString.Buffer,
DestinationString.MaximumLength,
0);
if( DeviceRegProp < 0 )
{
v16 = *(_QWORD *)(a1 + 224);
if( v16 )
v17 = *(_QWORD *)(v16 + 8);
else
v17 = 0i64;
RegRtlDeleteKeyTransacted((char *)v22, (const WCHAR *)v25, v17);
}
}
}
}
}
}
}
ExReleaseResourceLite(*(PERESOURCE *)(a1 + 240));
KeLeaveCriticalRegion();
if( Handle )
ZwClose(Handle);
}
else
{
DeviceRegProp = -1073741772;
}
}
if( v22 )
ZwClose(v22);
return(unsigned int)DeviceRegProp;
}Referenced by:
CmGetDeviceSoftwareKeyPath