Giter Club home page Giter Club logo

Comments (10)

albertz avatar albertz commented on August 17, 2024

In the function mach_inject, can you play around with imageOffset = 0;? See the related comment there. I introduced this patch because it didn't worked on MacOSX 10.7 32bit.

I would wonder though if in one case, RIP-relative addressing is used and not in the other.

from mach_star.

alexzielenski avatar alexzielenski commented on August 17, 2024

Yes I see this:

#if defined(__x86_64__)
        imageOffset = 0; // RIP-relative addressing
#else
//      ASSERT_CAST( void*, remoteCode );
//      imageOffset = ((void*) remoteCode) - image;
        // WARNING: See bug https://github.com/rentzsch/mach_star/issues/11 . Not sure about this.
        imageOffset = 0;
#endif

from mach_star.

albertz avatar albertz commented on August 17, 2024

Where exactly does it fail? Have you debugged it in more detail?

from mach_star.

alexzielenski avatar alexzielenski commented on August 17, 2024

I just logged every single place where err is defined in mach_inject(…) and this is the only/last spot it errors out.

// create thread and launch it

        err = thread_create_running( remoteTask, x86_THREAD_STATE64,
                                     (thread_state_t) &remoteThreadState, x86_THREAD_STATE64_COUNT,
                                     &remoteThread );

But this makes no sense because that is inside the x86_64 code block.

So i did some testing and put this code into mach_inject.c

#if defined (__i386__)
    printf("i386\n");
#endif

#if defined (__x86_64__)
    printf("x86_64\n");
#endif

and the x86_64 log came up every time even when injecting into a 32bit app so I think there lies the problem. If the application that is using mach_inject is Universal or 64-bit it cannot inject into 32bit applications (or bundle stubs/framework)

EDIT: Update. After compiling my app for 32-bit only. (only the app, nothing else) I got it to work in 32-bit apps. But now 64-bit apps don't get injected into!

from mach_star.

alexzielenski avatar alexzielenski commented on August 17, 2024

So is that even possible to fix?

from mach_star.

albertz avatar albertz commented on August 17, 2024

OSX is either running the 32 or the 64bit code of your injection app (and i.e. of mach_inject). If you compiled it for both, of course it will run the 64bit code. And the 64bit code cannot inject into 32bit processes.

This might be possible to fix but probably very hard.

I went another way and created a few small helper apps for each target (i.e. 32bit and 64bit processes). See https://github.com/albertz/simbl.

from mach_star.

alexzielenski avatar alexzielenski commented on August 17, 2024

But perhaps mach_inject can be modified to use a certain architecture if the executable being injected into is 32bit, etc. Also, your method only works on NSRunningApplication instances. What if I'm injecting into a non-bundle/no-identifier process? How could the architecture be identified then?

from mach_star.

albertz avatar albertz commented on August 17, 2024

No, my method works always. See the code. (Whereby the code is only used for real applications in that case; but take a look at the really relevant code; it just needs a PID and nothing else, that is also what is passed to the helper tool.)

You might mean the code which determines the architecture of any target process. This one is simplified and not general because it was just easier this way for this specific project. You just might want to replace that by some more general code.

from mach_star.

alexzielenski avatar alexzielenski commented on August 17, 2024

Yes I mean the code which determines the architecture of the target process. NSRunning application does not apply to a process, for instance, like "mds"-one without a bundle. I have been googling around and have not yet found a way to find the architecture of a running process at runtime. Is there another way to do so?

from mach_star.

loco4 avatar loco4 commented on August 17, 2024

Has there been any more progress on "fixing" this?

from mach_star.

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.