Code Monkey home page Code Monkey logo

Comments (4)

rodionovd avatar rodionovd commented on June 13, 2024

Hi Nuno,

I've just came across the same issue (I'm on 10.9.5). I guess Apple may have changed something in their latest releases for both 10.9 and 10.10.

This x86_64 hack is very old and I really should have fixed it months ago…

Anyway, the reason of this hack is that __DATA segment is allocated quite far from other segments and, most importantly, before the image header itself. Due to this fact, current _remap_image() implementation will remap __DATA segment to an invalid location before our pre-allocated zone:

mach_vm_address_t seg_target = *new_location + (seg_source - header);
                                                ^^^^^^^^^^^^^^^^^^^
                                                  negative value

That's what I've added a „leftover hack“ for: to allocate a safety zone before the actual target address. In this case __DATA segment would be mapped into a valid (owned by user) memory region and everything would be OK.

For some reasons __DATA segment was shifted even further in modern versions of OS X, and now we have to pre-allocate up to 3*image_size bytes of safety zone before the actual remapped image.

One possible solution for the problem is to allocate a separate memory zone for each segment, and use an address of __TEXT segment as pointer to a new location of the image.


I'm quite sure that your patch is enough to solve the problem with a reentry function you have. But I'm not sure about these unpredictable crashes… It would be great if you could reproduce them.

from rd_route.

rodionovd avatar rodionovd commented on June 13, 2024

@nfgrilo please check if this solution works for you: fix-DATA-segment-remapping-issue branch

from rd_route.

nfgrilo avatar nfgrilo commented on June 13, 2024

@rodionovd, thank you so much for looking into this so quickly, and for your detailed explanation! Also, I have been playing with your fix from the branch, and so far so good! Applications doesn't crash when calling the reentry function, Quicktime Player doesn't crash when calling rd_route(), and so far I have not been able to experience those unpredictable crashes (not easy to reproduce)!

Thank you sooooo much! Since I'm relying and playing a lot with your rd_route(), I will keep you updated in case anything unusual is detected.

Loving your rd_route project 😋

from rd_route.

rodionovd avatar rodionovd commented on June 13, 2024

Thank you very much, @nfgrilo! I really appreciate you effort to help the project ✌️

Looking forward for your further feedback.

from rd_route.

Related Issues (7)

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.