Skip to main content

Crate etw_wrapper

Crate etw_wrapper 

Source
Expand description

A strongly typed Event Tracing for Windows wrapper.

The gen_etw_wrapper! macro turns an ETW manifest into a strongly typed provider struct. See the examples directory for a basic demonstration.

use etw_wrapper::{Result, gen_etw_wrapper};

gen_etw_wrapper!("manifests/widgetservice.man", PROVIDER_WIDGETSERVICE -> WidgetLogger);

fn main() -> Result<()> {
    let provider = WidgetLogger::register()?;
    provider.request_failed(0x12ABCDEF, 500, 42, "failed to succeed")?;
    Ok(())
}

To avoid the procedural macro, call EtwLogger::register, check EtwLogger::enabled before each call to EtwLogger::write, and convert parameters to EVENT_DATA_DESCRIPTOR instances with the helpers in the field module.

use etw_wrapper::{EVENT_DESCRIPTOR, EtwLogger, GUID, field::*};
let ctx = EtwLogger::register(&GUID::default()).unwrap();
let x = 1u32;
let y = to_u16cstring("hello");

let descriptor = EVENT_DESCRIPTOR::default();
ctx.write(&descriptor, &[scalar(&x), str16(&y)]).unwrap();

Modules§

field
Serialization primitives that turn typed values into EVENT_DATA_DESCRIPTOR instances.

Macros§

gen_etw_wrappermacro
Generates strongly typed ETW providers from an instrumentation manifest.

Structs§

EVENT_DATA_DESCRIPTOR
EVENT_DESCRIPTOR
Error
An error object consists of both an error code and optional detailed error information for debugging.
EtwLogger
A registered ETW provider.
FILETIME
GUID
A globally unique identifier (GUID) used to identify COM and WinRT interfaces.
PSID
SYSTEMTIME

Type Aliases§

Result
A specialized Result type that provides Windows error information.