Skip to content

Commit

Permalink
lsteamclient: Use GetEnvironmentVariableW() in load_steamclient().
Browse files Browse the repository at this point in the history
CW-Bug-Id: #23142
  • Loading branch information
Paul Gofman authored and ivyl committed Feb 15, 2024
1 parent f2fa9ed commit 5d374bd
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lsteamclient/steamclient_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,18 +304,31 @@ struct w_steam_iface *create_win_interface(const char *name, void *u_iface)
return ret;
}

static BOOL get_env_win(const WCHAR *name, char *value, unsigned int size)
{
DWORD i, env_size;

if (!(env_size = GetEnvironmentVariableW(name, (WCHAR *)value, size / sizeof(WCHAR))) || env_size >= size / sizeof(WCHAR))
return FALSE;

for (i = 0; i <= env_size; ++i)
value[i] = ((WCHAR *)value)[i];

return TRUE;
}

static int load_steamclient(void)
{
char steam_app_id[4096], ignore_child_processes[4096];
struct steamclient_init_params params = {.g_tmppath = temp_path_buffer};

if (!GetEnvironmentVariableA("SteamAppId", steam_app_id, ARRAY_SIZE(steam_app_id)))
params.steam_app_id_unset = GetLastError() == ERROR_ENVVAR_NOT_FOUND;
if (!get_env_win(u"SteamAppId", steam_app_id, sizeof(steam_app_id)))
params.steam_app_id_unset = TRUE;
else
params.steam_app_id = steam_app_id;

if (!GetEnvironmentVariableA("IgnoreChildProcesses", ignore_child_processes, ARRAY_SIZE(ignore_child_processes)))
params.ignore_child_processes_unset = GetLastError() == ERROR_ENVVAR_NOT_FOUND;
if (!get_env_win(u"IgnoreChildProcesses", ignore_child_processes, sizeof(ignore_child_processes)))
params.ignore_child_processes_unset = TRUE;
else
params.ignore_child_processes = ignore_child_processes;

Expand Down

0 comments on commit 5d374bd

Please sign in to comment.