Daniel Berger
2009-Aug-21 22:04 UTC
[Win32utils-devel] GetTokenInformation failure on XP VM
Hi,
Any idea why this would fail on XP Pro, SP 3? It works fine on Vista
home premium.
I''m getting "The parameter is incorrect."
# test.rb
require ''windows/security''
require ''windows/process''
require ''windows/error''
include Windows::Error
include Windows::Process
include Windows::Security
token = 0.chr * 4
unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token)
raise get_last_error
end
token = token.unpack(''V'')[0]
te = 0.chr * 4 # TOKEN_ELEVATION
rl = 0.chr * 4 # Return length
bool = GetTokenInformation(
token,
TokenElevation,
te,
te.size,
rl
)
unless bool
raise get_last_error # => The parameter is incorrect.
end
p te.unpack(''L'').first
Regards,
Dan
Daniel Berger
2009-Aug-22 01:00 UTC
[Win32utils-devel] GetTokenInformation failure on XP VM
Heesob Park wrote:> Hi, > > 2009/8/22 Daniel Berger <djberg96 at gmail.com>: >> Hi, >> >> Any idea why this would fail on XP Pro, SP 3? It works fine on Vista >> home premium. >> >> I''m getting "The parameter is incorrect." >> >> # test.rb >> require ''windows/security'' >> require ''windows/process'' >> require ''windows/error'' >> include Windows::Error >> include Windows::Process >> include Windows::Security >> >> token = 0.chr * 4 >> >> unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token) >> raise get_last_error >> end >> >> token = token.unpack(''V'')[0] >> >> te = 0.chr * 4 # TOKEN_ELEVATION >> rl = 0.chr * 4 # Return length >> >> bool = GetTokenInformation( >> token, >> TokenElevation, >> te, >> te.size, >> rl >> ) >> >> unless bool >> raise get_last_error # => The parameter is incorrect. >> end >> >> p te.unpack(''L'').first >> > TOKEN_ELEVATION structure is not supported on Windows XP/2000. > > Refer to http://msdn.microsoft.com/en-us/library/bb530717(VS.85).aspxOh, that''s right. I forgot that method was implemented for Vista. It''s a bug in the test win32-security test suite then. I need to omit the test for that method unless it''s Vista or later. Regards, Dan
Hi, 2009/8/22 Daniel Berger <djberg96 at gmail.com>:> Hi, > > Any idea why this would fail on XP Pro, SP 3? It works fine on Vista > home premium. > > I''m getting "The parameter is incorrect." > > # test.rb > require ''windows/security'' > require ''windows/process'' > require ''windows/error'' > include Windows::Error > include Windows::Process > include Windows::Security > > token = 0.chr * 4 > > unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token) > ? raise get_last_error > end > > token = token.unpack(''V'')[0] > > te = 0.chr * 4 # TOKEN_ELEVATION > rl = 0.chr * 4 # Return length > > bool = GetTokenInformation( > ? token, > ? TokenElevation, > ? te, > ? te.size, > ? rl > ) > > unless bool > ? raise get_last_error ?# => The parameter is incorrect. > end > > p te.unpack(''L'').first >TOKEN_ELEVATION structure is not supported on Windows XP/2000. Refer to http://msdn.microsoft.com/en-us/library/bb530717(VS.85).aspx Regards, Park Heesob