msi: Allocate token information buffer dynamically.

This commit is contained in:
Hans Leidekker 2009-03-27 13:41:35 +01:00 committed by Alexandre Julliard
parent f0d1d61d3b
commit 4365b34838
1 changed files with 8 additions and 4 deletions

View File

@ -516,15 +516,19 @@ static void create_test_guid(LPSTR prodcode, LPSTR squashed)
static void get_user_sid(LPSTR *usersid)
{
HANDLE token;
BYTE buf[1024];
DWORD size;
PTOKEN_USER user;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
size = sizeof(buf);
GetTokenInformation(token, TokenUser, buf, size, &size);
user = (PTOKEN_USER)buf;
size = 0;
GetTokenInformation(token, TokenUser, NULL, size, &size);
user = HeapAlloc(GetProcessHeap(), 0, size);
GetTokenInformation(token, TokenUser, user, size, &size);
pConvertSidToStringSidA(user->User.Sid, usersid);
HeapFree(GetProcessHeap(), 0, user);
CloseHandle(token);
}