http://ruixiazun.blog.163.com/blog/static/9068791820141173588694/
iphone real run environment is not sys/ptrace.h thrown. The Ptrace method is not thrown and can be obtained by Dlopen.
Dlopen: When the PATH parameter is 0, he will automatically find $LD _library_path, $DYLD _library_path, $DYLD _fallback_library_path and the dynamic link library in the current working directory.
#import <dlfcn.h>
#import <sys/types.h>
typedef int (*ptrace_ptr_t) (int _request, pid_t _pid, caddr_t _addr, int _data);
#if!defined (Pt_deny_attach)
#define Pt_deny_attach 31
#endif//!defined (Pt_deny_attach)
void Disable_gdb () {
void* handle = Dlopen (0, Rtld_global | Rtld_now);
ptrace_ptr_t ptrace_ptr = Dlsym (handle, "ptrace");
Ptrace_ptr (pt_deny_attach, 0, 0, 0);
Dlclose (handle);
}
int main (int argc, Charchar *argv[])
{
#ifndef DEBUG
Disable_gdb ();
#endif
@autoreleasepool {
Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Wqmainpageappdelegate class]));
}
}
iOS programs prevent dynamic debugging and code injection