PiPnpRtlSetDeviceRegProperty

__int64 __fastcall PiPnpRtlSetDeviceRegProperty(
        __int64 a1,
        const WCHAR *a2,
        __int64 a3,
        signed int a4,
        unsigned int a5,
        int *a6,
        unsigned int a7,
        unsigned int a8){
  unsigned int v8; 
  int *v9; 
  unsigned int v13; 
  char v14; 
  unsigned int v15; 
  WCHAR v16; 
  bool v18; 
  _ETHREAD *CurrentThread; 
  UINT64 OldConfigFlags; 
  struct _UNICODE_STRING DestinationString; 
  int v23; 
  v8 = a7;
  v9 = a6;
  v23 = 0;
  OldConfigFlags = 0i64;
  v13 = 0;
  v14 = 0;
  DestinationString = 0i64;
  if( a4 < 2 )
    goto LABEL_7;
  if( a4 <= 3 )
  {
    v18 = CmIsRootEnumeratedDevice(a2) == 0;
  }
  else
  {
    if( a4 == 11 )
    {
      if( !a6 || a7 != 4 )
        return(unsigned int)-1073741811;
      if( (unsigned __int8)SeAuditingWithTokenForSubcategory(0x89ui64, 0i64) )
      {
        v23 = 4;
        if( (int)CmGetDeviceRegProp(
                    a1,
                    a2,
                    a3,
                    11,
                    (__int64)&OldConfigFlags + 4,
                    (__int64)&OldConfigFlags,
                    (__int64)&v23,
                    0) < 0
          || v23 != 4
          || HIDWORD(OldConfigFlags) != 4 )
        {
          LODWORD(OldConfigFlags) = 0;
        }
        v13 = *v9;
      }
      goto LABEL_7;
    }
    if( a4 == 9 )
    {
      CurrentThread = (_ETHREAD *)KeGetCurrentThread();
      --*((_WORD *)CurrentThread + 242);
      v14 = 1;
      ExAcquireResourceExclusiveLite(&PnpRegistryDeviceResource, 1u);
      goto LABEL_7;
    }
    if( a4 <= 15 )
      goto LABEL_7;
    if( a4 <= 17 || a4 == 29 )
      return(unsigned int)-1073741790;
    v18 = a4 == 37;
  }
  if( v18 )
    return(unsigned int)-1073741790;
LABEL_7:
  v15 = CmSetDeviceRegProp(a1, a2, a3, a4, a5, (__int64)v9, v8, a8);
  if( a4 == 11 && (unsigned __int8)SeAuditingWithTokenForSubcategory(0x89ui64, 0i64) )
  {
    RtlInitUnicodeString(&DestinationString, a2, v16);
    PiAuditDeviceEnableDisableRequest(&DestinationString, (unsigned int)OldConfigFlags, v13, (v15 & 0x80000000) == 0);
  }
  if( v14 )
  {
    ExReleaseResourceLite(&PnpRegistryDeviceResource);
    KeLeaveCriticalRegionThread((__int64)KeGetCurrentThread());
  }
  return v15;
}

Referenced by:

PiCMSetRegistryProperty
PiDevCfgSetDeviceRegProp