WdipSemLoadNextEndEvent

NTSTATUS __stdcall WdipSemLoadNextEndEvent(_HANDLE KeyHandle, UINT32 Index, _GUID *Guid){
  VOID *v5; 
  int v6; 
  unsigned int v7; 
  __int64 v8; 
  __int16 v9; 
  __int64 v10; 
  int v11; 
  __int16 *v12; 
  __int16 v13; 
  NTSTATUS ValueFromRegistry; 
  char v15; 
  NTSTATUS v16; 
  __int64 v17; 
  NTSTATUS v18; 
  UINT64 Length; 
  UINT64 Value; 
  int v22; 
  int v23; 
  VOID *Key; 
  __int64 v25; 
  _UNICODE_STRING DestinationString; 
  int KeyInformation[40]; 
  __int16 SourceString[64]; 
  __int16 v29[64]; 

  Key = 0i64;
  Value = 0i64;
  v5 = *(VOID **)&KeyHandle;
  v22 = 0;
  v23 = 0;
  v25 = 0i64;
  DestinationString = 0i64;
  if( !*(_QWORD *)&KeyHandle || !Guid )
    return -1073741811;
  memset(KeyInformation, 0i64, 0x98u);
  LODWORD(Length) = 150;
  v6 = ZwEnumerateKey(v5, Index, KeyBasicInformation, KeyInformation, Length, &Value);
  if( v6 >= 0 )
  {
    if( KeyInformation[3] >= 0x80u )
    {
      v6 = -2147483643;
      goto LABEL_31;
    }
    *((_WORD *)&KeyInformation[4] + ((unsigned __int64)(unsigned int)KeyInformation[3] >> 1)) = 0;
    memset(SourceString, 0i64, sizeof(SourceString));
    memset(v29, 0i64, sizeof(v29));
    v7 = 0;
    v8 = 0i64;
    while( 1 )
    {
      v9 = *(_WORD *)((char *)&KeyInformation[4] + v8 * 2);
      if( v9 == 59 )
        break;
      SourceString[v8] = v9;
      ++v7;
      ++v8;
      if( v7 >= 0x40 )
        goto LABEL_11;
    }
    if( 2 * (unsigned __int64)v7 >= 0x80 )
      _report_rangecheckfailure();
    SourceString[v7] = 0;
LABEL_11:
    if( v7 >= 0x40 )
      goto LABEL_38;
    v10 = v7 + 1;
    v11 = 0;
    if( (unsigned int)v10 >= 0x40 )
      goto LABEL_38;
    v12 = (__int16 *)&KeyInformation[4] + v10;
    do
    {
      v13 = *v12;
      v29[v11] = *v12;
      if( !v13 )
        break;
      LODWORD(v10) = v10 + 1;
      ++v12;
      ++v11;
    }
    while( (unsigned int)v10 < 0x40 );
    if( (unsigned int)v10 >= 0x40 )
    {
LABEL_38:
      v6 = -1073741823;
      goto LABEL_31;
    }
    RtlInitUnicodeString(&DestinationString, (PCWSTR)SourceString);
    v6 = RtlGUIDFromString(&DestinationString, Guid);
    if( v6 >= 0 )
    {
      RtlInitUnicodeString(&DestinationString, (PCWSTR)v29);
      v6 = RtlUnicodeStringToInteger(&DestinationString, 0xAui64, (UINT64 *)((char *)&Value + 4));
      if( v6 >= 0 )
      {
        LOWORD(Guid[1].Data1) = WORD2(Value);
        v6 = WdipSemOpenRegistryKey((const WCHAR *)&KeyInformation[4], v5, &Key);
        if( v6 >= 0 )
        {
          ValueFromRegistry = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"Level", 4i64);
          v6 = ValueFromRegistry;
          if( ValueFromRegistry < 0 )
          {
            if( ValueFromRegistry != -1073741772 )
              goto LABEL_31;
            BYTE2(Guid[1].Data1) = -1;
          }
          else
          {
            v15 = v22;
            if( !v22 )
              v15 = -1;
            BYTE2(Guid[1].Data1) = v15;
          }
          v16 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"Keyword", 11i64);
          v6 = v16;
          if( v16 >= 0 )
          {
            v17 = v25;
            if( !v25 )
              v17 = -1i64;
            *(_QWORD *)Guid[1].Data4 = v17;
            goto LABEL_28;
          }
          if( v16 == -1073741772 )
          {
            *(_QWORD *)Guid[1].Data4 = -1i64;
LABEL_28:
            v18 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"EnableProperty", 4i64);
            v6 = v18;
            if( v18 >= 0 )
            {
              *(_DWORD *)&Guid[2].Data2 = v23;
            }
            else if( v18 == -1073741772 )
            {
              v6 = 0;
              *(_DWORD *)&Guid[2].Data2 = 0;
            }
          }
        }
      }
    }
  }
LABEL_31:
  if( Key )
    ZwClose((_HANDLE)Key);
  return v6;
}

Referenced by:

WdipSemLoadNextScenario