WdipSemLoadNextContextProvider

NTSTATUS __stdcall WdipSemLoadNextContextProvider(_HANDLE KeyHandle, UINT32 Index, _GUID *Guid){
  VOID *v5; 
  int v6; 
  __int64 v7; 
  NTSTATUS ValueFromRegistry; 
  char v9; 
  NTSTATUS v10; 
  __int64 v11; 
  NTSTATUS v12; 
  NTSTATUS v13; 
  UINT64 Length; 
  UINT64 ResultLength; 
  VOID *Key; 
  int v18; 
  int v19; 
  __int64 v20; 
  _UNICODE_STRING DestinationString; 
  int KeyInformation[38]; 

  ResultLength = 0i64;
  Key = 0i64;
  v18 = 0;
  v5 = *(VOID **)&KeyHandle;
  v19 = 0;
  v20 = 0i64;
  DestinationString = 0i64;
  if( !*(_QWORD *)&KeyHandle || !Guid )
    return -1073741811;
  memset(KeyInformation, 0i64, sizeof(KeyInformation));
  LODWORD(Length) = 150;
  v6 = ZwEnumerateKey(v5, Index, KeyBasicInformation, KeyInformation, Length, &ResultLength);
  if( v6 >= 0 )
  {
    if( KeyInformation[3] >= 0x80u )
    {
      v6 = -2147483643;
      goto LABEL_24;
    }
    *((_WORD *)&KeyInformation[4] + ((unsigned __int64)(unsigned int)KeyInformation[3] >> 1)) = 0;
    RtlInitUnicodeString(&DestinationString, (PCWSTR)&KeyInformation[4]);
    v6 = RtlGUIDFromString(&DestinationString, Guid);
    if( v6 < 0 )
      goto LABEL_24;
    v7 = *(_QWORD *)&Guid->Data1 - *(_QWORD *)&WDI_SEM_PROVIDER.Data1;
    if( *(_QWORD *)&Guid->Data1 == *(_QWORD *)&WDI_SEM_PROVIDER.Data1 )
      v7 = *(_QWORD *)Guid->Data4 - *(_QWORD *)WDI_SEM_PROVIDER.Data4;
    if( !v7 )
    {
      v6 = -1073741823;
      goto LABEL_24;
    }
    v6 = WdipSemOpenRegistryKey((const WCHAR *)&KeyInformation[4], v5, &Key);
    if( v6 < 0 )
      goto LABEL_24;
    ValueFromRegistry = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"Level", 4i64);
    v6 = ValueFromRegistry;
    if( ValueFromRegistry < 0 )
    {
      if( ValueFromRegistry != -1073741772 )
        goto LABEL_24;
      BYTE2(Guid[1].Data1) = -1;
    }
    else
    {
      v9 = v18;
      if( !v18 )
        v9 = -1;
      BYTE2(Guid[1].Data1) = v9;
    }
    v10 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"Keyword", 11i64);
    v6 = v10;
    if( v10 < 0 )
    {
      if( v10 != -1073741772 )
        goto LABEL_24;
      *(_QWORD *)Guid[1].Data4 = -1i64;
    }
    else
    {
      v11 = v20;
      if( !v20 )
        v11 = -1i64;
      *(_QWORD *)Guid[1].Data4 = v11;
    }
    v12 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"CaptureState", 4i64);
    v6 = v12;
    if( v12 >= 0 )
    {
      Guid[2].Data1 = HIDWORD(ResultLength);
LABEL_21:
      v13 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"EnableProperty", 4i64);
      v6 = v13;
      if( v13 >= 0 )
      {
        *(_DWORD *)&Guid[2].Data2 = v19;
      }
      else if( v13 == -1073741772 )
      {
        v6 = 0;
        *(_DWORD *)&Guid[2].Data2 = 0;
      }
      goto LABEL_24;
    }
    if( v12 == -1073741772 || HIDWORD(ResultLength) >= 3 )
    {
      Guid[2].Data1 = 0;
      goto LABEL_21;
    }
  }
LABEL_24:
  if( Key )
    ZwClose((_HANDLE)Key);
  return v6;
}

Referenced by:

WdipSemLoadNextScenario