Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Halo-Michael committed Feb 2, 2023
1 parent cf25fc2 commit 494c8c2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
4 changes: 2 additions & 2 deletions resolutionsetter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.0;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.michael.resolutionsetter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -353,7 +353,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.1.0;
MARKETING_VERSION = 1.1.1;
PRODUCT_BUNDLE_IDENTIFIER = com.michael.resolutionsetter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
45 changes: 45 additions & 0 deletions resolutionsetter/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
#import <removefile.h>
#import "helpers.h"

#define PROC_ALL_PIDS 1
#define PROC_PIDPATHINFO_MAXSIZE (4*MAXPATHLEN)
#define SafeFree(x) do { if (x) free(x); } while(false)
#define SafeFreeNULL(x) do { SafeFree(x); (x) = NULL; } while(false)

int proc_listpids(uint32_t type, uint32_t typeinfo, void *buffer, int buffersize);
int proc_pidpath(int pid, void *buffer, uint32_t buffersize);

#define bundleID CFSTR("com.apple.iokit.IOMobileGraphicsFamily")
#define userName CFSTR("mobile")

Expand All @@ -31,6 +39,43 @@ BOOL vaildNumber(NSString *string) {
return NO;
}

char *get_path_for_pid(pid_t pid) {
char *ret = NULL;
uint32_t path_size = PROC_PIDPATHINFO_MAXSIZE;
char *path = malloc(path_size);
if (path != NULL) {
if (proc_pidpath(pid, path, path_size) >= 0)
ret = strdup(path);
SafeFreeNULL(path);
}
return ret;
}

pid_t pidOfProcess(const char *name) {
char real[PROC_PIDPATHINFO_MAXSIZE];
bzero(real, sizeof(real));
realpath(name, real);
int numberOfProcesses = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
pid_t pids[numberOfProcesses];
bzero(pids, sizeof(pids));
proc_listpids(PROC_ALL_PIDS, 0, pids, (int)sizeof(pids));
bool foundProcess = false;
pid_t processPid = 0;
for (int i = 0; i < numberOfProcesses && !foundProcess; ++i) {
if (pids[i] == 0)
continue;
char *path = get_path_for_pid(pids[i]);
if (path != NULL) {
if (strlen(path) > 0 && strcmp(path, real) == 0) {
processPid = pids[i];
foundProcess = true;
}
SafeFreeNULL(path);
}
}
return processPid;
}

NSDictionary *loadPrefs() {
CFArrayRef keyList = CFPreferencesCopyKeyList(bundleID, userName, kCFPreferencesAnyHost);
if (keyList != NULL) {
Expand Down
4 changes: 3 additions & 1 deletion resolutionsetter/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ - (IBAction)Set:(id)sender {
lchown("/private/var/tmp/com.michael.iokit.IOMobileGraphicsFamily/com.apple.iokit.IOMobileGraphicsFamily.plist", 501, 501);
xpc_crasher("com.apple.cfprefsd.daemon");
sleep(1);
xpc_crasher("com.apple.backboard.hid-services.xpc");
if (kill(pidOfProcess("/usr/libexec/backboardd"), SIGTERM)) {
xpc_crasher("com.apple.backboard.hid-services.xpc");
}
[_Set setAttributedTitle:[[NSAttributedString alloc] initWithString:@"Failed" attributes:@{NSFontAttributeName:_Set.titleLabel.font}] forState:UIControlStateNormal];
} else {
[_Set setUserInteractionEnabled:true];
Expand Down

0 comments on commit 494c8c2

Please sign in to comment.