示例#1
0
VOID NTAPI ChickenAddInterceptTsc (
  PCPU Cpu
)
{

  ULONG64 Tsc = RegGetTSC ();
  if (Cpu->ChickenQueueSize == CHICKEN_QUEUE_SZ)
    ChQueueDequeue (Cpu);       // make space
  ChQueueEnqueue (Cpu, Tsc);

}
示例#2
0
VOID NTAPI ComInit (
)
{
  g_BpId = (UCHAR) RegGetTSC ();
  CmInitSpinLock (&g_ComSpinLock);
}
示例#3
0
VOID NTAPI ComPrint (
  PUCHAR fmt,
  ...
)
{
  va_list args;
  UCHAR str[1024] = { 0 };
  int i, len, j;
  ULONG64 tsc = RegGetTSC ();

#ifdef USE_COM_PRINTS
  if (g_bDisableComOutput)
    return;
#endif

  va_start (args, fmt);
  CmAcquireSpinLock (&g_ComSpinLock);

#ifdef COMPRINT_OVERFLOW_PROTECTION

  if (SkippedLines) {
    if (tsc - QueueGetLast () <= COMPRINT_SLEEP) {
      SkippedLines++;
      //if (SkippedLines % 100 == 0) _ComPrint (">>> still skipping...\n");
      CmReleaseSpinLock (&g_ComSpinLock);
      return;
    } else {
      QueueSize = 0;
      QueueHead = QueueTail = 0;
      snprintf ((PUCHAR) & str, sizeof (str), ">>> %d lines skipped, continuing normal output...\n", SkippedLines);
      _ComPrint (str);
      str[0] = 0;
      SkippedLines = 0;

    }

  }

  if ((QueueSize == COMPRINT_QUEUE_SZ)
      && (tsc - QueueGetFirst () <= COMPRINT_QUEUE_TH)) {
    // suppress Com output...
    if (!SkippedLines)
      _ComPrint (">>> Supressing further output temporarily...\n");
    SkippedLines++;
    CmReleaseSpinLock (&g_ComSpinLock);
    return;
  }

  if (QueueSize == COMPRINT_QUEUE_SZ)
    QueueDequeue ();            // make space
  QueueEnqueue (tsc);

#endif

  tsc >>= 10;                   // don't be too precise when displaying the time deltas...

#ifndef USE_LOCAL_DBGPRINTS
  if (tsc > LastTsc)
    snprintf ((PUCHAR) & str, sizeof (str), "+% 8x <%02X>:  ", tsc - LastTsc, g_BpId);
  else
    snprintf ((PUCHAR) & str, sizeof (str), "-% 8x <%02X>:  ", LastTsc - tsc, g_BpId);

  len = (int) strlen (str);
  _ComPrint (str);
#endif

  vsnprintf ((PUCHAR) & str, sizeof (str), (PUCHAR) fmt, args);
  len = (int) strlen (str);

  _ComPrint (str);
  LastTsc = tsc;
  CmReleaseSpinLock (&g_ComSpinLock);
}