Play-/Source/ui_ios/DebuggerSimulator.cpp
Jean-Philip Desjardins 80bfc0a099 Simulate the debugger being detached when quitting the app.
Prevents the application from being stuck when killed by external means.
2020-06-19 15:46:49 -04:00

20 lines
496 B
C++

#include <dlfcn.h>
#include <sys/types.h>
#include <cstdlib>
#define PT_TRACE_ME 0
#define PT_DENY_ATTACH 31
typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);
void StartSimulateDebugger()
{
auto ptrace_ptr = reinterpret_cast<ptrace_ptr_t>(dlsym(RTLD_SELF, "ptrace"));
ptrace_ptr(PT_TRACE_ME, 0, NULL, 0);
}
void StopSimulateDebugger()
{
auto ptrace_ptr = reinterpret_cast<ptrace_ptr_t>(dlsym(RTLD_SELF, "ptrace"));
ptrace_ptr(PT_DENY_ATTACH, 0, NULL, 0);
}