Compare commits

..

No commits in common. "9f1a9de3d748683e6d0e71805adf0130642f2689" and "08feef776b8b8e29e082e568bf631d1cd2684b9f" have entirely different histories.

10 changed files with 68 additions and 90 deletions

View File

@ -13,13 +13,13 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: dependencies - name: dependencies
run: sudo apt-get update && sudo apt-get install gcc-mingw-w64 make run: sudo apt-get update && sudo apt-get install gcc-mingw-w64 make
- name: make - name: make
run: make run: make
- name: artifact - name: artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: bridge name: bridge
path: build path: build

View File

@ -5,10 +5,7 @@
"includePath": [ "includePath": [
"${workspaceFolder}/**" "${workspaceFolder}/**"
], ],
"defines": [ "defines": [],
"GIT_COMMIT",
"GIT_BRANCH"
],
"cStandard": "c17", "cStandard": "c17",
"cppStandard": "gnu++17", "cppStandard": "gnu++17",
"intelliSenseMode": "windows-gcc-x64" "intelliSenseMode": "windows-gcc-x64"

View File

@ -1,10 +1,7 @@
C_SOURCES = $(shell find ./ -type f -name '*.c') C_SOURCES = $(shell find ./ -type f -name '*.c')
C_OBJECTS = $(C_SOURCES:.c=.o) C_OBJECTS = $(C_SOURCES:.c=.o)
GIT_COMMIT = $(shell git rev-parse --short HEAD) CFLAGS = -std=c17 -Wno-int-conversion
GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
CFLAGS = -std=c17 -Wno-int-conversion -DGIT_COMMIT='"$(GIT_COMMIT)"' -DGIT_BRANCH='"$(GIT_BRANCH)"'
LFLAGS = -lgdi32 LFLAGS = -lgdi32
# DBGFLAGS = -Wl,--export-all-symbols -g -O0 -ggdb3 -Wall # DBGFLAGS = -Wl,--export-all-symbols -g -O0 -ggdb3 -Wall

View File

@ -282,53 +282,41 @@ void ConnectToSocket(int fd)
print("IPC directory: %s\n", runtime); print("IPC directory: %s\n", runtime);
/* TODO: check for multiple discord instances and create a pipe for each */ /* TODO: check for multiple discord instances and create a pipe for each */
const char *discordUnixSockets[] = { const char *discordUnixPipes[] = {
"%s/discord-ipc-%d", "/discord-ipc-0",
"%s/app/com.discordapp.Discord/discord-ipc-%d", "/snap.discord/discord-ipc-0",
"%s/.flatpak/dev.vencord.Vesktop/xdg-run/discord-ipc-%d", "/app/com.discordapp.Discord/discord-ipc-0",
"%s/snap.discord/discord-ipc-%d",
"%s/snap.discord-canary/discord-ipc-%d",
}; };
struct sockaddr_un socketAddr; struct sockaddr_un socketAddr;
socketAddr.sun_family = AF_UNIX; socketAddr.sun_family = AF_UNIX;
char *pipePath = NULL;
int sockRet = -1;
int sockRet = 0; for (int i = 0; i < sizeof(discordUnixPipes) / sizeof(discordUnixPipes[0]); i++)
for (int i = 0; i < sizeof(discordUnixSockets) / sizeof(discordUnixSockets[0]); i++)
{ {
size_t pipePathLen = strlen(runtime) + strlen(discordUnixSockets[i]) + 1; pipePath = malloc(strlen(runtime) + strlen(discordUnixPipes[i]) + 1);
char *pipePath = malloc(pipePathLen); strcpy(pipePath, runtime);
strcat(pipePath, discordUnixPipes[i]);
strcpy_s(socketAddr.sun_path, sizeof(socketAddr.sun_path), pipePath);
for (int j = 0; j < 16; j++) print("Connecting to %s\n", pipePath);
if (IsLinux)
{ {
snprintf(pipePath, pipePathLen, discordUnixSockets[i], runtime, j); unsigned long socketArgs[] = {
strcpy_s(socketAddr.sun_path, sizeof(socketAddr.sun_path), pipePath); (unsigned long)fd,
print("Probing %s\n", pipePath); (unsigned long)(intptr_t)&socketAddr,
sizeof(socketAddr)};
if (IsLinux) sockRet = sys_socketcall(SYS_CONNECT, socketArgs);
{
unsigned long socketArgs[] = {
(unsigned long)fd,
(unsigned long)(intptr_t)&socketAddr,
sizeof(socketAddr)};
sockRet = sys_socketcall(SYS_CONNECT, socketArgs);
}
else
sockRet = sys_connect(fd, (caddr_t)&socketAddr, sizeof(socketAddr));
print(" error: %d\n", sockRet);
if (sockRet >= 0)
break;
} }
else
sockRet = sys_connect(fd, (caddr_t)&socketAddr, sizeof(socketAddr));
if (sockRet >= 0)
{
print("Connecting to %s\n", pipePath);
free(pipePath);
break;
}
free(pipePath); free(pipePath);
if (sockRet >= 0)
break;
} }
if (sockRet < 0) if (sockRet < 0)

View File

@ -3,7 +3,7 @@
<assemblyIdentity <assemblyIdentity
version="1.0.0.0" version="1.0.0.0"
processorArchitecture="amd64" processorArchitecture="amd64"
name="com.enderice2.rpc-bridge" name="EnderIce2.rpc-bridge"
type="win32" type="win32"
/> />
<description>Simple bridge that allows you to use Discord Rich Presence with Wine games/software.</description> <description>Simple bridge that allows you to use Discord Rich Presence with Wine games/software.</description>

View File

@ -21,10 +21,10 @@ TEMP_PATH="$XDG_RUNTIME_DIR"
TEMP_PATH=${TEMP_PATH:-"$TMPDIR"} TEMP_PATH=${TEMP_PATH:-"$TMPDIR"}
VESSEL_PATH="$BRIDGE_PATH" VESSEL_PATH="$BRIDGE_PATH"
IPC_PATHS="$TEMP_PATH /run/user/$UID $TEMP_PATH/app/com.discordapp.Discord $TEMP_PATH/.flatpak/dev.vencord.Vesktop/xdg-run $TEMP_PATH/snap.discord $TEMP_PATH/snap.discord-canary" IPC_PATHS="$TEMP_PATH /run/user/$UID $TEMP_PATH/snap.discord $TEMP_PATH/app/com.discordapp.Discord"
for discord_ipc in $IPC_PATHS; do for discord_ipc in $IPC_PATHS; do
if [ -S "$discord_ipc"/discord-ipc-? ]; then if [ -S "$discord_ipc"/discord-ipc-0 ]; then
VESSEL_PATH="$BRIDGE_PATH:$(echo "$discord_ipc"/discord-ipc-?)" VESSEL_PATH="$BRIDGE_PATH:$(echo "$discord_ipc"/discord-ipc-0)"
break break
fi fi
done done

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

13
gui.c
View File

@ -191,14 +191,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case IDM_HELP_ABOUT: case IDM_HELP_ABOUT:
{ {
char msg[256]; char msg[256];
snprintf(msg, sizeof(msg), sprintf(msg, "rpc-bridge v%s\n\n"
"rpc-bridge v%s\n" "Simple bridge that allows you to use Discord Rich Presence with Wine games/software.\n\n"
" branch: %s\n" "Created by EnderIce2\n\n"
" commit: %s\n\n" "Licensed under the MIT License",
"Simple bridge that allows you to use Discord Rich Presence with Wine games/software.\n\n" VER_VERSION_STR);
"Created by EnderIce2\n\n"
"Licensed under the MIT License",
VER_VERSION_STR, GIT_BRANCH, GIT_COMMIT);
MessageBox(NULL, msg, "About", MB_OK); MessageBox(NULL, msg, "About", MB_OK);
break; break;
} }

61
main.c
View File

@ -273,38 +273,38 @@ void HandleArguments(int argc, char *argv[])
} }
else if (strcmp(argv[1], "--version") == 0) else if (strcmp(argv[1], "--version") == 0)
{ {
/* Already shows the version */ printf("%s\n", VER_VERSION_STR);
ExitProcess(0); ExitProcess(0);
} }
else if (strcmp(argv[1], "--help") == 0) else if (strcmp(argv[1], "--help") == 0)
{ {
print("Usage:\n" printf("Usage:\n"
" %s [args]\n" " %s [args]\n"
"\n" "\n"
"Arguments:\n" "Arguments:\n"
" --help Show this help\n" " --help Show this help\n"
"\n" "\n"
" --version Show version\n" " --version Show version\n"
"\n" "\n"
" --install Install service\n" " --install Install service\n"
" This will copy the binary to C:\\windows\\bridge.exe and register it as a service\n" " This will copy the binary to C:\\windows\\bridge.exe and register it as a service\n"
"\n" "\n"
" --uninstall Uninstall service\n" " --uninstall Uninstall service\n"
" This will remove the service and delete C:\\windows\\bridge.exe\n" " This will remove the service and delete C:\\windows\\bridge.exe\n"
"\n" "\n"
" --steam Reserved for Steam\n" " --steam Reserved for Steam\n"
" This will start the service and exit (used with bridge.sh)\n" " This will start the service and exit (used with bridge.sh)\n"
"\n" "\n"
" --no-service Do not run as service\n" " --no-service Do not run as service\n"
" (only for --steam)\n" " (only for --steam)\n"
"\n" "\n"
" --service Reserved for service\n" " --service Reserved for service\n"
"\n" "\n"
" --rpc <dir> Set RPC_PATH environment variable\n" " --rpc <dir> Set RPC_PATH environment variable\n"
" This is used to specify the directory where 'discord-ipc-0' is located\n" " This is used to specify the directory where 'discord-ipc-0' is located\n"
"\n" "\n"
"Note: If no arguments are provided, the GUI will be shown instead\n", "Note: If no arguments are provided, the GUI will be shown instead\n",
argv[0]); argv[0]);
ExitProcess(0); ExitProcess(0);
} }
} }
@ -316,12 +316,11 @@ int main(int argc, char *argv[])
g_logFile = fopen(logFilePath, "w"); g_logFile = fopen(logFilePath, "w");
if (g_logFile == NULL) if (g_logFile == NULL)
{ {
MessageBox(NULL, "Failed to open logs file", "Error", MB_OK | MB_ICONERROR); printf("Failed to open logs file: %ld\n",
printf("Failed to open logs file: %ld\n", GetLastError()); GetLastError());
ExitProcess(1); ExitProcess(1);
} }
print("rpc-bridge v%s %s-%s\n", VER_VERSION_STR, GIT_BRANCH, GIT_COMMIT);
if (argc > 1) if (argc > 1)
HandleArguments(argc, argv); HandleArguments(argc, argv);
else else

View File

@ -5,5 +5,5 @@
#define IDM_HELP_ABOUT 40003 #define IDM_HELP_ABOUT 40003
#define IDM_VIEW_LOG 40004 #define IDM_VIEW_LOG 40004
#define VER_VERSION 1, 3, 0, 0 #define VER_VERSION 1, 2, 0, 0
#define VER_VERSION_STR "1.3\0" #define VER_VERSION_STR "1.2\0"