WdipSemLoadLocalGroupPolicy

NTSTATUS __stdcall WdipSemLoadLocalGroupPolicy(VOID *WdiGroupPolicyKey){
  VOID *v2; 
  unsigned int v3; 
  NTSTATUS v4; 
  NTSTATUS v5; 
  VOID **v6; 
  VOID **PoolWithTag; 
  unsigned int v8; 
  char *Length; 
  VOID *Key; 
  UINT64 ResultLength; 
  _UNICODE_STRING DestinationString; 
  _GUID Guid; 
  int KeyInformation[38]; 

  ResultLength = 0i64;
  v2 = 0i64;
  Key = 0i64;
  v3 = 0;
  DestinationString = 0i64;
  Guid = 0i64;
  if( !WdiGroupPolicyKey )
    return -1073741811;
  while( 1 )
  {
    if( v2 )
    {
      ZwClose((_HANDLE)v2);
      Key = 0i64;
    }
    memset(KeyInformation, 0i64, sizeof(KeyInformation));
    LODWORD(Length) = 150;
    v5 = ZwEnumerateKey(WdiGroupPolicyKey, v3++, KeyBasicInformation, KeyInformation, (UINT64)Length, &ResultLength);
    if( v5 == -2147483622 )
      break;
    if( v5 >= 0 )
    {
      if( KeyInformation[3] >= 0x80u )
      {
        v4 = -2147483643;
        goto LABEL_22;
      }
      *((_WORD *)&KeyInformation[4] + ((unsigned __int64)(unsigned int)KeyInformation[3] >> 1)) = 0;
      RtlInitUnicodeString(&DestinationString, (PCWSTR)&KeyInformation[4]);
      if( RtlGUIDFromString(&DestinationString, &Guid) >= 0
        && WdipSemOpenRegistryKey((const WCHAR *)&KeyInformation[4], WdiGroupPolicyKey, &Key) >= 0 )
      {
        Length = (char *)&ResultLength + 4;
        if( WdipSemQueryValueFromRegistry((_HANDLE)Key, L"ScenarioExecutionEnabled", 4i64) >= 0
          && !HIDWORD(ResultLength) )
        {
          v6 = (VOID **)*(&ExBootDevicesRemovedEvent + 557);
          if( !*(&ExBootDevicesRemovedEvent + 557) )
          {
            PoolWithTag = ExAllocatePoolWithTag(
                            (unsigned int)(*(&ExBootDevicesRemovedEvent + 1114) + 1),
                            0x404ui64,
                            1934181463i64);
            *(&ExBootDevicesRemovedEvent + 557) = PoolWithTag;
            v6 = PoolWithTag;
            if( !PoolWithTag )
            {
              v4 = -1073741670;
              goto LABEL_22;
            }
            memset(PoolWithTag, 0i64, 0x404u);
          }
          v8 = *((_DWORD *)v6 + 256);
          if( v8 >= 0x40 )
          {
            v4 = -1073741823;
            goto LABEL_22;
          }
          *((_DWORD *)v6 + 256) = v8 + 1;
          *(_GUID *)&v6[2 * v8] = Guid;
        }
      }
    }
    v2 = Key;
  }
  v4 = 0;
LABEL_22:
  if( Key )
    ZwClose((_HANDLE)Key);
  return v4;
}

Referenced by:

WdipSemLoadGroupPolicy