microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.34k stars 119 forks source link

Provide `SYNCHRONIZATION_ACCESS_RIGHTS` constants #1973

Closed seritools closed 2 months ago

seritools commented 3 months ago

Suggestion

Functions like OpenMutexW expect a SYNCHRONIZATION_ACCESS_RIGHTS value, however the constants for it are not exposed.

It seems like the ones that are shared with windows::Win32::Storage::FileSystem::FILE_ACCESS_RIGHTS, such as SYNCHRONIZE, are missing in windows::Win32::System::Threading.

This makes it a bit harder to discover the values, esp. if the "Win32_Storage_FileSystem" feature is not enabled. In our project, my colleague ported some winapi-based code, but couldn't find SYNCHRONIZE with the correct newtype wrapper and fell back to manually specifying the value 0x00100000 for it.

kennykerr commented 3 months ago

This is more of a Win32 metadata issue - will forward for their consideration.

riverar commented 3 months ago

I think you're looking for SYNCHRONIZATION_SYNCHRONIZE, here's the enum:

[Flags]
public enum SYNCHRONIZATION_ACCESS_RIGHTS : uint
{
    EVENT_ALL_ACCESS = 0x1F0003u,
    EVENT_MODIFY_STATE = 2u,
    MUTEX_ALL_ACCESS = 0x1F0001u,
    MUTEX_MODIFY_STATE = 1u,
    SEMAPHORE_ALL_ACCESS = 0x1F0003u,
    SEMAPHORE_MODIFY_STATE = 2u,
    TIMER_ALL_ACCESS = 0x1F0003u,
    TIMER_MODIFY_STATE = 2u,
    TIMER_QUERY_STATE = 1u,
    SYNCHRONIZATION_DELETE = 0x10000u,
    SYNCHRONIZATION_READ_CONTROL = 0x20000u,
    SYNCHRONIZATION_WRITE_DAC = 0x40000u,
    SYNCHRONIZATION_WRITE_OWNER = 0x80000u,
    SYNCHRONIZATION_SYNCHRONIZE = 0x100000u
}
seritools commented 2 months ago

interesting! I guess it doesn't match the MSDN docs because it collides with the FILE_ACCESS_RIGHTS definition. rustdoc/windows-docs-rs doesn't seem to have an easy way for "give me all constants of this type" → gotta remember to fire up IlSpy in the future to check ^^

thanks! not sure if there are any actionable issues then, feel free to close

riverar commented 2 months ago

Yup, we're forced to ensure enum constants are unique as some projections emit them as global constants. Will close for now, but feel free to reach out again as needed.