Skip to content

Commit

Permalink
Applied a quick fix for "Throwing unknown load command on dataOffsetF…
Browse files Browse the repository at this point in the history
…orAddress preemptive#39 "
  • Loading branch information
mfarhand-sa committed May 17, 2023
1 parent 2d07f79 commit f94440b
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 0 deletions.
Binary file added Resources/libsystem_kernel.dylib
Binary file not shown.
Binary file added Resources/libsystem_platform.dylib
Binary file not shown.
Binary file added Resources/libsystem_pthread.dylib
Binary file not shown.
49 changes: 49 additions & 0 deletions Source/CDClassDump.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,40 @@ - (BOOL)loadFile:(CDFile *)file error:(NSError **)error depth:(int)depth {
if ([path hasPrefix:loaderPathPrefix]) {
NSString *loaderPath = [machOFile.filename stringByDeletingLastPathComponent];
path = [[path stringByReplacingOccurrencesOfString:loaderPathPrefix withString:loaderPath] stringByStandardizingPath];

} else {

// First of all, God bless me for fixing this stupid issue and hopefully, the owner of this repo will fix the problem fundamentally 🚀 🎉
// Fixing issue#39 : https://github.com/preemptive/PPiOS-Rename/issues/39 🪲
// Why do we need to do these f...g workaround? 🦧
// because It's so common for Apple to ruin our life 😩
// Many things have been changed on the DYLIB files in the new releases so we need to use the old files 🤷🏻‍♂️
// Thanks to the @BillBai that who motivated me to debug this issue with the following response🫡:

/*
This is because the iOS SDK's frameworks binaries from newer version of Xcode are using chained fixups and export trie Mach-O load commands to encode bind/rebase and symbol info. Not the dyld info in the older version. And the ppios-rename does not support these load commands yet.
A quick fix is just download the older version of Xcode (https://xcodereleases.com) ,and use the older version sdk by passing the "--sdk-root" argument.
*/


// I've added old files to a bundle and read them for this particular DYLIB file. 🥳
// We received the error "Unknown load command: 0x80000033" because of these 3 dylibs files even though we passed the old Xcode path as --sdk-root params in our command.
//You might need to add more dylibs files depending on your project requirements. ( You still need to pass the iPhoneOS.sdk path from the old Xcode (e.g 11-12)

if ([path containsString:@"/usr/lib/system/libsystem_kernel.dylib"]) {
path = [self getFilePathForPPiOSBundle:@"libsystem_kernel.dylib"];
} else if ([path isEqualToString:@"/usr/lib/system/libsystem_platform.dylib"]) {
path = [self getFilePathForPPiOSBundle:@"libsystem_platform.dylib"];
} else if ([path isEqualToString:@"/usr/lib/system/libsystem_pthread.dylib"]) {
path = [self getFilePathForPPiOSBundle:@"libsystem_pthread.dylib"];
}
}

// My $1 tip to you guys: you can find what libraries causing "Unknown load command: 0x80000033" by uncommenting the next line and find it in the terminal windows

// NSLog(@"MoLowKey-Debug : %@ \n",path);
[self machOFileWithName:path andDepth:depth+1]; // Loads as a side effect
}
[self.searchPathState popSearchPaths];
Expand Down Expand Up @@ -486,5 +519,21 @@ - (int)alterPrefixPCHFilesIn:(NSString *)prefixPCHDirectory
return 0;
}

#pragma mark - dylibsHelper

-(NSString*)getFilePathForPPiOSBundle:(NSString*)dylibName {

NSString * dylibsPath = [[NSBundle mainBundle] pathForResource:@"ppiOSBundle" ofType:@"bundle"];
if (dylibsPath) {
NSBundle * ppiOSBundle = [NSBundle bundleWithPath:dylibsPath];
if (ppiOSBundle) {
NSString * path = [[ppiOSBundle resourcePath] stringByAppendingPathComponent:dylibName];
return path;
}
}
return nil;

}

@end

202 changes: 202 additions & 0 deletions ppios-rename.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
95E3D8AE1C89F37800CF28E2 /* class-dump.m in Sources */ = {isa = PBXBuildFile; fileRef = 95E3D8AD1C89F37800CF28E2 /* class-dump.m */; };
C270B5C616C54AD6006CA75D /* ULEB128.m in Sources */ = {isa = PBXBuildFile; fileRef = C270B5C516C54AD5006CA75D /* ULEB128.m */; };
C270B5C816C54B0C006CA75D /* ULEB128.h in Headers */ = {isa = PBXBuildFile; fileRef = C270B5C716C54B0A006CA75D /* ULEB128.h */; };
CD6ACDAF2A1576FA0040CAC0 /* libsystem_kernel.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD6ACDAC2A1576FA0040CAC0 /* libsystem_kernel.dylib */; };
CD6ACDB02A1576FA0040CAC0 /* libsystem_platform.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD6ACDAD2A1576FA0040CAC0 /* libsystem_platform.dylib */; };
CD6ACDB12A1576FA0040CAC0 /* libsystem_pthread.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = CD6ACDAE2A1576FA0040CAC0 /* libsystem_pthread.dylib */; };
CD6ACDB42A15771F0040CAC0 /* libsystem_kernel.dylib in Resources */ = {isa = PBXBuildFile; fileRef = CD6ACDAC2A1576FA0040CAC0 /* libsystem_kernel.dylib */; };
CD6ACDB52A15771F0040CAC0 /* libsystem_platform.dylib in Resources */ = {isa = PBXBuildFile; fileRef = CD6ACDAD2A1576FA0040CAC0 /* libsystem_platform.dylib */; };
CD6ACDB62A15771F0040CAC0 /* libsystem_pthread.dylib in Resources */ = {isa = PBXBuildFile; fileRef = CD6ACDAE2A1576FA0040CAC0 /* libsystem_pthread.dylib */; };
DA7533B213AA587A003BE32C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01EB826313A590D9003EDE60 /* Foundation.framework */; };
/* End PBXBuildFile section */

Expand All @@ -146,6 +152,13 @@
remoteGlobalIDString = 013D1F1013A5AE5A00BF0A67;
remoteInfo = MachObjC;
};
CD6ACDB22A15770A0040CAC0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 01EB825613A590D9003EDE60 /* Project object */;
proxyType = 1;
remoteGlobalIDString = CD6ACDA62A1576A00040CAC0;
remoteInfo = PPiOSBundle;
};
/* End PBXContainerItemProxy section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -375,6 +388,10 @@
95E3D8AD1C89F37800CF28E2 /* class-dump.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "class-dump.m"; path = "Source/class-dump.m"; sourceTree = "<group>"; };
C270B5C516C54AD5006CA75D /* ULEB128.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ULEB128.m; path = Source/ULEB128.m; sourceTree = "<group>"; };
C270B5C716C54B0A006CA75D /* ULEB128.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ULEB128.h; path = Source/ULEB128.h; sourceTree = "<group>"; };
CD6ACDA72A1576A00040CAC0 /* PPiOSBundle.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PPiOSBundle.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
CD6ACDAC2A1576FA0040CAC0 /* libsystem_kernel.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libsystem_kernel.dylib; sourceTree = "<group>"; };
CD6ACDAD2A1576FA0040CAC0 /* libsystem_platform.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libsystem_platform.dylib; sourceTree = "<group>"; };
CD6ACDAE2A1576FA0040CAC0 /* libsystem_pthread.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libsystem_pthread.dylib; sourceTree = "<group>"; };
F7D447FFEF466980B4EED9EE /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -407,6 +424,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
CD6ACDA42A1576A00040CAC0 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
CD6ACDB12A1576FA0040CAC0 /* libsystem_pthread.dylib in Frameworks */,
CD6ACDB02A1576FA0040CAC0 /* libsystem_platform.dylib in Frameworks */,
CD6ACDAF2A1576FA0040CAC0 /* libsystem_kernel.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -521,6 +548,7 @@
01EB826513A590D9003EDE60 /* class-dump */,
013D1EFE13A5A0F100BF0A67 /* deprotect */,
0165B8B41827137D00CC647F /* UnitTests */,
CD6ACDAB2A1576E50040CAC0 /* Resources */,
01EB826213A590D9003EDE60 /* Frameworks */,
01EB826013A590D9003EDE60 /* Products */,
38653105C3AD1ECFFF532A50 /* ppios-rename Spec */,
Expand All @@ -536,6 +564,7 @@
01EB825F13A590D9003EDE60 /* ppios-rename */,
013D1F1113A5AE5A00BF0A67 /* libMachObjC.a */,
0165B8B11827137D00CC647F /* UnitTests.xctest */,
CD6ACDA72A1576A00040CAC0 /* PPiOSBundle.bundle */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -831,6 +860,16 @@
path = lib;
sourceTree = "<group>";
};
CD6ACDAB2A1576E50040CAC0 /* Resources */ = {
isa = PBXGroup;
children = (
CD6ACDAC2A1576FA0040CAC0 /* libsystem_kernel.dylib */,
CD6ACDAD2A1576FA0040CAC0 /* libsystem_platform.dylib */,
CD6ACDAE2A1576FA0040CAC0 /* libsystem_pthread.dylib */,
);
path = Resources;
sourceTree = "<group>";
};
EB20856B1CAFC4E2CAF0CA43 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -916,13 +955,31 @@
buildRules = (
);
dependencies = (
CD6ACDB32A15770A0040CAC0 /* PBXTargetDependency */,
0158A8161412DED0003FEB91 /* PBXTargetDependency */,
);
name = "ppios-rename";
productName = "class-dump";
productReference = 01EB825F13A590D9003EDE60 /* ppios-rename */;
productType = "com.apple.product-type.tool";
};
CD6ACDA62A1576A00040CAC0 /* PPiOSBundle */ = {
isa = PBXNativeTarget;
buildConfigurationList = CD6ACDAA2A1576A00040CAC0 /* Build configuration list for PBXNativeTarget "PPiOSBundle" */;
buildPhases = (
CD6ACDA32A1576A00040CAC0 /* Sources */,
CD6ACDA42A1576A00040CAC0 /* Frameworks */,
CD6ACDA52A1576A00040CAC0 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = PPiOSBundle;
productName = PPiOSBundle;
productReference = CD6ACDA72A1576A00040CAC0 /* PPiOSBundle.bundle */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -934,13 +991,19 @@
0165B8B01827137D00CC647F = {
TestTargetID = 01EB825E13A590D9003EDE60;
};
CD6ACDA62A1576A00040CAC0 = {
CreatedOnToolsVersion = 14.2;
DevelopmentTeam = QQAR8U96PN;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 01EB825913A590D9003EDE60 /* Build configuration list for PBXProject "ppios-rename" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 01EB825413A590D9003EDE60;
Expand All @@ -951,6 +1014,7 @@
013D1F1013A5AE5A00BF0A67 /* MachObjC */,
01EB825E13A590D9003EDE60 /* ppios-rename */,
0165B8B01827137D00CC647F /* UnitTests */,
CD6ACDA62A1576A00040CAC0 /* PPiOSBundle */,
);
};
/* End PBXProject section */
Expand All @@ -968,6 +1032,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
CD6ACDA52A1576A00040CAC0 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CD6ACDB42A15771F0040CAC0 /* libsystem_kernel.dylib in Resources */,
CD6ACDB52A15771F0040CAC0 /* libsystem_platform.dylib in Resources */,
CD6ACDB62A15771F0040CAC0 /* libsystem_pthread.dylib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -1113,6 +1187,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
CD6ACDA32A1576A00040CAC0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand All @@ -1121,6 +1202,11 @@
target = 013D1F1013A5AE5A00BF0A67 /* MachObjC */;
targetProxy = 0158A8151412DED0003FEB91 /* PBXContainerItemProxy */;
};
CD6ACDB32A15770A0040CAC0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = CD6ACDA62A1576A00040CAC0 /* PPiOSBundle */;
targetProxy = CD6ACDB22A15770A0040CAC0 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
Expand Down Expand Up @@ -1404,6 +1490,113 @@
};
name = Release;
};
CD6ACDA82A1576A00040CAC0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = QQAR8U96PN;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSPrincipalClass = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Resources",
);
MACOSX_DEPLOYMENT_TARGET = 13.1;
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.secureauth.PPiOSBundle;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
WRAPPER_EXTENSION = bundle;
};
name = Debug;
};
CD6ACDA92A1576A00040CAC0 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = QQAR8U96PN;
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
INFOPLIST_KEY_NSPrincipalClass = "";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Bundles";
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Resources",
);
MACOSX_DEPLOYMENT_TARGET = 13.1;
MARKETING_VERSION = 1.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.secureauth.PPiOSBundle;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
WRAPPER_EXTENSION = bundle;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -1443,6 +1636,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
CD6ACDAA2A1576A00040CAC0 /* Build configuration list for PBXNativeTarget "PPiOSBundle" */ = {
isa = XCConfigurationList;
buildConfigurations = (
CD6ACDA82A1576A00040CAC0 /* Debug */,
CD6ACDA92A1576A00040CAC0 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 01EB825613A590D9003EDE60 /* Project object */;
Expand Down

0 comments on commit f94440b

Please sign in to comment.