-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0cc5ab1
commit 647f430
Showing
10 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
int enableJIT(NSString *bundleID); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@import Foundation; | ||
@import Darwin; | ||
|
||
@interface RBSProcessPredicate | ||
+ (instancetype)predicateMatchingBundleIdentifier:(NSString *)bundleID; | ||
@end | ||
|
||
@interface RBSProcessHandle | ||
+ (instancetype)handleForPredicate:(RBSProcessPredicate *)predicate error:(NSError **)error; | ||
- (int)rbs_pid; | ||
@end | ||
|
||
#define PT_DETACH 11 | ||
#define PT_ATTACHEXC 14 | ||
int ptrace(int request, pid_t pid, caddr_t addr, int data); | ||
|
||
int enableJIT(NSString *bundleID) { | ||
#ifdef EMBEDDED_ROOT_HELPER | ||
return -1; | ||
#else | ||
RBSProcessPredicate *predicate = [RBSProcessPredicate predicateMatchingBundleIdentifier:bundleID]; | ||
RBSProcessHandle* process = [RBSProcessHandle handleForPredicate:predicate error:nil]; | ||
int pid = process.rbs_pid; | ||
|
||
if (!pid) | ||
{ | ||
return ESRCH; | ||
} | ||
|
||
int ret = ptrace(PT_ATTACHEXC, pid, 0, 0); | ||
if (ret == -1) | ||
{ | ||
return errno; | ||
} | ||
|
||
usleep(100000); | ||
ret = ptrace(PT_DETACH, pid, 0, 0); | ||
if (ret == -1) | ||
{ | ||
return errno; | ||
} | ||
return 0; | ||
#endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters