2009-03-29 07:30:54 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# This file is part of Metasm, the Ruby assembly manipulation suite
|
2010-09-09 18:19:35 +00:00
|
|
|
# Copyright (C) 2006-2009 Yoann GUILLOT
|
2009-03-29 07:30:54 +00:00
|
|
|
#
|
|
|
|
# Licence is LGPL, see LICENCE in the top-level directory
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# compiles a PE file with the specified resource directory
|
|
|
|
# TODO build an icon or something
|
|
|
|
#
|
|
|
|
|
|
|
|
require 'metasm'
|
|
|
|
|
|
|
|
pe = Metasm::PE.assemble Metasm::Ia32.new, <<EOS
|
|
|
|
.entrypoint
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
EOS
|
|
|
|
|
|
|
|
rsrc = { 1 => { 1 => { 2 => 'xxx' }, 'toto' => { 12 => 'tata' } } }
|
|
|
|
pe.resource = Metasm::COFF::ResourceDirectory.from_hash rsrc
|
|
|
|
|
|
|
|
pe.encode_file('pe-testrsrc.exe')
|