WdipSemLoadNextScenario
__int64 __fastcall WdipSemLoadNextScenario(HANDLE KeyHandle, ULONG Index, GUID *Guid){
PSLIST_ENTRY v6;
char v7;
int v8;
unsigned int v9;
__int64 v10;
__int16 v11;
__int64 v12;
unsigned int v13;
WCHAR *v14;
WCHAR v15;
WCHAR v16;
int v17;
char v18;
int v19;
__int64 v20;
int v21;
ULONG v23;
PSLIST_ENTRY v24;
int NextEndEvent;
EVENT_DESCRIPTOR *v26;
UINT32 v27;
NTSTATUS NextContextProvider;
EVENT_DESCRIPTOR *v29;
__int64 Data1;
__int64 v31;
EVENT_DESCRIPTOR *v32;
UINT64 Length;
UINT64 ResultLength;
HANDLE Handle;
UINT64 Value;
int v37;
HANDLE Key;
HANDLE KeyHandlea;
__int64 v40;
struct _UNICODE_STRING DestinationString;
char KeyInformation[12];
unsigned int v43;
WCHAR KeyName[68];
__int16 SourceString[64];
INT64 result[16];
Handle = 0i64;
Key = 0i64;
KeyHandlea = 0i64;
LODWORD(ResultLength) = 0;
v6 = 0i64;
Value = 0i64;
v37 = 0;
v40 = 0i64;
v7 = 0;
DestinationString = 0i64;
if( !KeyHandle || !Guid )
return(unsigned int)-1073741811;
memset((INT64)KeyInformation, 0i64);
LODWORD(Length) = 150;
v8 = ZwEnumerateKey(KeyHandle, Index, KeyBasicInformation, KeyInformation, Length, &ResultLength);
if( v8 >= 0 )
{
if( v43 >= 0x80 )
{
v8 = -2147483643;
goto LABEL_36;
}
KeyName[(unsigned __int64)v43 >> 1] = 0;
memset((INT64)SourceString, 0i64);
memset((INT64)result, 0i64);
v9 = 0;
v10 = 0i64;
while( 1 )
{
v11 = KeyName[v10];
if( v11 == 59 )
break;
SourceString[v10] = v11;
++v9;
++v10;
if( v9 >= 0x40 )
goto LABEL_11;
}
if( 2 * (unsigned __int64)v9 >= 0x80 )
_report_rangecheckfailure();
SourceString[v9] = 0;
LABEL_11:
if( v9 >= 0x40 )
goto LABEL_71;
v12 = v9 + 1;
v13 = 0;
if( (unsigned int)v12 >= 0x40 )
goto LABEL_71;
v14 = &KeyName[v12];
do
{
v15 = *v14;
*((_WORD *)result + v13) = *v14;
if( !v15 )
break;
LODWORD(v12) = v12 + 1;
++v14;
++v13;
}
while( (unsigned int)v12 < 0x40 );
if( (unsigned int)v12 >= 0x40 )
goto LABEL_71;
if( v13 == 1 && LOWORD(result[0]) == 42 )
v7 = 1;
RtlInitUnicodeString(&DestinationString, (PCWSTR)SourceString, v13);
v8 = RtlGUIDFromString(&DestinationString, Guid);
if( v8 < 0 )
goto LABEL_36;
if( !v7 )
{
RtlInitUnicodeString(&DestinationString, (PCWSTR)result, v16);
v8 = RtlUnicodeStringToInteger(&DestinationString, 0xAui64, &Value);
if( v8 < 0 )
goto LABEL_36;
LOWORD(Guid[1].Data1) = Value;
}
v8 = WdipSemOpenRegistryKey(KeyName, KeyHandle, &Handle);
if( v8 >= 0 )
{
v17 = WdipSemQueryValueFromRegistry(Handle, (WCHAR *)L"Level", 4ui64, 4ui64, (char *)&Value + 4, &ResultLength);
v8 = v17;
if( v17 < 0 )
{
if( v17 != -1073741772 )
goto LABEL_36;
BYTE2(Guid[1].Data1) = -1;
}
else
{
v18 = BYTE4(Value);
if( !HIDWORD(Value) )
v18 = -1;
BYTE2(Guid[1].Data1) = v18;
}
v19 = WdipSemQueryValueFromRegistry(Handle, (WCHAR *)L"Keyword", 0xBui64, 8ui64, &v40, &ResultLength);
v8 = v19;
if( v19 < 0 )
{
if( v19 != -1073741772 )
goto LABEL_36;
*(_QWORD *)Guid[1].Data4 = -1i64;
}
else
{
v20 = v40;
if( !v40 )
v20 = -1i64;
*(_QWORD *)Guid[1].Data4 = v20;
}
v21 = WdipSemQueryValueFromRegistry(Handle, (WCHAR *)L"EnableProperty", 4ui64, 4ui64, &v37, &ResultLength);
v8 = v21;
if( v21 >= 0 )
{
*(_DWORD *)&Guid[2].Data2 = v37;
goto LABEL_34;
}
if( v21 == -1073741772 )
{
*(_DWORD *)&Guid[2].Data2 = 0;
LABEL_34:
if( (int)WdipSemOpenRegistryKey(L"EndEvents", Handle, &KeyHandlea) < 0 )
{
LABEL_35:
v8 = 0;
goto LABEL_36;
}
v23 = 0;
while( 1 )
{
v24 = WdipSemFastAllocate(0, 0x30u);
v6 = v24;
if( !v24 )
goto LABEL_78;
*v24 = 0i64;
v24[1] = 0i64;
v24[2] = 0i64;
NextEndEvent = WdipSemLoadNextEndEvent(KeyHandlea, v23++, (GUID *)v24);
v8 = NextEndEvent;
if( NextEndEvent == -2147483622 )
break;
if( NextEndEvent < 0 )
goto LABEL_36;
v31 = *(unsigned int *)&Guid[3].Data2;
if( (unsigned int)v31 >= 0x10 )
{
if( EtwEventEnabled(WdipSemRegHandle, (EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_SCENARIO_END_EVENT_MAX, v26) )
{
v32 = (EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_SCENARIO_END_EVENT_MAX;
LABEL_70:
WdipSemWriteScenarioLimitExceededEvent(v32, Guid, Guid[1].Data1);
}
goto LABEL_71;
}
*(_QWORD *)&Guid[65].Data4[8 * v31] = v6;
++*(_DWORD *)&Guid[3].Data2;
}
if( !*(_DWORD *)&Guid[3].Data2 )
goto LABEL_35;
if( !v7 )
{
if( (int)WdipSemOpenRegistryKey(L"ContextProviders", Handle, &Key) < 0 )
goto LABEL_35;
v27 = 0;
while( 1 )
{
if( !v6 )
{
v6 = WdipSemFastAllocate(0, 0x30u);
if( !v6 )
break;
}
*v6 = 0i64;
v6[1] = 0i64;
v6[2] = 0i64;
NextContextProvider = WdipSemLoadNextContextProvider(Key, v27++, (GUID *)v6);
v8 = NextContextProvider;
if( NextContextProvider == -2147483622 )
goto LABEL_35;
if( NextContextProvider < 0 )
goto LABEL_36;
Data1 = Guid[3].Data1;
if( (unsigned int)Data1 >= 0x7C )
{
if( !EtwEventEnabled(
WdipSemRegHandle,
(EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_SCENARIO_CONTEXT_PROVIDER_MAX,
v29) )
goto LABEL_71;
v32 = (EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_SCENARIO_CONTEXT_PROVIDER_MAX;
goto LABEL_70;
}
*(_QWORD *)&Guid[3].Data4[8 * Data1] = v6;
v6 = 0i64;
++Guid[3].Data1;
}
LABEL_78:
v8 = -1073741670;
goto LABEL_36;
}
LABEL_71:
v8 = -1073741823;
}
}
}
LABEL_36:
if( Handle )
ZwClose(Handle);
if( Key )
ZwClose(Key);
if( KeyHandlea )
ZwClose(KeyHandlea);
if( v6 )
WdipSemFastFree(0i64, v6);
return(unsigned int)v8;
}Referenced by:
WdipSemLoadScenarioTable