DYLDSharedCache.hopperLoader icon indicating copy to clipboard operation
DYLDSharedCache.hopperLoader copied to clipboard

My hack to fix this on Hopper v4.5

Open junebeetle opened this issue 5 years ago • 3 comments

This plugin no longer works on Hopper 4, but there's a pretty easy fix. I'd make a pull request, but this is sloppy (especially the last step) and the author or someone smarter can probably do a better job.

Patches for DYLDSharedCacheLoader.mm:

  • Change the return type of pluginUUID to id to prevent a compiler error.
  • Change the class name to anything that's not DYLDSharedCacheLoader (Hopper has a built-in class with the same name, and it fails to load a plugin with the same name). I just used DYLDSharedCacheLoader2.
  • Add a param returnAdjustFilename:(NSString * _Nullable * _Nullable)newFilename to the end of the extractFromData:usingDetectedFileType:returnAdjustOffset: function to match the new SDK.
  • Add a param ofFileNamed:(nullable NSString *)filename to detectedTypesForData: for the same reason.
  • Add these functions for the same reason:
-(NSArray<NSString*>*)commandLineIdentifiers
{
	return @[];
}
+(int)sdkVersion
{
	return HOPPER_CURRENT_SDK_VERSION;
}

Build the plugin normally with CMake.

Now for the massively horrifying hack: open the main executable of the compiled bundle in a text editor and find+replace all instances of _open to any other 5-character string (I used _xxxx). This is because Hopper checks plugins for certain function calls and blocks them from loading if any are present (ostensibly to improve performance; I think it's probably an anti-crack tactic). There are numerous open() calls in the dyld source code, but none are used by this plugin just including it. There is definitely a better solution than this, but I don't know what it is.

These steps get the plugin working on my system with Hopper 4.5.22, but YMMV. I hope this helps somebody!

junebeetle avatar Jul 21 '20 04:07 junebeetle

Please open a PR as it makes it much easier to discuss the code changes and the maintainers can also make changes directly to your branch.

tmm1 avatar Jul 25 '20 17:07 tmm1

As I said, my fix is a horrible hack, not to mention that I have no idea how to automate the last step. Otherwise I would have.

When I have the time, I may find a better solution and then I will create a pull request.

junebeetle avatar Aug 03 '20 23:08 junebeetle

I understand. I would like to help fix the open hack (a simple preprocessor macro is probably enough), but I don't want to have to recreate your patch from a series of instructions first.

tmm1 avatar Aug 03 '20 23:08 tmm1