lib/rex/assembly/nasm.rb in librex-0.0.63 vs lib/rex/assembly/nasm.rb in librex-0.0.65
- old
+ new
@@ -35,22 +35,22 @@
end
#
# Assembles the supplied assembly and returns the raw opcodes.
#
- def self.assemble(assembly)
+ def self.assemble(assembly, bits=32)
check
# Open the temporary file
tmp = Tempfile.new('nasmXXXX')
tmp.binmode
tpath = tmp.path
opath = tmp.path + '.out'
# Write the assembly data to a file
- tmp.write("BITS 32\n" + assembly)
+ tmp.write("BITS #{bits}\n" + assembly)
tmp.flush()
tmp.seek(0)
# Run nasm
if (system(@@nasm_path, '-f', 'bin', '-o', opath, tpath) == false)
@@ -68,11 +68,11 @@
end
#
# Disassembles the supplied raw opcodes
#
- def self.disassemble(raw)
+ def self.disassemble(raw, bits=32)
check
tmp = Tempfile.new('nasmout')
tmp.binmode
@@ -80,10 +80,10 @@
tfd.write(raw)
tfd.flush()
tfd.close
- p = ::IO.popen("\"#{@@ndisasm_path}\" -u \"#{tmp.path}\"")
+ p = ::IO.popen("\"#{@@ndisasm_path}\" -b #{bits} \"#{tmp.path}\"")
o = ''
begin
until p.eof?
o += p.read