PnpOpenPropertiesKey

__int64 __fastcall PnpOpenPropertiesKey(
        __int64 a1,
        char *a2,
        const wchar_t *a3,
        ACCESS_MASK a4,
        char a5,
        __int64 a6,
        void **a7){
  NTSTATUS v7; 
  void *v9; 
  WCHAR *PoolWithTag; 
  void *v11; 
  ACCESS_MASK v12; 
  unsigned int v14; 
  int v15; 
  __int64 v16; 
  NTSTATUS v17; 
  __int64 v19; 
  int Key; 
  __int64 v21; 
  __int64 v22; 
  UINT64 v23; 
  void *PropertiesSecurityDescriptor; 
  void *v25; 
  int Tree; 
  UINT64 dwFlags; 
  char *v29; 
  __int64 pcchLength[2]; 
  wchar_t pszDest[64]; 
  v7 = 0;
  pcchLength[0] = 0i64;
  v9 = 0i64;
  v29 = a2;
  PoolWithTag = 0i64;
  *a7 = 0i64;
  v11 = 0i64;
  v12 = a4;
  if( a3 )
  {
    v7 = RtlUnalignedStringCchLengthW(a3, 0x200ui64, (SIZE_T *)pcchLength);
    if( v7 < 0 )
      return(unsigned int)v7;
    if( pcchLength[0] >= 0x30ui64 )
    {
      v14 = LODWORD(pcchLength[0]) + 12;
      PoolWithTag = (WCHAR *)ExAllocatePoolWithTag(
                               PagedPool,
                               2i64 * (unsigned int)(LODWORD(pcchLength[0]) + 12),
                               0x52504E50ui64);
      if( !PoolWithTag )
        return(unsigned int)-1073741801;
    }
    else
    {
      PoolWithTag = pszDest;
      v14 = 59;
    }
    LODWORD(dwFlags) = 2048;
    RtlStringCchPrintfExW(PoolWithTag, v14, 0i64, 0i64, dwFlags, L"%s\\%s", L"Properties", a3);
    v7 = v15;
    if( v15 < 0 )
      goto LABEL_11;
    if( a1 )
      v16 = *(_QWORD *)(a1 + 224);
    else
      v16 = 0i64;
    v17 = SysCtxRegOpenKey(v16, v29, PoolWithTag, 0, a4, a7);
    if( v17 == -1073741444 )
    {
      v7 = -1073741772;
      goto LABEL_11;
    }
    if( !a5 || v17 != -1073741772 )
    {
      v7 = v17;
      goto LABEL_11;
    }
    v12 = a4;
    a2 = v29;
  }
  if( a1 )
    v19 = *(_QWORD *)(a1 + 224);
  else
    v19 = 0i64;
  Key = SysCtxRegOpenKey(v19, a2, L"Properties", 0, v12, a7);
  if( Key != -1073741772 )
    goto LABEL_29;
  if( !a5 )
  {
LABEL_21:
    v7 = Key;
    goto LABEL_22;
  }
  PropertiesSecurityDescriptor = PnpGetPropertiesSecurityDescriptor(v22, v21, v23);
  v9 = PropertiesSecurityDescriptor;
  if( PropertiesSecurityDescriptor )
  {
    if( !RtlValidSecurityDescriptor(PropertiesSecurityDescriptor) )
    {
      v7 = -1073741595;
      goto LABEL_22;
    }
    Key = PnpCtxRegCreateKey(a1, (__int64)v29, L"Properties", 0, a4, v9, a7, 0i64);
LABEL_29:
    if( Key != -1073741444 )
    {
      if( Key < 0 )
        goto LABEL_21;
      if( !a3 )
      {
LABEL_22:
        if( v9 )
          ExFreePoolWithTag(v9, 0);
        goto LABEL_11;
      }
      v11 = *a7;
      v25 = *a7;
      *a7 = 0i64;
      Tree = PnpCtxRegCreateTree(a1, v25, a3, 0, a4, 0i64, (__int64)a7, 0i64);
      if( Tree != -1073741444 )
      {
        if( Tree < 0 )
          v7 = Tree;
        goto LABEL_22;
      }
    }
    v7 = -1073741772;
    goto LABEL_22;
  }
  v7 = -1073741595;
LABEL_11:
  if( PoolWithTag && PoolWithTag != pszDest )
    ExFreePoolWithTag(PoolWithTag, 0);
  if( v11 )
    ZwClose(v11);
  return(unsigned int)v7;
}

Referenced by:

CmDeleteInstallerClassMappedPropertyFromRegValue
CmDeleteInterfaceClassMappedPropertyFromRegValue
CmGetInstallerClassMappedPropertyFromRegValue
CmGetInstallerClassRegPropWorker
CmGetInterfaceClassMappedPropertyFromRegValue
CmSetInstallerClassMappedPropertyFromRegValue
CmSetInstallerClassRegPropWorker
CmSetInterfaceClassMappedPropertyFromRegValue
PnpDeletePropertyWorker
PnpGetGenericStoreProperty
PnpGetGenericStorePropertyKeys
PnpGetGenericStorePropertyLocales
PnpSetPropertyWorker