summaryrefslogtreecommitdiff
path: root/platform/mac/platform_mac.cpp
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-07-11 13:48:50 -0400
committerPeter LaFosse <peter@vector35.com>2024-07-11 16:28:13 -0400
commit0bad362009c60a18364a0b153004b6c00aa34653 (patch)
tree4af27d0a2c5e26e65b45cb0053c3edf1e312cdae /platform/mac/platform_mac.cpp
parentf7f05179bd9063fad6d3d2e243a7a6d44d6e7f94 (diff)
Fix a database upgrade issue regarding mac-aarch64 dbs that are now loaded as ios-aarch64 (skip-ci)
Diffstat (limited to 'platform/mac/platform_mac.cpp')
-rw-r--r--platform/mac/platform_mac.cpp60
1 files changed, 50 insertions, 10 deletions
diff --git a/platform/mac/platform_mac.cpp b/platform/mac/platform_mac.cpp
index 6a539f66..c922dd18 100644
--- a/platform/mac/platform_mac.cpp
+++ b/platform/mac/platform_mac.cpp
@@ -108,10 +108,19 @@ public:
static Ref<Platform> Recognize(BinaryView* view, Metadata* metadata)
{
+ bool shouldRecognizeOnIOS = false;
+ if (view->GetFile()->IsBackedByDatabase())
+ {
+ if (auto database = view->GetFile()->GetDatabase())
+ {
+ if (database->HasGlobal("original_version") && database->ReadGlobal("original_version").asInt64() < 6)
+ shouldRecognizeOnIOS = true;
+ }
+ }
auto machoPlatform = metadata->Get("machoplatform");
if (!machoPlatform || !machoPlatform->IsUnsignedInteger())
return nullptr;
- if (machoPlatform->GetUnsignedInteger() != 2)
+ if (machoPlatform->GetUnsignedInteger() != 2 || shouldRecognizeOnIOS)
return g_macArmv7;
return nullptr;
@@ -143,10 +152,19 @@ public:
static Ref<Platform> Recognize(BinaryView* view, Metadata* metadata)
{
+ bool shouldRecognizeOnIOS = false;
+ if (view->GetFile()->IsBackedByDatabase())
+ {
+ if (auto database = view->GetFile()->GetDatabase())
+ {
+ if (database->HasGlobal("original_version") && database->ReadGlobal("original_version").asInt64() < 6)
+ shouldRecognizeOnIOS = true;
+ }
+ }
auto machoPlatform = metadata->Get("machoplatform");
if (!machoPlatform || !machoPlatform->IsUnsignedInteger())
return nullptr;
- if (machoPlatform->GetUnsignedInteger() != 2)
+ if (machoPlatform->GetUnsignedInteger() != 2 || shouldRecognizeOnIOS)
return g_macArm64;
return nullptr;
@@ -179,12 +197,23 @@ public:
static Ref<Platform> Recognize(BinaryView* view, Metadata* metadata)
{
auto machoPlatform = metadata->Get("machoplatform");
+ if (machoPlatform->GetUnsignedInteger() != 2)
+ return nullptr;
if (!machoPlatform || !machoPlatform->IsUnsignedInteger())
return nullptr;
- if (machoPlatform->GetUnsignedInteger() == 2)
- return g_iosArmv7;
-
- return nullptr;
+ if (view->GetFile()->IsBackedByDatabase())
+ {
+ if (auto database = view->GetFile()->GetDatabase())
+ {
+ if (database->HasGlobal("original_version") && database->ReadGlobal("original_version").asInt64() < 6)
+ {
+ LogError("%s", "iOS database was saved with mac platform. Unable to upgrade. For iOS typelibs to"
+ " function properly, this binary must be reopened.");
+ return nullptr;
+ }
+ }
+ }
+ return g_iosArmv7;
}
};
@@ -215,10 +244,21 @@ public:
auto machoPlatform = metadata->Get("machoplatform");
if (!machoPlatform || !machoPlatform->IsUnsignedInteger())
return nullptr;
- if (machoPlatform->GetUnsignedInteger() == 2)
- return g_iosArm64;
-
- return nullptr;
+ if (machoPlatform->GetUnsignedInteger() != 2)
+ return nullptr;
+ if (view->GetFile()->IsBackedByDatabase())
+ {
+ if (auto database = view->GetFile()->GetDatabase())
+ {
+ if (database->HasGlobal("original_version") && database->ReadGlobal("original_version").asInt64() < 6)
+ {
+ LogError("%s", "iOS database was saved with mac platform. Unable to upgrade. For iOS typelibs to"
+ " function properly, this binary must be reopened.");
+ return nullptr;
+ }
+ }
+ }
+ return g_iosArm64;
}
};