Fix windows connection

This commit is contained in:
msciotti 2018-11-08 16:32:58 -08:00
parent d90a8efd47
commit 6796d2ffa9
No known key found for this signature in database
GPG Key ID: 40FADA25CF0EAD84

View File

@ -6,6 +6,7 @@
#define NOIME #define NOIME
#include <assert.h> #include <assert.h>
#include <windows.h> #include <windows.h>
#include <sstream>
int GetProcessId() int GetProcessId()
{ {
@ -32,9 +33,10 @@ static BaseConnectionWin Connection;
bool BaseConnection::Open(int pipe) bool BaseConnection::Open(int pipe)
{ {
wchar_t pipeName[]{L"\\\\?\\pipe\\discord-ipc-0"}; std::wostringstream stream{};
const size_t pipeDigit = sizeof(pipeName) / sizeof(wchar_t) - 2; stream << L"\\\\?\\pipe\\discord-ipc-" << pipe;
pipeName[pipeDigit] = sprintf(L"%d", pipe); std::wstring asString = stream.str();
const WCHAR* pipeName = asString.c_str();
auto self = reinterpret_cast<BaseConnectionWin*>(this); auto self = reinterpret_cast<BaseConnectionWin*>(this);
for (;;) { for (;;) {
self->pipe = ::CreateFileW( self->pipe = ::CreateFileW(