as of the [0/1] problem, it should be fixed in the upcoming version of pb:
http://purebasic.fr/english/viewtopic.php?f=4&t=66442
however, this does not solve your problem of simply using this structure the wrong way.
here is what you have to do:
- call the appropriate function to find out the required size.
- create a structured buffer of given size.
- call the appropriate function again to fill the buffer.
- browse through the buffer to get the information you need.
this code uses TOKEN_GROUPS instead of TOKEN_PRIVILEGES, but the concept of use is the same:
Code: Select all
EnableExplicit
Define hToken, dwSize, *GroupInfo.TOKEN_GROUPS, SIDAuth.SID_IDENTIFIER_AUTHORITY\Value[5] = 5, *SID, i, Result$
If OpenProcessToken_(GetCurrentProcess_(), #TOKEN_QUERY, @hToken) And hToken
SetLastError_(0)
If GetTokenInformation_(hToken, #TokenGroups, 0, 0, @dwSize) = #False And GetLastError_() = #ERROR_INSUFFICIENT_BUFFER And dwSize
*GroupInfo = AllocateMemory(dwSize)
If *GroupInfo
If GetTokenInformation_(hToken, #TokenGroups, *GroupInfo, dwSize, @dwSize)
If AllocateAndInitializeSid_(@SIDAuth, 2, #SECURITY_BUILTIN_DOMAIN_RID, #DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, @*SID)
For i = 0 To *GroupInfo\GroupCount - 1
If EqualSid_(*GroupInfo\Groups[i]\Sid, *SID)
Result$ = "OK"
Break
EndIf
Next
FreeSid_(*SID)
EndIf
EndIf
FreeMemory(*GroupInfo)
EndIf
EndIf
CloseHandle_(hToken)
EndIf
Debug Result$
and as you can see, it doesnt crash.
c ya,
nco2k