Ejemplo n.º 1
0
// Uninstall the windows performance counters exposing  the HPX counters.
void uninstall_windows_counters()
{
    // uninstall counter instances
    if (queue_counter) {
        PerfDeleteInstance(HPXHeartBeat, queue_counter);
        queue_counter = 0;
    }
    if (avg_queue_counter) {
        PerfDeleteInstance(HPXHeartBeat, avg_queue_counter);
        avg_queue_counter = 0;
    }

    // uninstall counter set, detach this provider
    CounterCleanup();
}
Ejemplo n.º 2
0
EXTERN_C FORCEINLINE
ULONG
CounterInitialize(
    __in_opt PERFLIBREQUEST NotificationCallback,
    __in_opt PERF_MEM_ALLOC MemoryAllocationFunction,
    __in_opt PERF_MEM_FREE MemoryFreeFunction,
    __inout_opt PVOID MemoryFunctionsContext
    )
{
    ULONG Status;
    PERF_PROVIDER_CONTEXT ProviderContext;

    ZeroMemory(&ProviderContext, sizeof(PERF_PROVIDER_CONTEXT));
    ProviderContext.ContextSize = sizeof(PERF_PROVIDER_CONTEXT);
    ProviderContext.ControlCallback = NotificationCallback;
    ProviderContext.MemAllocRoutine = MemoryAllocationFunction;
    ProviderContext.MemFreeRoutine = MemoryFreeFunction;
    ProviderContext.pMemContext = MemoryFunctionsContext;

    Status = PerfStartProviderEx(&YardmasterGuid,
                                 &ProviderContext,
                                 &Yardmaster);
    if (Status != ERROR_SUCCESS) {
        Yardmaster = NULL;
        return Status;
    }

    Status = PerfSetCounterSetInfo(Yardmaster,
                                   &PerformanceInfo.CounterSet,
                                   sizeof PerformanceInfo);
    if (Status != ERROR_SUCCESS) {
        CounterCleanup();
        return Status;
    }
    return ERROR_SUCCESS;
}