Add --rpc command to manually specify the location of discord-ipc-0

This commit is contained in:
EnderIce2
2024-05-13 02:39:19 +03:00
parent 5d0e6c4026
commit e9f6b969b6
2 changed files with 34 additions and 4 deletions

View File

@ -164,13 +164,26 @@ static inline int sys_connect(int s, caddr_t name, socklen_t namelen)
char *native_getenv(const char *name)
{
static char lpBuffer[512];
DWORD ret = GetEnvironmentVariable("BRIDGE_RPC_PATH", lpBuffer, sizeof(lpBuffer));
if (ret != 0)
return lpBuffer;
if (!IsLinux)
{
char *value = getenv(name);
if (value == NULL)
{
print("Failed to get environment variable: %s\n", name);
return NULL;
/* Use GetEnvironmentVariable as a last resort */
DWORD ret = GetEnvironmentVariable(name, lpBuffer, sizeof(lpBuffer));
if (ret == 0)
{
print("GetEnvironmentVariable(\"%s\", ...) failed: %d\n", name, ret);
return NULL;
}
return lpBuffer;
}
return value;
}