Created
February 20, 2014 04:01
-
-
Save jstanley0/9106896 to your computer and use it in GitHub Desktop.
Convert microcorruption memory dump to binary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buffer = "".force_encoding("BINARY") | |
ARGF.each_line do |line| | |
addr, data = line.split(':', 2) | |
next unless data | |
addr = addr.to_i(16) | |
data = data[/(?:\h\h\h\h )+/] | |
next unless data | |
data = [data.gsub(' ', '')].pack("H*") | |
buffer << ("\0" * (addr - buffer.size)) | |
buffer << data | |
end | |
STDOUT.write buffer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment