more test

This commit is contained in:
Nick Chan committed 2026-05-24 23:40:03 +08:00
1 parent dc2ce0f947
commit 070c181a91
2 files changed
+22 -12

No files matched your search

+10 -1
View File
@@ -185,6 +185,15 @@ setenv_ra1n:
return -1; return -1;
} }
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path); LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
#if defined(__APPLE__)
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
waitpid(pid, NULL, WUNTRACED);
ret = ptrace(PT_DETACH, pid, NULL, 0);
if (ret)
LOG(LOG_WARNING, "Cannot ptrace(PT_DETACH): %d (%s)", errno, strerror(errno));
#endif
#endif
sleep(2); sleep(2);
if (ext_checkra1n == NULL) { if (ext_checkra1n == NULL) {
unlink(checkra1n_path); unlink(checkra1n_path);
@@ -192,7 +201,7 @@ setenv_ra1n:
checkra1n_path = NULL; checkra1n_path = NULL;
} }
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);
if (!external_pongo && pongo_path != NULL) { if (!external_pongo && pongo_path != NULL) {
unlink(pongo_path); unlink(pongo_path);
} }
if (pongo_path != NULL) free(pongo_path); if (pongo_path != NULL) free(pongo_path);
+12 -11
View File
@@ -6,6 +6,7 @@
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <spawn.h> #include <spawn.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include <limits.h> #include <limits.h>
#include <TargetConditionals.h> #include <TargetConditionals.h>
@@ -16,6 +17,11 @@ extern char **environ;
extern char ***_NSGetArgv(void); extern char ***_NSGetArgv(void);
extern int *_NSGetArgc(void); extern int *_NSGetArgc(void);
#define CS_OPS_STATUS 0
#define CS_DEBUGGED 0x10000000
int csops(pid_t pid, unsigned int ops, void *useraddr, size_t usersize);
__attribute__((constructor)) void ctor(void) __attribute__((constructor)) void ctor(void)
{ {
char ***argvp = _NSGetArgv(); char ***argvp = _NSGetArgv();
@@ -28,17 +34,12 @@ __attribute__((constructor)) void ctor(void)
char **argv = *argvp; char **argv = *argvp;
#if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR #if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
if (argc == 2 && strcmp(argv[1], "__CHECKRA1N_JIT_PLEASE__") == 0) { assert(ptrace(PT_TRACE_ME, 0, 0, 0) == 0);
assert(ptrace(PT_TRACE_ME, 0, 0, 0) == 0); uint32_t csflags;
exit(0); assert(csops(getpid(), CS_OPS_STATUS, &csflags, sizeof(csflags)) == 0);
} else {
char exe_path[PATH_MAX]; if (!(csflags & CS_DEBUGGED))
uint32_t exe_path_size = PATH_MAX; printf("WARNING: CS_DEBUGGED is not set (0x%x)\n", csflags);
assert(_NSGetExecutablePath(exe_path, &exe_path_size) == 0);
pid_t pid;
assert(posix_spawnp(&pid, exe_path, NULL, NULL, (char*[]){"__CHECKRA1N_JIT_PLEASE__",NULL}, environ) == 0);
assert(waitpid(pid, NULL, 0) == pid);
}
#endif #endif
char *c1_path = getenv("LIBCHECKRA1NHELPER_CHECKRA1N_PATH"); char *c1_path = getenv("LIBCHECKRA1NHELPER_CHECKRA1N_PATH");