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

Add InvalidHandleValue metadata for REGHANDLE #2027

Open
riverar opened this issue Nov 26, 2024 · 3 comments
Open

Add InvalidHandleValue metadata for REGHANDLE #2027

riverar opened this issue Nov 26, 2024 · 3 comments
Assignees

Comments

@riverar
Copy link
Collaborator

riverar commented Nov 26, 2024

From evtprov.h:

/*
A REGHANDLE represents an event provider session.
A REGHANDLE is opened with EventRegister and closed with EventUnregister.
*/
typedef ULONGLONG REGHANDLE, *PREGHANDLE;

From docs:

If EventRegister fails, it returns a zero-valued RegHandle. ETW APIs such as EventWrite and EventUnregister will safely accept a zero-valued RegHandle value, do nothing, and return immediately. Callers do not need to check for a zero-valued RegHandle before calling EventWrite or EventUnregister.

Suggested fixes:

  1. Add [InvalidHandleValue(0)]
  2. Add metadata test to fail if IHV metadata is missing from RAIIFree marked types.

Originally posted by @kennykerr in #1891

@riverar riverar changed the title Add RAII metadata for REGHANDLE Add InvalidHandleValue metadata for REGHANDLE Nov 26, 2024
@riverar riverar self-assigned this Dec 2, 2024
@riverar
Copy link
Collaborator Author

riverar commented Dec 2, 2024

Additional:

  • BSTR (⚠️ This is not a handle type)
  • HSTRING (⚠️ Has no invalid handle value)
  • PROCESSTRACE_HANDLE
  • PDH_HLOG
  • PDH_HQUERY
  • PRINTER_HANDLE
  • LPPROC_THREAD_ATTRIBUTE_LIST (⚠️ This is not a handle type)

@kennykerr
Copy link
Contributor

This is not a handle type

I was curious what you meant by this (I'm still curious) and then I happened to notice that there seems to be a new metadata attribute I wasn't aware of. HSTRING for example has the NativeTypedef attribute while PROCESSTRACE_HANDLE has the MetadataTypedef attribute. Rust only deals with the former, but the latter seems to indicate the same or similar thing. Why are there two attributes?

@riverar
Copy link
Collaborator Author

riverar commented Dec 2, 2024

I was just making a note to indicate which types shouldn't get an InvalidHandleValue assigned to them, given that attribute is meant for handles and not pointers. I recognize HSTRING is a handle; HSTRING is notable though as it has no invalid value.

NativeTypedef indicates the typedef declaration natively appears in the headers, while MetadataTypedef indicates it was artificially created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants