Comments (10)
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.
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.
Where exactly does it fail? Have you debugged it in more detail?
from mach_star.
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.
So is that even possible to fix?
from mach_star.
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.
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.
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.
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.
Has there been any more progress on "fixing" this?
from mach_star.
Related Issues (20)
- DisposeWindow+Beep_Injector doesn't work on Lion or Snow Leopard
- 32bit Intel on MacOSX 10.7 - vm_protect(..., VM_PROT_EXECUTE | VM_PROT_WRITE | VM_PROT_READ) needed HOT 2
- Calling Real Function With Custom Variables Crash HOT 1
- Mach_Error 4 Occurring When Attempting Injection HOT 1
- Failed to override Cocoa functions like NSLog, objc_msgSend HOT 1
- mach_override: some instructions unknown! Need to update mach_override.c HOT 2
- Code injection not working on Snow Leopard
- Problem with injection
- Crash in target process when injecting into 32-bit Chrome on Lion 10.7 HOT 1
- Performance is slow on Lion 64-bit
- Injection does not work in SecurityAgent?
- Can't file bugs in Lighthouse because the account doesn't exist HOT 1
- Error hooking 32-bit code
- Bundle Load Error on OS X 10.7 Lion HOT 2
- Doesnt work on Mountain Lion
- Dynamic re-injection HOT 1
- TTTTIIFAAAA
- Using mach_inject and swizzling applicationDidFinishLaunching:
- Unknown instructions
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 mach_star.