PPHYSICAL_COUNTER_OVERFLOW_HANDLER - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
// ntddk.h

PPHYSICAL_COUNTER_OVERFLOW_HANDLER PphysicalCounterOverflowHandler;

VOID PphysicalCounterOverflowHandler(
  ULONGLONG OverflowBits,
  HANDLE OwningHandle
)
{...}
View the official Windows Driver Kit DDI reference

NtDoc

No description available.

Windows Driver Kit DDI reference (nc-ntddk-pphysical_counter_overflow_handler)

Description

The PPHYSICAL_COUNTER_OVERFLOW_HANDLER is implemented by the client driver to handle counter overflows from the counters resources acquired through the HalAllocateHardwareCounters routine.

Parameters

OverflowBits

Provides a bitmap describing which counters overflowed.

OwningHandle

Provides the HANDLE corresponding to the resource set the overflowing counters belong to.

Remarks

Register your implementation of this callback function by calling HalAllocateHardwareCounters with a structure of type PHYSICAL_COUNTER_RESOURCE_LIST. In the PHYSICAL_COUNTER_RESOURCE_LIST, provide a structure of type PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR that specifies a PHYSICAL_COUNTER_RESOURCE_DESCRIPTOR_TYPE of ResourceTypeOverflow.

Here is an example prototype for an overflow handler:

VOID
PmuAwareOverflowHandler (
    _In_ ULONGLONG OverflowStatus,
    _In_ HANDLE OwningHandle
    )

/*++

Routine Description:

    This routine is the PMU Overflow Handler for a sharing driver.

Arguments:

    OverflowStatus - The counters which have overflowed.

    OwningHandle - The handle owning the counters.

Return Value:

    None.

--*/
{
}

To register the overflow handler, use code like this:

VOID
CreateOverflowDescriptor (
    _Inout_ PPHYSICAL_COUNTER_RESOURCE_LIST CounterResourceList,
    _In_ ULONG DescriptorIndex
    )
{

    CounterResourceList->Descriptors[DescriptorIndex].Type = ResourceTypeOverflow;
    CounterResourceList->Descriptors[DescriptorIndex].u.OverflowHandler = PmuAwareOverflowHandler;
}

This callback is called at IRQL = PROFILE_LEVEL. This means it must always be memory-resident. The callback should return as quickly as possible and should not attempt to do any of the following.

The callback does not need to handle clearing any overflow registers as it will be handled by the HAL.

See also