Skip to content
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

Bug: EVT_HANDLE is treated as an isize in the Win32_System_EventLog API #1292

Closed
disassembledd opened this issue Oct 2, 2022 · 2 comments
Closed
Assignees
Labels
bug Something isn't working rust Critical for Rust adoption

Comments

@disassembledd
Copy link

disassembledd commented Oct 2, 2022

Which crate is this about?

windows

Crate version

0.42

Summary

All of the methods residing in the Win32_System_EventLog API expect and return isize instead of EVT_HANDLE. This means various HANDLE helper methods (such as is_invalid) are unavailable.

As a side note, EventLog constants are referred to as i32 meaning it requires a rather ugly EvtQueryChannelPath.0 as u32 to use them.

Toolchain version/configuration

Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\user\.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.63.0 (4b91a6ea7 2022-08-08)

Reproducible example

use windows::{Win32::{System::EventLog::{EvtQuery, EvtQueryChannelPath, EvtClose}}, w};

fn main() {
    unsafe {
        // hQuery is isize. First parameter of EvtQuery is intended to be the session (also an isize)
        let hQuery = EvtQuery(0isize, w!("Security"), w!("Event/System[EventID=4624]"), EvtQueryChannelPath.0 as u32);
        EvtClose(hQuery);
    }
}

Crate manifest

windows = { version = "0.42", features = ["Win32_Foundation", "Win32_Security", "Win32_System_EventLog"] }

Expected behavior

hQuery should result in an EVT_HANDLE type.

Actual behavior

hQuery currently results in as isize.

Additional comments

This may very well be a win32-metadata issue realistically however I am not sure.

@disassembledd disassembledd added the bug Something isn't working label Oct 2, 2022
@kennykerr
Copy link
Contributor

Thanks for reporting. This looks like something that should be fixed in the win32 metadata. Will transfer.

@kennykerr kennykerr transferred this issue from microsoft/windows-rs Oct 3, 2022
@kennykerr kennykerr added the rust Critical for Rust adoption label Oct 3, 2022
@mikebattista mikebattista self-assigned this Oct 25, 2022
@mikebattista
Copy link
Collaborator

Windows.Win32.System.EventLog.Apis.EvtArchiveExportedLog : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtCancel : Object...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtClearLog : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtClose : Object...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtCreateBookmark : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtCreateRenderContext : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtExportLog : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtFormatMessage : Event...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtFormatMessage : PublisherMetadata...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtGetChannelConfigProperty : ChannelConfig...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtGetEventInfo : Event...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtGetEventMetadataProperty : EventMetadata...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtGetLogInfo : Log...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtGetPublisherMetadataProperty : PublisherMetadata...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtGetQueryInfo : QueryOrSubscription...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtNext : ResultSet...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtNextChannelPath : ChannelEnum...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtNextEventMetadata : EventMetadataEnum...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtNextEventMetadata : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtNextPublisherId : PublisherEnum...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenChannelConfig : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenChannelConfig : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenChannelEnum : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenChannelEnum : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenEventMetadataEnum : PublisherMetadata...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenEventMetadataEnum : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenLog : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenLog : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenPublisherEnum : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenPublisherEnum : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenPublisherMetadata : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenPublisherMetadata : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtOpenSession : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtQuery : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtQuery : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtRender : Context...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtRender : Fragment...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSaveChannelConfig : ChannelConfig...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSeek : Bookmark...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSeek : ResultSet...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSetChannelConfigProperty : ChannelConfig...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSubscribe : Bookmark...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSubscribe : return...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtSubscribe : Session...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtUpdateBookmark : Bookmark...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.Apis.EvtUpdateBookmark : Event...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.EVT_CHANNEL_REFERENCE_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_EXPORTLOG_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_FORMAT_MESSAGE_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_HANDLE added
Windows.Win32.System.EventLog.EVT_OPEN_LOG_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_QUERY_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_RENDER_CONTEXT_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_RENDER_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_RPC_LOGIN_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_SEEK_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_SUBSCRIBE_CALLBACK.Invoke : Event...IntPtr => EVT_HANDLE
Windows.Win32.System.EventLog.EVT_SUBSCRIBE_FLAGS.value__...System.Int32 => System.UInt32
Windows.Win32.System.EventLog.EVT_VARIANT._Anonymous_e__Union.EvtHandleVal...System.IntPtr => Windows.Win32.System.EventLog.EVT_HANDLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rust Critical for Rust adoption
Projects
None yet
Development

No branches or pull requests

3 participants