[Win32utils-devel] GetTokenInformation failure on XP VM

Heesob Park phasis at gmail.com
Fri Aug 21 21:01:16 EDT 2009


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


More information about the win32utils-devel mailing list