On 3/16/23 10:18, Kevin Connor Arpe wrote:
My questions:
1. Do you agree with Raymond Chen's technique for Wine source code? (Or: Is there a better way to do it for Wine source code?)
I'm not even sure I would bother with that quirkâsimply forwarding to GetTempPath() would be simpler and probably good enough.
2. Should my SYSTEM account test use IsCurrentProcessRunningAsSystem() or IsCurrentThreadRunningAsSystem()? If I read the official docs literally, I think "process" not "thread". Please advise.
Generally speaking, that's the sort of thing you'd have to write tests for.
3. Reading the WIL code: TOKEN_INFORMATION_CLASS TokenUser appears to require this pattern: 1. Call GetTokenInformation() to get required buffer size 2. malloc buffer 3. Call GetTokenInformation() again with buffer 4. Check: WinLocalSystemSid == ((TOKEN_USER *) buffer)->User.Sid 5. free buffer 1. Is there a way to avoid the above steps? malloc+free seems like overkill to decide if the current user is SYSTEM! 2. Do I misunderstand the WIL code? Reading the Wine code for: GetTokenInformation() -> NtQueryInformationToken():
TOKEN_USER appears to be fixed size. Why does WIL think TOKEN_USER is not fixed size? I am confused! :-)
TOKEN_USER contains a pointer. I believe that GetTokenInformation() returns a pointer to data placed immediately after the TOKEN_USER structure. Since a SID is not a fixed-size structure, it's necessary to allocate dynamically.
Kind regards, Kevin Connor ARPE Tokyo, Japan