WdipSemLoadScenarioTable
INT64 __fastcall WdipSemLoadScenarioTable(){
__int64 v0;
UINT64 v1;
int v2;
unsigned int v3;
NTSTATUS v4;
WCHAR v5;
bool v6;
ULONG v7;
PSLIST_ENTRY v8;
int NextScenario;
INT64 v10;
EVENT_DESCRIPTOR *v11;
INT64 v12;
unsigned int v13;
unsigned int v14;
int v15;
unsigned int v17;
unsigned int v18;
__int64 v19;
__int64 v20;
UINT64 Length;
ULONG ResultLength[2];
HANDLE Key;
HANDLE Handle;
int ReturnValue;
int v26;
__int64 v27;
HANDLE KeyHandle;
HANDLE v29;
struct _UNICODE_STRING v30;
struct _OSVERSIONINFOEXW VersionInfo;
GUID Guid;
char KeyInformation[12];
unsigned int v34;
WCHAR SourceString[68];
KeyHandle = 0i64;
Handle = 0i64;
Key = 0i64;
v29 = 0i64;
v0 = 0i64;
ResultLength[0] = 0;
ReturnValue = 0;
v26 = 0;
v30 = 0i64;
Guid = 0i64;
memset((INT64)&VersionInfo, 0i64);
v1 = 0i64;
v2 = WdipSemOpenRegistryKey(
L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET\\Control\\WDI\\Scenarios",
0i64,
&KeyHandle);
if( v2 >= 0 )
{
v3 = 0;
while( 1 )
{
while( 1 )
{
do
{
while( 1 )
{
do
{
do
{
LABEL_3:
if( Handle )
{
ZwClose(Handle);
Handle = 0i64;
}
if( Key )
{
ZwClose(Key);
Key = 0i64;
}
if( v29 )
{
ZwClose(v29);
v29 = 0i64;
}
memset((INT64)KeyInformation, 0i64);
LODWORD(Length) = 150;
v4 = ZwEnumerateKey(
KeyHandle,
v3++,
KeyBasicInformation,
KeyInformation,
Length,
(UINT64 *)ResultLength);
if( v4 == -2147483622 )
{
v2 = 0;
WdipSemEnableAllProviders();
goto LABEL_36;
}
}
while( v4 < 0 );
if( v34 >= 0x80 )
{
v2 = -2147483643;
goto LABEL_36;
}
SourceString[(unsigned __int64)v34 >> 1] = 0;
RtlInitUnicodeString(&v30, SourceString, v5);
}
while( RtlGUIDFromString(&v30, &Guid) < 0 );
if( !WdipSemDisabledScenarioTable )
break;
v17 = *((_DWORD *)WdipSemDisabledScenarioTable + 256);
v18 = 0;
if( !v17 )
break;
while( 1 )
{
v19 = 16i64 * v18;
v20 = *(_QWORD *)&Guid.Data1 - *(_QWORD *)((char *)WdipSemDisabledScenarioTable + v19);
if( *(_QWORD *)&Guid.Data1 == *(_QWORD *)((char *)WdipSemDisabledScenarioTable + v19) )
v20 = *(_QWORD *)Guid.Data4 - *(_QWORD *)((char *)WdipSemDisabledScenarioTable + v19 + 8);
if( !v20 )
break;
if( ++v18 >= v17 )
goto LABEL_14;
}
}
LABEL_14:
;
}
while( (int)WdipSemOpenRegistryKey(SourceString, KeyHandle, &Handle) < 0 );
LODWORD(v27) = 1;
v6 = 1;
if( (int)WdipSemOpenRegistryKey(L"Config", Handle, &Key) >= 0 )
break;
LABEL_16:
if( (int)WdipSemOpenRegistryKey(L"Instrumentation", Handle, &v29) >= 0 )
{
v7 = 0;
while( 1 )
{
while( 1 )
{
if( v0 )
WdipSemFreeScenario(v0);
v8 = WdipSemFastAllocate(1, 0x4A0u);
v0 = (__int64)v8;
if( !v8 )
{
v2 = -1073741670;
goto LABEL_36;
}
memset((INT64)v8, 0i64);
*(_BYTE *)(v0 + 1176) = v6;
NextScenario = WdipSemLoadNextScenario(v29, v7++, (GUID *)v0);
v13 = NextScenario;
if( NextScenario == -2147483622 )
goto LABEL_3;
if( NextScenario >= 0 )
break;
if( EtwEventEnabled(WdipSemRegHandle, (EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_MISCONFIG, v11) )
WdipSemWriteMisconfigEvent((GUID *)v0, *(_WORD *)(v0 + 16), v13);
}
if( (unsigned int)dword_140C1A360 >= 0x40 )
break;
v14 = OldNumProviders;
WdipSemUpdateProviderTableWithScenario(v0, v10, (INT64)v11, v12);
if( v15 < 0 || *(_DWORD *)(v0 + 52) && (int)WdipSemAddScenarioToTable(v0) < 0 )
{
WdipSemRollBackProviderTable(v14);
}
else
{
WdipSemUpdateProviderEntriesForScenario(v0);
if( *(_DWORD *)(v0 + 52) )
v0 = 0i64;
}
}
if( EtwEventEnabled(WdipSemRegHandle, (EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_SCENARIO_MAX, v11) )
WdipSemWriteScenarioLimitExceededEvent(
(EVENT_DESCRIPTOR *)&WDI_SEM_EVENT_INIT_SCENARIO_MAX,
(GUID *)v0,
*(_WORD *)(v0 + 16));
}
}
if( (int)WdipSemQueryValueFromRegistry(
Key,
(WCHAR *)L"ScenarioExecutionEnabled",
4ui64,
4ui64,
&ReturnValue,
(UINT64 *)ResultLength) < 0
|| ReturnValue )
{
if( (int)WdipSemQueryValueFromRegistry(
Key,
(WCHAR *)L"ScenarioExecutionRestrictions",
4ui64,
4ui64,
&v26,
(UINT64 *)ResultLength) < 0
|| (v26 & 1) == 0
|| (memset((INT64)&VersionInfo, 0i64),
VersionInfo.wSuiteMask = 16,
v1 = VerSetConditionMask(v1, 0x40ui64, 6u),
RtlVerifyVersionInfo(&VersionInfo, 0x40u, v1) < 0) )
{
if( (int)WdipSemQueryValueFromRegistry(
Key,
(WCHAR *)L"ScenarioTimeoutEnabled",
4ui64,
4ui64,
&v27,
(UINT64 *)ResultLength) >= 0 )
v6 = (_DWORD)v27 != 0;
goto LABEL_16;
}
}
}
}
LABEL_36:
if( KeyHandle )
{
ZwClose(KeyHandle);
KeyHandle = 0i64;
}
if( Handle )
{
ZwClose(Handle);
Handle = 0i64;
}
if( Key )
{
ZwClose(Key);
Key = 0i64;
}
if( v29 )
ZwClose(v29);
if( v0 )
WdipSemFreeScenario(v0);
return(unsigned int)v2;
}Referenced by:
WdipSemCleanStart