Also handle root directory as a discovery path

This commit is contained in:
pancake committed 2026-05-06 16:18:19 +02:00
1 parent cf1c9f4e81
commit 01b02def82
2 files changed
+61 -5

No files matched your search

+6 -5
View File
@@ -375,11 +375,12 @@ R_API bool r2unity_is_debug (void);
/* Companion-file discovery.
*
* Given any file inside a Unity IL2CPP deployment (the main app binary, the
* IL2CPP native library, or a sibling dropped into a flat fixture directory),
* r2unity_detect_paths probes the well-known layouts for iOS, macOS, Windows,
* Linux, Android (extracted APK) and the r2unity companion-file layout. Returns
* NULL if no layout matches or `global-metadata.dat` cannot be located. */
* Given any file or root directory inside a Unity IL2CPP deployment (the main
* app binary, the IL2CPP native library, or a sibling dropped into a flat
* fixture directory), r2unity_detect_paths probes the well-known layouts for
* iOS, macOS, Windows, Linux, Android (extracted APK) and the r2unity
* companion-file layout. Returns NULL if no layout matches or
* `global-metadata.dat` cannot be located. */
typedef struct {
char *platform; /* "ios", "macos", "windows", "linux", "android", "fixture" */
char *main_executable; /* absolute path of the input file */
+55
View File
@@ -316,6 +316,57 @@ static char *expand_app_bundle (const char *dir) {
return NULL;
}
/* Extracted iOS app root without a .app suffix: Data sits next to the main
* Mach-O, whose basename is project-specific. */
static char *expand_ios_root_dir (const char *dir) {
char *metadata = find_ios_metadata (dir);
if (!metadata) {
return NULL;
}
free (metadata);
char *out = NULL;
if (take_if_exists (&out, r_file_new (dir, "Frameworks", "UnityFramework.framework", "UnityFramework", NULL))) {
return out;
}
if (take_if_exists (&out, pjoin (dir, "UnityFramework"))) {
return out;
}
RList *entries = r_sys_dir (dir);
if (!entries) {
return NULL;
}
char *fallback = NULL;
RListIter *it;
char *name;
r_list_foreach (entries, it, name) {
if (*name == '.') {
continue;
}
if (!strcmp (name, "Data") || !strcmp (name, "Info.plist")
|| !strcmp (name, "PkgInfo") || !strcmp (name, "global-metadata.dat")
|| !strcmp (name, "embedded.mobileprovision")) {
continue;
}
char *f = pjoin (dir, name);
if (r_file_is_regular (f)) {
if (r_file_is_executable (f)) {
r_list_free (entries);
free (fallback);
return f;
}
if (!fallback) {
fallback = f;
continue;
}
}
free (f);
}
r_list_free (entries);
return fallback;
}
/* Windows/Linux standalone: look for a *_Data sibling and pick its stem as the
* main exe (or fall back to the IL2CPP binary). */
static char *expand_winlin_dir (const char *dir) {
@@ -385,6 +436,10 @@ static char *expand_dir_input (const char *dir) {
return out;
}
}
char *ios = expand_ios_root_dir (dir);
if (ios) {
return ios;
}
char *flat = find_il2cpp_sibling (dir);
if (flat) {
return flat;