msi: Allocate token information buffer dynamically.
This commit is contained in:
parent
f0d1d61d3b
commit
4365b34838
|
@ -516,15 +516,19 @@ static void create_test_guid(LPSTR prodcode, LPSTR squashed)
|
||||||
static void get_user_sid(LPSTR *usersid)
|
static void get_user_sid(LPSTR *usersid)
|
||||||
{
|
{
|
||||||
HANDLE token;
|
HANDLE token;
|
||||||
BYTE buf[1024];
|
|
||||||
DWORD size;
|
DWORD size;
|
||||||
PTOKEN_USER user;
|
PTOKEN_USER user;
|
||||||
|
|
||||||
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
|
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
|
||||||
size = sizeof(buf);
|
|
||||||
GetTokenInformation(token, TokenUser, buf, size, &size);
|
size = 0;
|
||||||
user = (PTOKEN_USER)buf;
|
GetTokenInformation(token, TokenUser, NULL, size, &size);
|
||||||
|
user = HeapAlloc(GetProcessHeap(), 0, size);
|
||||||
|
|
||||||
|
GetTokenInformation(token, TokenUser, user, size, &size);
|
||||||
pConvertSidToStringSidA(user->User.Sid, usersid);
|
pConvertSidToStringSidA(user->User.Sid, usersid);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, user);
|
||||||
CloseHandle(token);
|
CloseHandle(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue