Class: Idevice::ImageMounterClient

Inherits:
C::ManagedOpaquePointer show all
Includes:
LibHelpers
Defined in:
lib/idevice/image_mounter.rb

Overview

Used to mount developer/debug disk images on the device.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LibHelpers

included

Methods inherited from C::ManagedOpaquePointer

#initialize

Constructor Details

This class inherits a constructor from Idevice::C::ManagedOpaquePointer

Class Method Details

.attach(opts = {}) ⇒ Object


43
44
45
46
47
48
49
50
51
52
# File 'lib/idevice/image_mounter.rb', line 43

def self.attach(opts={})
  _attach_helper("com.apple.mobile.mobile_image_mounter", opts) do |idevice, ldsvc, p_mim|
    err = C.mobile_image_mounter_new(idevice, ldsvc, p_mim)
    raise ImageMounterError, "ImageMounter error: #{err}" if err != :SUCCESS

    mim = p_mim.read_pointer
    raise ImageMounterError, "mobile_image_mounter_new returned a NULL client" if mim.null?
    return new(mim)
  end
end

.release(ptr) ⇒ Object


35
36
37
38
39
40
41
# File 'lib/idevice/image_mounter.rb', line 35

def self.release(ptr)
  C::Freelock.synchronize do
    unless ptr.null?
      C.mobile_image_mounter_free(ptr)
    end
  end
end

Instance Method Details

#hangupObject

Raises:


86
87
88
89
90
91
# File 'lib/idevice/image_mounter.rb', line 86

def hangup
  err = C.mobile_image_mounter_hangup(self)
  raise ImageMounterError, "ImageMounter error: #{err}" if err != :SUCCESS

  return true
end

#is_mounted?(image_type = "Developer") ⇒ Boolean

Returns:

  • (Boolean)

54
55
56
57
# File 'lib/idevice/image_mounter.rb', line 54

def is_mounted?(image_type="Developer")
  ret = lookup_image(image_type)
  return (ret["ImagePresent"] == true)
end

#lookup_image(image_type = "Developer") ⇒ Object


59
60
61
62
63
64
65
66
67
68
69
# File 'lib/idevice/image_mounter.rb', line 59

def lookup_image(image_type="Developer")
  FFI::MemoryPointer.new(:pointer) do |p_result|
    err = C.mobile_image_mounter_lookup_image(self, image_type, p_result)
    raise ImageMounterError, "ImageMounter error: #{err}" if err != :SUCCESS

    result = p_result.read_pointer.read_plist_t
    raise ImageMounterError, "mobile_image_mounter_lookup_image returned a NULL result" if result.nil?

    return result
  end
end

#mount_image(path, signature, image_type = "Developer") ⇒ Object


71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/idevice/image_mounter.rb', line 71

def mount_image(path, signature, image_type="Developer")
  signature = signature.dup.force_encoding('binary')
  FFI::MemoryPointer.from_bytes(signature) do |p_signature|
    FFI::MemoryPointer.new(:pointer) do |p_result|
      err = C.mobile_image_mounter_mount_image(self, path, p_signature, p_signature.size, image_type, p_result)
      raise ImageMounterError, "ImageMounter error: #{err}" if err != :SUCCESS

      result = p_result.read_pointer.read_plist_t
      raise ImageMounterError, "mobile_image_mounter_mount_image returned a NULL result" if result.nil?

      return result
    end
  end
end