Using the SEC_IS_BEING_DEBUGGED_RETURN_NIL Macro in an iOS Application

I found out about the following code snippet, which allegedly prevents the Swizzling method to some extent.

#ifndef DEBUG SEC_IS_BEING_DEBUGGED_RETURN_NIL(); #endif 

But when included in my project for testing, I get an error message.

Implicit declaration of function 'SEC_IS_BEING_DEBUGGED_RETURN_NIL' is invalid in C99

Can someone help me with this error if I need to include any library header for the same.

+2
source share
1 answer

I was not going to answer my question. From the above comment, I searched for any such implementation. And found this in a GitHub project . What is the NSObject

Perhaps this will help anyone in the future .

 #define SEC_IS_BEING_DEBUGGED_RETURN_NIL() size_t size = sizeof(struct kinfo_proc); \ struct kinfo_proc info; \ int ret, name[4]; \ memset(&info, 0, sizeof(struct kinfo_proc)); \ name[0] = CTL_KERN; \ name[1] = KERN_PROC; \ name[2] = KERN_PROC_PID; \ name[3] = getpid(); \ if ((ret = (sysctl(name, 4, &info, &size, NULL, 0)))) { \ if (ret) return nil; \ } \ if (info.kp_proc.p_flag & P_TRACED) return nil 

Loans to the creator of this

// Created by Derek Selander on a happy day.//
// Copyright (c)
// 2013 Derek Selander. All rights reserved. //

+6
source

Source: https://habr.com/ru/post/1237568/


All Articles