[Win32utils-devel] GetTokenInformation failure on XP VM

Daniel Berger djberg96 at gmail.com
Fri Aug 21 18:04:03 EDT 2009


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


More information about the win32utils-devel mailing list