Compare commits

...

2 Commits

Author SHA1 Message Date
EnderIce2
56168a6d3d
Add socket system call constants 2024-01-26 03:35:34 +02:00
EnderIce2
d2b23eb2e8
Check if it's running under Linux 2024-01-26 03:34:00 +02:00
2 changed files with 23 additions and 2 deletions

View File

@ -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))
@ -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",
@ -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)
@ -372,7 +376,7 @@ NewConnection:
(unsigned long)SOCK_STREAM,
0};
int fd = sys_socketcall(1, socketArgs);
int fd = sys_socketcall(SYS_SOCKET, socketArgs);
print("Socket %d created\n", fd);

17
main.c
View File

@ -52,6 +52,23 @@ void DetectWine()
GetErrorMessage(), MB_OK | MB_ICONINFORMATION);
ExitProcess(1);
}
static void(CDECL * wine_get_host_version)(const char **sysname, const char **release);
wine_get_host_version = (void *)GetProcAddress(hNTdll, "wine_get_host_version");
assert(wine_get_host_version);
const char *__sysname;
const char *__release;
wine_get_host_version(&__sysname, &__release);
if (strcmp(__sysname, "Linux") != 0)
{
int result = MessageBox(NULL, "This program is designed for Linux only!\nDo you want to proceed?",
NULL, MB_YESNO | MB_ICONQUESTION);
if (result == IDYES)
return;
else if (result == IDNO)
ExitProcess(1);
}
}
void print(char const *fmt, ...)