GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Native hooking improvements by noopsledge · Pull Request #404 · satisfactorymodding/SatisfactoryModLoader

Conversation

@noopsledge

@noopsledge noopsledge commented Dec 8, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  1. Added two new hook types: Vtable and UFunction. These are intended to be used in the cases where compiler optimizations have made the functions un-hookable with the normal methods, e.g. if they have been merged with other (unrelated) functions.
  2. Fixed a crash on Linux when hooking a member function that returns a class.
  3. Fixed various issues when hooking virtual functions when multiple inheritance is involved.

Tests added in a PR here: satisfactorymodding/SMLFeatureTests#3

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
noopsledge added 3 commits December 6, 2025 16:37
@noopsledge
Fix a crash on Linux when hooking a member function that returns a class
a524300
The existing code was following the Windows ABI on all platforms, which
meant that on Linux the parameters were in the wrong order.
@noopsledge
Refactor NativeHookManager to more easily support new hooking types
9091dbb
This removes all code duplication around member and non-member functions
and introduces a generalized HookInvoker that can hook in other ways by
swapping out the backend.
@noopsledge
Implement 2 new native hook types: vtable and UFunction
31afcdb
These are intended to be used in the cases where compiler optimizations
have made the functions un-hookable with the normal methods, e.g. if
they have been merged with other (unrelated) functions.
@github-project-automation github-project-automation Bot added this to Mod Loader (SML), Alpakit, ExampleMod, and Engine Dec 8, 2025
@github-project-automation github-project-automation Bot moved this to 🆕 New in Mod Loader (SML), Alpakit, ExampleMod, and Engine Dec 8, 2025
@noopsledge noopsledge mentioned this pull request Dec 8, 2025
Add tests for native hooking satisfactorymodding/SMLFeatureTests#3
Draft
@Archengius
Archengius self-requested a review December 8, 2025 20:59
Archengius
Archengius previously approved these changes Dec 8, 2025
View reviewed changes

@Archengius Archengius left a comment

Copy link
Copy Markdown
Member

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.

Looks good to me as long as the changes are well tested on both Win64 and Linux

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
noopsledge added 6 commits December 12, 2025 19:14
@noopsledge
Change DebugSymbolName from a dynamically-allocated string to a raw s…
d5a9056
…tring

This is something I wanted to do before, but now I've got an actual
excuse: the next submission will be adding a new handle type, which will
need to store that debug name, and it needs to be as lightweight as
possible.

This technically breaks binary compatibility with vtable and UFunction
hooks, but they haven't reached a release yet so that should be fine. A
backwards-compatible export has been provided for standard hooks.
@noopsledge
Add a new handle API for unsubscribing native hooks
1b8af9c
This is a replacement for the old UNSUBSCRIBE_* macros, which have now
been removed. Unsubscribing is now a lot easier as the handle will
remember the parameters for you, so you don't need to worry about them
when unsubscribing. This will be necessary (instead of just nice to
have) after a future submission which will add new parameters to virtual
hooks that users can't repeat when unsubscribing.

The signature of UnregisterHook on the backends is now locked in,
instead of letting the backend add custom parameters, because the handle
doesn't know about backend-specific stuff. Fortunately none of the
backends have custom parameters so this isn't an issue.
@noopsledge
Fix virtual hooks getting grouped when using different runtime types
c111221
Hooks are grouped by the function pointer that they're hooking. However
with virtual functions you can have the same function pointer resolve to
different functions, depending on the SampleObjectInstance that you give
it. This has been worked around by ensuring that each virtual function
hook has its own HookInvoker. This is mildly less efficient if the same
module hooks the same virtual function multiple times, but that's the
best that we can do.
@noopsledge
Fix issues when mixing inheritance between SampleObjectInstance and M…
37a758c
…ethodReference

If the MethodReference referred to a base class, but
SampleObjectInstance was of a derived type, then the appropriate
adjustment wasn't being applied to the pointer when finding the vtable.

This has been resolved by changing the SampleObjectInstance parameter to
match the class referred to by MethodReference, instead of just using a
void pointer, so that the adjustment will be done for us.
@noopsledge
Refactor TCallScope to remove duplication between the specializations
e3c6f9e
I'm going to be making some changes to that core logic and I didn't want
to have to do it twice...
@noopsledge
Fix for hooks getting the wrong 'this' pointer when multiple inherita…
5410c8e
…nce is involved

Before we could have cases where a hook thought it had a pointer to a
derived class, when it fact it pointed to a base class, so the pointer
was effectively garbage.

Crimes have been committed to make this work in a way that's backwards
compatible, apologies for the pain and suffering this has caused.
@noopsledge
noopsledge dismissed Archengius’s stale review via 5410c8e December 18, 2025 00:22
@noopsledge noopsledge changed the title Implement 2 new native hook types: vtable and UFunction Native hooking improvements Dec 18, 2025
@noopsledge

noopsledge commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

I've updated the PR with a bunch of other bug fixes that we discussed recently. There's one more bug fix which is waiting on the change to AssemblyAnalyzer (satisfactorymodding/AssemblyAnalyzer#1)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@budak7273

budak7273 commented Jun 3, 2026

Copy link
Copy Markdown
Member

Delayed till after 3.12 since we want to give this a close inspection + want to get 3.12 out first

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Archengius Archengius Archengius left review comments

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

Mod Loader (SML), Alpakit, ExampleMod, and Engine
Status: 🆕 New

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@noopsledge @budak7273 @Archengius
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.