Comments (8)
Could you please provide a test code which reproduces the issue?
Thanks,
Angelo
from pylibemu.
emu = pylibemu.Emulator()
emu.prepare('\x90\x90\xc3\x90\x90\x90', 0)
emu.test(2)
eip = emu.cpu_eip_get()
print "eip:", eip, hex(eip)
print emu.memory_read_byte(eip)
----------output-----------
eip: 4288514 0x417002L
Segmentation fault (core dumped)
platform:
ubuntu 12.04 64bit
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Cython version 0.15.1
from pylibemu.
I'm not able to reproduce it here...
buffer@alnitak ~ $ python
Python 2.7.3 (default, May 15 2012, 11:39:38)
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import pylibemu
emu = pylibemu.Emulator()
emu.prepare('\x90\x90\xc3\x90\x90\x90', 0)
emu.test(2)
0
eip = emu.cpu_eip_get()
print "eip:", eip, hex(eip)
eip: 4288514 0x417002L
print emu.memory_read_byte(eip)
195
Cython is really not needed by your side because setup.py compiles the generated C file so the only difference between our environments is gcc (here 4.5.3).
Could you please try creating a .py file and run it in gdb? You should just do something like
$ gdb python
run test.py
After the segfault please something like backtrace' and
info frame N' would be really useful to understand what's going on by your side.
from pylibemu.
(gdb) run rkaji.py
Starting program: /usr/bin/python rkaji.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
eip: 4288513 0x417001L
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff55662e5 in emu_memory_read_byte (m=0xc2c780, addr=4288513, byte=0x0) at emu_memory.c:272
272 *byte = *((uint8_t *)address);
from pylibemu.
I think the problem is uninitialize pointer in memory_read_byte in pylibemu.pyc.
You declare byte:
cdef uint8_t *byte # line 993
then without initialize it, you send it as parameter in
if emu_memory_read_byte(_mem, addr, byte) # line 999
I change the function as below and it works.
#--------------code-begin---------------------------
def memory_read_byte(self, uint32_t addr):
cdef c_emu_memory *_mem
cdef uint8_t byte # I change this line
if self._emu is NULL:
raise RuntimeError('Emulator not initialized')
_mem = emu_memory_get(self._emu)
if emu_memory_read_byte(_mem, addr, &byte): # I change this line
raise RuntimeError("Error while reading a byte at address 0x%x" % (addr, ))
return byte# I change this line
#-------------code-end---------------------------
from pylibemu.
Committed a patch for your issue. I still had not the possibility to test memory_read_string method but the other memory_read methods should work for you too now. Please run tests/cpu_mem_test.py and tell if everything is ok.
from pylibemu.
Added a test for memory_read_string method too.
from pylibemu.
Great, its working now. Thank you.
from pylibemu.
Related Issues (16)
- error: command 'gcc' failed with exit status 1 HOT 2
- test function is quit expensive HOT 3
- method implementation request
- Compilation errors HOT 3
- cannot open shared object file HOT 1
- Error on import: pylibemu.so: undefined symbol: emu_cpu_debugflag_unset HOT 1
- Memory leaks in emulator memory
- pylibemu and pyqt4 HOT 1
- GPLv2 or GPLv2+?
- problems with setup.py HOT 4
- Error trying to install, same error using pip and manual install HOT 5
- Error with install: autoreconf fails to run aclocal HOT 12
- Tell wether eip is hooked winapi HOT 5
- Disassemble eip HOT 6
- Issue on env_w32_hook_check HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylibemu.