EmonEnableMonitoring

INT64 __fastcall EmonEnableMonitoring(INT64 a1, INT64 a2, UINT64 *r8_0){
  unsigned int v3; 
  unsigned int v5; 
  unsigned __int64 v6; 
  _QWORD **v7; 
  int ProfileDescriptor; 
  INT64 v9; 
  INT64 v10; 
  INT64 v11; 
  unsigned int v12; 
  UINT64 v13; 
  CHAR v14; 
  unsigned int v15; 
  INT64 a3; 
  _QWORD v18[2]; 
  INT64 v19; 
  a3 = 0i64;
  v3 = a1;
  LODWORD(v19) = 0;
  v18[0] = 0i64;
  v5 = a2;
  v6 = (unsigned __int8)HalpAcquireHighLevelLock(&EmonProfileSourceDescriptorListLock);
  ProfileDescriptor = HalpGetProfileDescriptor(v5, &EmonProfileSourceDescriptorListHead, &a3);
  if( ProfileDescriptor >= 0 )
  {
    v9 = a3;
    v10 = *(unsigned int *)(a3 + 216);
    if( (_DWORD)v10 != 37 && (int)HalpGetProfileDescriptor(v10, v7, v18) >= 0 )
    {
      v9 = v18[0];
      a3 = v18[0];
    }
    v11 = a3;
    v12 = KiProcessorIndexToNumberMappingTable[*((unsigned int *)KeGetPcr() + 105)];
    if( ((*(_QWORD *)(a3 + 8i64 * (v12 >> 6) + 40) >> (v12 & 0x3F)) & 1) != 0 )
    {
      ProfileDescriptor = EmonAllocateCounter(v3, v9, v5, &v19);
      if( ProfileDescriptor >= 0 )
      {
        v13 = (unsigned int)v19;
        if( v3 )
        {
          v15 = EmonNumberArchCounters;
          v14 = 0;
          *(_DWORD *)r8_0 = v19;
          if( (unsigned int)v13 >= v15 )
            *(_DWORD *)r8_0 = (v13 - v15) | 0x40000000;
        }
        else
        {
          v14 = 1;
        }
        EmonConfigureCounter(v13, 1, *(unsigned int *)(v11 + 24), *(unsigned int *)(v9 + 208), v14);
      }
    }
    else
    {
      ProfileDescriptor = -1073741637;
    }
  }
  KxReleaseSpinLock(&EmonProfileSourceDescriptorListLock);
  __writecr8(v6);
  return(unsigned int)ProfileDescriptor;
}

Referenced by:

No references.