CmSetDeviceRegPropWorker
__int64 __fastcall CmSetDeviceRegPropWorker(
__int64 a1,
const WCHAR *a2,
void *a3,
int a4,
ULONG a5,
_DWORD *SecurityDescriptorInput,
ULONG SecurityDescriptorLength,
__int16 a8){
int inited;
_DWORD *v13;
int v14;
__int64 v15;
wchar_t *v16;
HANDLE v17;
NTSTATUS v18;
HANDLE v19;
HANDLE v21;
HANDLE Handle;
struct _UNICODE_STRING DestinationString;
inited = 0;
Handle = 0i64;
if( a8 )
return(unsigned int)-1073741811;
if( SecurityDescriptorLength )
{
v13 = SecurityDescriptorInput;
if( !SecurityDescriptorInput )
return(unsigned int)-1073741811;
}
else
{
v13 = 0i64;
}
if( (unsigned int)(a4 - 1) > 0x24 || !CmDevicePropertyRead(a1, a4) )
goto LABEL_54;
if( !CmDevicePropertyWrite() )
return(unsigned int)-1073741790;
v14 = MapCmDevicePropertyToRegType(a4);
if( !v14 )
return(unsigned int)-1073741264;
if( a5 != v14 )
return(unsigned int)-1073741811;
if( a4 == 11 )
{
if( !SecurityDescriptorLength )
goto LABEL_12;
if( v13 && SecurityDescriptorLength == 4 )
{
if( *v13 && CmIsRootDevice(a2) )
return(unsigned int)-1073741808;
goto LABEL_12;
}
return(unsigned int)-1073741811;
}
if( a4 == 8 )
{
if( SecurityDescriptorLength <= 0x40 )
goto LABEL_12;
return(unsigned int)-1073741811;
}
if( a4 == 24
&& SecurityDescriptorLength
&& (!RtlValidRelativeSecurityDescriptor(v13, SecurityDescriptorLength, 0i64)
|| (unsigned int)RtlLengthSecurityDescriptor(v13) != SecurityDescriptorLength) )
{
inited = -1073741811;
goto LABEL_25;
}
LABEL_12:
if( a3 || (inited = CmOpenDeviceRegKey(a1, a2, 16, 0, 33554434, 0, (__int64)&Handle, 0i64), inited >= 0) )
{
if( a4 == 8 )
goto LABEL_21;
v16 = (wchar_t *)MapCmDevicePropertyToRegValue(v15, a4);
if( v16 )
{
if( SecurityDescriptorLength )
{
v17 = Handle;
if( a3 )
v17 = a3;
v18 = RegRtlSetValue(v17, v16, a5, v13, SecurityDescriptorLength);
if( v18 == -1073741444 )
{
inited = -1073741810;
goto LABEL_25;
}
if( v18 < 0 )
inited = v18;
}
else
{
v21 = Handle;
DestinationString = 0i64;
if( a3 )
v21 = a3;
inited = RtlInitUnicodeStringEx(&DestinationString, v16);
if( inited >= 0 )
inited = ZwDeleteValueKey(v21, &DestinationString);
if( inited == -1073741772 || inited == -1073741444 )
inited = -1073741275;
}
LABEL_21:
if( inited >= 0 )
{
v19 = Handle;
if( a3 )
v19 = a3;
CmRaisePropertyChangeEvent(a1, (__int64)a2, 1u, (__int64)v19, a4);
}
goto LABEL_25;
}
LABEL_54:
inited = -1073741264;
}
LABEL_25:
if( Handle )
ZwClose(Handle);
return(unsigned int)inited;
}Referenced by:
CmSetDeviceRegProp