1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
use super::bindings::Windows::Win32::Etw;
use crate::native::etw_types::EventPropertyInfo;
use num_traits::FromPrimitive;
#[derive(Debug, Clone, Default)]
pub struct Property {
pub name: String,
pub flags: PropertyFlags,
length: u16,
in_type: TdhInType,
out_type: TdhOutType,
}
#[doc(hidden)]
impl Property {
pub fn new(name: String, property: &EventPropertyInfo) -> Self {
unsafe {
let out_type = FromPrimitive::from_u16(property.Anonymous1.nonStructType.OutType)
.unwrap_or(TdhOutType::OutTypeNull);
let in_type = FromPrimitive::from_u16(property.Anonymous1.nonStructType.InType)
.unwrap_or(TdhInType::InTypeNull);
Property {
name,
flags: PropertyFlags::from(property.Flags),
length: property.Anonymous3.length,
in_type,
out_type,
}
}
}
pub fn in_type(&self) -> TdhInType {
self.in_type
}
pub fn out_type(&self) -> TdhOutType {
self.out_type
}
pub fn len(&self) -> usize {
self.length.clone() as usize
}
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, FromPrimitive, ToPrimitive, PartialEq)]
pub enum TdhInType {
InTypeNull,
InTypeUnicodeString,
InTypeAnsiString,
InTypeInt8,
InTypeUInt8,
InTypeInt16,
InTypeUInt16,
InTypeInt32,
InTypeUInt32,
InTypeInt64,
InTypeUInt64,
InTypeFloat,
InTypeDouble,
InTypeBoolean,
InTypeBinary,
InTypeGuid,
InTypePointer,
InTypeFileTime,
InTypeSystemTime,
InTypeSid,
InTypeHexInt32,
InTypeHexInt64,
InTypeCountedString = 300,
}
impl Default for TdhInType {
fn default() -> TdhInType {
TdhInType::InTypeNull
}
}
#[repr(u16)]
#[derive(Debug, Clone, Copy, FromPrimitive, ToPrimitive, PartialEq)]
pub enum TdhOutType {
OutTypeNull,
OutTypeString,
OutTypeDateTime,
OutTypeInt8,
OutTypeUInt8,
OutTypeInt16,
OutTypeUInt16,
OutTypeInt32,
OutTypeUInt32,
OutTypeInt64,
OutTypeUInt64,
OutTypeFloat,
OutTypeDouble,
OutTypeBoolean,
OutTypeGuid,
OutTypeHexBinary,
OutTypeHexInt8,
OutTypeHexInt16,
OutTypeHexInt32,
OutTypeHexInt64,
OutTypePid,
OutTypeTid,
OutTypePort,
OutTypeIpv4,
OutTypeIpv6,
OutTypeWin32Error = 30,
OutTypeNtStatus = 31,
OutTypeHResult = 32,
OutTypeJson = 34,
OutTypeUtf8 = 35,
OutTypePkcs7 = 36,
OutTypeCodePointer = 37,
OutTypeDatetimeUtc = 38,
}
impl Default for TdhOutType {
fn default() -> TdhOutType {
TdhOutType::OutTypeNull
}
}
bitflags! {
#[derive(Default)]
pub struct PropertyFlags: u32 {
const PROPERTY_STRUCT = 0x1;
const PROPERTY_PARAM_LENGTH = 0x2;
const PROPERTY_PARAM_COUNT = 0x4;
const PROPERTY_WBEMXML_FRAGMENT = 0x8;
const PROPERTY_PARAM_FIXED_LENGTH = 0x10;
const PROPERTY_PARAM_FIXED_COUNT = 0x20;
const PROPERTY_HAS_TAGS = 0x40;
const PROPERTY_HAS_CUSTOM_SCHEMA = 0x80;
}
}
impl From<Etw::PROPERTY_FLAGS> for PropertyFlags {
fn from(val: Etw::PROPERTY_FLAGS) -> Self {
let flags: i32 = val.0.into();
PropertyFlags::from_bits_truncate(flags as u32)
}
}