Skip to content

Instantly share code, notes, and snippets.

@lopex
Created December 12, 2017 03:08
Show Gist options
  • Save lopex/7c92b5a817ea6f9e91a3ca5b7783da64 to your computer and use it in GitHub Desktop.
Save lopex/7c92b5a817ea6f9e91a3ca5b7783da64 to your computer and use it in GitHub Desktop.
trans_name = "utf8_mac"
src = open("#{repo_path}/enc/trans/#{trans_name}.c").read
process_binary "#{repo_path}/enc/trans/#{trans_name}.o", section_name do |name, binary, address|
case name
when /_byte_array/
size = src[/(\w+?_byte_array)\[(\d+?)\]/m, 2].to_i
open("test/" + name.capitalize, "wb") do |f|
f << [size].pack("N")
f << binary[address, size]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment