#include #include bool debugger_detected_short() { unsigned long long start = __rdtsc(); unsigned long long stop = __rdtsc(); // std::cout << "short: " << stop - start << std::endl; return (stop - start) > 100; } bool debugger_detected_long() { unsigned long long start = __rdtsc(); try { throw 0; } catch(...) {} unsigned long long stop = __rdtsc(); // std::cout << "long: " << stop - start << std::endl; return (stop - start) > 250'000; } int main(int argc, char **argv) { if (debugger_detected_short() || debugger_detected_long()) std::cout << "debbuger detected!!!" << std::endl; else std::cout << "debbuger not detected!!!" << std::endl; }