ReactOS 0.4.15-dev-7958-gcd0bb1a
fxwmicompat.h File Reference
#include <evntrace.h>
Include dependency graph for fxwmicompat.h:

Go to the source code of this file.

Macros

#define WPP_TRACE   FxWmiTraceMessage
 
#define WPP_IFR   FxIFR
 
#define WmiQueryTraceInformation   FxWmiQueryTraceInformation
 

Functions

_Must_inspect_result_ NTSTATUS FxWmiTraceMessage (__in TRACEHANDLE LoggerHandle, __in ULONG MessageFlags, __in LPGUID MessageGuid, __in USHORT MessageNumber,...)
 
_Must_inspect_result_ NTSTATUS FxIFR (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in UCHAR MessageLevel, __in ULONG MessageFlags, __in LPGUID MessageGuid, __in USHORT MessageNumber,...)
 
_Must_inspect_result_ NTSTATUS FxWmiQueryTraceInformation (__in TRACE_INFORMATION_CLASS TraceInformationClass, __out_bcount(TraceInformationLength) PVOID TraceInformation, __in ULONG TraceInformationLength, __out_opt PULONG RequiredLength, __in_opt PVOID Buffer)
 

Macro Definition Documentation

◆ WmiQueryTraceInformation

#define WmiQueryTraceInformation   FxWmiQueryTraceInformation

Definition at line 64 of file fxwmicompat.h.

◆ WPP_IFR

#define WPP_IFR   FxIFR

Definition at line 48 of file fxwmicompat.h.

◆ WPP_TRACE

#define WPP_TRACE   FxWmiTraceMessage

Definition at line 35 of file fxwmicompat.h.

Function Documentation

◆ FxIFR()

_Must_inspect_result_ NTSTATUS FxIFR ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in UCHAR  MessageLevel,
__in ULONG  MessageFlags,
__in LPGUID  MessageGuid,
__in USHORT  MessageNumber,
  ... 
)

Definition at line 613 of file tracingum.cpp.

645{
646 size_t size;
648
649 UNREFERENCED_PARAMETER( MessageLevel );
650
651 //
652 // Return early if IFR is disabled.
653 //
655 ASSERT(FxDriverGlobals->WdfLogHeader == NULL);
656 return STATUS_SUCCESS;
657 }
658
659 if ( FxDriverGlobals->WdfLogHeader == NULL) {
660 return STATUS_UNSUCCESSFUL;
661 }
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687 UNREFERENCED_PARAMETER( MessageFlags );
688
689
690 //
691 // Determine the number bytes to follow header
692 //
693 size = 0; // For Count of Bytes
694
695 //
696 // Determine how much log space is needed for this
697 // trace record's data.
698 //
699 {
700 va_list ap;
701 size_t argLen;
702
704#pragma prefast(suppress: __WARNING_BUFFER_OVERFLOW, "Recommneded by EndClean");
705 while ((va_arg(ap, PVOID)) != NULL) {
706
707 argLen = va_arg(ap, size_t);
708
709 if (argLen > 0) {
710
711 if (argLen > FxIFRMaxMessageSize) {
712 goto drop_message;
713 }
714 size += (USHORT) argLen;
715 }
716 }
717
718 va_end(ap);
719
720 //
721 // NOTE: The final size must be 32-bit (ULONG) aligned.
722 // This is necessary for IA64 to prevent Alignment Faults.
723 //
724 size += (size % sizeof(ULONG)) ? sizeof(ULONG) - (size % sizeof(ULONG)) : 0;
725
727 goto drop_message;
728 }
729 }
730
731 size += sizeof(WDF_IFR_RECORD);
732
733 //
734 // Allocate log space of the calculated size
735 //
736 {
738 WDF_IFR_OFFSET offsetRet;
739 WDF_IFR_OFFSET offsetCur;
740 WDF_IFR_OFFSET offsetNew;
741 USHORT usSize = (USHORT) size; // for a prefast artifact.
742
743 header = (PWDF_IFR_HEADER) FxDriverGlobals->WdfLogHeader;
744 ASSERT(header->Size < FxIFRMaxLogSize); // size doesn't include header.
745 ASSERT(header->Size >= header->Offset.u.s.Current);
746 ASSERT(header->Size >= header->Offset.u.s.Previous);
747
748 offsetRet.u.AsLONG = header->Offset.u.AsLONG;
749 offsetNew.u.AsLONG = offsetRet.u.s.Current;
750
751 do {
752 offsetCur.u.AsLONG = offsetRet.u.AsLONG;
753
754 if (&header->Base[header->Size] < &header->Base[offsetCur.u.s.Current+size]) {
755
756 offsetNew.u.s.Current = 0;
757 offsetNew.u.s.Previous = offsetRet.u.s.Previous;
758
759 offsetRet.u.AsLONG =
760 InterlockedCompareExchange( &header->Offset.u.AsLONG,
761 offsetNew.u.AsLONG,
762 offsetCur.u.AsLONG );
763
764 if (offsetCur.u.AsLONG != offsetRet.u.AsLONG) {
765 continue;
766 } else {
767 offsetNew.u.s.Current = offsetCur.u.s.Current + usSize;
768 offsetNew.u.s.Previous = offsetRet.u.s.Current;
769 }
770 } else {
771
772 offsetNew.u.s.Current = offsetCur.u.s.Current + usSize;
773 offsetNew.u.s.Previous = offsetCur.u.s.Current;
774 }
775
776 offsetRet.u.AsLONG =
777 InterlockedCompareExchange( &header->Offset.u.AsLONG,
778 offsetNew.u.AsLONG,
779 offsetCur.u.AsLONG );
780
781 } while (offsetCur.u.AsLONG != offsetRet.u.AsLONG);
782
783 record = (PWDF_IFR_RECORD) &header->Base[offsetRet.u.s.Current];
784
785 // RtlZeroMemory( record, sizeof(WDF_IFR_RECORD) );
786
787 //
788 // Build record (fill all fields!)
789 //
790 record->Signature = FxIFRRecordSignature;
791 record->Length = (USHORT) size;
792 record->PrevOffset = (USHORT) offsetRet.u.s.Previous;
793 record->MessageNumber = MessageNumber;
794 record->Sequence = InterlockedIncrement(header->SequenceNumberPointer);
795 record->MessageGuid = *MessageGuid;
796 }
797
798 //
799 // Move variable part of data into log.
800 //
801 {
802 va_list ap;
803 size_t argLen;
805 PUCHAR argsData;
806
807 argsData = (UCHAR*) &record[1];
808
810#pragma prefast(suppress: __WARNING_BUFFER_OVERFLOW, "Recommneded by EndClean");
811 while ((source = va_arg(ap, PVOID)) != NULL) {
812
813 argLen = va_arg(ap, size_t);
814
815 if (argLen > 0) {
816
817 RtlCopyMemory( argsData, source, argLen );
818 argsData += argLen;
819 }
820 }
821
822 va_end(ap);
823 }
824
825 return STATUS_SUCCESS;
826
827 {
828 //
829 // Increment sequence number to indicate dropped message
830 //
831drop_message:
833 header = (PWDF_IFR_HEADER) FxDriverGlobals->WdfLogHeader;
834 InterlockedIncrement(header->SequenceNumberPointer);
835 return STATUS_UNSUCCESSFUL;
836 }
837}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define InterlockedIncrement
Definition: armddk.h:53
#define NULL
Definition: types.h:112
struct _WDF_IFR_HEADER * PWDF_IFR_HEADER
struct _WDF_IFR_RECORD WDF_IFR_RECORD
struct _WDF_IFR_RECORD * PWDF_IFR_RECORD
@ FxIFRMaxLogSize
Definition: fxifrkm.h:24
@ FxIFRMaxMessageSize
Definition: fxifrkm.h:27
@ FxIFRRecordSignature
Definition: fxifrkm.h:29
GLsizeiptr size
Definition: glext.h:5919
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define ASSERT(a)
Definition: mode.c:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
unsigned short USHORT
Definition: pedump.c:61
FxLibraryGlobalsType FxLibraryGlobals
Definition: globals.cpp:95
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _WDF_IFR_OFFSET::@4763::@4764 s
LONG AsLONG
Definition: fxifr.h:83
union _WDF_IFR_OFFSET::@4763 u
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
void int int ULONGLONG int va_list * ap
Definition: winesup.h:36
_Must_inspect_result_ typedef _In_ ULONG _In_ ULONG MessageNumber
Definition: iotypes.h:4304
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ FxWmiQueryTraceInformation()

_Must_inspect_result_ NTSTATUS FxWmiQueryTraceInformation ( __in TRACE_INFORMATION_CLASS  TraceInformationClass,
__out_bcount(TraceInformationLength) PVOID  TraceInformation,
__in ULONG  TraceInformationLength,
__out_opt PULONG  RequiredLength,
__in_opt PVOID  Buffer 
)

Definition at line 310 of file tracingum.cpp.

317{
318 return STATUS_UNSUCCESSFUL;
319}

◆ FxWmiTraceMessage()

_Must_inspect_result_ NTSTATUS FxWmiTraceMessage ( __in TRACEHANDLE  LoggerHandle,
__in ULONG  MessageFlags,
__in LPGUID  MessageGuid,
__in USHORT  MessageNumber,
  ... 
)

Definition at line 323 of file tracingum.cpp.

330{
332
333 va_list va;
335 //
336 // UMDF is supported only on XP and newer OS so no need to support w2k
337 // tracing (which requires using a different tracing api, see kmdf impl)
338 //
339#pragma prefast(suppress:__WARNING_BUFFER_OVERFLOW, "Recommneded by EndClean");
340 status = TraceMessageVa(LoggerHandle,
341 MessageFlags,
342 MessageGuid,
344 va);
345
346 va_end(va);
347
348 return status;
349}
LONG NTSTATUS
Definition: precomp.h:26
EXTERN_C ULONG WMIAPI TraceMessageVa(IN TRACEHANDLE LoggerHandle, IN ULONG MessageFlags, IN LPCGUID MessageGuid, IN USHORT MessageNumber, IN va_list MessageArgList)
Definition: ps.c:97