djhenderson / pefile

Automatically exported from code.google.com/p/pefile
Other
0 stars 0 forks source link

Error when disassembling a file #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Disassemble a .net file with ephash with the following code:

import sys
import pefile
import pydasm

file = sys.argv[1]

pe =  pefile.PE(file)

print "EP: " + str(pe.OPTIONAL_HEADER.AddressOfEntryPoint)

ep = pe.OPTIONAL_HEADER.AddressOfEntryPoint
ep_ava = ep+pe.OPTIONAL_HEADER.ImageBase
data = pe.get_memory_mapped_image()[ep:ep+100]
while offset < len(data):
  i = pydasm.get_instruction(data[offset:], pydasm.MODE_32)
  print i.length
  print pydasm.get_instruction_string(i, pydasm.FORMAT_INTEL, ep_ava+offset)
  offset += i.length

What is the expected output? What do you see instead?
I wanted to see the disassembly.

I get this error:
Traceback (most recent call last):
  File "statictest.py", line 17, in <module>
    while offset < len(data):
NameError: name 'offset' is not defined

* The file attach is the file on which i tested.
I could get it to disassemble only the first line.

Help would be appreciated.

Original issue reported on code.google.com by mar...@centauri.co.il on 10 Nov 2014 at 8:04

Attachments:

GoogleCodeExporter commented 9 years ago
From you code snippet and the error message it appears that "offset" is not 
defined.

Original comment by ero.carr...@gmail.com on 10 Nov 2014 at 8:25

GoogleCodeExporter commented 9 years ago
My bad, it was a different python code.
This is the error:

Traceback (most recent call last):
  File "statictest.py", line 18, in <module>
    while offset < len(data):
OverflowError: long int too large to convert to int

Original comment by mar...@centauri.co.il on 10 Nov 2014 at 9:32