ruby-macho 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14255fd4c8aaab675981bcf982893a8be8b6ba0c
4
- data.tar.gz: e89c2ff64ebe885089b1b3b3ffa3c80418070fdd
3
+ metadata.gz: 090544df5b83590546313bc137f4b55c1e6d270a
4
+ data.tar.gz: 0d0a63b966d573b4dccb87e5ae2e9bd4cf085b40
5
5
  SHA512:
6
- metadata.gz: f8796363fb1de467d352e6ed808865d83a84b8cbca747037c542f788feb316cc6e733d03817d01d4182d5049b90b557365e8c4bd9e24ef2f4eab15cca212c92a
7
- data.tar.gz: efc4df8def9305d15edb6273ea72baf8d8da778151697bae975be45750da6f7eec6c541b9852875b8ce4f469ee05bf8b380816ea0fe79ea5e66e04a1e710565e
6
+ metadata.gz: abc929ddc16551d654a75234565d1bc07ced095b3c0a22b52439bcd44067458d3704a7f7d26843b475285ecff2e7556aa7ef15e85c7f18daec5cc6f653692870
7
+ data.tar.gz: 4ddc78eb70a82da2ba9f1361362089b3066da0ba98aaefc234323cd00b60791eb00783c742ff35c9bd95b843978cdb7cfb6a6e642a1e415015083008588a6363
data/README.md CHANGED
@@ -31,7 +31,7 @@ file.filetype # => :execute
31
31
 
32
32
  # get all load commands in the file and print their offsets:
33
33
  file.load_commands.each do |lc|
34
- puts "#{lc}: offset #{lc.offset}, size: #{lc.cmdsize}"
34
+ puts "#{lc.type}: offset #{lc.offset}, size: #{lc.cmdsize}"
35
35
  end
36
36
 
37
37
  # access a specific load command
@@ -34,9 +34,7 @@ module MachO
34
34
 
35
35
  @filename = filename
36
36
  @raw_data = File.open(@filename, "rb", &:read)
37
- @header = populate_fat_header
38
- @fat_archs = populate_fat_archs
39
- @machos = populate_machos
37
+ populate_fields
40
38
  end
41
39
 
42
40
  # Initializes a new FatFile instance from a binary string.
@@ -45,9 +43,7 @@ module MachO
45
43
  def initialize_from_bin(bin)
46
44
  @filename = nil
47
45
  @raw_data = bin
48
- @header = populate_fat_header
49
- @fat_archs = populate_fat_archs
50
- @machos = populate_machos
46
+ populate_fields
51
47
  end
52
48
 
53
49
  # The file's raw fat data.
@@ -122,6 +118,21 @@ module MachO
122
118
  machos.first.filetype
123
119
  end
124
120
 
121
+ # Populate the instance's fields with the raw Fat Mach-O data.
122
+ # @return [void]
123
+ # @note This method is public, but should (almost) never need to be called.
124
+ def populate_fields
125
+ @header = populate_fat_header
126
+ @fat_archs = populate_fat_archs
127
+ @machos = populate_machos
128
+ end
129
+
130
+ # All load commands responsible for loading dylibs in the file's Mach-O's.
131
+ # @return [Array<MachO::DylibCommand>] an array of DylibCommands
132
+ def dylib_load_commands
133
+ machos.map(&:dylib_load_commands).flatten
134
+ end
135
+
125
136
  # The file's dylib ID. If the file is not a dylib, returns `nil`.
126
137
  # @example
127
138
  # file.dylib_id # => 'libBar.dylib'
@@ -149,7 +160,7 @@ module MachO
149
160
  macho.change_dylib_id(new_id, options)
150
161
  end
151
162
 
152
- synchronize_raw_data
163
+ repopulate_raw_machos
153
164
  end
154
165
 
155
166
  alias dylib_id= change_dylib_id
@@ -180,7 +191,7 @@ module MachO
180
191
  macho.change_install_name(old_name, new_name, options)
181
192
  end
182
193
 
183
- synchronize_raw_data
194
+ repopulate_raw_machos
184
195
  end
185
196
 
186
197
  alias change_dylib change_install_name
@@ -206,7 +217,7 @@ module MachO
206
217
  macho.change_rpath(old_path, new_path, options)
207
218
  end
208
219
 
209
- synchronize_raw_data
220
+ repopulate_raw_machos
210
221
  end
211
222
 
212
223
  # Add the given runtime path to the file's Mach-Os.
@@ -221,7 +232,7 @@ module MachO
221
232
  macho.add_rpath(path, options)
222
233
  end
223
234
 
224
- synchronize_raw_data
235
+ repopulate_raw_machos
225
236
  end
226
237
 
227
238
  # Delete the given runtime path from the file's Mach-Os.
@@ -236,7 +247,7 @@ module MachO
236
247
  macho.delete_rpath(path, options)
237
248
  end
238
249
 
239
- synchronize_raw_data
250
+ repopulate_raw_machos
240
251
  end
241
252
 
242
253
  # Extract a Mach-O with the given CPU type from the file.
@@ -324,6 +335,17 @@ module MachO
324
335
  machos
325
336
  end
326
337
 
338
+ # Repopulate the raw Mach-O data with each internal Mach-O object.
339
+ # @return [void]
340
+ # @api private
341
+ def repopulate_raw_machos
342
+ machos.each_with_index do |macho, i|
343
+ arch = fat_archs[i]
344
+
345
+ @raw_data[arch.offset, arch.size] = macho.serialize
346
+ end
347
+ end
348
+
327
349
  # Yield each Mach-O object in the file, rescuing and accumulating errors.
328
350
  # @param options [Hash]
329
351
  # @option options [Boolean] :strict (true) whether or not to fail loudly
@@ -351,16 +373,5 @@ module MachO
351
373
  # Non-strict mode: Raise first error if *all* Mach-O slices failed.
352
374
  raise errors.first if errors.size == machos.size
353
375
  end
354
-
355
- # Synchronize the raw file data with each internal Mach-O object.
356
- # @return [void]
357
- # @api private
358
- def synchronize_raw_data
359
- machos.each_with_index do |macho, i|
360
- arch = fat_archs[i]
361
-
362
- @raw_data[arch.offset, arch.size] = macho.serialize
363
- end
364
- end
365
376
  end
366
377
  end
@@ -612,31 +612,7 @@ module MachO
612
612
  # A load command containing the address of the dynamic shared library
613
613
  # initialization routine and an index into the module table for the module
614
614
  # that defines the routine. Corresponds to LC_ROUTINES_64.
615
- class RoutinesCommand64 < LoadCommand
616
- # @return [Fixnum] the address of the initialization routine
617
- attr_reader :init_address
618
-
619
- # @return [Fixnum] the index into the module table that the init routine is defined in
620
- attr_reader :init_module
621
-
622
- # @return [void]
623
- attr_reader :reserved1
624
-
625
- # @return [void]
626
- attr_reader :reserved2
627
-
628
- # @return [void]
629
- attr_reader :reserved3
630
-
631
- # @return [void]
632
- attr_reader :reserved4
633
-
634
- # @return [void]
635
- attr_reader :reserved5
636
-
637
- # @return [void]
638
- attr_reader :reserved6
639
-
615
+ class RoutinesCommand64 < RoutinesCommand
640
616
  # @see MachOStructure::FORMAT
641
617
  # @api private
642
618
  FORMAT = "L=2Q=8".freeze
@@ -644,20 +620,6 @@ module MachO
644
620
  # @see MachOStructure::SIZEOF
645
621
  # @api private
646
622
  SIZEOF = 72
647
-
648
- # @api private
649
- def initialize(view, cmd, cmdsize, init_address, init_module, reserved1,
650
- reserved2, reserved3, reserved4, reserved5, reserved6)
651
- super(view, cmd, cmdsize)
652
- @init_address = init_address
653
- @init_module = init_module
654
- @reserved1 = reserved1
655
- @reserved2 = reserved2
656
- @reserved3 = reserved3
657
- @reserved4 = reserved4
658
- @reserved5 = reserved5
659
- @reserved6 = reserved6
660
- end
661
623
  end
662
624
 
663
625
  # A load command signifying membership of a subframework containing the name
data/lib/macho.rb CHANGED
@@ -13,5 +13,5 @@ require "#{File.dirname(__FILE__)}/macho/tools"
13
13
  # The primary namespace for ruby-macho.
14
14
  module MachO
15
15
  # release version
16
- VERSION = "0.2.5".freeze
16
+ VERSION = "0.2.6".freeze
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-macho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Woodruff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-07 00:00:00.000000000 Z
11
+ date: 2016-11-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for viewing and manipulating Mach-O files in Ruby.
14
14
  email: william@tuffbizz.com
@@ -51,9 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  requirements: []
53
53
  rubyforge_project:
54
- rubygems_version: 2.4.5.1
54
+ rubygems_version: 2.5.1
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: ruby-macho - Mach-O file analyzer.
58
58
  test_files: []
59
- has_rdoc: