Permalink
Browse files

Cosmetic changes and comments.

  • Loading branch information...
1 parent b0483c9 commit 9715cc4fd1ace7b5a94827b7df0dd8b368739761 @djberg96 committed Oct 9, 2010
Showing with 40 additions and 39 deletions.
  1. +40 −39 lib/win32/security.rb
View
@@ -9,56 +9,57 @@
# The Win32 module serves as a namespace only.
module Win32
- # The Security class encapsulates security aspects of MS Windows.
- class Security
+ # The Security class encapsulates security aspects of MS Windows.
+ class Security
- # Base error class for all Win32::Security errors.
- class Error < StandardError; end
+ # Base error class for all Win32::Security errors.
+ class Error < StandardError; end
- include Windows::Security
+ include Windows::Security
- extend Windows::Process
- extend Windows::Security
- extend Windows::Handle
- extend Windows::Error
+ extend Windows::Process
+ extend Windows::Security
+ extend Windows::Handle
+ extend Windows::Error
- # The version of the win32-security library
- VERSION = '0.1.3'
+ # The version of the win32-security library
+ VERSION = '0.1.3'
- # Returns whether or not the owner of the current process is running
- # with elevated security privileges.
- #
- # Only supported on Windows Vista or later.
- #
- def self.elevated_security?
- token = 0.chr * 4
+ # Returns whether or not the owner of the current process is running
+ # with elevated security privileges.
+ #
+ # Only supported on Windows Vista or later.
+ #
+ def self.elevated_security?
+ token = 0.chr * 4
- unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token)
- raise Error, get_last_error
- end
+ unless OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, token)
+ raise Error, get_last_error
+ end
- begin
- token = token.unpack('V')[0]
+ begin
+ token = token.unpack('V')[0]
- te = 0.chr * 4 # TOKEN_ELEVATION
- rl = 0.chr * 4 # Return length
+ te = 0.chr * 4 # TOKEN_ELEVATION
+ rl = 0.chr * 4 # Return length
- bool = GetTokenInformation(
- token,
- TokenElevation,
- te,
- te.size,
- rl
- )
+ bool = GetTokenInformation(
+ token,
+ TokenElevation,
+ te,
+ te.size,
+ rl
+ )
- raise Error, get_last_error unless bool
- ensure
- CloseHandle(token)
- end
-
- te.unpack('L')[0] != 0
+ raise Error, get_last_error unless bool
+ ensure
+ CloseHandle(token)
end
- end
+
+ # TokenIsElevated member of the TOKEN_ELEVATION struct
+ te.unpack('L')[0] != 0
+ end
+ end
end
require 'win32/security/sid'

0 comments on commit 9715cc4

Please sign in to comment.