mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-05-25 22:14:38 +00:00
Add --rpc command to manually specify the location of discord-ipc-0
This commit is contained in:
parent
5d0e6c4026
commit
e9f6b969b6
15
bridge.c
15
bridge.c
@ -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;
|
||||
}
|
||||
|
23
main.c
23
main.c
@ -259,6 +259,19 @@ void HandleArguments(int argc, char *argv[])
|
||||
RemoveService();
|
||||
ExitProcess(0);
|
||||
}
|
||||
else if (strcmp(argv[1], "--rpc") == 0)
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
print("No directory provided\n");
|
||||
ExitProcess(1);
|
||||
}
|
||||
|
||||
SetEnvironmentVariable("BRIDGE_RPC_PATH", argv[2]);
|
||||
print("BRIDGE_RPC_PATH has been set to \"%s\"\n", argv[2]);
|
||||
CreateBridge();
|
||||
ExitProcess(0);
|
||||
}
|
||||
else if (strcmp(argv[1], "--help") == 0)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
@ -269,17 +282,21 @@ void HandleArguments(int argc, char *argv[])
|
||||
|
||||
printf(" --install Install service\n");
|
||||
printf(" This will copy the binary to C:\\windows\\bridge.exe and register it as a service\n\n");
|
||||
|
||||
printf(" --uninstall Uninstall service\n");
|
||||
|
||||
printf(" This will remove the service and delete C:\\windows\\bridge.exe\n\n");
|
||||
|
||||
printf(" --steam Reserved for Steam\n");
|
||||
|
||||
printf(" This will start the service and exit (used with bridge.sh)\n\n");
|
||||
printf(" --no-service Do not run as service\n");
|
||||
|
||||
printf(" --no-service Do not run as service\n");
|
||||
printf(" (only for --steam)\n\n");
|
||||
|
||||
printf(" --service Reserved for service\n\n");
|
||||
|
||||
printf(" --rpc <dir> Set RPC_PATH environment variable\n");
|
||||
printf(" This is used to specify the directory where 'discord-ipc-0' is located\n\n");
|
||||
|
||||
printf("Note: If no arguments are provided, the GUI will be shown instead\n");
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user