SpecialKO / SpecialK

Lovingly referred to as the Swiss Army Knife of PC gaming, Special K does a bit of everything.
https://www.special-k.info/
GNU General Public License v3.0
718 stars 45 forks source link

Template DLL Plugin #189

Open gir489returns opened 3 days ago

gir489returns commented 3 days ago

There doesn't seem to be a good or accurate depiction of a real SpecialK plugin at least that I can find. All of the ones in the repo are hard dependent on being compiled into/with the project. There also doesn't seem to be very many ways of making a purely abstract DLL, things like toast notifications and interface implementations have to be hard-coded with macros that SpecialK uses, instead of external calls to the actual runtime DLL, this creates the potential for code rot, as instead of making a microservices-like project, you've created a tightly coupled dependency.

cathyjf commented 1 day ago

A Special K plugin is just any DLL that you produce. Special K will load the DLL in such a way as to cause DllMain to be invoked. You'll likely want to spawn a thread in DllMain to do anything interesting. There isn't a simple way to do much interaction with Special K itself from within your plugin, although there are various complicated ways, such as finding the Special K module in the address space of the process and invoking functions that are exported by the Special K module.

Aemony commented 1 day ago

Once upon a time Special K had a proper ABI used by external DLL based plugins but over time that transitioned into becoming a more internal part of the codebase. Instead, the command console was exposed externally at one point, to allow for third-party DLL plugins to engage with Special K's internals.

But most "third-party DLL plugins" are as cathyjf mentioned just normal DllMain based DLLs that SK loads through a normal LoadLibrary call.