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

TOKEN_PRIVILEGES #364

Closed
kennykerr opened this issue Mar 16, 2021 · 4 comments
Closed

TOKEN_PRIVILEGES #364

kennykerr opened this issue Mar 16, 2021 · 4 comments
Labels
broken api An API is inaccurate and could lead to runtime failure bug Something isn't working

Comments

@kennykerr
Copy link
Contributor

This struct is defined as follows:

typedef struct _TOKEN_PRIVILEGES {
    DWORD PrivilegeCount;
    LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
} TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;

However the metadata emits it as follows:

public struct TOKEN_PRIVILEGES
{
	public uint PrivilegeCount;
	public TOKEN_PRIVILEGES_PrivilegesFlags Privileges;
}

There are two main issues:

  • How to deal with the trailing variable sized array.
  • The type of the second field is incorrect.
@sotteson1
Copy link
Contributor

@AArnott, the scraper thought the flags should go on the Privileges member of TOKEN_PRIVILEGES, but it should have gone on LUID_AND_ATTRIBUTES.Attributes. If you plan on re-running the docs enum scraper, maybe you need to add a hint or tell it not to scrape this page or something else.

As for the second issue, we've talked about adding an attribute in the metadata to arrays to indicate the arrays are variable length. @kennykerr, would that solution work for you?

@kennykerr
Copy link
Contributor Author

Yes, an attribute sounds good - thanks!

@AArnott
Copy link
Member

AArnott commented Mar 16, 2021

#266 tracks the attribution of variable-length arrays.
Yes, I expect to run the scraper at least once more. I'll copy this bug to track the issue in the scraper, assuming you'll fix the broken API in the meantime.
I took a look at the docs and I think you'd have to be a human or understand the underlying types to understand that the attributes enum does not apply to the field itself, and we had scoped the design of the scraper to not have to read the metadata in order to establish the type of the enum. Can you instead handle reading the json we emit and realizing the field is not a primitive that could legitimately back an enum? In fact, as the field should be a struct, how is it that you're defining the enum now anyways since c# won't let LUID_AND_ATTRIBUTES be the base type of an enum?

sotteson1 pushed a commit that referenced this issue Mar 16, 2021
…tionFlags, make CreateLogFile use more enums.

Fixes #365, addresses an issue in #364
@mikebattista mikebattista added broken api An API is inaccurate and could lead to runtime failure bug Something isn't working labels Mar 18, 2021
@sotteson1
Copy link
Contributor

This has been fixed, but still need to do #266 to add the attribute to variable length arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broken api An API is inaccurate and could lead to runtime failure bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants