2

我正在尝试使用 iOSOpenDev Captain-Hook 调整进行简单调整。这是我的代码:

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "CaptainHook/CaptainHook.h"

CHDeclareClass(TESTCLASS); // declare class

CHOptimizedMethod(0, self, void, TESTCLASS, testm) // hook method (with no arguments and no return value)
{
    // write code here ...
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"HACK" message:@"message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];

    //CHSuper(0, TESTCLASS, testm); // call old (original) method
    //return nil;
}

CHConstructor // code block that runs immediately upon load
{
    @autoreleasepool
    {
        CHLoadLateClass(TESTCLASS);  // load class (that will be "available later")
        CHHook(0, TESTCLASS, testm); // register hook
    }
}

我也有我的其他应用程序的过滤包的 plist。我的其他应用调用[TESTCLASS testm]。如果我将 .plist 和 .dylib 放在 /Library/MobileSubstrate/DynamicLibraries 它不起作用,则什么也不会发生。但是,如果我将 dylib 添加到我的第二个应用程序中的项目并编译它,它可以工作,即使没有将实际的 dylib 复制到应用程序(在 /Library/MobileSubstrate/DynamicLibraries 中使用它)并显示我的警报。我怎样才能让它工作?

尝试挂钩一些跳板的示例调用 - 它们不起作用。使用 Xcode 5.0.2、iOSOpenDev 1.6-2、iPad1 5.1.1

4

0 回答 0