diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3cae64e..562801b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -243,7 +243,7 @@ jobs: ls -laR /home/runner/Millennium/build mkdir -p /home/runner/env - cp ./build/user32 /home/runner/env/user32 + cp ./build/libMillennium.so /home/runner/env/libMillennium.so cp ~/.pyenv/versions/3.11.8/lib/libpython3.11.so /home/runner/env/libpython3.11.so cp ./scripts/posix/start_millennium.sh /home/runner/env/start_millennium.sh diff --git a/scripts/posix/start.sh b/scripts/posix/start.sh new file mode 100755 index 00000000..db68a83d --- /dev/null +++ b/scripts/posix/start.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# This function filters out the error message "from LD_PRELOAD cannot be preloaded" from 64 bit executables +# The messages are just failing module side effects and not fatal. +filter_output() { + local pattern='from LD_PRELOAD cannot be preloaded' + while IFS= read -r msg; do + if [[ ! "$msg" =~ $pattern ]]; then + printf '%s\n' "$msg" + fi + done +} + +steam_output() { + while IFS= read -r msg; do + printf '\033[35mSTEAM\033[0m %s\n' "$msg" + done +} + +exec 3>&1 # Save a copy of file descriptor 1 (stdout) so we can restore it later +exec 1> >(filter_output) # Redirect stdout to filter_output + +export STEAM_RUNTIME_LOGGER=0 # On archlinux, this needed to stop stdout from being piped into /dev/null instead of the terminal +export LD_PRELOAD=~/Documents/Millennium/build/libMillennium.so # preload Millennium into Steam + +# Millennium hooks __libc_start_main to initialize itself, which is a function that is called before main. +# Besides that, Millennium does not alter Steam memory and runs completely disjoint. + +bash ~/.steam/steam/steam.sh > >(steam_output) 2>&1 \ No newline at end of file diff --git a/scripts/posix/start_millennium.sh b/scripts/posix/start_millennium.sh deleted file mode 100644 index 17b18fdf..00000000 --- a/scripts/posix/start_millennium.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh - -export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH -STEAM_EXECUTABLE="/usr/bin/steam" - -start_user32() { - echo "Starting user32..." - ./user32 & - USER32_PID=$! -} - -# Define the Steam process ID file -STEAM_PID_FILE="/tmp/steam.pid" - -# Get the PID of the running Steam process -get_steam_pid() { - pgrep -x "steam" -} - -# Start watching for the Steam process to close -watch_steam() { - local pid - pid=$(get_steam_pid) - - if [[ -z "$pid" ]]; then - echo "Steam is not running." - exit 1 - fi - - # Save the PID to a temporary file - echo "$pid" > "$STEAM_PID_FILE" - - # Watch for the process to exit - while [[ -e /proc/$pid ]]; do - sleep 1 - done - - echo "Steam has been closed." - rm -f "$STEAM_PID_FILE" -} - -while true; do - if [ -z "$(pgrep -x steam)" ]; then - echo "Waiting for Steam to start..." - inotifywait -e open "$STEAM_EXECUTABLE" - echo "Steam is now open!" - fi - - # start_user32 - - echo "Waiting for Steam to close..." - - while [ -n "$(pgrep -x steam)" ]; do - inotifywait -e close "$STEAM_EXECUTABLE" >/dev/null 2>&1 - done - - echo "Steam has closed. Killing user32..." - if [ -n "$USER32_PID" ]; then - kill $USER32_PID - wait $USER32_PID 2>/dev/null - fi -done