Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Test Subject
Original Poster
#1 Old 31st Dec 2019 at 9:14 AM
Default Injecting into an injected method?
Quick question... I have to inject into a method for my mod, but I know a few other mods also inject into that same method. What happens if two mods inject different things into the same method? Does one wrap the other? Is one of the injections overriden? What should I do to prevent any sort of collisions?
Advertisement
Lab Assistant
#2 Old 1st Jan 2020 at 8:08 PM
Hey! Injecting is in fact wrapping, not modifying the actual function. Your function goes around the original function and then takes place of it so the game runs the modified wrapped function first (then you run the original function inside your injecting function). When you wrap ("inject") a function, each wrapping adds a layer that runs before the actual original function is reached. The layers are actually other mods potentially wrapping your injecting function or you wrapping some other mods injecting function. It's all perfectly safe if done properly.

What's not safe are insecure injections. Some mods might wrap functions without returning the original result, some might change passed arguments in such a way that might break your injection, some might cause errors that the game itself doesn't experience, and some might not even run the original function. It's not your fault, but it might completely break your mod and there's nothing you can do about it. And you might be doing it yourself without even thinking about it. Inject responsibly, kids.

EDIT: Just to add to this, there are "injections" of class methods, static methods, or functions (the above statement is actually about in-class methods). I assume you're speaking about the typical injection using an injector, since the other "injections" sometimes are done as overrides instead.
Guest
#3 Old 3rd Jan 2020 at 5:55 AM
I agree to the above explanations.
Back to top