Closed GoogleCodeExporter closed 9 years ago
Hey Ero,
Thanks for the patch,
I will add it to source this weekend,
unfortunately I can't check it out myself...
Original comment by distorm@gmail.com
on 10 Oct 2010 at 9:52
Hey, I fixed a few other things and also my previous "fixes" weren't thoroughly
tested and I had broken some things.
Use this new patch instead of the old one (I'll try to delete the old one). The
new one includes all changes.
Original comment by ero.carr...@gmail.com
on 12 Oct 2010 at 3:34
Attachments:
Ero,
I didn't understand the rationale of changing the 'code' pointer related lines.
Original comment by distorm@gmail.com
on 16 Oct 2010 at 10:38
"addressof()" does not return a valid address in OSX 64bit. "pointer()" does.
The problem is that "pointer" returns and instance that does not seem to allow
for simple addition to the pointer value to move it forward in the data buffer
being decoded.
Hence I create copies of the sliced buffer and get a pointer() for each,
effectively achieving the same behavior.
I would agree that would cleaner to operate in pointers as the original code
intended to, but that does not work on OSX 64bit. I didn't test if it was a
problem generic to all 64bit platforms or only on Mac. My main interest was to
get it working, if you feel the problem is rather something with ctypes
implementation then maybe we can let those guys know. I didn't have time to
look into the issue in more depth.
Original comment by ero.carr...@gmail.com
on 17 Oct 2010 at 11:59
The question if it really creates a buffer every time, cause otherwise it's not
so good performance-wise.
I will check it out, thanks.
Original comment by distorm@gmail.com
on 18 Oct 2010 at 8:24
Ok, I made it byref, instead of pointer. Seems to be better according to ctypes
docs.
And the create_code_buffer to be a problem.
Waiting for your test-confirmation on Mac.
Original comment by distorm@gmail.com
on 20 Oct 2010 at 2:12
Hey,
The changes look good & work on OSX. I would only propose to tweak it a bit
more so that the "create_string_buffer" is called only once and then we work
with the byref() on that object. I didn't know that byref() can take the offset
as a second optional argument, that's really convenient. Although according to
the documentation that was just introduced in Python 2.6 will prevent distorm
from working with Python versions older than 2.5.
I'm just pasting the relevant part of the diff next as it's just a few minor
changes.
diff -x .svn -urN distorm-read-only/Python/__init__.py
distorm-read-only-osxfix/Python/__init__.py
--- distorm-read-only/Python/__init__.py 2010-10-20 04:13:38.000000000
+0200
+++ distorm-read-only-osxfix/Python/__init__.py 2010-10-26 17:23:24.000000000
+0200
@@ -374,7 +374,8 @@
raise ValueError("Invalid decode type value: %r" % (dt,))
codeLen = len(code)
- p_code = byref(create_string_buffer(code))
+ code_buf = create_string_buffer(code)
+ p_code = byref(code_buf)
result = (_DecodedInst * MAX_INSTRUCTIONS)()
p_result = byref(result)
instruction_off = 0
@@ -405,7 +406,7 @@
if delta <= 0:
break
codeOffset = codeOffset + delta
- p_code = byref(create_string_buffer(code), instruction_off)
+ p_code = byref(code_buf, instruction_off)
codeLen = codeLen - delta
def Decode(offset, code, type = Decode32Bits):
@@ -712,7 +713,8 @@
raise ValueError("Invalid decode type value: %r" % (dt,))
codeLen = len(code)
- p_code = byref(create_string_buffer(code))
+ code_buf = create_string_buffer(code)
+ p_code = byref(code_buf)
result = (_DInst * MAX_INSTRUCTIONS)()
instruction_off = 0
@@ -738,7 +740,7 @@
if delta <= 0:
break
codeOffset = codeOffset + delta
- p_code = byref(create_string_buffer(code), instruction_off)
+ p_code = byref(code_buf, instruction_off)
codeLen = codeLen - delta
def Decompose(offset, code, type = Decode32Bits):
Original comment by ero.carr...@gmail.com
on 26 Oct 2010 at 4:48
That's nice indeed! Thanks a lot.
Original comment by distorm@gmail.com
on 31 Oct 2010 at 8:10
Original issue reported on code.google.com by
ero.carr...@gmail.com
on 10 Oct 2010 at 11:50Attachments: