Skip to content

Commit

Permalink
Add socket system call constants
Browse files Browse the repository at this point in the history
  • Loading branch information
EnderIce2 committed Jan 26, 2024
1 parent d2b23eb commit 56168a6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#define __NR_close 6
#define __NR_socketcall 102

#define SYS_SOCKET 1
#define SYS_CONNECT 3

#define O_RDONLY 00

#define likely(expr) (__builtin_expect(!!(expr), 1))
Expand Down Expand Up @@ -136,6 +139,7 @@ void ConnectToSocket(int fd)

print("XDG_RUNTIME_DIR: %s\n", runtime);

/* TODO: check for multiple discord instances and create a pipe for each */
const char *discordUnixPipes[] = {
"/discord-ipc-0",
"/snap.discord/discord-ipc-0",
Expand All @@ -161,7 +165,7 @@ void ConnectToSocket(int fd)
(unsigned long)&socketAddr,
sizeof(socketAddr)};

sockRet = sys_socketcall(3, socketArgs);
sockRet = sys_socketcall(SYS_CONNECT, socketArgs);

free(pipePath);
if (sockRet >= 0)
Expand Down Expand Up @@ -372,7 +376,7 @@ void CreateBridge()
(unsigned long)SOCK_STREAM,
0};

int fd = sys_socketcall(1, socketArgs);
int fd = sys_socketcall(SYS_SOCKET, socketArgs);

print("Socket %d created\n", fd);

Expand Down

0 comments on commit 56168a6

Please sign in to comment.