-
Notifications
You must be signed in to change notification settings - Fork 120
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
Missing SID_IDENTIFIER_AUTHORITY
constants
#1337
Comments
Windows SDK defines: #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5} // ntifs It is an initializer for the SID_IDENTIFIER_AUTHORITY structure. Would this need a new SidIdentifierAuthorityAttribute type akin to PropertyKeyAttribute, or is there some other way to represent the constant in metadata? |
Other constants whose values are structures but not GUID nor PROPERTYKEY:
Can there be a generic solution, or do projections have to support each type separately? Perhaps one could have [AttributeUsage(AttributeTargets.Class)]
public sealed class ConstInitializer : Attribute
{
}
[ConstInitializer]
[AttributeUsage(AttributeTargets.Field)]
public sealed class SidIdentifierAuthorityAttribute : Attribute
{
public SidIdentifierAuthorityAttribute(byte[] Value) {}
}
[SidIdentifierAuthority(new byte[] { 0, 0, 0, 0, 0, 5 })]
public static readonly SID_IDENTIFIER_AUTHORITY SECURITY_NT_AUTHORITY; and let projections recognize just the ConstInitializerAttribute type and then map the parameters of the constructor to the fields of the SID_IDENTIFIER_AUTHORITY type. |
@kennykerr / @riverar thoughts on this? |
I really don't like these type-specific attributes, like the existing |
Or not use an attribute at all but instead use a string constant that language tools can coerce:
A similar approach is already being used by constants like |
@AArnott any thoughts on @kennykerr's recommendation? Are you handling the TD_WARNING_ICON scenario today? |
I can't get CsWin32 to generate Nevertheless, sounds like a good idea to me. Will need some light docs on how to interpret the list items (e.g. 0,0xA vs 0,10, spaces, alternate ways to represent the list separator |
Really? What version are you using, @riverar? It came right up for me and generated this: internal static readonly unsafe winmdroot.Foundation.PCWSTR TD_WARNING_ICON = (char*)(-1); This is a simple case because this constant is typed as a typedef struct, so casting is generally sufficient to get it to work.
|
I'm not suggesting copying bits to initialize structs. I don't know of a language where that would work reliably, taking into account alignment and padding. I'm suggesting that when the literal value is a string and the constant type is a struct that the string represent a list of primitive values used to initialize the struct. So if the struct has field The trouble with the |
Do all the constant structs have only primitive fields? Or do we have to account for structs within structs? |
We should probably support something like |
That should work. |
Given that we have to define this in C#, what would be the right way to define a constant whose type is a struct but whose value is a string? The obvious options don't compile. |
You can't do it in C# like that. You could use an attribute that takes a string parameter though. |
Could you clarify then what the spec should be for SECURITY_NT_AUTHORITY? |
I'm hoping @kennykerr can offer an example, as I'm not familiar with this struct/constant. |
An example of what? |
Would an attribute not work? [Constant("1, {2, 3}, 4")]
public static SOME_STRUCT SOME_CONSTANT; |
SECURITY_NT_AUTHORITY example: [Constant("{ 0, 0, 0, 0, 0, 5 }")]
public static ... SID_IDENTIFIER_AUTHORITY SECURITY_NT_AUTHORITY; PKEY_Address_Country example: [Constant("{ { 0xC07B4199, 0xE1DF, 0x4493, 0xB1, 0xE1, 0xDE, 0x59, 0x46, 0xFB, 0x58, 0xF8 }, 100 }")]
public static ... PROPERTYKEY PKEY_Address_Country; |
Sounds good. Thanks. |
The build is still not recognizing this for some reason. I don't get any diffs even after a clean build. I left off at https://github.com/microsoft/win32metadata/tree/mikebattista/structinitializers if someone wants to take a look. |
@mikebattista Fixed. 055ba0e |
Thanks! |
As an example,
SECURITY_NT_AUTHORITY
. Referred to in Well-known SIDs list.The text was updated successfully, but these errors were encountered: