4.1.1 MobileHooker 的例子 屏幕背景色不能变成红色

源码是
#import “RootViewController.h”

class CPPClass
{
public:
void CPPFunction(const char *);
};

void CPPClass::CPPFunction(const char *arg0)
{
for (int i = 0; i < 66; i++) // This for loop makes this function long enough to validate MSHookFunction
{
u_int32_t randomNumber;
if (i % 3 == 0) randomNumber = arc4random_uniform(i);
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSString *hostName = processInfo.hostName;
int pid = processInfo.processIdentifier;
NSString *globallyUniqueString = processInfo.globallyUniqueString;
NSString *processName = processInfo.processName;
NSArray *junks = @[hostName, globallyUniqueString, processName];
NSString *junk = @"";
for (int j = 0; j < pid; j++)
{
if (pid % 6 == 0) junk = junks[j % 3];
}
if (i % 68 == 1) NSLog(@“Junk: %@”, junk);
}
NSLog(@“iOSRE: CPPFunction: %s”, arg0);
}

extern “C” void CFunction(const char *arg0)
{
for (int i = 0; i < 66; i++) // This for loop makes this function long enough to validate MSHookFunction
{
u_int32_t randomNumber;
if (i % 3 == 0) randomNumber = arc4random_uniform(i);
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
NSString *hostName = processInfo.hostName;
int pid = processInfo.processIdentifier;
NSString *globallyUniqueString = processInfo.globallyUniqueString;
NSString *processName = processInfo.processName;
NSArray *junks = @[hostName, globallyUniqueString, processName];
NSString *junk = @"";
for (int j = 0; j < pid; j++)
{
if (pid % 6 == 0) junk = junks[j % 3];
}
if (i % 68 == 1) NSLog(@“Junk: %@”, junk);
}
NSLog (@“iOSRE: CFunction: %s”, arg0);
}

extern “C” void ShortCFunction (const char *arg0) // ShortCFunction is too short to be hooked
{
CPPClass cppClass;
cppClass.CPPFunction(arg0);
}

@implementation RootViewController

  • (void)loadViev {
    self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
    self.view.backgroundColor = [UIColor redColor];
    NSLog (@“iOSRE: backgroundColor”);
    }

  • (void)viewDidLoad
    {
    [super viewDidLoad];

    CPPClass cppClass;
    cppClass.CPPFunction(“This is a C++ function!”);
    CFunction(“This is a C function!”);
    ShortCFunction(“This is a short C function!”);
    }
    @end

我在ipad上面测试 背景颜色不会改变 源码贴出来了

问题解决了

[quote=“lds, post:1, topic:1571”]

  • (void)loadViev
    [/quote] 的最后一个字母拼错了 应该是- (void)loadView

感谢2%