From 5a996971d7c62a013afe29ce4fc3db867ad31458 Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Thu, 2 May 2024 12:14:54 -0600 Subject: [PATCH] lsteamclient: Initialize sockets in load_steamclient(). CW-Bug-Id: #23749 --- lsteamclient/Makefile.in | 2 +- lsteamclient/steamclient_main.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lsteamclient/Makefile.in b/lsteamclient/Makefile.in index c4e0c419c..03b809c9a 100644 --- a/lsteamclient/Makefile.in +++ b/lsteamclient/Makefile.in @@ -1,6 +1,6 @@ MODULE = lsteamclient.dll UNIXLIB = lsteamclient.so -IMPORTS = user32 +IMPORTS = user32 ws2_32 EXTRADEFS = -DWINE_NO_LONG_TYPES -DSTEAM_API_EXPORTS -Dprivate=public -Dprotected=public diff --git a/lsteamclient/steamclient_main.c b/lsteamclient/steamclient_main.c index 12c3cb7bf..f5adbb547 100644 --- a/lsteamclient/steamclient_main.c +++ b/lsteamclient/steamclient_main.c @@ -10,6 +10,7 @@ #include "winnls.h" #include "winuser.h" #include "winternl.h" +#include "winsock2.h" #include "steamclient_private.h" @@ -49,6 +50,7 @@ static char temp_path_buffer[TEMP_PATH_BUFFER_LENGTH]; static CRITICAL_SECTION steamclient_cs = { NULL, -1, 0, 0, 0, 0 }; static HANDLE steam_overlay_event; +static BOOL wsa_initialized; BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) { @@ -67,6 +69,11 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) break; case DLL_PROCESS_DETACH: CloseHandle(steam_overlay_event); + if (wsa_initialized) + { + WSACleanup(); + wsa_initialized = FALSE; + } break; } @@ -347,6 +354,14 @@ static int load_steamclient(void) params.ignore_child_processes = ignore_child_processes; if (STEAMCLIENT_CALL( steamclient_init, ¶ms )) return 0; + if (!wsa_initialized) + { + /* Some games depend on winsocks being initialized after initializing Steam API. */ + WSADATA data; + + WSAStartup(0x202, &data); + wsa_initialized = TRUE; + } return 1; }