Skip to content

Commit

Permalink
lsteamclient: Initialize sockets in load_steamclient().
Browse files Browse the repository at this point in the history
CW-Bug-Id: #23749
  • Loading branch information
Paul Gofman authored and ivyl committed May 23, 2024
1 parent 5cfe529 commit 5a99697
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lsteamclient/Makefile.in
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 15 additions & 0 deletions lsteamclient/steamclient_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "winnls.h"
#include "winuser.h"
#include "winternl.h"
#include "winsock2.h"

#include "steamclient_private.h"

Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -347,6 +354,14 @@ static int load_steamclient(void)
params.ignore_child_processes = ignore_child_processes;

if (STEAMCLIENT_CALL( steamclient_init, &params )) 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;
}

Expand Down

0 comments on commit 5a99697

Please sign in to comment.