KsepEngineGetShimsFromRegistry
NTSTATUS __stdcall KsepEngineGetShimsFromRegistry(
_KSE_ENGINE *Engine,
_UNICODE_STRING *DriverName,
_KSE_SHIM_INFO **Shims,
UINT64 *ShimCount){
_KSE_SHIM_INFO *v4;
_KSE_SHIM_INFO **v6;
WCHAR *Paged;
UINT64 *v9;
WCHAR *v10;
int DriverShims;
__int64 v13;
int v14;
_KSE_SHIM_INFO *v15;
_UNICODE_STRING *v16;
__int64 i;
__int64 v18;
_UNICODE_STRING *v19;
_KSE_SHIM_INFO **v20;
INT64 a3;
UINT64 BufferLength;
INT64 a4;
_KSE_SHIM_INFO **v24;
v24 = Shims;
BufferLength = 0i64;
v4 = 0i64;
a3 = 0i64;
LODWORD(a4) = 0;
v6 = Shims;
if( (Engine[2] & 1) != 0 )
{
DriverShims = -1073741275;
goto LABEL_5;
}
Paged = (WCHAR *)KsepPoolAllocatePaged(0x800ui64);
v10 = Paged;
if( !Paged )
{
DriverShims = -1073741801;
goto LABEL_5;
}
DriverShims = KsepRegistryQueryDriverShims(DriverName->Buffer, Paged, v9);
if( DriverShims >= 0 )
{
KsepStringSplitMultiString(
v10,
BufferLength,
(INT64)&a3,
(INT64)&a4,
(_UNICODE_STRING **)a3,
(UINT64 *)BufferLength);
v13 = (unsigned int)a4;
DriverShims = v14;
if( v14 >= 0 )
{
v15 = (_KSE_SHIM_INFO *)KsepPoolAllocatePaged(80i64 * (unsigned int)a4);
v16 = (_UNICODE_STRING *)a3;
v4 = v15;
if( !v15 )
{
DriverShims = -1073741801;
LABEL_20:
if( v16 )
{
if( (_DWORD)v13 )
{
v19 = v16;
do
{
KsepStringFree(v19++);
--v13;
}
while( v13 );
}
KsepPoolFreePaged(v16);
}
v6 = v24;
goto LABEL_4;
}
for( i = 0i64; (unsigned int)i < (unsigned int)v13; i = (unsigned int)(i + 1) )
{
if( KsepStringDuplicate((_UNICODE_STRING *)&v4[20 * i + 4], v16[(unsigned int)i].Buffer) < 0 )
break;
v4[20 * i + 17] = 0;
}
DriverShims = KsepDbGetShimInfo(v4, (unsigned int)v13);
if( DriverShims >= 0 )
{
v20 = v24;
DriverShims = 0;
*(_DWORD *)ShimCount = v13;
*v20 = v4;
goto LABEL_20;
}
v18 = ((unsigned __int8)_InterlockedExchangeAdd(&KsepHistoryErrorsIndex, 1u) + 1) & 0x3F;
KsepHistoryErrors[2 * v18 + 1] = DriverShims;
KsepHistoryErrors[2 * v18] = 132101;
if( (KsepDebugFlag & 2) != 0 )
KsepDebugPrint(0i64, "KSE: Cannot resolve registry shims to Sdb: 0x%x\n", (unsigned int)DriverShims);
KsepLogError(0, "KSE: Cannot resolve registry shims to Sdb: 0x%x\n", (unsigned int)DriverShims);
v13 = (unsigned int)a4;
}
v16 = (_UNICODE_STRING *)a3;
goto LABEL_20;
}
LABEL_4:
KsepPoolFreePaged(v10);
if( DriverShims < 0 )
{
LABEL_5:
KsepPoolFreePaged(v4);
*v6 = 0i64;
*(_DWORD *)ShimCount = 0;
}
return DriverShims;
}Referenced by:
KsepGetShimsForDriver