我按照《iOS应用逆向工程(第2版)》221页的demo新建iOSRETargetApp,在终端运行““make package install”之后,终端报了几十个错误:
错误提示:
XXRootViewController.m:4:15: error: expected ‘;’ after top level declarator
Class CPPClass {
^
;
XXRootViewController.m:8:6: error: variable has incomplete type ‘void’
void CPPClass::CPPFunction(const char *arg0) {
^
XXRootViewController.m:8:14: error: expected ‘;’ after top level declarator
void CPPClass::CPPFunction(const char *arg0) {
^
;
XXRootViewController.m:8:15: error: expected identifier or ‘(’
void CPPClass::CPPFunction(const char *arg0) {
^
XXRootViewController.m:37:65: error: expected identifier or ‘(’
globallyUniqueString, processName]; NSStr…
^
XXRootViewController.m:38:13: error: expected identifier or ‘(’
for (int j = 0; j < pid; j++) {
^
XXRootViewController.m:41:19: error: expected parameter declarator
NSLog(@“iOSRE: CFunction: %s”, arg0);
^
XXRootViewController.m:41:19: error: expected ‘)’
XXRootViewController.m:41:18: note: to match this ‘(’
NSLog(@“iOSRE: CFunction: %s”, arg0);
^
XXRootViewController.m:41:13: error: type specifier missing, defaults to ‘int’
[-Werror,-Wimplicit-int]
NSLog(@“iOSRE: CFunction: %s”, arg0);
^
XXRootViewController.m:41:13: error: conflicting types for ‘NSLog’
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.3.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:519:24: note:
previous declaration is here
FOUNDATION_EXPORT void NSLog(NSString *format, …) NS_FORMAT_FUNCTION(1…
^
XXRootViewController.m:42:9: error: extraneous closing brace (‘}’)
}
^
XXRootViewController.m:43:16: error: expected identifier or ‘(’
extern “C” void ShortCFunction(const char *arg0) // ShortCFuncti…
^
XXRootViewController.m:53:21: error: expected ‘;’ after expression
CPPClass cppClass;
^
;
XXRootViewController.m:53:22: error: use of undeclared identifier ‘cppClass’
CPPClass cppClass;
^
XXRootViewController.m:54:13: error: use of undeclared identifier ‘cppClass’
cppClass.CPPFunction(“This is a C++ function!”); CFunction(“…
^
XXRootViewController.m:54:62: error: implicit declaration of function
‘CFunction’ is invalid in C99 [-Werror,-Wimplicit-function-declaration]
cppClass.CPPFunction(“This is a C++ function!”); CFunction(”…
^
XXRootViewController.m:54:98: error: implicit declaration of function
‘ShortCFunction’ is invalid in C99
[-Werror,-Wimplicit-function-declaration]
…is a C++ function!"); CFunction(“This is a C function!”); ShortCFunction…
^
XXRootViewController.m:53:13: error: expression result unused
[-Werror,-Wunused-value]
CPPClass cppClass;
^~~~~~~~
18 errors generated.
make[3]: *** [/Users/wangxiushuai/Desktop/221页demo/iosretargetapp/.theos/obj/debug/armv7/XXRootViewController.m.b40f1e1f.o] Error 1
make[2]: *** [/Users/wangxiushuai/Desktop/221页demo/iosretargetapp/.theos/obj/debug/armv7/iOSRETargetApp.app/iOSRETargetApp] Error 2
make[1]: *** [internal-application-all_] Error 2
make: *** [iOSRETargetApp.all.application.variables] Error 2
是XXRootViewController.m文件里面的代码就是复制的书上的啊
XXRootViewController.m代码:
#import “XXRootViewController.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 XXRootViewController - (void)loadView {
self.view = [[[UIView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]] autorelease];
self.view.backgroundColor = [UIColor redColor];
}
- (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
来个大神指导我一下吧,谢谢