Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

logger.c File Reference

#include "exp.h"

Go to the source code of this file.

Functions

PEX_DEBUG_LOG ExCreateDebugLog (IN UCHAR MaximumNumberOfTags, IN ULONG MaximumNumberOfEvents)
UCHAR ExCreateDebugLogTag (IN PEX_DEBUG_LOG Log, IN PCHAR Name, IN UCHAR Format1, IN UCHAR Format2, IN UCHAR Format3, IN UCHAR Format4)
VOID ExDebugLogEvent (IN PEX_DEBUG_LOG Log, IN UCHAR Tag, IN ULONG Data1, IN ULONG Data2, IN ULONG Data3, IN ULONG Data4)


Function Documentation

PEX_DEBUG_LOG ExCreateDebugLog IN UCHAR  MaximumNumberOfTags,
IN ULONG  MaximumNumberOfEvents
 

Definition at line 30 of file logger.c.

References ExAllocatePoolWithTag, _EX_DEBUG_LOG::First, KeInitializeSpinLock(), _EX_DEBUG_LOG::Last, _EX_DEBUG_LOG::Lock, _EX_DEBUG_LOG::MaximumNumberOfTags, _EX_DEBUG_LOG::Next, NonPagedPool, NULL, Size, and _EX_DEBUG_LOG::Tags.

00034 { 00035 PEX_DEBUG_LOG Log; 00036 ULONG Size; 00037 00038 Size = sizeof( EX_DEBUG_LOG ) + 00039 (MaximumNumberOfTags * 00040 sizeof( EX_DEBUG_LOG_TAG ) 00041 ) + 00042 (MaximumNumberOfEvents * 00043 sizeof( EX_DEBUG_LOG_EVENT ) 00044 ); 00045 00046 00047 Log = ExAllocatePoolWithTag( NonPagedPool, Size, 'oLbD' ); 00048 if (Log != NULL) { 00049 RtlZeroMemory( Log, Size ); 00050 KeInitializeSpinLock( &Log->Lock ); 00051 Log->MaximumNumberOfTags = MaximumNumberOfTags; 00052 Log->Tags = (PEX_DEBUG_LOG_TAG)(Log + 1); 00053 Log->First = (PEX_DEBUG_LOG_EVENT)(Log->Tags + MaximumNumberOfTags); 00054 Log->Last = Log->First + MaximumNumberOfEvents; 00055 Log->Next = Log->First; 00056 } 00057 00058 return Log; 00059 }

UCHAR ExCreateDebugLogTag IN PEX_DEBUG_LOG  Log,
IN PCHAR  Name,
IN UCHAR  Format1,
IN UCHAR  Format2,
IN UCHAR  Format3,
IN UCHAR  Format4
 

Definition at line 62 of file logger.c.

References ExAllocatePoolWithTag, ExFreePool(), _EX_DEBUG_LOG_TAG::Format, Name, _EX_DEBUG_LOG_TAG::Name, NonPagedPool, NULL, Size, and strlen().

00070 { 00071 KIRQL OldIrql; 00072 ULONG Size; 00073 PEX_DEBUG_LOG_TAG Tag; 00074 UCHAR TagIndex; 00075 PCHAR CapturedName; 00076 00077 Size = strlen( Name ); 00078 CapturedName = ExAllocatePoolWithTag( NonPagedPool, Size, 'oLbD' ); 00079 RtlMoveMemory( CapturedName, Name, Size + 1 ); 00080 00081 ExAcquireSpinLock( &Log->Lock, &OldIrql ); 00082 00083 if (Log->NumberOfTags < Log->MaximumNumberOfTags) { 00084 TagIndex = (UCHAR)(Log->NumberOfTags++); 00085 Tag = &Log->Tags[ TagIndex ]; 00086 Tag->Name = CapturedName; 00087 Tag->Format[ 0 ] = Format1; 00088 Tag->Format[ 1 ] = Format2; 00089 Tag->Format[ 2 ] = Format3; 00090 Tag->Format[ 3 ] = Format4; 00091 CapturedName = NULL; 00092 } 00093 else { 00094 TagIndex = (UCHAR)0xFF; 00095 } 00096 00097 ExReleaseSpinLock( &Log->Lock, OldIrql ); 00098 00099 if (CapturedName != NULL) { 00100 ExFreePool( CapturedName ); 00101 } 00102 return TagIndex; 00103 }

VOID ExDebugLogEvent IN PEX_DEBUG_LOG  Log,
IN UCHAR  Tag,
IN ULONG  Data1,
IN ULONG  Data2,
IN ULONG  Data3,
IN ULONG  Data4
 

Definition at line 106 of file logger.c.

References _ETHREAD::Cid, _EX_DEBUG_LOG_EVENT::Data, KeQuerySystemTime(), _EX_DEBUG_LOG_EVENT::ProcessId, PsGetCurrentThread, _EX_DEBUG_LOG_EVENT::Tag, _EX_DEBUG_LOG_EVENT::ThreadId, and _EX_DEBUG_LOG_EVENT::Time.

00114 { 00115 KIRQL OldIrql; 00116 PEX_DEBUG_LOG_EVENT p; 00117 PETHREAD Thread = PsGetCurrentThread(); 00118 LARGE_INTEGER CurrentTime; 00119 00120 KeQuerySystemTime( &CurrentTime ); 00121 00122 ExAcquireSpinLock( &Log->Lock, &OldIrql ); 00123 00124 p = Log->Next; 00125 if (p == Log->Last) { 00126 p = Log->First; 00127 } 00128 Log->Next = p + 1; 00129 00130 p->ThreadId = Thread->Cid.UniqueThread; 00131 p->ProcessId = Thread->Cid.UniqueProcess; 00132 p->Time = CurrentTime.LowPart; 00133 p->Tag = Tag; 00134 p->Data[ 0 ] = Data1; 00135 p->Data[ 1 ] = Data2; 00136 p->Data[ 2 ] = Data3; 00137 p->Data[ 3 ] = Data4; 00138 00139 ExReleaseSpinLock( &Log->Lock, OldIrql ); 00140 00141 return; 00142 }


Generated on Sat May 15 19:44:33 2004 for test by doxygen 1.3.7