-
Notifications
You must be signed in to change notification settings - Fork 34
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
Dynamic class name in %init(<class>=<expr>) and %hook <class> to assume type #43
Comments
Elaborating on this: %hook ClassToHook
-(void)hookedMethod {}
%end
%ctor {
%init(ClassToHook = objc_getClass("aClass"));
} Logos will currently generate the function definition: static void _logos_method$_ungrouped$ClassToHook$hookedMethod(_LOGOS_SELF_TYPE_NORMAL id _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) {} and declarations: @class ClassToHook;
static void (*_logos_orig$_ungrouped$ClassToHook$hookedMethod)(_LOGOS_SELF_TYPE_NORMAL id _LOGOS_SELF_CONST, SEL); static void _logos_method$_ungrouped$ClassToHook$hookedMethod(_LOGOS_SELF_TYPE_NORMAL id _LOGOS_SELF_CONST, SEL); (notice how it still generates the static void _logos_method$_ungrouped$ClassToHook$hookedMethod(_LOGOS_SELF_TYPE_NORMAL ClassToHook* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) {} and declarations: @class ClassToHook;
static void (*_logos_orig$_ungrouped$ClassToHook$hookedMethod)(_LOGOS_SELF_TYPE_NORMAL ClassToHook* _LOGOS_SELF_CONST, SEL); static void _logos_method$_ungrouped$ClassToHook$hookedMethod(_LOGOS_SELF_TYPE_NORMAL ClassToHook* _LOGOS_SELF_CONST, SEL); As would be generated if the class was hooked normally, without being passed into |
@Nosskirneh How exactly is logos supposed to know which class it's supposed to be at compile-time? |
@NSExceptional my examples show the output I believe that logos should generate to resolve this issue, and that this is indeed a bug by the unused |
Ah, my bad. I understand now. |
This is really biting me in the ass right now. @uroboro do you know where exactly I might go to resolve this in Logos? I've been digging around for an hour and can't find it |
I think I've found it, in sub type {
my $self = shift;
if(@_) { $self->{TYPE} = shift; }
# return $self->{TYPE} if $self->{TYPE};
return $self->{NAME}." *";
} Commenting out the 2nd-to-last line as above does the trick. @uroboro If this is the only thing |
TLDR
Specifying the class like
%init([<class>=<expr>, …]);
, results in the hooked object (self
) being left without type to the compiler. I understand that not assuming any class is the most sane thing to do, but I was wondering if it would be possible to automatically set the object to a known type or to one that conforms to a protocol in order to avoid casting.Background
I have a few hooks for iOS 11 and 12 (pre 12.2) that hooks the class
MediaControlsPanelViewController
in a few of my tweaks. In iOS 12.2 however, this class was renamed toMRPlatterViewController
. All properties and methods seems to be the same. Thus, I would like to reuse the code within the hook, like:This works fine, but inside the actual hooked code, the compiler does no longer know which type
self
has.I realize that it's possible to do something like this:
and then in the code cast it to an object that conforms to that protocol:
instead of using
self
. I was wondering if it would be possible to automatically set the object to a known type or to one that conforms to a protocol in order to avoid doing this casting. Ideally this would be done in the%ctor
once instead of once in every hooked method.The text was updated successfully, but these errors were encountered: