rentzsch / mach_star

code injection and function overriding for Mac OS X
254 stars 46 forks source link

Failed to override Cocoa functions like NSLog, objc_msgSend #24

Open szcoder opened 13 years ago

szcoder commented 13 years ago

Thank you for this project. I successfully use mach_override to replace local functions and stdio functions. However I failed to override cocoa functions, for example, objc_msgSend and NSLog. The error is below

mach_override: some instructions unknown! Need to update mach_override.c err = f8000001 /Volumes/Data/rentzsch-mach_star-b5c0803/mach_override/mach_override.c:226 err = f8000001 /Volumes/Data/rentzsch-mach_star-b5c0803/mach_override/mach_override.c:239 err = f8000001 /Volumes/Data/rentzsch-mach_star-b5c0803/mach_override/mach_override.c:245 err = f8000001 /Volumes/Data/rentzsch-mach_star-b5c0803/mach_override/mach_override.c:259 err = f8000001 /Volumes/Data/rentzsch-mach_star-b5c0803/mach_override/mach_override.c:264

I am using Xcode 4.2 and Mac OS X Lion 10.7.2, 64bit kernel and app. Can you please look into it? Many thanks.

szcoder commented 13 years ago

Below is the source of my test.m file

import "objc/objc.h"

import "objc/runtime.h"

import "objc/message.h"

include "stdio.h"

include "mach_override.h"

id (*savedFuncPtr)(id obj, SEL sel, ...);

id my_msgSend(id obj, SEL sel, ...) { printf("my_msgSend Called\n"); return nil; }

int main(int argc, const char* argv[]) { mach_override_ptr(objc_msgSend, my_msgSend, (void**)&savedFuncPtr); //objc_msgSend(nil, nil); return 0; }