# File metasm/exe_format/mz.rb, line 39 def decode(mz) super(mz) raise InvalidExeFormat, "Invalid MZ signature #{h.magic.inspect}" if @magic != MAGIC end
# File metasm/exe_format/mz.rb, line 19 def encode(mz, relocs) h = EncodedData.new set_default_values mz, h, relocs h << super(mz) end
# File metasm/exe_format/mz.rb, line 25 def set_default_values(mz, h=nil, relocs=nil) return if not h @cblp ||= Expression[[mz.label_at(mz.body, mz.body.virtsize), :-, mz.label_at(h, 0)], :%, 512] # number of bytes used in last page @cp ||= Expression[[mz.label_at(mz.body, mz.body.virtsize), :-, mz.label_at(h, 0)], :/, 512] # number of pages used @crlc ||= relocs.virtsize/4 @cparhdr ||= Expression[[mz.label_at(relocs, 0), :-, mz.label_at(h, 0)], :/, 16] # header size in paragraphs (16o) @minalloc ||= ((mz.body.virtsize - mz.body.rawsize) + 15) / 16 @maxalloc ||= @minalloc @sp ||= 0 # ss:sp points at 1st byte of body => works if body does not reach end of segment (or maybe the overflow make the stack go to header space) @lfarlc ||= Expression[mz.label_at(relocs, 0), :-, mz.label_at(h, 0)] super(mz) end