summaryrefslogtreecommitdiffhomepage
path: root/src/sst.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-01-06 23:39:21 +0000
committerMichael Smith <mikesmiffy128@gmail.com>2022-01-06 23:39:21 +0000
commit4ed68f73dae9e7621d7d7512b5feb686e9440bb2 (patch)
tree9646293b25a5a49b517d776baccce7ddff52a293 /src/sst.c
parentc3ecdf5caf17825b047e4d8b5d979986cbe380b0 (diff)
Tidy up stubs, make vstdlib a stub, build on Linux
Important note: it doesn't WORK on Linux, and there's tons of warnings and stuff, but it's easier to work on when all the compiler output and whatnot is there.
Diffstat (limited to 'src/sst.c')
-rw-r--r--src/sst.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/src/sst.c b/src/sst.c
index 94e1661..9cf21c2 100644
--- a/src/sst.c
+++ b/src/sst.c
@@ -84,6 +84,9 @@ static const char *VCALLCONV GetStringForSymbol_hook(void *this, int s) {
return ret;
}
+// vstdlib symbol, only currently used in l4d2 but exists everywhere so oh well
+IMPORT void *KeyValuesSystem(void);
+
static bool do_load(ifacefactory enginef, ifacefactory serverf) {
factory_engine = enginef; factory_server = serverf;
#ifndef __linux__
@@ -133,31 +136,15 @@ nc: gamedata_init();
// NOTE: this is technically redundant for early versions but I CBA writing
// a version check; it's easier to just do this unilaterally.
if (GAMETYPE_MATCHES(L4D2)) {
-#ifdef _WIN32
- // XXX: not sure if vstdlib should be done dynamically like this or just
- // another stub like tier0?
- void *vstdlib = GetModuleHandleW(L"vstdlib.dll");
- if (!vstdlib) {
- con_warn("sst: warning: couldn't get vstdlib, won't be able to "
- "prevent nag message\n");
+ void *kvs = KeyValuesSystem();
+ kvsvt = *(void ***)kvs;
+ if (!os_mprot(kvsvt + 4, sizeof(void *), PAGE_READWRITE)) {
+ con_warn("sst: warning: couldn't unprotect KeyValuesSystem "
+ "vtable; won't be able to prevent nag message\n");
goto e;
}
- void *(*KeyValuesSystem)(void) = (void *(*)(void))os_dlsym(vstdlib,
- "KeyValuesSystem");
- if (KeyValuesSystem) {
- void *kvs = KeyValuesSystem();
- kvsvt = *(void ***)kvs;
- if (!os_mprot(kvsvt + 4, sizeof(void *), PAGE_READWRITE)) {
- con_warn("sst: warning: couldn't unprotect KeyValuesSystem "
- "vtable; won't be able to prevent nag message\n");
- goto e;
- }
- orig_GetStringForSymbol = (GetStringForSymbol_func)hook_vtable(
- kvsvt, 4, (void *)GetStringForSymbol_hook);
- }
-#else
-#warning TODO(linux) suitably abstract this stuff to Linux!
-#endif
+ orig_GetStringForSymbol = (GetStringForSymbol_func)hook_vtable(kvsvt,
+ 4, (void *)GetStringForSymbol_hook);
}
e: con_colourmsg(RGBA(64, 255, 64, 255),