From c6cead45dc8e2deb05caf2a3a2c42b241bb23d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 18 Feb 2020 00:45:22 +0100 Subject: [PATCH] lsteamclient: Reallocate new interface only when linux_side changes. This fixes Batman: AK's Denuvo DRM incorrectly flagging the game as pirated. --- build/makefile_base.mak | 2 ++ lsteamclient/steamclient_main.c | 50 +++++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/build/makefile_base.mak b/build/makefile_base.mak index 1b021355..5ac0fefd 100644 --- a/build/makefile_base.mak +++ b/build/makefile_base.mak @@ -1047,6 +1047,7 @@ $(LSTEAMCLIENT_CONFIGURE_FILES64): $(LSTEAMCLIENT64) $(MAKEFILE_DEP) | $(LSTEAMC -I"../$(TOOLS_DIR64)"/include/ \ -I"../$(TOOLS_DIR64)"/include/wine/ \ -I"../$(TOOLS_DIR64)"/include/wine/windows/ \ + -I"../$(WINE)"/include/ \ -L"../$(TOOLS_DIR64)"/lib64/ \ -L"../$(TOOLS_DIR64)"/lib64/wine/ \ --dll ../$(LSTEAMCLIENT64) && \ @@ -1065,6 +1066,7 @@ $(LSTEAMCLIENT_CONFIGURE_FILES32): $(LSTEAMCLIENT32) $(MAKEFILE_DEP) | $(LSTEAMC -I"../$(TOOLS_DIR32)"/include/ \ -I"../$(TOOLS_DIR32)"/include/wine/ \ -I"../$(TOOLS_DIR32)"/include/wine/windows/ \ + -I"../$(WINE)"/include/ \ -L"../$(TOOLS_DIR32)"/lib/ \ -L"../$(TOOLS_DIR32)"/lib/wine/ \ --dll ../$(LSTEAMCLIENT32) && \ diff --git a/lsteamclient/steamclient_main.c b/lsteamclient/steamclient_main.c index 94dc6a09..be8f62cd 100644 --- a/lsteamclient/steamclient_main.c +++ b/lsteamclient/steamclient_main.c @@ -10,6 +10,7 @@ #include "winnls.h" #include "wine/debug.h" #include "wine/library.h" +#include "wine/list.h" #include "steam_defs.h" #ifdef __linux__ @@ -24,6 +25,8 @@ char g_tmppath[PATH_MAX]; static char *controller_glyphs[512]; /* at least k_EControllerActionOrigin_Count */ +static CRITICAL_SECTION steamclient_cs = { NULL, -1, 0, 0, 0, 0 }; + BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) { TRACE("(%p, %u, %p)\n", instance, reason, reserved); @@ -355,23 +358,58 @@ static const struct { #include "win_constructors_table.dat" }; +struct steamclient_interface +{ + struct list entry; + const char *name; + void *linux_side; + void *interface; +}; + +static struct list steamclient_interfaces = LIST_INIT(steamclient_interfaces); + void *create_win_interface(const char *name, void *linux_side) { + struct steamclient_interface *e; + void *ret = NULL; int i; TRACE("trying to create %s\n", name); - if(!linux_side) + if (!linux_side) return NULL; - for(i = 0; i < sizeof(constructors) / sizeof(*constructors); ++i){ - if(!strcmp(name, constructors[i].iface_version)) - return constructors[i].ctor(linux_side); + EnterCriticalSection(&steamclient_cs); + + LIST_FOR_EACH_ENTRY(e, &steamclient_interfaces, struct steamclient_interface, entry) + { + if (e->linux_side == linux_side && !strcmp(e->name, name)) + { + ret = e->interface; + TRACE("-> %p\n", ret); + goto done; + } } - ERR("Don't recognize interface name: %s\n", name); + for (i = 0; i < sizeof(constructors) / sizeof(*constructors); ++i) + { + if (!strcmp(name, constructors[i].iface_version)) + { + e = HeapAlloc(GetProcessHeap(), 0, sizeof(*e)); + e->name = constructors[i].iface_version; + e->linux_side = linux_side; + e->interface = constructors[i].ctor(linux_side); + list_add_tail(&steamclient_interfaces, &e->entry); - return NULL; + ret = e->interface; + break; + } + } + +done: + LeaveCriticalSection(&steamclient_cs); + if (!ret) ERR("Don't recognize interface name: %s\n", name); + return ret; } static void *steamclient_lib;