class TurboRex::Windows::COM::COMRegistry::AppIDEntry

Attributes

access_permission[RW]
appid_guid[RW]
executable_name[RW]
launch_permission[RW]
local_service[RW]

Public Class Methods

from_registry(reg_key) click to toggle source
# File lib/turborex/windows/com/com_registry.rb, line 66
def self.from_registry(reg_key)
  appid_entry = AppIDEntry.new
  if reg_key.keyname  =~ /^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/i
    appid_entry.appid_guid = reg_key.keyname
    if (raw = reg_key.read('LaunchPermission').last rescue nil)
      sd = TurboRex::Windows::Win32API.alloc_c_ary('BYTE', raw.bytesize)
      sd.str = raw
      lpbDaclPresent = TurboRex::Windows::Win32API.alloc_c_ptr('BOOL')
      pdacl = TurboRex::Windows::Win32API.alloc_c_ptr('PVOID')
      lpbDaclDefaulted = TurboRex::Windows::Win32API.alloc_c_ptr('BOOL')

      TurboRex::Windows::Win32API.getsecuritydescriptordacl(sd, lpbDaclPresent, pdacl, lpbDaclDefaulted)
      appid_entry.launch_permission = TurboRex::Windows::Security::SecurityDescriptor.from_raw(raw)
    end

    if (raw = reg_key.read('AccessPermission').last rescue nil)
      sd = TurboRex::Windows::Win32API.alloc_c_ary('BYTE', raw.bytesize)
      sd.str = raw
      lpbDaclPresent = TurboRex::Windows::Win32API.alloc_c_ptr('BOOL')
      pdacl = TurboRex::Windows::Win32API.alloc_c_ptr('PVOID')
      lpbDaclDefaulted = TurboRex::Windows::Win32API.alloc_c_ptr('BOOL')

      TurboRex::Windows::Win32API.getsecuritydescriptordacl(sd, lpbDaclPresent, pdacl, lpbDaclDefaulted)
      appid_entry.access_permission = TurboRex::Windows::Security::SecurityDescriptor.from_raw(raw)
    end
  else
    appid_entry.executable_name = reg_key.keyname
  end

end