geokar2006 / ByNameModding

MOVED https://github.com/ByNameModding/BNM-Android
113 stars 34 forks source link

How can I hook a class with <T> operator #34

Closed chiteroman closed 1 year ago

chiteroman commented 1 year ago

I have this class: image

And I want to hook the method "Instance" to get the instance of MobManager. Something like this: TargetableListManagerBase<MobManager>

MobManager is another class which I have already hook it.

Is it possible to do this and get the instance? Thanks.

geokar2006 commented 1 year ago

Just use GetPropertyByName with Mob manager class.

BNM::LoadClass MobManager(OBFUSCATE_BNM(""), OBFUSCATE_BNM("MobManager"));
BNM::Property<void*> MobManager$$Instance = MobManager.GetPropertyByName(OBFUSCATE_BNM("Instance"));

BNM automatically finding methods in parent class if it not found in base.

chiteroman commented 1 year ago

Works like a charm, thank you!