/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/***************************** Windows implementation of probes, using xperf
*****************************/ #include <windows.h> #include <wmistr.h> #include <evntrace.h>
// Note: The Windows API is just a little bit scary there. // The only way to obtain the session handle is to //- ignore the session handle obtained from RegisterTraceGuids //- pass a callback //- in that callback, request the session handle through // GetTraceLoggerHandle and some opaque value received by the callback
ULONG WINAPI ControlCallback(WMIDPREQUESTCODE aRequestCode, PVOID aContext,
ULONG* aReserved, PVOID aBuffer) {
ProbeManager* context = (ProbeManager*)aContext; switch (aRequestCode) { case WMI_ENABLE_EVENTS: {
context->mIsActive = true;
TRACEHANDLE sessionHandle = GetTraceLoggerHandle(aBuffer); // Note: We only accept one handle if ((HANDLE)sessionHandle == INVALID_HANDLE_VALUE) {
ULONG result = GetLastError();
LOG(("Probes: ControlCallback failed, %lu", result)); return result;
} elseif (context->mIsActive && context->mSessionHandle &&
context->mSessionHandle != sessionHandle) {
LOG(
("Probes: Can only handle one context at a time, " "ignoring activation")); return ERROR_SUCCESS;
} else {
context->mSessionHandle = sessionHandle;
LOG(("Probes: ControlCallback activated")); return ERROR_SUCCESS;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.