Code Monkey home page Code Monkey logo

Comments (4)

aquynh avatar aquynh commented on July 17, 2024

On Mon, Dec 23, 2013 at 4:49 AM, felixwilhelm [email protected]:

Hi,

the python API fails silently when the Cs object goes out of scope. I am
not sure about the best way to fix this. The del method of Cs calls
cs_close which makes a big chunk of the API unusable.
Adding a reference to Cs in each object is an easy fix, but adds an
(inacceptable) overhead to each instruction object. A better way might be
some kind of internal reference counting to ensure that cs_close is only
called when all instruction are out of scope as well.

Example code:

import capstone

def test_disasm():
md = capstone.Cs(capstone.CS_ARCH_X86, capstone.CS_MODE_32)
# jmp esp
instr = md.disasm("\xff\xe4",0x10,1)[0]
print instr.reg_name(instr.operands[0].value.reg) # "esp"
return instr

instr2 = test_disasm()
print instr2.reg_name(instr2.operands[0].value.reg) # "None"

If this is the desired behavior, it should be documented more clearly.

This is not a designed behavior. We will work on this, and get back to you
soon.

Thanks.

from capstone.

aquynh avatar aquynh commented on July 17, 2024

On Mon, Dec 23, 2013 at 10:20 AM, Nguyen Anh Quynh [email protected] wrote:

On Mon, Dec 23, 2013 at 4:49 AM, felixwilhelm [email protected]:

Hi,

the python API fails silently when the Cs object goes out of scope. I am
not sure about the best way to fix this. The del method of Cs calls
cs_close which makes a big chunk of the API unusable.
Adding a reference to Cs in each object is an easy fix, but adds an
(inacceptable) overhead to each instruction object.

Btw, why adding reference to Cs adds "inacceptable overhead" to CsInsn?

Thanks.

from capstone.

aquynh avatar aquynh commented on July 17, 2024

On Mon, Dec 23, 2013 at 11:18 AM, Nguyen Anh Quynh [email protected] wrote:

On Mon, Dec 23, 2013 at 10:20 AM, Nguyen Anh Quynh [email protected]:

On Mon, Dec 23, 2013 at 4:49 AM, felixwilhelm [email protected]:

Hi,

the python API fails silently when the Cs object goes out of scope. I am
not sure about the best way to fix this. The del method of Cs calls
cs_close which makes a big chunk of the API unusable.
Adding a reference to Cs in each object is an easy fix, but adds an
(inacceptable) overhead to each instruction object.

Btw, why adding reference to Cs adds "inacceptable overhead" to CsInsn?

Felix, i just commited a fix for this issue to "next" branch. could you
confirm it works for you?

thanks.

from capstone.

felixwilhelm avatar felixwilhelm commented on July 17, 2024

Thanks for the quick fix :). Works like a charm.

from capstone.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.