-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The object_manager_provider does not support DuplicateHandle events #212
Comments
Update: If it may be of any help, when I inspect errors using
I suppose 1168 refers to |
I think it's a bug. Probably in code I contributed. 😅 |
@jstarink thank you for the detailed repro steps! I was able to repro this locally - looks like it may actually be a bug in Windows. The ETW provider gives us an I'll reach out to the Windows team to see how to get this fixed. |
Thanks for getting back to this. I came to the same conclusion after debugging the issue myself, but thought my understanding of In case anyone else encounters this problem, as a temporary workaround, I have been using this code to parse out the MOF data manually: ob_provider.add_on_event_callback([](const EVENT_RECORD& record, const krabs::trace_context& context)
{
/* ... */
switch (record.EventHeader.EventDescriptor.Opcode)
{
/* ... */
case 34: // DuplicateHandle
char* data = (char*)record.UserData;
auto object_pointer = *(uint64_t*) data; data += sizeof(uint64_t);
auto source_handle = *(uint32_t*) data; data += sizeof(uint32_t);
auto target_handle = *(uint32_t*) data; data += sizeof(uint32_t);
auto target_pid = *(uint32_t*) data; data += sizeof(uint32_t);
auto object_type = *(uint16_t*) data; data += sizeof(uint16_t);
/* ... */
break;
}
}); This seems to have worked well enough for my use-cases. Looking forward to proper support for this however :). |
Summary
I am trying to track object creation, destruction and duplication on a live Windows 10 machine. According to the MOF definitions on MSDN, these events correspond to opcodes 32, 33 and 34 respectively:
According to the examples,
object_manager_provider
is the struct to go for when tracking these events. And indeed, I can receive and parse events with opcode 32 and 33. However, events with opcode 34 seem to never be reported by the callback. Am I missing something, should I enable some extra flags/options, or could this be a bug?To Reproduce
I use the following source code, which is heavily inspired by the provided examples:
krabstest.cpp
As a test application, I have a basic program that creates a new file object, duplicates it 10 times, then closes all duplicated handles, and finally closes the main handle.
testerapp.cpp
When running this with admin rights on a Windows 10 Pro N x64 machine, version 22H2, build 19045.3086, I only get the following output:
Notice how a single file object creation (
12c
) is directly followed up by 11 handle closure events, without any report of the file handle being duplicated.Additional Context
It is maybe worth mentioning that other libraries that consume ETW events do seem to be able to report on object duplication. For example, using
Microsoft.Diagnostics.Tracing.TraceEvent
of the perfview project, reporting on handle duplication works fine:The text was updated successfully, but these errors were encountered: