Looking at MSDN documentaion for GetTokenInformation() and the Getting the Logon SID example, GetTokenInformation() needs to be called twice. The first call is to get the buffer size.
So, buffer size of what? Just say I use TokenUser as its second parameter, I see that the dwReturnLength returned by first call is not the size of TOKEN_USER structure.
Thanks in advance
The
TOKEN_USERstructure contains pointers (in particular, a pointer to aSIDthat itself has variable length). Those pointers have to point somewhere. The API function will expect a buffer big enough to hold not only the theTOKEN_USERstructure, but also all the things that structure points to. The function tells you how much memory it needs for everything. It will all reside in adjacent memory.