Skip to content

Instantly share code, notes, and snippets.

@sadn1ck
Last active January 9, 2022 16:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadn1ck/d68cfdc28067b329bc82e7f80ab0b71e to your computer and use it in GitHub Desktop.
Save sadn1ck/d68cfdc28067b329bc82e7f80ab0b71e to your computer and use it in GitHub Desktop.
Bakkesmod 1.95 (Season 3 Patch) Working on Arch Linux

Bakkesmod on Arch with proton-tkg 6.5

Packages Needed

└❯ pacman -Qs mingw
local/mingw-w64-binutils 2.35.1-1 (mingw-w64-toolchain mingw-w64)
    Cross binutils for the MinGW-w64 cross-compiler
local/mingw-w64-crt 8.0.0-1 (mingw-w64-toolchain mingw-w64)
    MinGW-w64 CRT for Windows
local/mingw-w64-gcc 10.2.0-2 (mingw-w64-toolchain mingw-w64)
    Cross GCC for the MinGW-w64 cross-compiler
local/mingw-w64-headers 8.0.0-1 (mingw-w64-toolchain mingw-w64)
    MinGW-w64 headers for Windows
local/mingw-w64-tools 8.0.0-1 (mingw-w64)
    MinGW-w64 utilities
local/mingw-w64-winpthreads 8.0.0-1 (mingw-w64-toolchain mingw-w64)
    MinGW-w64 winpthreads library

Injector Compiler

  • change include paths according to your system
  • make sure to run bakkesmod atleast once before compiling since it needs the dll (doesnt have to be successful)
  • change path in L115 of inject.cpp as well according to your system
$ x86_64-w64-mingw32-c++ -I/usr/lib/gcc/x86_64-w64-mingw32/10.2.0\;/usr/x86_64-w64-mingw32/lib inject.cpp -municode -std=c++17 -static-libgcc -static-libstdc++ -static -o ../inject.exe

Injector Runner

  • esync or fsync according to your kernel
  • start rocket league via steam and THEN RUN THIS COMMAND
$ WINEESYNC=1 WINEPREFIX=/home/anik/.steam/steam/steamapps/compatdata/252950/pfx/ WINEPATH=/usr/lib/gcc/x86_64-w64-mingw32/10.2.0\;/usr/x86_64-w64-mingw32/lib ~/.steam/steam/compatibilitytools.d/proton_tkg_6.5.r1.g2e42e7d9.release/dist/bin/wine ../inject.exe

Running Bakkesmod

$ WINEESYNC=1 protontricks -c '~/.steam/steam/compatibilitytools.d/proton_tkg_6.5.r1.g2e42e7d9.release/dist/bin/wine /home/anik/Games/bakkeshack/BakkesMod.exe' 252950
#include <windows.h>
#include <tlhelp32.h>
#include <iostream>
#include <string>
#define LOG_LINE(x, msg) std::cout << msg << std::endl;
DWORD GetProcessID64(std::wstring processName)
{
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);
HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (processesSnapshot == INVALID_HANDLE_VALUE)
return 0;
Process32First(processesSnapshot, &processInfo);
if (_wcsicmp(processName.c_str(), processInfo.szExeFile) == 0)
{
BOOL iswow64 = FALSE;
// https://stackoverflow.com/questions/14184137/how-can-i-determine-whether-a-process-is-32-or-64-bit
// If IsWow64Process() reports true, the process is 32-bit running on a
// 64-bit OS So we want it to return false (32 bit on 32 bit os, or 64 bit on
// 64 bit OS, since we build x64 the first condition will never satisfy since
// they can't run this exe)
auto hProcess =
OpenProcess(PROCESS_ALL_ACCESS, FALSE, processInfo.th32ProcessID);
if (hProcess == NULL)
{
LOG_LINE(INFO, "Error on OpenProcess to check bitness");
}
else
{
if (IsWow64Process(hProcess, &iswow64))
{
// LOG_LINE(INFO, "Rocket league process ID is " <<
// processInfo.th32ProcessID << " | " << " has the WOW factor: " <<
// iswow64);
if (!iswow64)
{
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
}
else
{
LOG_LINE(INFO, "IsWow64Process failed bruv " << GetLastError());
}
CloseHandle(hProcess);
}
}
while (Process32Next(processesSnapshot, &processInfo))
{
if (_wcsicmp(processName.c_str(), processInfo.szExeFile) == 0)
{
BOOL iswow64 = FALSE;
auto hProcess =
OpenProcess(PROCESS_ALL_ACCESS, FALSE, processInfo.th32ProcessID);
if (hProcess == NULL)
{
LOG_LINE(INFO, "Error on OpenProcess to check bitness");
}
else
{
if (IsWow64Process(hProcess, &iswow64))
{
// LOG_LINE(INFO, "Rocket league process ID is " <<
// processInfo.th32ProcessID << " | " << " has the WOW factor: " <<
// iswow64);
if (!iswow64)
{
CloseHandle(processesSnapshot);
return processInfo.th32ProcessID;
}
}
else
{
LOG_LINE(INFO, "IsWow64Process failed bruv " << GetLastError());
}
CloseHandle(hProcess);
}
}
// CloseHandle(processesSnapshot);
}
CloseHandle(processesSnapshot);
return 0;
}
int wmain(int argc, wchar_t* argv[])
{
DWORD processID;
while (true)
{
processID = GetProcessID64(L"RocketLeague.exe");
if (processID != 0)
break;
Sleep(100);
}
HANDLE h = OpenProcess(PROCESS_ALL_ACCESS, false, processID);
if (h)
{
LPVOID LoadLibAddr = (LPVOID)GetProcAddress(
GetModuleHandleW(L"kernel32.dll"), "LoadLibraryW");
// auto ws = path.wstring().c_str();
auto ws =
L"/home/anik/.steam/steam/steamapps/compatdata/252950/pfx/drive_c/users/steamuser/Application Data/bakkesmod/bakkesmod/dll/bakkesmod.dll";
auto wslen = (std::wcslen(ws) + 1) * sizeof(WCHAR);
LPVOID dereercomp = VirtualAllocEx(
h, NULL, wslen, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
WriteProcessMemory(h, dereercomp, ws, wslen, NULL);
HANDLE asdc = CreateRemoteThread(
h,
NULL,
NULL,
(LPTHREAD_START_ROUTINE)LoadLibAddr,
dereercomp,
0,
NULL);
WaitForSingleObject(asdc, INFINITE);
DWORD res = 0;
GetExitCodeThread(asdc, &res);
LOG_LINE(INFO, "GetExitCodeThread(): " << (int)res);
LOG_LINE(INFO, "Last error: " << GetLastError());
VirtualFreeEx(h, dereercomp, wslen, MEM_RELEASE);
CloseHandle(asdc);
CloseHandle(h);
return res == 0;
}
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment