GithubHelp home page GithubHelp logo

Comments (2)

kirb avatar kirb commented on June 16, 2024

%init; or %init(); with no group name implies initialising _ungrouped. Groups can’t override each other — actually you can have a hook for the same method in multiple groups and they will be applied in the order you init them. Nothing is overridden on Logos’ level; it’s just allowing you to control exactly where in the program Logos places the calls to Substrate to create the hooks.

Running Logos directly or checking for the processed Logos output under .theos/obj/arm64/Tweak.x.m might help you to understand what exactly Logos is doing and if it might be an issue on our side. See my example below.


Logos input
%hook Thing
- (id)description { returm @"Thing"; }
- (NSInteger)florps { return 5; }
%end

%group MyGroup
%hook Thing
- (id)description { return [%orig stringByAppendingString:@" (of doom)"]; }
- (id)anotherThing { return nil; }
%end
%end

BOOL something = YES;

%ctor {
        %init;
        if (something) {
                %init(MyGroup);
        }
}
Logos output (Simplified for readability)
#include <substrate.h>

@class Thing;

static id (*_logos_orig$_ungrouped$Thing$description)(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL);
static id _logos_method$_ungrouped$Thing$description(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL);
static NSInteger (*_logos_orig$_ungrouped$Thing$florps)(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL);
static NSInteger _logos_method$_ungrouped$Thing$florps(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL); 

static id _logos_method$_ungrouped$Thing$description(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) { returm @"Thing"; }
static NSInteger _logos_method$_ungrouped$Thing$florps(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) { return 5; }

static id (*_logos_orig$MyGroup$Thing$description)(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL);
static id _logos_method$MyGroup$Thing$description(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL);
static id (*_logos_orig$MyGroup$Thing$anotherThing)(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL);
static id _logos_method$MyGroup$Thing$anotherThing(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST, SEL); 

static id _logos_method$MyGroup$Thing$description(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) { return [_logos_orig$MyGroup$Thing$description(self, _cmd) stringByAppendingString:@" (of doom)"]; }
static id _logos_method$MyGroup$Thing$anotherThing(_LOGOS_SELF_TYPE_NORMAL Thing* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) { return nil; }

BOOL something = YES;

static __attribute__((constructor)) void _logosLocalCtor_36cf86a9(int __unused argc, char __unused **argv, char __unused **envp) {
	{
		Class _logos_class$_ungrouped$Thing = objc_getClass("Thing");
		MSHookMessageEx(_logos_class$_ungrouped$Thing, @selector(description), (IMP)&_logos_method$_ungrouped$Thing$description, (IMP*)&_logos_orig$_ungrouped$Thing$description);
		MSHookMessageEx(_logos_class$_ungrouped$Thing, @selector(florps), (IMP)&_logos_method$_ungrouped$Thing$florps, (IMP*)&_logos_orig$_ungrouped$Thing$florps);
	}
	if (something) {
		{
			Class _logos_class$MyGroup$Thing = objc_getClass("Thing");
			MSHookMessageEx(_logos_class$MyGroup$Thing, @selector(description), (IMP)&_logos_method$MyGroup$Thing$description, (IMP*)&_logos_orig$MyGroup$Thing$description);
			MSHookMessageEx(_logos_class$MyGroup$Thing, @selector(anotherThing), (IMP)&_logos_method$MyGroup$Thing$anotherThing, (IMP*)&_logos_orig$MyGroup$Thing$anotherThing);
		}
	}
}

from logos.

liuxuan30 avatar liuxuan30 commented on June 16, 2024

Hi @kirb, thanks for answering! It turned out that one of my MSHookMessageEx crashed, so it seems the init is overwritten. Deleting the crash code will work like you said.

btw, in my path .theos/obj/debug/arm64, I didn't see a Tweak.x.m like yours, just Tweak.xm.f4523a75.Td and Tweak.xm.f4523a75.o. Did I miss anything? Thank you.

I think this thread can be closed then

from logos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.