WdipSemLoadNextContextProvider

NTSTATUS __stdcall WdipSemLoadNextContextProvider(HANDLE KeyHandle, UINT32 Index, GUID *Guid){
  NTSTATUS v6; 
  WCHAR v7; 
  __int64 v8; 
  int v9; 
  char v10; 
  int v11; 
  __int64 v12; 
  int v13; 
  int v14; 
  UINT64 Length; 
  UINT64 ResultLength; 
  HANDLE Handle; 
  int ReturnValue; 
  int v20; 
  __int64 v21; 
  struct _UNICODE_STRING DestinationString; 
  char KeyInformation[12]; 
  unsigned int v24; 
  WCHAR SourceString[68]; 
  ResultLength = 0i64;
  Handle = 0i64;
  ReturnValue = 0;
  v20 = 0;
  v21 = 0i64;
  DestinationString = 0i64;
  if( !KeyHandle || !Guid )
    return -1073741811;
  memset((INT64)KeyInformation, 0i64);
  LODWORD(Length) = 150;
  v6 = ZwEnumerateKey(KeyHandle, Index, KeyBasicInformation, KeyInformation, Length, &ResultLength);
  if( v6 >= 0 )
  {
    if( v24 >= 0x80 )
    {
      v6 = -2147483643;
      goto LABEL_24;
    }
    SourceString[(unsigned __int64)v24 >> 1] = 0;
    RtlInitUnicodeString(&DestinationString, SourceString, v7);
    v6 = RtlGUIDFromString(&DestinationString, Guid);
    if( v6 < 0 )
      goto LABEL_24;
    v8 = *(_QWORD *)&Guid->Data1 - *(_QWORD *)&WDI_SEM_PROVIDER.Data1;
    if( *(_QWORD *)&Guid->Data1 == *(_QWORD *)&WDI_SEM_PROVIDER.Data1 )
      v8 = *(_QWORD *)Guid->Data4 - *(_QWORD *)WDI_SEM_PROVIDER.Data4;
    if( !v8 )
    {
      v6 = -1073741823;
      goto LABEL_24;
    }
    v6 = WdipSemOpenRegistryKey(SourceString, KeyHandle, &Handle);
    if( v6 < 0 )
      goto LABEL_24;
    v9 = WdipSemQueryValueFromRegistry(Handle, (WCHAR *)L"Level", 4ui64, 4ui64, &ReturnValue, &ResultLength);
    v6 = v9;
    if( v9 < 0 )
    {
      if( v9 != -1073741772 )
        goto LABEL_24;
      BYTE2(Guid[1].Data1) = -1;
    }
    else
    {
      v10 = ReturnValue;
      if( !ReturnValue )
        v10 = -1;
      BYTE2(Guid[1].Data1) = v10;
    }
    v11 = WdipSemQueryValueFromRegistry(Handle, (WCHAR *)L"Keyword", 0xBui64, 8ui64, &v21, &ResultLength);
    v6 = v11;
    if( v11 < 0 )
    {
      if( v11 != -1073741772 )
        goto LABEL_24;
      *(_QWORD *)Guid[1].Data4 = -1i64;
    }
    else
    {
      v12 = v21;
      if( !v21 )
        v12 = -1i64;
      *(_QWORD *)Guid[1].Data4 = v12;
    }
    v13 = WdipSemQueryValueFromRegistry(
            Handle,
            (WCHAR *)L"CaptureState",
            4ui64,
            4ui64,
            (char *)&ResultLength + 4,
            &ResultLength);
    v6 = v13;
    if( v13 >= 0 )
    {
      Guid[2].Data1 = HIDWORD(ResultLength);
LABEL_21:
      v14 = WdipSemQueryValueFromRegistry(Handle, (WCHAR *)L"EnableProperty", 4ui64, 4ui64, &v20, &ResultLength);
      v6 = v14;
      if( v14 >= 0 )
      {
        *(_DWORD *)&Guid[2].Data2 = v20;
      }
      else if( v14 == -1073741772 )
      {
        v6 = 0;
        *(_DWORD *)&Guid[2].Data2 = 0;
      }
      goto LABEL_24;
    }
    if( v13 == -1073741772 || HIDWORD(ResultLength) >= 3 )
    {
      Guid[2].Data1 = 0;
      goto LABEL_21;
    }
  }
LABEL_24:
  if( Handle )
    ZwClose(Handle);
  return v6;
}

Referenced by:

WdipSemLoadNextScenario