Ejemplo n.º 1
0
/**
 * Effects: Append the string <str> into the end of the debug window
 * If the debug window not exists, then it will be created at first.
 * 把<str>续写到调试窗口末尾,如果调试窗口不存在,则创建调试窗口
 **/
static NTSTATUS NTAPI _WriteInfo(PUCHAR str,ULONG32 strLength)
{
	CmAcquireSpinLock (&g_PrintSpinLock);
	//Step 1. Check if the debug window exists.
	if(!g_debugWindowAddrVA)
	{
		if(!NT_SUCCESS(_CreateDebugWindow(NUM_DEBUG_PAGES)))
		{
			//Continous Memory Allocate Failed!
			return STATUS_UNSUCCESSFUL;
		}
	}
	//Step 2.Append the <str> at the end of the debug window.
	_AppendStringToAddress(str,strLength);
	CmReleaseSpinLock (&g_PrintSpinLock);
	return STATUS_SUCCESS;
}
Ejemplo n.º 2
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);
}