-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for UnrealEngine's wrong file path #174
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,24 +179,27 @@ static OSStatus pt_SecItemDelete(CFDictionaryRef query) { | |
DYLD_INTERPOSE(pt_SecItemUpdate, SecItemUpdate) | ||
DYLD_INTERPOSE(pt_SecItemDelete, SecItemDelete) | ||
|
||
static bool is_ue4 = false; | ||
|
||
static char const* ue4_fix_filename(char const* filename) { | ||
char const UE4_PATTERN[] = "Library//Users"; | ||
char const* p = NULL; | ||
if (!is_ue4) { | ||
return filename; | ||
} | ||
|
||
if ((p = strstr(filename, UE4_PATTERN))) { | ||
return p + 8; | ||
static uint8_t ue_status = 0; | ||
|
||
static char const* ue_fix_filename(char const* filename) { | ||
static char UE_PATTERN[1024] = "//Users/"; | ||
getlogin_r(UE_PATTERN + 8, sizeof(UE_PATTERN) - 8); | ||
|
||
char const* p = filename; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you rename this variable so it is more descriptive of its purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will rename the variable |
||
if (ue_status == 2) { | ||
char const* last_p = p; | ||
while ((p = strstr(p, UE_PATTERN))) { | ||
last_p = ++p; | ||
} | ||
|
||
return last_p; | ||
} | ||
|
||
return filename; | ||
return p; | ||
} | ||
|
||
static int pt_open(char const* restrict filename, int oflag, ... ) { | ||
filename = ue4_fix_filename(filename); | ||
filename = ue_fix_filename(filename); | ||
|
||
if (oflag == O_CREAT) { | ||
int mod; | ||
|
@@ -212,19 +215,19 @@ static int pt_open(char const* restrict filename, int oflag, ... ) { | |
} | ||
|
||
static int pt_stat(char const* restrict path, struct stat* restrict buf) { | ||
return stat(ue4_fix_filename(path), buf); | ||
return stat(ue_fix_filename(path), buf); | ||
} | ||
|
||
static int pt_access(char const* path, int mode) { | ||
return access(ue4_fix_filename(path), mode); | ||
return access(ue_fix_filename(path), mode); | ||
} | ||
|
||
static int pt_rename(char const* restrict old_name, char const* restrict new_name) { | ||
return rename(ue4_fix_filename(old_name), ue4_fix_filename(new_name)); | ||
return rename(ue_fix_filename(old_name), ue_fix_filename(new_name)); | ||
} | ||
|
||
static int pt_unlink(char const* path) { | ||
return unlink(ue4_fix_filename(path)); | ||
return unlink(ue_fix_filename(path)); | ||
} | ||
|
||
DYLD_INTERPOSE(pt_open, open) | ||
|
@@ -237,15 +240,23 @@ @implementation PlayLoader | |
|
||
static void __attribute__((constructor)) initialize(void) { | ||
[PlayCover launch]; | ||
|
||
NSURL* appFolder = [[NSBundle mainBundle] bundleURL]; | ||
NSURL* ue4commandlinetxt = [appFolder URLByAppendingPathComponent:@"ue4commandline.txt"]; | ||
|
||
is_ue4 |= !access( | ||
[[ue4commandlinetxt path] cStringUsingEncoding:NSUTF8StringEncoding], F_OK | ||
); | ||
if (is_ue4) { | ||
[PlayKeychain debugLogger: [NSString stringWithFormat:@"Is it UE4? : %@", @(is_ue4)]]; | ||
|
||
if (ue_status == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will |
||
NSURL* appFolder = [[NSBundle mainBundle] bundleURL]; | ||
NSArray* ueFiles = @[ | ||
[appFolder URLByAppendingPathComponent:@"ue4commandline.txt"], | ||
[appFolder URLByAppendingPathComponent:@"uecommandline.txt"], | ||
]; | ||
|
||
for (NSURL* ueFile in ueFiles) { | ||
if (!access([[ueFile path] cStringUsingEncoding:NSUTF8StringEncoding], F_OK)) { | ||
ue_status = 2; | ||
} | ||
} | ||
} | ||
|
||
if (ue_status == 2) { | ||
[PlayKeychain debugLogger: [NSString stringWithFormat:@"UnrealEngine Hooked"]]; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this function do in the code (seems unused)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prefix
//Users
can be insufficient, so I added the username to the prefix pathUE_PATTERN
.