Add support for section dumping
git-svn-id: file:///home/svn/framework3/trunk@6686 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
e3a2433146
commit
977447f56a
|
@ -627,7 +627,10 @@ class PeBase
|
|||
[ 'uint32v', 'VirtualAddress', 0 ],
|
||||
[ 'uint32v', 'SizeOfRawData', 0 ],
|
||||
[ 'uint32v', 'PointerToRawData', 0 ],
|
||||
[ 'uint32v', 'PointerToRelocations', 0 ]
|
||||
[ 'uint32v', 'PointerToRelocations', 0 ],
|
||||
[ 'uint32v', 'NumberOfRelocations', 0 ],
|
||||
[ 'uint32v', 'NumberOfLineNumbers', 0 ],
|
||||
[ 'uint32v', 'Characteristics', 0 ]
|
||||
)
|
||||
|
||||
class SectionHeader < GenericHeader
|
||||
|
@ -1516,4 +1519,4 @@ class PeBase
|
|||
rname.to_s
|
||||
end
|
||||
|
||||
end end end
|
||||
end end end
|
||||
|
|
|
@ -42,6 +42,24 @@ class Section
|
|||
_section_header.v['Name'].gsub(/\x00+$/, '')
|
||||
end
|
||||
|
||||
def flags
|
||||
# a section header is not required
|
||||
return nil if !_section_header
|
||||
_section_header.v['Characteristics']
|
||||
end
|
||||
|
||||
def vma
|
||||
# a section header is not required
|
||||
return nil if !_section_header
|
||||
_section_header.v['VirtualAddress']
|
||||
end
|
||||
|
||||
def raw_size
|
||||
# a section header is not required
|
||||
return nil if !_section_header
|
||||
_section_header.v['SizeOfRawData']
|
||||
end
|
||||
|
||||
def _check_offset(offset, len = 1)
|
||||
if offset < 0 || offset+len > size
|
||||
raise BoundsError, "Offset #{offset} outside of section", caller
|
||||
|
@ -115,4 +133,4 @@ class Section
|
|||
|
||||
end
|
||||
|
||||
end end
|
||||
end end
|
||||
|
|
|
@ -194,7 +194,15 @@ module Analyze
|
|||
end
|
||||
$stdout.puts tbl.to_s
|
||||
$stdout.puts "\n\n"
|
||||
end
|
||||
end
|
||||
|
||||
tbl = table("Section Header", ["Name", "VirtualAddress", "SizeOfRawData", "Characteristics"])
|
||||
pe.sections.each do |sec|
|
||||
tbl << [ sec.name, *[sec.vma, sec.raw_size, sec.flags].map{|x| "0x%.8x" % x} ]
|
||||
end
|
||||
$stdout.puts tbl.to_s
|
||||
$stdout.puts "\n\n"
|
||||
|
||||
end
|
||||
|
||||
def table(name, cols)
|
||||
|
|
Loading…
Reference in New Issue