KeAllocateProcessorProfileStructures
NTSTATUS __stdcall KeAllocateProcessorProfileStructures(
UINT64 a1,
INT64 a2,
PROCESSOR_PROFILE_CONTROL_AREA **a3,
CHAR a4){
unsigned __int8 CurrentIrql;
struct _KPRCB *CurrentPrcb;
__int64 v8;
unsigned __int64 v9;
char *IndependentPages;
__int64 v11;
PROCESSOR_PROFILE_CONTROL_AREA *v12;
PROCESSOR_PROFILE_CONTROL_AREA *v13;
unsigned __int64 *PebsGpCounterReset;
NTSTATUS v15;
int v16;
char v18;
v16 = a1;
CurrentIrql = KeGetCurrentIrql();
if( !a4 )
{
__writecr8(2ui64);
CurrentPrcb = KeGetCurrentPrcb();
CurrentPrcb->ProcessorProfileControlArea = *a3;
CurrentPrcb->ProfileEventIndexAddress = &(*a3)->PebsDsSaveArea.As64Bit.PebsIndex;
__writecr8(CurrentIrql);
return 0;
}
*a3 = 0i64;
v18 = 0;
v8 = (unsigned int)a1;
v9 = a2 * (unsigned int)a1 + 160i64 * (unsigned int)a1;
if( KiKvaShadow )
v9 = (v9 + 4095) & 0xFFFFFFFFFFFFF000ui64;
IndependentPages = (char *)MmAllocateIndependentPages(v9, 0i64);
if( IndependentPages )
{
memset(IndependentPages, 0i64, v9);
if( !KiKvaShadow )
goto LABEL_9;
if( MmCreateShadowMapping(IndependentPages, v9) )
{
v18 = 1;
LABEL_9:
CurrentIrql = KeGetCurrentIrql();
__writecr8(2ui64);
if( KiIsIntelPebsSupported(KeGetCurrentPrcb()) )
{
v13 = *(PROCESSOR_PROFILE_CONTROL_AREA **)(v11 + 33944);
if( v13 )
{
*a3 = v13;
v15 = -1073741302;
}
else
{
if( v16 )
{
PebsGpCounterReset = v12->PebsDsSaveArea.As32Bit.PebsGpCounterReset;
do
{
*PebsGpCounterReset = (unsigned __int64)IndependentPages;
IndependentPages += a2;
PebsGpCounterReset += 20;
--v8;
}
while( v8 );
}
IndependentPages = 0i64;
*a3 = v12;
v15 = 0;
}
}
else
{
v15 = -1073741637;
}
goto LABEL_15;
}
v15 = -1073741670;
}
else
{
v15 = -1073741801;
}
LABEL_15:
__writecr8(CurrentIrql);
if( IndependentPages )
{
if( v18 )
MmDeleteShadowMapping(IndependentPages, v9);
MmFreeIndependentPages(IndependentPages, v9);
}
return v15;
}Referenced by:
EmonCompleteInitializeProfiling