microsoft / microsoft/win32metadata

TRUSTEE_W (and _A) seem to fail to handle the actual union well

Open
#2,103 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

### Summary

Using the latest (as of the time of writing this) windows crate, this is the enum in the crate:

```rust
pub struct TRUSTEE_W {
pub pMultipleTrustee: *mut TRUSTEE_W,
pub MultipleTrusteeOperation: MULTIPLE_TRUSTEE_OPERATION,
pub TrusteeForm: TRUSTEE_FORM,
pub TrusteeType: TRUSTEE_TYPE,
pub ptstrName: windows_core::PWSTR,
}
```

https://learn.microsoft.com/en-us/windows/win32/api/accctrl/ns-accctrl-trustee_w

```cpp
typedef struct _TRUSTEE_W {
struct _TRUSTEE_W *pMultipleTrustee;
MULTIPLE_TRUSTEE_OPERATION MultipleTrusteeOperation;
TRUSTEE_FORM TrusteeForm;
TRUSTEE_TYPE TrusteeType;
union {
LPWSTR ptstrName;
SID *pSid;
OBJECTS_AND_SID *pObjectsAndSid;
OBJECTS_AND_NAME_W *pObjectsAndName;
};
LPWCH ptstrName;
} TRUSTEE_W, *PTRUSTEE_W, TRUSTEEW, *PTRUSTEEW;
```

So, if I have a (P)SID in hand, windows-rs wants a PWSTR. Is this something worth looking into?

### Crate manifest

```TOML

```

### Crate code

```Rust

```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the metadata or generation inputs for TRUSTEE_W and TRUSTEE_A, then compare their generated Rust structs with the documented Win32 definition. Done means determining whether the documented SID, OBJECTS_AND_SID, and OBJECTS_AND_NAME union variants are represented correctly rather than only exposing PWSTR.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
operating-systems, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.