From a33e3d105d9a9a8d3de34914e3c63461bf41c099 Mon Sep 17 00:00:00 2001 From: Derek Lesho Date: Mon, 24 Feb 2020 09:47:04 -0600 Subject: [PATCH] lsteamclient: Sync important environment variables before calling CreateInterface. --- lsteamclient/steamclient_main.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lsteamclient/steamclient_main.c b/lsteamclient/steamclient_main.c index be8f62cd..e0eac015 100644 --- a/lsteamclient/steamclient_main.c +++ b/lsteamclient/steamclient_main.c @@ -19,6 +19,8 @@ #include "steamclient_private.h" +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + WINE_DEFAULT_DEBUG_CHANNEL(steamclient); char g_tmppath[PATH_MAX]; @@ -41,6 +43,33 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved) return TRUE; } +void sync_environment(void) +{ + static const char *steamapi_envs[] = + { + "SteamAppId", + "IgnoreChildProcesses", + }; + + char value[32767]; + + for (unsigned int i = 0; i < ARRAY_SIZE(steamapi_envs); i++) + { + if (!GetEnvironmentVariableA(steamapi_envs[i], value, ARRAY_SIZE(value))) + { + if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) + { + TRACE("unsetenv(\"%s\")\n", steamapi_envs[i]); + unsetenv(steamapi_envs[i]); + } + continue; + } + + TRACE("setenv(\"%s\", \"%s\", 1)\n", steamapi_envs[i], value); + setenv(steamapi_envs[i], value, 1); + } +} + /* returns the number of bytes written to dst, not including the NUL terminator */ unsigned int steamclient_unix_path_to_dos_path(bool api_result, const char *src, char *dst, uint32 dst_bytes, int is_url) { @@ -423,6 +452,8 @@ static int load_steamclient(void) { char path[PATH_MAX], resolved_path[PATH_MAX]; + sync_environment(); + if(steamclient_lib) return 1;