-
Notifications
You must be signed in to change notification settings - Fork 21
Fix compatibility hash spoofing when plugins are present. #60
Conversation
I have no idea what the linter is complaining about. Those line/column targets don't appear valid to me. edit: LJ fixed this with some dark magic of some sort |
|
Some example logs using a couple of plugins I have lying around. with with |
SQUASH THIS SHIT
375e40e to
c9c80fb
Compare
…he-version-spoofining
|
This sounds like a very hacky way to proceed, especially if we're having to deal with things such as
...But I guess we can't do transpiler magic to just remove NeosModLoader, since the hash is calculated before NML loads? |
Correct, the compatibility hash is calculated before NML is loaded, and Neos does not keep a list of loaded plugins I can use to recalculate after the fact. So the real problem here is how to get the list of plugins. I have two ideas for this I've listed in #58 (comment), and this PR uses the idea that, in my opinion, is the lesser of the evils. The only way to get a non-hacky solution for this would for NML to not be a plugin at all, and to hook into Neos using a more "normal" modloader technique. And at that point we might as well just use a prexisting modloader, like BepinEx. |
| bool otherPluginsPresent = extraAssemblies.Count > 1; | ||
| bool shouldSpoofCompatibility = !otherPluginsPresent || config.Unsafe; | ||
| bool shouldSpoofVersion = !config.AdvertiseVersion && shouldSpoofCompatibility; | ||
| // get all PostX'd assemblies. This is useful, as plugins can't NOT be PostX'd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some plugin authors use external tools to postX their plugins before they are loaded into neos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's either PostX'd or not, and it doesn't matter if it's been done a month ago or seconds ago by neos.
| public class ModLoader | ||
| { | ||
| internal const string VERSION_CONSTANT = "1.11.3"; | ||
| internal const string VERSION_CONSTANT = "1.12.0"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that version bumps should usually just be done by @zkxs directly to the main branch in a commit that also tags it as the v1.12.0 for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're probably right. It'd definitely make the commit log easier to read. I'll start doing that in the future.
l-2-j
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I thoroughly reviewed this, but as it seemed okay and can always be changed later on, 👍
yep, we can always change it later. |
Resolves #58.
This enumerates all loaded assemblies and uses a couple of heuristics to make a very educated guess about which ones are plugins. Those plugins are then used in the compatibility hash calculation.
edit: I'll go into more detail
[module: Description("POSTX_PROCESSED")]marker to filter to just the PostX processed assembliesEngine.ExtraAssemblies. ExtraAssemblies is a list of the loaded plugins, but it only contains their filenames. No path information.