WdipSemLoadNextScenario
NTSTATUS __stdcall WdipSemLoadNextScenario(
VOID *InstrumentationKey,
UINT64 Index,
_WDIP_SEM_SCENARIO_INFO *Scenario,
INT64 a4,
INT64 a5,
INT64 a6,
INT64 a7,
INT64 a8){
unsigned int v9;
_GUID *v11;
char v12;
int v13;
unsigned int v14;
__int64 v15;
__int16 v16;
__int64 v17;
int v18;
__int16 *v19;
__int16 v20;
NTSTATUS ValueFromRegistry;
char v22;
NTSTATUS v23;
__int64 v24;
NTSTATUS v25;
UINT32 v27;
_GUID *v28;
NTSTATUS NextEndEvent;
UINT32 v30;
NTSTATUS NextContextProvider;
__int64 v32;
__int64 v33;
const _EVENT_DESCRIPTOR *v34;
UINT64 Length;
UINT64 ResultLength;
VOID *Key;
UINT64 Value;
_WDIP_SEM_SCENARIO_INFO v39;
_HANDLE Handle[2];
_HANDLE KeyHandle[2];
__int64 v42;
_UNICODE_STRING DestinationString;
int KeyInformation[38];
__int16 SourceString[64];
__int16 v46[64];
Key = 0i64;
*(_QWORD *)Handle = 0i64;
v9 = Index;
*(_QWORD *)KeyHandle = 0i64;
LODWORD(ResultLength) = 0;
v11 = 0i64;
Value = 0i64;
v39 = 0;
v42 = 0i64;
v12 = 0;
DestinationString = 0i64;
if( !InstrumentationKey || !Scenario )
return -1073741811;
memset(KeyInformation, 0i64, sizeof(KeyInformation));
LODWORD(Length) = 150;
v13 = ZwEnumerateKey(InstrumentationKey, v9, KeyBasicInformation, KeyInformation, Length, &ResultLength);
if( v13 >= 0 )
{
if( KeyInformation[3] >= 0x80u )
{
v13 = -2147483643;
goto LABEL_36;
}
*((_WORD *)&KeyInformation[4] + ((unsigned __int64)(unsigned int)KeyInformation[3] >> 1)) = 0;
memset(SourceString, 0i64, sizeof(SourceString));
memset(v46, 0i64, sizeof(v46));
v14 = 0;
v15 = 0i64;
while( 1 )
{
v16 = *(_WORD *)((char *)&KeyInformation[4] + v15 * 2);
if( v16 == 59 )
break;
SourceString[v15] = v16;
++v14;
++v15;
if( v14 >= 0x40 )
goto LABEL_11;
}
if( 2 * (unsigned __int64)v14 >= 0x80 )
_report_rangecheckfailure();
SourceString[v14] = 0;
LABEL_11:
if( v14 >= 0x40 )
goto LABEL_71;
v17 = v14 + 1;
v18 = 0;
if( (unsigned int)v17 >= 0x40 )
goto LABEL_71;
v19 = (__int16 *)&KeyInformation[4] + v17;
do
{
v20 = *v19;
v46[v18] = *v19;
if( !v20 )
break;
LODWORD(v17) = v17 + 1;
++v19;
++v18;
}
while( (unsigned int)v17 < 0x40 );
if( (unsigned int)v17 >= 0x40 )
goto LABEL_71;
if( v18 == 1 && v46[0] == 42 )
v12 = 1;
RtlInitUnicodeString(&DestinationString, (PCWSTR)SourceString);
v13 = RtlGUIDFromString(&DestinationString, (_GUID *)Scenario);
if( v13 < 0 )
goto LABEL_36;
if( !v12 )
{
RtlInitUnicodeString(&DestinationString, (PCWSTR)v46);
v13 = RtlUnicodeStringToInteger(&DestinationString, 0xAui64, &Value);
if( v13 < 0 )
goto LABEL_36;
*((_WORD *)Scenario + 8) = Value;
}
v13 = WdipSemOpenRegistryKey((const WCHAR *)&KeyInformation[4], InstrumentationKey, &Key);
if( v13 >= 0 )
{
ValueFromRegistry = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"Level", 4i64);
v13 = ValueFromRegistry;
if( ValueFromRegistry < 0 )
{
if( ValueFromRegistry != -1073741772 )
goto LABEL_36;
*((_BYTE *)Scenario + 18) = -1;
}
else
{
v22 = BYTE4(Value);
if( !HIDWORD(Value) )
v22 = -1;
*((_BYTE *)Scenario + 18) = v22;
}
v23 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"Keyword", 11i64);
v13 = v23;
if( v23 < 0 )
{
if( v23 != -1073741772 )
goto LABEL_36;
*((_QWORD *)Scenario + 3) = -1i64;
}
else
{
v24 = v42;
if( !v42 )
v24 = -1i64;
*((_QWORD *)Scenario + 3) = v24;
}
v25 = WdipSemQueryValueFromRegistry((_HANDLE)Key, L"EnableProperty", 4i64);
v13 = v25;
if( v25 >= 0 )
{
Scenario[9] = v39;
goto LABEL_34;
}
if( v25 == -1073741772 )
{
Scenario[9] = 0;
LABEL_34:
if( WdipSemOpenRegistryKey(L"EndEvents", Key, (VOID **)KeyHandle) < 0 )
{
LABEL_35:
v13 = 0;
goto LABEL_36;
}
v27 = 0;
while( 1 )
{
v28 = (_GUID *)WdipSemFastAllocate(WDI_SEM_ALLOC_EVENT, 0x30ui64);
v11 = v28;
if( !v28 )
goto LABEL_78;
*v28 = 0i64;
v28[1] = 0i64;
v28[2] = 0i64;
NextEndEvent = WdipSemLoadNextEndEvent(KeyHandle[0], v27++, v28);
v13 = NextEndEvent;
if( NextEndEvent == -2147483622 )
break;
if( NextEndEvent < 0 )
goto LABEL_36;
v33 = (unsigned int)Scenario[13];
if( (unsigned int)v33 >= 0x10 )
{
if( EtwEventEnabled(*(&ExBootDevicesRemovedEvent + 560), &WDI_SEM_EVENT_INIT_SCENARIO_END_EVENT_MAX) )
{
v34 = &WDI_SEM_EVENT_INIT_SCENARIO_END_EVENT_MAX;
LABEL_70:
WdipSemWriteScenarioLimitExceededEvent((const in6_addr *)v34, (INT64)Scenario, *((_WORD *)Scenario + 8));
}
goto LABEL_71;
}
*(_QWORD *)&Scenario[2 * v33 + 262] = v11;
++Scenario[13];
}
if( !Scenario[13] )
goto LABEL_35;
if( !v12 )
{
if( WdipSemOpenRegistryKey(L"ContextProviders", Key, (VOID **)Handle) < 0 )
goto LABEL_35;
v30 = 0;
while( 1 )
{
if( !v11 )
{
v11 = (_GUID *)WdipSemFastAllocate(WDI_SEM_ALLOC_EVENT, 0x30ui64);
if( !v11 )
break;
}
*v11 = 0i64;
v11[1] = 0i64;
v11[2] = 0i64;
NextContextProvider = WdipSemLoadNextContextProvider(Handle[0], v30++, v11);
v13 = NextContextProvider;
if( NextContextProvider == -2147483622 )
goto LABEL_35;
if( NextContextProvider < 0 )
goto LABEL_36;
v32 = (unsigned int)Scenario[12];
if( (unsigned int)v32 >= 0x7C )
{
if( !EtwEventEnabled(
*(&ExBootDevicesRemovedEvent + 560),
&WDI_SEM_EVENT_INIT_SCENARIO_CONTEXT_PROVIDER_MAX) )
goto LABEL_71;
v34 = &WDI_SEM_EVENT_INIT_SCENARIO_CONTEXT_PROVIDER_MAX;
goto LABEL_70;
}
*(_QWORD *)&Scenario[2 * v32 + 14] = v11;
v11 = 0i64;
++Scenario[12];
}
LABEL_78:
v13 = -1073741670;
goto LABEL_36;
}
LABEL_71:
v13 = -1073741823;
}
}
}
LABEL_36:
if( Key )
ZwClose((_HANDLE)Key);
if( *(_QWORD *)Handle )
ZwClose(Handle[0]);
if( *(_QWORD *)KeyHandle )
ZwClose(KeyHandle[0]);
if( v11 )
WdipSemFastFree(0i64, (_SLIST_ENTRY *)v11);
return v13;
}Referenced by:
WdipSemLoadScenarioTable