The TOKEN_USER
structure contains a pointer to a Sid
structure. How long does this SID live (alternatively, where is the SID stored in memory)? Is the SID stored in the TOKEN_USER
structure (so it lives until this structure is dropped)?
Context
To obtain the current user SID, I open the process token using OpenProcessToken()
.
Then I write the user TOKEN_USER
to an allocated buffer using GetTokenInformation()
with TokenUser
as the token information class.
A pointer to the SID is in the User.Sid
field, but the documentation doesn't say where the SID is stored.
Will the SID pointer remain valid when the process token is closed? Or when the TokenUser
structure is deallocated?