From a9a6b756922b32f74c7f00974cffb6c614304022 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 02:51:31 +0100 Subject: [PATCH 01/27] Use x64 mumble by default, this closes #5. --- AUMInjector/user/mumble-link.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUMInjector/user/mumble-link.cpp b/AUMInjector/user/mumble-link.cpp index 46a91f9..0b3ed0c 100644 --- a/AUMInjector/user/mumble-link.cpp +++ b/AUMInjector/user/mumble-link.cpp @@ -8,7 +8,7 @@ LinkedMem* lm = NULL; HANDLE hMapObject = NULL; -std::string mumble_exe = "C:\\Program Files (x86)\\Mumble\\mumble.exe"; +std::string mumble_exe = "C:\\Program Files\\Mumble\\mumble.exe"; // Initializes mumble IPC and RPC From 66f5fcd899d897348c51d13c6561e6c005eda10d Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 02:53:48 +0100 Subject: [PATCH 02/27] Update README.md --- README.md | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 65085cd..93e1d23 100644 --- a/README.md +++ b/README.md @@ -6,26 +6,9 @@ | 2020.9.22s | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `2020922` | | 2020.10.22s | [1.0.0.4](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.4) | `20201022` | -Please ensure that you use the correct version for your game installation. All binaries are 32 bit, because the game ist 32 bit and also the free version of the Detours library cant do 64 bit. However, everything runs fine on a 64 bit system if you set it up as specified. +Please ensure that you use the correct version for your game installation. All binaries are 32 bit, because the game ist 32 bit and also the free version of the Detours library cant do 64 bit. However, everything runs fine on a 64 bit system. -## State of the Project - - - [x] Load into the game using a DLL proxy - - [x] Hook into the game logic - - [x] Extract the player position - - [x] Pass the position to Mumble via the Link API - - [x] Handle mute after death, and unmute at game start - - [x] Handle voting events - - [x] Port to 2020.10.22s - - #### Planned for the next release - - - [ ] Change the default mumble binary path to the x64 one - - [ ] Port to Linux / Proton - - #### Planned for the future - - - [ ] Implement differentiation between multiple lobbies in the same voice channel +## [State of the Project](https://github.com/StarGate01/AmongUs-Mumble/projects/1) ## Installation @@ -33,7 +16,7 @@ Download the latest compatible release from https://github.com/StarGate01/AmongU If you don't have the `Visual C++ Redistributable for Visual Studio 2015` installed, get it from https://www.microsoft.com/en-us/download/details.aspx?id=48145 . Choose the x86 version, even if your PC is 64 bit. -Install Mumble (Tested: Version 1.3.3) if you have not already: https://www.mumble.info/downloads/ . If the path Mumble was installed to is not `C:\Program Files (x86)\Mumble\mumble.exe` (if you installed the 32 bit version), you have to specify it by editing the Steam launch options of Among Us, for example like this: `-m "C:\Program Files\Mumble\mumble.exe"` if you installed the 64 bit version. +Install Mumble (Tested: Version 1.3.3) if you have not already: https://www.mumble.info/downloads/ . If the path Mumble was installed to is not `C:\Program Files\Mumble\mumble.exe` (if you installed the 64 bit version), you have to specify it by editing the Steam launch options of Among Us, for example like this: `-m "C:\Program Files (x86)\Mumble\mumble.exe"` if you installed the 32 bit version on a 64 bit system. In Mumble, the proximity audio options have to be enabled and configured beforehand: - Run `Configure -> Audio Wizard` and configure your Headset From da05e225a737e67e826d64ec11e8d1beb59ac31e Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 03:28:50 +0100 Subject: [PATCH 03/27] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 93e1d23..0f1c667 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ Please ensure that you use the correct version for your game installation. All b ## [State of the Project](https://github.com/StarGate01/AmongUs-Mumble/projects/1) +## Community + +If you are looking for a community that uses this mod, join the Discord server: https://discord.gg/4UkHEJ5sqg ! + ## Installation Download the latest compatible release from https://github.com/StarGate01/AmongUs-Mumble/releases/ , or build it yourself (see below). Drop the `winhttp.dll` file into the same directory as the `Among Us.exe` program (see [this explanation](https://github.com/StarGate01/AmongUs-Mumble/issues/1#issuecomment-723373278) if you are confused). From d8cff8fd4be06ee8a70869155b8667d21338a9bb Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 10:35:09 +0100 Subject: [PATCH 04/27] Update README.md --- README.md | 77 ++++++++----------------------------------------------- 1 file changed, 11 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 0f1c667..ce981ec 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,28 @@ # AmongUs-Mumble -[Mumble VoIP](https://www.mumble.info/) Plugin and mod for the popular game "Among Us" to enable **Proximity and Directional Voice Chat**. Currently only for Windows PCs and the Steam version. On Linux and OSX a small Mumble fake plugin is provided, which just sets your ingame position to `(0, 0)`. +[Mumble VoIP](https://www.mumble.info/) Plugin and mod for the popular game "Among Us" to enable **Proximity and Directional Voice Chat**. + +Currently only for Windows PCs and the Steam version. On Linux and OSX a small Mumble fake plugin is provided, which just sets your ingame position to `(0, 0)`. | Game version | DLL release | GAME_VERSION | | ------------ | ----------------------------------------------------------------------------- | ------------ | | 2020.9.22s | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `2020922` | | 2020.10.22s | [1.0.0.4](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.4) | `20201022` | -Please ensure that you use the correct version for your game installation. All binaries are 32 bit, because the game ist 32 bit and also the free version of the Detours library cant do 64 bit. However, everything runs fine on a 64 bit system. +Please ensure that you use the correct version for your game installation. -## [State of the Project](https://github.com/StarGate01/AmongUs-Mumble/projects/1) +## [Project State](https://github.com/StarGate01/AmongUs-Mumble/projects/1) -## Community +## Documentation + - [Installation and Setup](https://github.com/StarGate01/AmongUs-Mumble/wiki/Installation-and-Setup) + - [Frequently Asked Questions](https://github.com/StarGate01/AmongUs-Mumble/wiki/Frequently-Asked-Questions) + - [How It Works](https://github.com/StarGate01/AmongUs-Mumble/wiki/How-It-Works) + - [Development](https://github.com/StarGate01/AmongUs-Mumble/wiki/Development) + - [Using the POSIX Fake Client](https://github.com/StarGate01/AmongUs-Mumble/wiki/Using-the-POSIX-Fake-Client) If you are looking for a community that uses this mod, join the Discord server: https://discord.gg/4UkHEJ5sqg ! -## Installation - -Download the latest compatible release from https://github.com/StarGate01/AmongUs-Mumble/releases/ , or build it yourself (see below). Drop the `winhttp.dll` file into the same directory as the `Among Us.exe` program (see [this explanation](https://github.com/StarGate01/AmongUs-Mumble/issues/1#issuecomment-723373278) if you are confused). - -If you don't have the `Visual C++ Redistributable for Visual Studio 2015` installed, get it from https://www.microsoft.com/en-us/download/details.aspx?id=48145 . Choose the x86 version, even if your PC is 64 bit. - -Install Mumble (Tested: Version 1.3.3) if you have not already: https://www.mumble.info/downloads/ . If the path Mumble was installed to is not `C:\Program Files\Mumble\mumble.exe` (if you installed the 64 bit version), you have to specify it by editing the Steam launch options of Among Us, for example like this: `-m "C:\Program Files (x86)\Mumble\mumble.exe"` if you installed the 32 bit version on a 64 bit system. - -In Mumble, the proximity audio options have to be enabled and configured beforehand: - - Run `Configure -> Audio Wizard` and configure your Headset - - Enable `Plugins -> Options -> Link to Game and Transmit Position` - - Enable `Plugins -> Plugins -> Link v1.2.0` if its not already (note that the version can differ) - - Enable `Audio Output -> Interface -> Positional Audio` - - Set `Audio Output -> Positional Audio -> Minimum Distance` to 1.0m (lowest setting) - - Set `Audio Output -> Positional Audio -> Maximum Distance` to something between 2m and 6m - or even more, according to your preferences - - Set `Audio Output -> Positional Audio -> Minimum Volume` to 0% (lowest setting) - -Then run the game and observe the output of the console window (if you run the game in full screen, you might want to tab out or switch to windowed mode). Ensure that the mumble binary path is correct. Mumble should notify when the game connects. - If you have any issues or find bugs, report them here: https://github.com/StarGate01/AmongUs-Mumble/issues . -## How it works - -This is a DLL sideloading/hijacking proxy (proxies `winhttp.dll`), which hooks the IL2CPP functions in memory (using the Microsoft Detours library) and exposes the game state to Mumble via shared memory. Originally, I tried a memory-scanning approach (akin to https://github.com/shlifedev/AmongUsMemory/), but this proved to be way to slow. In addition, Mumble is instrumented using RPC commands (for muting and unmuting). - -Your anti-virus might flag this as malware, because some of these methods are also sometimes used by malware. If you dont trust me, read and compile the code for yourself. - -## FAQ - -Who has to install this mod? - - Everyone in the lobby. - -Does this work on mobile (Android / iOS)? - - No. It might however be possible to implement a similar hooking mechanism on rooted / jailbroken devices. This would require a mobile Mumble client which is capable of the Mumble Link API. When all baseline features are implemented, I might look into this. When Among Us eventually becomes open source software, this change of course becomes triveal. - -Does this work on Linux / OSX? - - Not yet. As there is no native build of the game (runs via Proton), the native OS IPC methods cant be used, which complicates the whole thing. But it is planned for the future. - - However, a small fake client is provided, which just sets your ingame position to `(0, 0)`. - -Why are you releasing this codebase? Hackers will use it to ruin the game! - - (1) They already do, I have not invented something totally new here. Maybe try playing only with people you know. (2) Trust in this kind of software can only be achieved by open sourcing it. (3) It might lead to more cool mods by the community. - -Somebody could just turn up the sliders in Mumble and listen to the whole map! - - Yes. This tool is intended to be used by a group of friends who all play fair. - -## Development - -For building, use *Visual Studio Community 2019*. - -Please note that no decompiled source code of the game is provided, instead you must download `Il2CppInspector` and then run `decompile.bat` after adjusting the file locations in the script. This will decompile your own copy of the game. You might have to add `Il2CppInspector` to your PATH. - -A post-build task ist defined in Visual Studio, which calls the file `vmupload.bat`. This script copies the compiled DLL to the Steam game installation directory, and pushes it to a few test VMs. You will probably have to disable or modify it. - -For testing, I recommend setting up a private game server using https://github.com/Impostor/Impostor . - -If you want to build for a specific version of the game (each build uses different obfuscated names), append the preprocessor macro `GAME_VERSION` in the project configuration like this: `GAME_VERSION=2020922`. See the table above for version numbers. - -### Using the POSIX fake client - -The fake client binds to the Mumble Link plugin on Linux and Mac OSX and sets your ingame position to zero. This is not optimal, but better than nothing. - -Install `make` and `g++`, on OSX you can use Homebrew (https://brew.sh). Then open your terminal, change into the `POSIX` directory. Run `make` to build the tool, and `make run` to run it. - ## Thanks to / Sources - https://github.com/djkaty/Il2CppInspector @@ -91,7 +37,6 @@ Install `make` and `g++`, on OSX you can use Homebrew (https://brew.sh). Then op - https://github.com/CLIUtils/CLI11 - https://github.com/TheNullicorn/among-us-api - ## Disclaimer This modification would be detected by any simple anti-cheat engine. At the time of writing, Among Us uses no such technology. However, I am not responsible for any bans or other problems arising from the usage of this mod. From 8b578f7ebff997c981be177c3088726840e30333 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 10:37:03 +0100 Subject: [PATCH 05/27] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ce981ec..a2e0835 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ Currently only for Windows PCs and the Steam version. On Linux and OSX a small M Please ensure that you use the correct version for your game installation. -## [Project State](https://github.com/StarGate01/AmongUs-Mumble/projects/1) +If you are looking for a community that uses this mod, join the Discord server: https://discord.gg/4UkHEJ5sqg ! + +If you have any issues or find bugs, report them here: https://github.com/StarGate01/AmongUs-Mumble/issues . ## Documentation - [Installation and Setup](https://github.com/StarGate01/AmongUs-Mumble/wiki/Installation-and-Setup) @@ -19,9 +21,9 @@ Please ensure that you use the correct version for your game installation. - [Development](https://github.com/StarGate01/AmongUs-Mumble/wiki/Development) - [Using the POSIX Fake Client](https://github.com/StarGate01/AmongUs-Mumble/wiki/Using-the-POSIX-Fake-Client) -If you are looking for a community that uses this mod, join the Discord server: https://discord.gg/4UkHEJ5sqg ! -If you have any issues or find bugs, report them here: https://github.com/StarGate01/AmongUs-Mumble/issues . +## Project State + - [Issues and Planned Features](https://github.com/StarGate01/AmongUs-Mumble/projects/1) ## Thanks to / Sources From c49a1df2cb35ce08ae324f3785df736b5bfc4bd0 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 10:41:44 +0100 Subject: [PATCH 06/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a2e0835..1103cea 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Currently only for Windows PCs and the Steam version. On Linux and OSX a small M | Game version | DLL release | GAME_VERSION | | ------------ | ----------------------------------------------------------------------------- | ------------ | -| 2020.9.22s | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `2020922` | | 2020.10.22s | [1.0.0.4](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.4) | `20201022` | +| 2020.9.22s | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `2020922` | Please ensure that you use the correct version for your game installation. From 3037a3c55049d7b639ddcf32219812b8919e411d Mon Sep 17 00:00:00 2001 From: Alien G Date: Tue, 10 Nov 2020 11:46:15 -0800 Subject: [PATCH 07/27] Updated credits string. Updated .gitignore for future build system and IDE settings folder. --- .gitignore | 5 ++++- AUMInjector/user/main.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 46a8249..895db35 100644 --- a/.gitignore +++ b/.gitignore @@ -361,4 +361,7 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd -tmp \ No newline at end of file +tmp +/cmake-build-release/ +/cmake-build-debug/ +/.idea/ diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index 067edef..4b84b31 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -151,7 +151,14 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) void Run() { NewConsole(); - printf("AmongUs-Mumble mod by StarGate01 (chrz.de)\nCompiled for game version %s\nDLL hosting successful\n\n", version_text); + + printf("AmongUs-Mumble mod by:\n"); + printf("\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features.\n"); + printf("\tAlisenai (Alien): Fixes, More Features.\n"); + printf("\tBillyDaBongo (Billy): Management, Testing.\n"); + + printf("Compiled for game version %s\n", version_text); + printf("DLL hosting successful\n\n"); // Setup mumble int lErrMumble = initMumble(); @@ -184,4 +191,4 @@ void Run() WaitForSingleObject(hExit, INFINITE); closeMumble(); printf("Unloading done\n"); -} \ No newline at end of file +} From 795a76c7482dcb203c62fdc9861cb5320e54ddab Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 Nov 2020 22:33:11 +0100 Subject: [PATCH 08/27] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1103cea..5571b34 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,10 @@ If you have any issues or find bugs, report them here: https://github.com/StarGa - [Development](https://github.com/StarGate01/AmongUs-Mumble/wiki/Development) - [Using the POSIX Fake Client](https://github.com/StarGate01/AmongUs-Mumble/wiki/Using-the-POSIX-Fake-Client) - ## Project State - [Issues and Planned Features](https://github.com/StarGate01/AmongUs-Mumble/projects/1) + - [Release branch](https://github.com/StarGate01/AmongUs-Mumble/tree/master) + - [Development branch](https://github.com/StarGate01/AmongUs-Mumble/tree/dev) ## Thanks to / Sources From d9dcb8c3113fd4fe86d1ce767783d2d76facc6de Mon Sep 17 00:00:00 2001 From: Alien G Date: Tue, 10 Nov 2020 22:35:31 -0800 Subject: [PATCH 09/27] Added a logging system. Currently supports: - Optionally, log to a file. - Verbosity level - Works with operator<< / std::hex / std::endl / etc - Log code (info / warning / error / etc) Added player position heartbeat to let users know it's finding their position. --- AUMInjector/AUMInjector.vcxproj | 2 + AUMInjector/AUMInjector.vcxproj.filters | 6 ++ AUMInjector/framework/helpers.cpp | 19 ----- AUMInjector/user/LoggingSystem.cpp | 103 ++++++++++++++++++++++++ AUMInjector/user/LoggingSystem.h | 89 ++++++++++++++++++++ AUMInjector/user/main.cpp | 51 +++++++----- vmupload.bat | 3 +- 7 files changed, 233 insertions(+), 40 deletions(-) create mode 100644 AUMInjector/user/LoggingSystem.cpp create mode 100644 AUMInjector/user/LoggingSystem.h diff --git a/AUMInjector/AUMInjector.vcxproj b/AUMInjector/AUMInjector.vcxproj index ef0fb7f..6070561 100644 --- a/AUMInjector/AUMInjector.vcxproj +++ b/AUMInjector/AUMInjector.vcxproj @@ -13,6 +13,7 @@ + @@ -32,6 +33,7 @@ + diff --git a/AUMInjector/AUMInjector.vcxproj.filters b/AUMInjector/AUMInjector.vcxproj.filters index 26e1791..33a2dfe 100644 --- a/AUMInjector/AUMInjector.vcxproj.filters +++ b/AUMInjector/AUMInjector.vcxproj.filters @@ -30,6 +30,9 @@ Quelldateien + + Quelldateien + @@ -74,6 +77,9 @@ Headerdateien + + Headerdateien + diff --git a/AUMInjector/framework/helpers.cpp b/AUMInjector/framework/helpers.cpp index 9e376c5..d04c9f4 100644 --- a/AUMInjector/framework/helpers.cpp +++ b/AUMInjector/framework/helpers.cpp @@ -13,22 +13,3 @@ extern const LPCWSTR LOG_FILE; uintptr_t GetBaseAddress() { return (uintptr_t) GetModuleHandleW(L"GameAssembly.dll"); } - -// Helper function to append text to a file -void LogWrite(std::string text) { - HANDLE hfile = CreateFileW(LOG_FILE, FILE_APPEND_DATA, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - - if (hfile == INVALID_HANDLE_VALUE) - MessageBoxW(0, L"Could not open log file", 0, 0); - - DWORD written; - WriteFile(hfile, text.c_str(), (DWORD) text.length(), &written, NULL); - WriteFile(hfile, "\r\n", 2, &written, NULL); - CloseHandle(hfile); -} - -// Helper function to open a new console window and redirect stdout there -void NewConsole() { - AllocConsole(); - freopen_s((FILE**) stdout, "CONOUT$", "w", stdout); -} \ No newline at end of file diff --git a/AUMInjector/user/LoggingSystem.cpp b/AUMInjector/user/LoggingSystem.cpp new file mode 100644 index 0000000..b83b805 --- /dev/null +++ b/AUMInjector/user/LoggingSystem.cpp @@ -0,0 +1,103 @@ +#include "LoggingSystem.h" +#include + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include "helpers.h" + +// Global externs for the logging system +LoggingSystem logger; +DevNullLogger devNullLogger; + +LoggingSystem::LoggingSystem() : std::ostream(this) +{ + // Open a console (to log to) + AllocConsole(); + freopen_s((FILE **) stdout, "CONOUT$", "w", stdout); +} + +LoggingSystem::~LoggingSystem() +{ + // Close the file, if needed + if (logToFile) + logFile.close(); +} + +// Enables logging to file +void LoggingSystem::EnableFileLogging() +{ + // Only open the file if not already opened + if (!logToFile) + { + logToFile = true; + + // Open the log file, based on the pre-defined location + // Placement new because std::ofstream is NOT copyable + new(&logFile) std::ofstream(LOGGING_FILE, std::ios::out); + + // Failed to open the log file + if (!logFile.is_open()) + { + // Don't log to file, something went wrong + Log("Could not initalize the log file - will not log to file", LOG_CODE::LOG_CODE_WARNING); + logToFile = false; + } + } +} + +// Sets the max verbosity to print (anything above will not be printed) +void LoggingSystem::SetVerbosity(LOG_CODE verbosity) +{ + this->verbosity = verbosity; +} + +void LoggingSystem::LogCode(LOG_CODE logCode) +{ + // Print to console + std::cout << "[" + logPrefixes[(unsigned) logCode] + "] "; + + // Log to file (optionally) + if (logToFile) + logFile << "[" + logPrefixes[(unsigned) logCode] + "] "; +} + +// Implemented for operator<< to work (from the inherited class) +int LoggingSystem::overflow(int c) +{ + // Print to console + std::cout.put((char)c); + + // Log to file (optionally) + if (logToFile) + logFile << (char)c; //Would use "logFile.put(c);", but it has edge cases + return 0; +} + +void LoggingSystem::Log(std::string message, LOG_CODE logCode, bool addNewLine) +{ + // Don't log due to set verbosity level + if (logCode > verbosity) return; + + // Log the given code (in the right format) + LogCode(logCode); + + // Log to console + std::cout << message << std::endl; + + // Log to file + if (logToFile) + logFile << message << std::endl; +} + +// Sets up the logging system for operator<< +std::ostream &LoggingSystem::BeginLog(LOG_CODE logCode) +{ + // Return the null logger so the chained operators don't have any effect + if (logCode > verbosity) return devNullLogger; + + // Prints the log and returns a reference to the extern + LogCode(logCode); + return *this; +} diff --git a/AUMInjector/user/LoggingSystem.h b/AUMInjector/user/LoggingSystem.h new file mode 100644 index 0000000..b305f0b --- /dev/null +++ b/AUMInjector/user/LoggingSystem.h @@ -0,0 +1,89 @@ +#include +#include +#include + +// File to use for logging messages from the logging system +#define LOGGING_FILE "ProximityLogFile.txt" + +enum class LOG_CODE +{ + // Something went wrong + LOG_CODE_ERROR = 3, + ERR = 3, + // Something bad may have happened + LOG_CODE_WARNING = 2, + WRN = 2, + // Information about what's happening + LOG_CODE_INFO = 1, + INF = 1, + // Telling the user something + LOG_CODE_MESSAGE = 0, + MSG = 0, + // Verbose output + LOG_CODE_DEBUG = 4, + DBG = 4, + // Enum length + COUNT +}; + + +// Logging system that is similar to /dev/null +// Used when no output is desired (used by the LoggingSystem) +class DevNullLogger : public std::streambuf, public std::ostream +{ +private: + int overflow(int c) + { return 0; } + +public: + DevNullLogger() : std::ostream(this) + {} +}; + + +class LoggingSystem : public std::streambuf, public std::ostream +{ +private: + // Lookup tabe to be used with the LOG_CODE enum for message prefixes + std::string logPrefixes[(unsigned) LOG_CODE::COUNT] = { + "ERR", "WRN", "INF", "MSG", "DBG" + }; + + // If the logging system log to a file + bool logToFile = false; + + // Output log file + std::ofstream logFile; + + // Verbosity level, anything above will not be logged + LOG_CODE verbosity = LOG_CODE::DBG; + + // Prints the string for the code to the log (and possibly the file) + void LogCode(LOG_CODE logCode); + + // Implemented for operator<< to work (from the inherited class) + int overflow(int c); + +public: + // Opens a console to prepare for logging + LoggingSystem(); + + // Closes the file, if needed + ~LoggingSystem(); + + // Enables logging to file + void EnableFileLogging(); + + // Sets the max verbosity to print (anything above will not be printed) + void SetVerbosity(LOG_CODE verbosity); + + // Logs a message to the console window, defaults to a message log type + void Log(std::string message, LOG_CODE logCode = LOG_CODE::MSG, bool addNewLine = true); + + // Sets up the logging system for operator<< + std::ostream &BeginLog(LOG_CODE logCode); +}; + +// Global extern logging system +extern LoggingSystem logger; +extern DevNullLogger devNullLogger; diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index 4b84b31..c542217 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -9,6 +9,7 @@ #include "helpers.h" #include #include "mumble-link.h" +#include #define GAME_VERSION_2020_9_22s 2020922 #define GAME_VERSION_2020_10_22s 20201022 @@ -62,6 +63,10 @@ float cache_x = 0.0f; float cache_y = 0.0f; bool voting = false; InnerNetClient_GameState__Enum last_game_state = InnerNetClient_GameState__Enum_Joined; +// Ints for tracking when to print the position +int frameCounter = 0; +const int timeToPrintPosition = 25; + // Fixed loop for a player object, but only get called when a player moves void PlayerControl_FixedUpdate_Hook(PlayerControl* __this, MethodInfo* method) @@ -84,7 +89,7 @@ void PlayerControl_Die_Hook(PlayerControl* __this, Player_Die_Reason__Enum reaso if (__this->fields.LightPrefab != nullptr) { - printf("You died\n"); + logger.Log("You died\n"); muteMumble(true); } } @@ -93,7 +98,7 @@ void PlayerControl_Die_Hook(PlayerControl* __this, Player_Die_Reason__Enum reaso void MeetingHud_Close_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Close_Trampoline(__this, method); - printf("Meeting ended\n"); + logger.Log("Meeting ended\n"); voting = false; } @@ -101,7 +106,7 @@ void MeetingHud_Close_Hook(MeetingHud* __this, MethodInfo* method) void MeetingHud_Start_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Start_Trampoline(__this, method); - printf("Meeting started\n"); + logger.Log("Meeting started\n"); voting = true; } @@ -115,7 +120,7 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) (__this->fields.GameState == InnerNetClient_GameState__Enum_Joined || __this->fields.GameState == InnerNetClient_GameState__Enum_Ended)) { - printf("Game joined or ended\n"); + logger.Log("Game joined or ended\n"); muteMumble(false); } last_game_state = __this->fields.GameState; @@ -143,6 +148,13 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) lm->fCameraPosition[0] = cache_x; lm->fAvatarPosition[2] = cache_y; lm->fCameraPosition[2] = cache_y; + + if (++frameCounter > timeToPrintPosition) + { + frameCounter = 0; + // Log the current player position to let the player know it is working + logger.BeginLog(LOG_CODE::INF) << "Current Position: (" << cache_x << ", " << cache_y << ")" << std::endl; + } } } } @@ -150,30 +162,31 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) // Entrypoint of the injected thread void Run() { - NewConsole(); + // Enable logging to file so we can debug user problems easier in the future + logger.EnableFileLogging(); - printf("AmongUs-Mumble mod by:\n"); - printf("\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features.\n"); - printf("\tAlisenai (Alien): Fixes, More Features.\n"); - printf("\tBillyDaBongo (Billy): Management, Testing.\n"); + logger.Log("AmongUs-Mumble mod by:", LOG_CODE::MSG); + logger.Log("\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features.", LOG_CODE::MSG); + logger.Log("\tAlisenai (Alien): Fixes, More Features.", LOG_CODE::MSG); + logger.Log("\tBillyDaBongo (Billy): Management, Testing.", LOG_CODE::MSG); - printf("Compiled for game version %s\n", version_text); - printf("DLL hosting successful\n\n"); + logger.BeginLog(LOG_CODE::MSG) << "Compiled for game version" << version_text << std::endl; + logger.Log("DLL hosting successful", LOG_CODE::INF); // Setup mumble int lErrMumble = initMumble(); if (lErrMumble == NO_ERROR) { - printf("Mumble link init successful\n"); - printf("Mumble exe: %s\n", mumble_exe.c_str()); + logger.Log("Mumble link init successful", LOG_CODE::INF); + logger.Log("Mumble exe: " + mumble_exe, LOG_CODE::INF); } - else printf("Cannot init Mumble link: %d\n", lErrMumble); + else logger.BeginLog(LOG_CODE::ERR) << "Cannot init Mumble link: " << lErrMumble << std::endl; // Setup type and memory info - printf("Waiting 10s for Unity to load\n"); + logger.Log("Waiting 10s for Unity to load"); Sleep(10000); init_il2cpp(); - printf("Type and function memory mapping successful\n"); + logger.Log("Type and function memory mapping successful"); // Setup hooks DetourTransactionBegin(); @@ -184,11 +197,11 @@ void Run() DetourAttach(&(PVOID&)MeetingHud_Start_Trampoline, MeetingHud_Start_Hook); DetourAttach(&(PVOID&)InnerNetClient_FixedUpdate_Trampoline, InnerNetClient_FixedUpdate_Hook); LONG lError = DetourTransactionCommit(); - if (lError == NO_ERROR) printf("Successfully detoured game functions\n\n"); - else printf("Detouring game functions failed: %d\n", lError); + if (lError == NO_ERROR) logger.Log("Successfully detoured game functions"); + else logger.Log("Detouring game functions failed: " + lError, LOG_CODE::ERR); // Wait for thread exit and then clean up WaitForSingleObject(hExit, INFINITE); closeMumble(); - printf("Unloading done\n"); + logger.Log("Unloading done"); } diff --git a/vmupload.bat b/vmupload.bat index 2ff7f00..2c7495c 100644 --- a/vmupload.bat +++ b/vmupload.bat @@ -1,2 +1 @@ -copy /b /v /y "..\Release\winhttp.dll" "D:\Steam\steamapps\common\Among Us\winhttp.dll" -for %%x in (A B C) do copy /b /v /y "..\Release\winhttp.dll" "\\GAMECLIENT%%x\Users\Christoph\Desktop\Among Us\winhttp.dll" \ No newline at end of file +copy /b /v /y "..\Release\winhttp.dll" "C:\Program Files (x86)\Steam\steamapps\common\Among Us\winhttp.dll" \ No newline at end of file From 456d6c4e813edec11bd844e72241760db067a855 Mon Sep 17 00:00:00 2001 From: Alien G Date: Wed, 11 Nov 2020 01:37:56 -0800 Subject: [PATCH 10/27] Reworked the logging system. Added: - "printf"-like logging function - Cleaned up the code and simplified it greatly - Better formatting for position heartbeat - Updated current log calls to new format - Other, minor, fixes Removed: - Due to threaded environment, support for operator<< / std::hex / std::endl / etc - Excess code Future: - Will probably edit the LOG_CODE enum for more reasonable logging codes --- AUMInjector/user/LoggingSystem.cpp | 92 ++++++++++++++++++------------ AUMInjector/user/LoggingSystem.h | 81 +++++++++++--------------- AUMInjector/user/main.cpp | 41 ++++++------- 3 files changed, 112 insertions(+), 102 deletions(-) diff --git a/AUMInjector/user/LoggingSystem.cpp b/AUMInjector/user/LoggingSystem.cpp index b83b805..22be0dd 100644 --- a/AUMInjector/user/LoggingSystem.cpp +++ b/AUMInjector/user/LoggingSystem.cpp @@ -9,15 +9,16 @@ // Global externs for the logging system LoggingSystem logger; -DevNullLogger devNullLogger; -LoggingSystem::LoggingSystem() : std::ostream(this) +// Opens a console to prepare for logging +LoggingSystem::LoggingSystem() { // Open a console (to log to) AllocConsole(); freopen_s((FILE **) stdout, "CONOUT$", "w", stdout); } +// Closes the file, if needed LoggingSystem::~LoggingSystem() { // Close the file, if needed @@ -37,11 +38,10 @@ void LoggingSystem::EnableFileLogging() // Placement new because std::ofstream is NOT copyable new(&logFile) std::ofstream(LOGGING_FILE, std::ios::out); - // Failed to open the log file if (!logFile.is_open()) { // Don't log to file, something went wrong - Log("Could not initalize the log file - will not log to file", LOG_CODE::LOG_CODE_WARNING); + Log(LOG_CODE::LOG_CODE_WARNING, "Could not initalize the log file - will not log to file"); logToFile = false; } } @@ -53,51 +53,73 @@ void LoggingSystem::SetVerbosity(LOG_CODE verbosity) this->verbosity = verbosity; } -void LoggingSystem::LogCode(LOG_CODE logCode) +// Prints the string for the code to the log (and possibly the file) +std::string LoggingSystem::GetLogCodeString(LOG_CODE logCode) { - // Print to console - std::cout << "[" + logPrefixes[(unsigned) logCode] + "] "; - - // Log to file (optionally) - if (logToFile) - logFile << "[" + logPrefixes[(unsigned) logCode] + "] "; + // Return the log code string + return ("[" + logPrefixes[(unsigned) logCode] + "] "); } -// Implemented for operator<< to work (from the inherited class) -int LoggingSystem::overflow(int c) +// Logs a message to the console window +// Newline is ensured (for flushing) +void LoggingSystem::Log(LOG_CODE logCode, std::string message) { - // Print to console - std::cout.put((char)c); + // Don't log due to set verbosity level + if (logCode > verbosity) return; - // Log to file (optionally) + // Build the whole string in one go, to prevent thread cross-printing + std::string finalText = GetLogCodeString(logCode) + message + "\n"; + std::cout << finalText; + + // Log to file, if needed if (logToFile) - logFile << (char)c; //Would use "logFile.put(c);", but it has edge cases - return 0; + { + logFile << finalText; + logFile.flush(); + } } -void LoggingSystem::Log(std::string message, LOG_CODE logCode, bool addNewLine) +// Logs a message to the console window, using the familiar "printf" format +// Newline is ensured (for flushing) +void LoggingSystem::LogVariadic(LOG_CODE logCode, const char* formatString, ...) { // Don't log due to set verbosity level if (logCode > verbosity) return; - // Log the given code (in the right format) - LogCode(logCode); + va_list argp = { nullptr }; - // Log to console - std::cout << message << std::endl; + // Get the exact size needed by getting the size of the result string + va_start(argp, formatString); + int bufferLen = vsnprintf(nullptr, 0, formatString, argp) + 1; + va_end(argp); - // Log to file - if (logToFile) - logFile << message << std::endl; -} + // Create a buffer for the string + char* newString = (char*)malloc(bufferLen); -// Sets up the logging system for operator<< -std::ostream &LoggingSystem::BeginLog(LOG_CODE logCode) -{ - // Return the null logger so the chained operators don't have any effect - if (logCode > verbosity) return devNullLogger; + // Malloc returned null (bad, but only a single message is missed) + if (!newString) return; + + // Null-terminate the string + newString[bufferLen - 1] = '\0'; + + // Format the string into the buffer + va_start(argp, formatString); + vsprintf_s(newString, bufferLen, formatString, argp); + va_end(argp); + + // Add the prefix to the gives format string + std::string message = GetLogCodeString(logCode) + newString + "\n"; + + // Print the message + printf("%s", message.c_str()); + + // Log to file, if needed + if (logToFile) + { + logFile << message; + logFile.flush(); + } - // Prints the log and returns a reference to the extern - LogCode(logCode); - return *this; + // Clean up dynamic memory + free(newString); } diff --git a/AUMInjector/user/LoggingSystem.h b/AUMInjector/user/LoggingSystem.h index b305f0b..2c272a3 100644 --- a/AUMInjector/user/LoggingSystem.h +++ b/AUMInjector/user/LoggingSystem.h @@ -1,6 +1,7 @@ #include #include #include +#include // File to use for logging messages from the logging system #define LOGGING_FILE "ProximityLogFile.txt" @@ -8,17 +9,17 @@ enum class LOG_CODE { // Something went wrong - LOG_CODE_ERROR = 3, - ERR = 3, + LOG_CODE_ERROR = 0, + ERR = 0, // Something bad may have happened - LOG_CODE_WARNING = 2, - WRN = 2, + LOG_CODE_WARNING = 1, + WRN = 1, // Information about what's happening - LOG_CODE_INFO = 1, - INF = 1, + LOG_CODE_INFO = 2, + INF = 2, // Telling the user something - LOG_CODE_MESSAGE = 0, - MSG = 0, + LOG_CODE_MESSAGE = 3, + MSG = 3, // Verbose output LOG_CODE_DEBUG = 4, DBG = 4, @@ -26,27 +27,37 @@ enum class LOG_CODE COUNT }; - -// Logging system that is similar to /dev/null -// Used when no output is desired (used by the LoggingSystem) -class DevNullLogger : public std::streambuf, public std::ostream +// Basic logging system +class LoggingSystem { -private: - int overflow(int c) - { return 0; } - public: - DevNullLogger() : std::ostream(this) - {} -}; + // Opens a console to prepare for logging + LoggingSystem(); + // Closes the file, if needed + ~LoggingSystem(); + + // Enables logging to file + void EnableFileLogging(); + + // Sets the max verbosity to print (anything above will not be printed) + void SetVerbosity(LOG_CODE verbosity); + + // Logs a message to the console window + // Newline is ensured (for flushing) + void Log(LOG_CODE logCode, std::string message); + + // Logs a message to the console window, using the familiar "printf" format + // Newline is ensured (for flushing) + void LogVariadic(LOG_CODE logCode, const char* formatString, ...); -class LoggingSystem : public std::streambuf, public std::ostream -{ private: + // Returns the string for the code to the log (and possibly the file) + std::string GetLogCodeString(LOG_CODE logCode); + // Lookup tabe to be used with the LOG_CODE enum for message prefixes std::string logPrefixes[(unsigned) LOG_CODE::COUNT] = { - "ERR", "WRN", "INF", "MSG", "DBG" + "ERR", "WRN", "INF", "MSG", "DBG" }; // If the logging system log to a file @@ -58,32 +69,8 @@ class LoggingSystem : public std::streambuf, public std::ostream // Verbosity level, anything above will not be logged LOG_CODE verbosity = LOG_CODE::DBG; - // Prints the string for the code to the log (and possibly the file) - void LogCode(LOG_CODE logCode); - - // Implemented for operator<< to work (from the inherited class) - int overflow(int c); - -public: - // Opens a console to prepare for logging - LoggingSystem(); - - // Closes the file, if needed - ~LoggingSystem(); - - // Enables logging to file - void EnableFileLogging(); - - // Sets the max verbosity to print (anything above will not be printed) - void SetVerbosity(LOG_CODE verbosity); - - // Logs a message to the console window, defaults to a message log type - void Log(std::string message, LOG_CODE logCode = LOG_CODE::MSG, bool addNewLine = true); - - // Sets up the logging system for operator<< - std::ostream &BeginLog(LOG_CODE logCode); + friend class ThreadSafeLogger; }; // Global extern logging system extern LoggingSystem logger; -extern DevNullLogger devNullLogger; diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index c542217..afbfda9 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -65,7 +65,7 @@ InnerNetClient_GameState__Enum last_game_state = InnerNetClient_GameState__Enum_ // Ints for tracking when to print the position int frameCounter = 0; -const int timeToPrintPosition = 25; +const int timeToPrintPosition = 45; // Fixed loop for a player object, but only get called when a player moves @@ -89,7 +89,7 @@ void PlayerControl_Die_Hook(PlayerControl* __this, Player_Die_Reason__Enum reaso if (__this->fields.LightPrefab != nullptr) { - logger.Log("You died\n"); + logger.Log(LOG_CODE::MSG, "You died\n"); muteMumble(true); } } @@ -98,7 +98,7 @@ void PlayerControl_Die_Hook(PlayerControl* __this, Player_Die_Reason__Enum reaso void MeetingHud_Close_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Close_Trampoline(__this, method); - logger.Log("Meeting ended\n"); + logger.Log(LOG_CODE::MSG, "Meeting ended\n"); voting = false; } @@ -106,7 +106,7 @@ void MeetingHud_Close_Hook(MeetingHud* __this, MethodInfo* method) void MeetingHud_Start_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Start_Trampoline(__this, method); - logger.Log("Meeting started\n"); + logger.Log(LOG_CODE::MSG, "Meeting started\n"); voting = true; } @@ -120,7 +120,7 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) (__this->fields.GameState == InnerNetClient_GameState__Enum_Joined || __this->fields.GameState == InnerNetClient_GameState__Enum_Ended)) { - logger.Log("Game joined or ended\n"); + logger.Log(LOG_CODE::MSG, "Game joined or ended"); muteMumble(false); } last_game_state = __this->fields.GameState; @@ -149,11 +149,12 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) lm->fAvatarPosition[2] = cache_y; lm->fCameraPosition[2] = cache_y; + // Only print the player position ever so many frames if (++frameCounter > timeToPrintPosition) { frameCounter = 0; // Log the current player position to let the player know it is working - logger.BeginLog(LOG_CODE::INF) << "Current Position: (" << cache_x << ", " << cache_y << ")" << std::endl; + logger.LogVariadic(LOG_CODE::INF, "Position: (% 7.3f, % 7.3f)", cache_x, cache_y); } } } @@ -165,28 +166,28 @@ void Run() // Enable logging to file so we can debug user problems easier in the future logger.EnableFileLogging(); - logger.Log("AmongUs-Mumble mod by:", LOG_CODE::MSG); - logger.Log("\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features.", LOG_CODE::MSG); - logger.Log("\tAlisenai (Alien): Fixes, More Features.", LOG_CODE::MSG); - logger.Log("\tBillyDaBongo (Billy): Management, Testing.", LOG_CODE::MSG); + logger.Log(LOG_CODE::MSG, "AmongUs-Mumble mod by:"); + logger.Log(LOG_CODE::MSG, "\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features."); + logger.Log(LOG_CODE::MSG, "\tAlisenai (Alien): Fixes, More Features."); + logger.Log(LOG_CODE::MSG, "\tBillyDaBongo (Billy): Management, Testing."); - logger.BeginLog(LOG_CODE::MSG) << "Compiled for game version" << version_text << std::endl; - logger.Log("DLL hosting successful", LOG_CODE::INF); + logger.LogVariadic(LOG_CODE::MSG, "Compiled for game version: %s", version_text); + logger.Log(LOG_CODE::INF, "DLL hosting successful"); // Setup mumble int lErrMumble = initMumble(); if (lErrMumble == NO_ERROR) { - logger.Log("Mumble link init successful", LOG_CODE::INF); - logger.Log("Mumble exe: " + mumble_exe, LOG_CODE::INF); + logger.Log(LOG_CODE::INF, "Mumble link init successful"); + logger.Log(LOG_CODE::INF, "Mumble exe: " + mumble_exe); } - else logger.BeginLog(LOG_CODE::ERR) << "Cannot init Mumble link: " << lErrMumble << std::endl; + else logger.LogVariadic(LOG_CODE::ERR, "Cannot init Mumble link: ", lErrMumble); // Setup type and memory info - logger.Log("Waiting 10s for Unity to load"); + logger.Log(LOG_CODE::MSG, "Waiting 10s for Unity to load"); Sleep(10000); init_il2cpp(); - logger.Log("Type and function memory mapping successful"); + logger.Log(LOG_CODE::INF, "Type and function memory mapping successful"); // Setup hooks DetourTransactionBegin(); @@ -197,11 +198,11 @@ void Run() DetourAttach(&(PVOID&)MeetingHud_Start_Trampoline, MeetingHud_Start_Hook); DetourAttach(&(PVOID&)InnerNetClient_FixedUpdate_Trampoline, InnerNetClient_FixedUpdate_Hook); LONG lError = DetourTransactionCommit(); - if (lError == NO_ERROR) logger.Log("Successfully detoured game functions"); - else logger.Log("Detouring game functions failed: " + lError, LOG_CODE::ERR); + if (lError == NO_ERROR) logger.Log(LOG_CODE::INF, "Successfully detoured game functions"); + else logger.LogVariadic(LOG_CODE::ERR, "Detouring game functions failed: ", lError); // Wait for thread exit and then clean up WaitForSingleObject(hExit, INFINITE); closeMumble(); - logger.Log("Unloading done"); + logger.Log(LOG_CODE::MSG, "Unloading done"); } From dd79686101b93df71da39f2e2c86598f06428db5 Mon Sep 17 00:00:00 2001 From: LelouBil Date: Wed, 11 Nov 2020 13:23:55 +0100 Subject: [PATCH 11/27] Added obfuscated names for 2020.11.4s --- AUMInjector/user/main.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index 4b84b31..9aaa4f2 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -12,8 +12,9 @@ #define GAME_VERSION_2020_9_22s 2020922 #define GAME_VERSION_2020_10_22s 20201022 +#define GAME_VERSION_2020_11_4s 20201104 #ifndef GAME_VERSION - #define GAME_VERSION GAME_VERSION_2020_10_22s + #define GAME_VERSION GAME_VERSION_2020_11_4s #endif using namespace app; @@ -46,6 +47,22 @@ using namespace app; #define MeetingHud_Close_Trampoline GPOHFPAIEMA_Close #define MeetingHud_Start_Trampoline GPOHFPAIEMA_Start #define InnerNetClient_FixedUpdate_Trampoline DNAFMCDBMCI_FixedUpdate + +#elif GAME_VERSION == GAME_VERSION_2020_11_4s + #define version_text "2020.11.4s" + using InnerNetClient_GameState__Enum = DBDDAJAICFN_DKEKFCCGGEO__Enum; + using PlayerControl = APNNOJFGDGP; + using Player_Die_Reason__Enum = LKBAAGPFMCB__Enum; + using MeetingHud = LFBAPIAFCFM; + using InnerNetClient = DBDDAJAICFN; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = DBDDAJAICFN_DKEKFCCGGEO__Enum_Joined; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = DBDDAJAICFN_DKEKFCCGGEO__Enum_Ended; + #define PlayerControl_FixedUpdate_Trampoline APNNOJFGDGP_FixedUpdate + #define PlayerControl_GetTruePosition_Trampoline APNNOJFGDGP_GetTruePosition + #define PlayerControl_Die_Trampoline APNNOJFGDGP_Die + #define MeetingHud_Close_Trampoline LFBAPIAFCFM_Close + #define MeetingHud_Start_Trampoline LFBAPIAFCFM_Start + #define InnerNetClient_FixedUpdate_Trampoline DBDDAJAICFN_FixedUpdate #else #error Unknown game version! #endif From 1f4671bdac615a3eaa187f7aaaa395efa3ff8d9e Mon Sep 17 00:00:00 2001 From: LelouBil Date: Wed, 11 Nov 2020 13:24:26 +0100 Subject: [PATCH 12/27] Added Il2CppInspector files to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 895db35..4c9bc09 100644 --- a/.gitignore +++ b/.gitignore @@ -365,3 +365,5 @@ tmp /cmake-build-release/ /cmake-build-debug/ /.idea/ + +Il2CppInspector* \ No newline at end of file From 972034d1b4fc70654ae443da13d5964ec87266e5 Mon Sep 17 00:00:00 2001 From: LelouBil Date: Wed, 11 Nov 2020 13:27:08 +0100 Subject: [PATCH 13/27] Made decompile.bat & vmupload.bat use new gamepath.bat script to get the game path Edited decompile.bat because so you have to put Il2CppInspector-cli.exe in the same folder Edited vmupload.bat since only winhttp.dll is needed and I don't know what the second line would do either way. Added gamepath.bat to .gitignore --- .gitignore | 4 +++- decompile.bat | 6 +++--- gamepath.bat | 3 +++ vmupload.bat | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 gamepath.bat diff --git a/.gitignore b/.gitignore index 4c9bc09..9b33014 100644 --- a/.gitignore +++ b/.gitignore @@ -366,4 +366,6 @@ tmp /cmake-build-debug/ /.idea/ -Il2CppInspector* \ No newline at end of file +Il2CppInspector* + +gamepath.bat \ No newline at end of file diff --git a/decompile.bat b/decompile.bat index 8d19417..2e69310 100644 --- a/decompile.bat +++ b/decompile.bat @@ -1,15 +1,15 @@ @echo off -set "AMONGUS=D:\Steam\steamapps\common\Among Us" +gamepath.bat mkdir tmp cd tmp -Il2CppInspector-cli.exe -i "%AMONGUS%\GameAssembly.dll" -m "%AMONGUS%\Among Us_Data\il2cpp_data\Metadata\global-metadata.dat" -h "cpp" --cpp-compiler MSVC +..\Il2CppInspector-cli.exe -i "%AMONGUS%\GameAssembly.dll" -m "%AMONGUS%\Among Us_Data\il2cpp_data\Metadata\global-metadata.dat" -h "cpp" --cpp-compiler MSVC xcopy "cpp\appdata\*.*" "..\AUMInjector\appdata\" /K /D /H /Y cd .. del /s /q tmp\* >nul 2>&1 rmdir /s /q tmp -pause \ No newline at end of file +pause diff --git a/gamepath.bat b/gamepath.bat new file mode 100644 index 0000000..c56f09a --- /dev/null +++ b/gamepath.bat @@ -0,0 +1,3 @@ +@echo off +Rem set here the path to your game folder +set "AMONGUS=C:\Steam\steamapps\common\Among Us" \ No newline at end of file diff --git a/vmupload.bat b/vmupload.bat index 2ff7f00..e00938c 100644 --- a/vmupload.bat +++ b/vmupload.bat @@ -1,2 +1,3 @@ -copy /b /v /y "..\Release\winhttp.dll" "D:\Steam\steamapps\common\Among Us\winhttp.dll" -for %%x in (A B C) do copy /b /v /y "..\Release\winhttp.dll" "\\GAMECLIENT%%x\Users\Christoph\Desktop\Among Us\winhttp.dll" \ No newline at end of file +@echo off +gamepath.bat +copy /b /v /y ".\Release\winhttp.dll" "%AMONGUS%\winhttp.dll" \ No newline at end of file From db0831a66ee4f9da1ac6386e6bb954eaca335870 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 15:34:55 +0100 Subject: [PATCH 14/27] Refactor decompilation scripts --- decompile.bat | 4 ++-- gamepath.bat | 3 --- setup.bat.example | 7 +++++++ 3 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 gamepath.bat create mode 100644 setup.bat.example diff --git a/decompile.bat b/decompile.bat index 2e69310..5c42d1f 100644 --- a/decompile.bat +++ b/decompile.bat @@ -1,11 +1,11 @@ @echo off -gamepath.bat +setup.bat mkdir tmp cd tmp -..\Il2CppInspector-cli.exe -i "%AMONGUS%\GameAssembly.dll" -m "%AMONGUS%\Among Us_Data\il2cpp_data\Metadata\global-metadata.dat" -h "cpp" --cpp-compiler MSVC +"%IL2CPPINSPECTOR%" -i "%AMONGUS%\GameAssembly.dll" -m "%AMONGUS%\Among Us_Data\il2cpp_data\Metadata\global-metadata.dat" -h "cpp" --cpp-compiler MSVC xcopy "cpp\appdata\*.*" "..\AUMInjector\appdata\" /K /D /H /Y cd .. diff --git a/gamepath.bat b/gamepath.bat deleted file mode 100644 index c56f09a..0000000 --- a/gamepath.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -Rem set here the path to your game folder -set "AMONGUS=C:\Steam\steamapps\common\Among Us" \ No newline at end of file diff --git a/setup.bat.example b/setup.bat.example new file mode 100644 index 0000000..c9071bc --- /dev/null +++ b/setup.bat.example @@ -0,0 +1,7 @@ +@echo off + +REM set the path to your game folder +SET "AMONGUS=C:\Steam\steamapps\common\Among Us" + +REM set the path of IL2CPPInspector +SET "IL2CPPINSPECTOR=Il2CppInspector-cli.exe" \ No newline at end of file From 02f6460bbc9973a7ec971f29f29cca3d7ae01ad2 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 15:35:29 +0100 Subject: [PATCH 15/27] Ignore user specific setup --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9b33014..7f3884e 100644 --- a/.gitignore +++ b/.gitignore @@ -368,4 +368,4 @@ tmp Il2CppInspector* -gamepath.bat \ No newline at end of file +setup.bat \ No newline at end of file From 536c9935b5f2557add9d6a6d00fc365f4d498eda Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 16:22:05 +0100 Subject: [PATCH 16/27] Fix the batch scripts --- decompile.bat | 19 ++++++++++--------- setup.bat.example | 11 +++++++++-- vmupload.bat | 17 ++++++++++++++--- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/decompile.bat b/decompile.bat index 5c42d1f..c846a6c 100644 --- a/decompile.bat +++ b/decompile.bat @@ -1,15 +1,16 @@ -@echo off +@ECHO OFF -setup.bat +CD /D "%~dp0" +CALL setup.bat -mkdir tmp -cd tmp +MKDIR tmp +CD tmp "%IL2CPPINSPECTOR%" -i "%AMONGUS%\GameAssembly.dll" -m "%AMONGUS%\Among Us_Data\il2cpp_data\Metadata\global-metadata.dat" -h "cpp" --cpp-compiler MSVC -xcopy "cpp\appdata\*.*" "..\AUMInjector\appdata\" /K /D /H /Y +XCOPY "cpp\appdata\*.*" "..\AUMInjector\appdata\" /K /D /H /Y -cd .. -del /s /q tmp\* >nul 2>&1 -rmdir /s /q tmp +CD .. +DEL /s /q tmp\* >NUL 2>&1 +RMDIR /s /q tmp -pause +PAUSE diff --git a/setup.bat.example b/setup.bat.example index c9071bc..da79795 100644 --- a/setup.bat.example +++ b/setup.bat.example @@ -1,7 +1,14 @@ -@echo off +@ECHO OFF REM set the path to your game folder SET "AMONGUS=C:\Steam\steamapps\common\Among Us" REM set the path of IL2CPPInspector -SET "IL2CPPINSPECTOR=Il2CppInspector-cli.exe" \ No newline at end of file +SET "IL2CPPINSPECTOR=Il2CppInspector-cli.exe" + +REM setup virtual machines for deployment +REM uncomment the following line to enable vm upload +REM SET "VM_UPLOAD=yes" +SET "VM_BASENAME=GAMECLIENT" +SET "VM_SUFFIXES=A B C" +SET "VM_AMONGUS=Users\Christoph\Desktop\Among Us" \ No newline at end of file diff --git a/vmupload.bat b/vmupload.bat index e00938c..cc88f8a 100644 --- a/vmupload.bat +++ b/vmupload.bat @@ -1,3 +1,14 @@ -@echo off -gamepath.bat -copy /b /v /y ".\Release\winhttp.dll" "%AMONGUS%\winhttp.dll" \ No newline at end of file +@ECHO OFF + +CD /D "%~dp0" +CALL setup.bat + +ECHO "Copying to %AMONGUS%" +COPY /b /v /y ".\Release\winhttp.dll" "%AMONGUS%\winhttp.dll" + +IF DEFINED VM_UPLOAD ( + FOR %%x IN (%VM_SUFFIXES%) DO ( + ECHO "Copying to VM %VM_BASENAME%%%x" + COPY /b /v /y ".\Release\winhttp.dll" "\\%VM_BASENAME%%%x\%VM_AMONGUS%\winhttp.dll" + ) +) \ No newline at end of file From b93f5caad51f601a8646d8a5d54d83ee6e0a89c9 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 16:37:59 +0100 Subject: [PATCH 17/27] Move deobfuscation to extra file --- AUMInjector/AUMInjector.vcxproj | 3 +- AUMInjector/AUMInjector.vcxproj.filters | 3 ++ AUMInjector/user/deobfuscate.h | 62 ++++++++++++++++++++++ AUMInjector/user/main.cpp | 68 +++---------------------- README.md | 11 ++-- 5 files changed, 79 insertions(+), 68 deletions(-) create mode 100644 AUMInjector/user/deobfuscate.h diff --git a/AUMInjector/AUMInjector.vcxproj b/AUMInjector/AUMInjector.vcxproj index ef0fb7f..b8c646f 100644 --- a/AUMInjector/AUMInjector.vcxproj +++ b/AUMInjector/AUMInjector.vcxproj @@ -1,4 +1,4 @@ - + @@ -34,6 +34,7 @@ + diff --git a/AUMInjector/AUMInjector.vcxproj.filters b/AUMInjector/AUMInjector.vcxproj.filters index 26e1791..0178971 100644 --- a/AUMInjector/AUMInjector.vcxproj.filters +++ b/AUMInjector/AUMInjector.vcxproj.filters @@ -74,6 +74,9 @@ Headerdateien + + Headerdateien + diff --git a/AUMInjector/user/deobfuscate.h b/AUMInjector/user/deobfuscate.h new file mode 100644 index 0000000..1808497 --- /dev/null +++ b/AUMInjector/user/deobfuscate.h @@ -0,0 +1,62 @@ +// This file contains deobfuscation mappings for different versions of the game + +#pragma once +#include "il2cpp-appdata.h" + +#define GAME_VERSION_2020_9_22s 20209220 +#define GAME_VERSION_2020_10_22s 202010220 +#define GAME_VERSION_2020_11_4s 202011040 +#ifndef GAME_VERSION + #define GAME_VERSION GAME_VERSION_2020_10_22s +#endif + +using namespace app; + +// Deobfuscate game bindings, depending on version +#if GAME_VERSION == GAME_VERSION_2020_9_22s + #define version_text "2020.9.22s" + using InnerNetClient_GameState__Enum = InnerNetClient_IFLBIJFJPMK__Enum; + using Player_Die_Reason__Enum = NPLMBOLMMLB__Enum; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = InnerNetClient_IFLBIJFJPMK__Enum_Joined; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = InnerNetClient_IFLBIJFJPMK__Enum_Ended; + #define PlayerControl_FixedUpdate_Trampoline PlayerControl_FixedUpdate + #define PlayerControl_GetTruePosition_Trampoline PlayerControl_GetTruePosition + #define PlayerControl_Die_Trampoline PlayerControl_Die + #define MeetingHud_Close_Trampoline MeetingHud_Close + #define MeetingHud_Start_Trampoline MeetingHud_Start + #define InnerNetClient_FixedUpdate_Trampoline InnerNetClient_FixedUpdate +#elif GAME_VERSION == GAME_VERSION_2020_10_22s + #define version_text "2020.10.22s" + using InnerNetClient_GameState__Enum = DNAFMCDBMCI_JPCEFDHGHAK__Enum; + using PlayerControl = GLHCHLEDNBA; + using Player_Die_Reason__Enum = CCCHKEBONBN__Enum; + using MeetingHud = GPOHFPAIEMA; + using InnerNetClient = DNAFMCDBMCI; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = DNAFMCDBMCI_JPCEFDHGHAK__Enum_Joined; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = DNAFMCDBMCI_JPCEFDHGHAK__Enum_Ended; + #define PlayerControl_FixedUpdate_Trampoline GLHCHLEDNBA_FixedUpdate + #define PlayerControl_GetTruePosition_Trampoline GLHCHLEDNBA_GetTruePosition + #define PlayerControl_Die_Trampoline GLHCHLEDNBA_Die + #define MeetingHud_Close_Trampoline GPOHFPAIEMA_Close + #define MeetingHud_Start_Trampoline GPOHFPAIEMA_Start + #define InnerNetClient_FixedUpdate_Trampoline DNAFMCDBMCI_FixedUpdate +#elif GAME_VERSION == GAME_VERSION_2020_11_4s + #define version_text "2020.11.4s" + using InnerNetClient_GameState__Enum = DBDDAJAICFN_DKEKFCCGGEO__Enum; + using PlayerControl = APNNOJFGDGP; + using Player_Die_Reason__Enum = LKBAAGPFMCB__Enum; + using MeetingHud = LFBAPIAFCFM; + using InnerNetClient = DBDDAJAICFN; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = DBDDAJAICFN_DKEKFCCGGEO__Enum_Joined; + InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = DBDDAJAICFN_DKEKFCCGGEO__Enum_Ended; + #define PlayerControl_FixedUpdate_Trampoline APNNOJFGDGP_FixedUpdate + #define PlayerControl_GetTruePosition_Trampoline APNNOJFGDGP_GetTruePosition + #define PlayerControl_Die_Trampoline APNNOJFGDGP_Die + #define MeetingHud_Close_Trampoline LFBAPIAFCFM_Close + #define MeetingHud_Start_Trampoline LFBAPIAFCFM_Start + #define InnerNetClient_FixedUpdate_Trampoline DBDDAJAICFN_FixedUpdate +#else + #error Unknown game version! +#endif + +#pragma message("Compiling for game version " version_text) \ No newline at end of file diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index 9aaa4f2..aba4505 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -9,67 +9,10 @@ #include "helpers.h" #include #include "mumble-link.h" - -#define GAME_VERSION_2020_9_22s 2020922 -#define GAME_VERSION_2020_10_22s 20201022 -#define GAME_VERSION_2020_11_4s 20201104 -#ifndef GAME_VERSION - #define GAME_VERSION GAME_VERSION_2020_11_4s -#endif +#include "deobfuscate.h" using namespace app; -// Deobfuscate game bindings, depending on version -#if GAME_VERSION == GAME_VERSION_2020_9_22s - #define version_text "2020.9.22s" - using InnerNetClient_GameState__Enum = InnerNetClient_IFLBIJFJPMK__Enum; - using Player_Die_Reason__Enum = NPLMBOLMMLB__Enum; - InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = InnerNetClient_IFLBIJFJPMK__Enum_Joined; - InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = InnerNetClient_IFLBIJFJPMK__Enum_Ended; - #define PlayerControl_FixedUpdate_Trampoline PlayerControl_FixedUpdate - #define PlayerControl_GetTruePosition_Trampoline PlayerControl_GetTruePosition - #define PlayerControl_Die_Trampoline PlayerControl_Die - #define MeetingHud_Close_Trampoline MeetingHud_Close - #define MeetingHud_Start_Trampoline MeetingHud_Start - #define InnerNetClient_FixedUpdate_Trampoline InnerNetClient_FixedUpdate -#elif GAME_VERSION == GAME_VERSION_2020_10_22s - #define version_text "2020.10.22s" - using InnerNetClient_GameState__Enum = DNAFMCDBMCI_JPCEFDHGHAK__Enum; - using PlayerControl = GLHCHLEDNBA; - using Player_Die_Reason__Enum = CCCHKEBONBN__Enum; - using MeetingHud = GPOHFPAIEMA; - using InnerNetClient = DNAFMCDBMCI; - InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = DNAFMCDBMCI_JPCEFDHGHAK__Enum_Joined; - InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = DNAFMCDBMCI_JPCEFDHGHAK__Enum_Ended; - #define PlayerControl_FixedUpdate_Trampoline GLHCHLEDNBA_FixedUpdate - #define PlayerControl_GetTruePosition_Trampoline GLHCHLEDNBA_GetTruePosition - #define PlayerControl_Die_Trampoline GLHCHLEDNBA_Die - #define MeetingHud_Close_Trampoline GPOHFPAIEMA_Close - #define MeetingHud_Start_Trampoline GPOHFPAIEMA_Start - #define InnerNetClient_FixedUpdate_Trampoline DNAFMCDBMCI_FixedUpdate - -#elif GAME_VERSION == GAME_VERSION_2020_11_4s - #define version_text "2020.11.4s" - using InnerNetClient_GameState__Enum = DBDDAJAICFN_DKEKFCCGGEO__Enum; - using PlayerControl = APNNOJFGDGP; - using Player_Die_Reason__Enum = LKBAAGPFMCB__Enum; - using MeetingHud = LFBAPIAFCFM; - using InnerNetClient = DBDDAJAICFN; - InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = DBDDAJAICFN_DKEKFCCGGEO__Enum_Joined; - InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = DBDDAJAICFN_DKEKFCCGGEO__Enum_Ended; - #define PlayerControl_FixedUpdate_Trampoline APNNOJFGDGP_FixedUpdate - #define PlayerControl_GetTruePosition_Trampoline APNNOJFGDGP_GetTruePosition - #define PlayerControl_Die_Trampoline APNNOJFGDGP_Die - #define MeetingHud_Close_Trampoline LFBAPIAFCFM_Close - #define MeetingHud_Start_Trampoline LFBAPIAFCFM_Start - #define InnerNetClient_FixedUpdate_Trampoline DBDDAJAICFN_FixedUpdate -#else - #error Unknown game version! -#endif - -#pragma message("Compiling for game version " version_text) - - extern const LPCWSTR LOG_FILE = L"il2cpp-log.txt"; extern HANDLE hExit; // Thread exit event extern std::string mumble_exe; @@ -170,11 +113,12 @@ void Run() NewConsole(); printf("AmongUs-Mumble mod by:\n"); - printf("\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features.\n"); - printf("\tAlisenai (Alien): Fixes, More Features.\n"); - printf("\tBillyDaBongo (Billy): Management, Testing.\n"); + printf(" StarGate01 (chrz.de):\tProxy DLL, Framework, Setup, Features.\n"); + printf(" Alisenai (Alien):\t\tFixes, More Features.\n"); + printf(" BillyDaBongo (Billy):\tManagement, Testing.\n"); + printf(" LelouBi:\t\t\tDeobfuscation.\n"); - printf("Compiled for game version %s\n", version_text); + printf("\nCompiled for game version %s\n", version_text); printf("DLL hosting successful\n\n"); // Setup mumble diff --git a/README.md b/README.md index 5571b34..c3099b7 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,13 @@ Currently only for Windows PCs and the Steam version. On Linux and OSX a small Mumble fake plugin is provided, which just sets your ingame position to `(0, 0)`. -| Game version | DLL release | GAME_VERSION | -| ------------ | ----------------------------------------------------------------------------- | ------------ | -| 2020.10.22s | [1.0.0.4](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.4) | `20201022` | -| 2020.9.22s | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `2020922` | +Version numbering: Release compatible builds use `1.0.0.X`, beta builds use `1.0.1.X`. See the table for compatibility. Please ensure that you use the correct version for your game installation. -Please ensure that you use the correct version for your game installation. +| Game version | Game channel | DLL release | GAME_VERSION | +| ------------ | ------------ | ----------------------------------------------------------------------------- | ------------ | +| 2020.11.4s | Beta | [1.0.1.0](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.1.0) | `202011040` | +| 2020.10.22s | Release | [1.0.0.4](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.4) | `202010220` | +| 2020.9.22s | Release | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `20209220` | If you are looking for a community that uses this mod, join the Discord server: https://discord.gg/4UkHEJ5sqg ! From 83fd85108bfbe96a7a0a8593bd0cd0e5fad9ee92 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 16:38:53 +0100 Subject: [PATCH 18/27] Update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c3099b7..be30ffb 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Version numbering: Release compatible builds use `1.0.0.X`, beta builds use `1.0 | Game version | Game channel | DLL release | GAME_VERSION | | ------------ | ------------ | ----------------------------------------------------------------------------- | ------------ | -| 2020.11.4s | Beta | [1.0.1.0](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.1.0) | `202011040` | +| 2020.11.4s | Beta | [1.0.1.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.1.1) | `202011040` | | 2020.10.22s | Release | [1.0.0.4](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.4) | `202010220` | | 2020.9.22s | Release | [1.0.0.1](https://github.com/StarGate01/AmongUs-Mumble/releases/tag/v1.0.0.1) | `20209220` | @@ -25,6 +25,7 @@ If you have any issues or find bugs, report them here: https://github.com/StarGa ## Project State - [Issues and Planned Features](https://github.com/StarGate01/AmongUs-Mumble/projects/1) - [Release branch](https://github.com/StarGate01/AmongUs-Mumble/tree/master) + - [Beta branch](https://github.com/StarGate01/AmongUs-Mumble/tree/beta) - [Development branch](https://github.com/StarGate01/AmongUs-Mumble/tree/dev) ## Thanks to / Sources From 3ec291211228f1f52ce756510b9ea29f8109d5f5 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 19:09:44 +0100 Subject: [PATCH 19/27] Add configuration file option, closes #7 --- AUMInjector/AUMInjector.vcxproj | 2 + AUMInjector/AUMInjector.vcxproj.filters | 6 +++ AUMInjector/user/main.cpp | 9 ++++- AUMInjector/user/mumble-link.cpp | 37 ++---------------- AUMInjector/user/settings.cpp | 52 +++++++++++++++++++++++++ AUMInjector/user/settings.h | 20 ++++++++++ 6 files changed, 90 insertions(+), 36 deletions(-) create mode 100644 AUMInjector/user/settings.cpp create mode 100644 AUMInjector/user/settings.h diff --git a/AUMInjector/AUMInjector.vcxproj b/AUMInjector/AUMInjector.vcxproj index b8c646f..ac9209e 100644 --- a/AUMInjector/AUMInjector.vcxproj +++ b/AUMInjector/AUMInjector.vcxproj @@ -13,6 +13,7 @@ + @@ -32,6 +33,7 @@ + diff --git a/AUMInjector/AUMInjector.vcxproj.filters b/AUMInjector/AUMInjector.vcxproj.filters index 0178971..9706751 100644 --- a/AUMInjector/AUMInjector.vcxproj.filters +++ b/AUMInjector/AUMInjector.vcxproj.filters @@ -30,6 +30,9 @@ Quelldateien + + Quelldateien + @@ -77,6 +80,9 @@ Headerdateien + + Headerdateien + diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index aba4505..5e2cfbd 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -10,12 +10,12 @@ #include #include "mumble-link.h" #include "deobfuscate.h" +#include "settings.h" using namespace app; extern const LPCWSTR LOG_FILE = L"il2cpp-log.txt"; extern HANDLE hExit; // Thread exit event -extern std::string mumble_exe; // Game state float cache_x = 0.0f; float cache_y = 0.0f; @@ -121,12 +121,17 @@ void Run() printf("\nCompiled for game version %s\n", version_text); printf("DLL hosting successful\n\n"); + app_settings.parse(); + app_settings.print_usage(); + printf("Current configuration:\n----\n"); + app_settings.print_config(); + printf("----\n\n"); + // Setup mumble int lErrMumble = initMumble(); if (lErrMumble == NO_ERROR) { printf("Mumble link init successful\n"); - printf("Mumble exe: %s\n", mumble_exe.c_str()); } else printf("Cannot init Mumble link: %d\n", lErrMumble); diff --git a/AUMInjector/user/mumble-link.cpp b/AUMInjector/user/mumble-link.cpp index 0b3ed0c..4feaf4d 100644 --- a/AUMInjector/user/mumble-link.cpp +++ b/AUMInjector/user/mumble-link.cpp @@ -1,47 +1,16 @@ #include #include #include -#include -#include "CLI11.hpp" #include "mumble-link.h" +#include "settings.h" LinkedMem* lm = NULL; HANDLE hMapObject = NULL; -std::string mumble_exe = "C:\\Program Files\\Mumble\\mumble.exe"; - // Initializes mumble IPC and RPC int initMumble() { - // Setup argument parser - CLI::App app{ "AmongUs-Mumble", "Among Us.exe" }; - app.allow_extras(); - app.add_option("-m,--mumble", mumble_exe, "Mumble executable path"); - // Get arguments from OS - int argc; - LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); - // Convert arguments from unicode to narrow - _bstr_t** argv_bstr = (_bstr_t**)malloc(argc * sizeof(_bstr_t*)); - char** argv_narrow = (char**)malloc(argc * sizeof(char*)); - for (int i = 0; i < argc; i++) - { - argv_bstr[i] = new _bstr_t(argv[i]); - argv_narrow[i] = *argv_bstr[i]; - } - // Parse arguments - app.parse(argc, argv_narrow); - printf("%s", app.help().c_str()); - // Free temp buffers - LocalFree(argv); - for (int i = 0; i < argc; i++) - { - argv_bstr[i]->~_bstr_t(); - free(argv_bstr[i]); - } - free(argv_bstr); - free(argv_narrow); - // Open shared memory file IPC hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); if (hMapObject == NULL) return GetLastError(); @@ -104,6 +73,6 @@ void closeMumble() // Mutes or unmutes mumble via RPC void muteMumble(bool mute) { - if(mute) system(("\"" + mumble_exe + "\" rpc mute").c_str()); - else system(("\"" + mumble_exe + "\" rpc unmute").c_str()); + if(mute) system(("\"" + app_settings.mumble_exe + "\" rpc mute").c_str()); + else system(("\"" + app_settings.mumble_exe + "\" rpc unmute").c_str()); } diff --git a/AUMInjector/user/settings.cpp b/AUMInjector/user/settings.cpp new file mode 100644 index 0000000..1b3ab09 --- /dev/null +++ b/AUMInjector/user/settings.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include "settings.h" + +Settings::Settings(): + mumble_exe("C:\\Program Files\\Mumble\\mumble.exe"), + app("AmongUs-Mumble", "Among Us.exe") +{ } + +void Settings::parse() +{ + // Setup argument parser + app.allow_extras(true); + app.allow_config_extras(true); + app.set_config("-c,--config", "config.ini", "Read an INI configuration file", false); + app.add_option("-m,--mumble", mumble_exe, "Mumble executable path", true); + // Get arguments from OS + int argc; + LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); + // Convert arguments from unicode to narrow + _bstr_t** argv_bstr = (_bstr_t**)malloc(argc * sizeof(_bstr_t*)); + char** argv_narrow = (char**)malloc(argc * sizeof(char*)); + for (int i = 0; i < argc; i++) + { + argv_bstr[i] = new _bstr_t(argv[i]); + argv_narrow[i] = *argv_bstr[i]; + } + // Parse arguments + app.parse(argc, argv_narrow); + // Free temp buffers + LocalFree(argv); + for (int i = 0; i < argc; i++) + { + argv_bstr[i]->~_bstr_t(); + free(argv_bstr[i]); + } + free(argv_bstr); + free(argv_narrow); +} + +void Settings::print_usage() +{ + std::cout << app.help(); +} + +void Settings::print_config() +{ + std::cout << app.config_to_str(true, true); +} + +Settings app_settings; \ No newline at end of file diff --git a/AUMInjector/user/settings.h b/AUMInjector/user/settings.h new file mode 100644 index 0000000..f47ed46 --- /dev/null +++ b/AUMInjector/user/settings.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include "CLI11.hpp" + +class Settings +{ + public: + std::string mumble_exe; + + Settings(); + void parse(); + void print_usage(); + void print_config(); + + private: + CLI::App app; +}; + +extern Settings app_settings; From 3fa744d4d674f0f5558966e2f30b210b64e3d324 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 21:47:12 +0100 Subject: [PATCH 20/27] Run RPC in new thread, should fix #13 --- AUMInjector/user/mumble-link.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AUMInjector/user/mumble-link.cpp b/AUMInjector/user/mumble-link.cpp index 4feaf4d..2e66751 100644 --- a/AUMInjector/user/mumble-link.cpp +++ b/AUMInjector/user/mumble-link.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "mumble-link.h" #include "settings.h" @@ -73,6 +74,9 @@ void closeMumble() // Mutes or unmutes mumble via RPC void muteMumble(bool mute) { - if(mute) system(("\"" + app_settings.mumble_exe + "\" rpc mute").c_str()); - else system(("\"" + app_settings.mumble_exe + "\" rpc unmute").c_str()); + std::thread t([mute] { + if (mute) system(("\"" + app_settings.mumble_exe + "\" rpc mute").c_str()); + else system(("\"" + app_settings.mumble_exe + "\" rpc unmute").c_str()); + }); + t.detach(); } From 7dd16078bbbf405c495de7e58f34ff891bcb4d60 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 22:37:34 +0100 Subject: [PATCH 21/27] Check which process hosts the dll, fixes #16 --- AUMInjector/user/main.cpp | 97 +++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index 5e2cfbd..df59ffc 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -110,51 +110,58 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) // Entrypoint of the injected thread void Run() { - NewConsole(); - - printf("AmongUs-Mumble mod by:\n"); - printf(" StarGate01 (chrz.de):\tProxy DLL, Framework, Setup, Features.\n"); - printf(" Alisenai (Alien):\t\tFixes, More Features.\n"); - printf(" BillyDaBongo (Billy):\tManagement, Testing.\n"); - printf(" LelouBi:\t\t\tDeobfuscation.\n"); - - printf("\nCompiled for game version %s\n", version_text); - printf("DLL hosting successful\n\n"); - - app_settings.parse(); - app_settings.print_usage(); - printf("Current configuration:\n----\n"); - app_settings.print_config(); - printf("----\n\n"); - - // Setup mumble - int lErrMumble = initMumble(); - if (lErrMumble == NO_ERROR) + // Check what process the dll was loaded into + // If loaded into the wrong process, exit injected thread + TCHAR hostExe[MAX_PATH]; + GetModuleFileName(NULL, hostExe, MAX_PATH); + char fname[_MAX_FNAME]; + _splitpath_s(hostExe, NULL, 0, NULL, 0, fname, _MAX_FNAME, NULL, 0); + if (strcmp(fname, "Among Us") == 0) { - printf("Mumble link init successful\n"); + NewConsole(); + + printf("AmongUs-Mumble mod by:\n"); + printf(" StarGate01 (chrz.de):\tProxy DLL, Framework, Setup, Features.\n"); + printf(" Alisenai (Alien):\t\tFixes, More Features.\n"); + printf(" BillyDaBongo (Billy):\tManagement, Testing.\n"); + printf(" LelouBi:\t\t\tDeobfuscation.\n"); + + printf("\nCompiled for game version %s\n", version_text); + printf("DLL hosting successful\n\n"); + + // Load settings + app_settings.parse(); + app_settings.print_usage(); + printf("Current configuration:\n----\n"); + app_settings.print_config(); + printf("----\n\n"); + + // Setup mumble + int lErrMumble = initMumble(); + if (lErrMumble == NO_ERROR) printf("Mumble link init successful\n"); + else printf("Cannot init Mumble link: %d\n", lErrMumble); + + // Setup type and memory info + printf("Waiting 10s for Unity to load\n"); + Sleep(10000); + init_il2cpp(); + printf("Type and function memory mapping successful\n"); + + // Setup hooks + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach(&(PVOID&)PlayerControl_FixedUpdate_Trampoline, PlayerControl_FixedUpdate_Hook); + DetourAttach(&(PVOID&)PlayerControl_Die_Trampoline, PlayerControl_Die_Hook); + DetourAttach(&(PVOID&)MeetingHud_Close_Trampoline, MeetingHud_Close_Hook); + DetourAttach(&(PVOID&)MeetingHud_Start_Trampoline, MeetingHud_Start_Hook); + DetourAttach(&(PVOID&)InnerNetClient_FixedUpdate_Trampoline, InnerNetClient_FixedUpdate_Hook); + LONG lError = DetourTransactionCommit(); + if (lError == NO_ERROR) printf("Successfully detoured game functions\n\n"); + else printf("Detouring game functions failed: %d\n", lError); + + // Wait for thread exit and then clean up + WaitForSingleObject(hExit, INFINITE); + closeMumble(); + printf("Unloading done\n"); } - else printf("Cannot init Mumble link: %d\n", lErrMumble); - - // Setup type and memory info - printf("Waiting 10s for Unity to load\n"); - Sleep(10000); - init_il2cpp(); - printf("Type and function memory mapping successful\n"); - - // Setup hooks - DetourTransactionBegin(); - DetourUpdateThread(GetCurrentThread()); - DetourAttach(&(PVOID&)PlayerControl_FixedUpdate_Trampoline, PlayerControl_FixedUpdate_Hook); - DetourAttach(&(PVOID&)PlayerControl_Die_Trampoline, PlayerControl_Die_Hook); - DetourAttach(&(PVOID&)MeetingHud_Close_Trampoline, MeetingHud_Close_Hook); - DetourAttach(&(PVOID&)MeetingHud_Start_Trampoline, MeetingHud_Start_Hook); - DetourAttach(&(PVOID&)InnerNetClient_FixedUpdate_Trampoline, InnerNetClient_FixedUpdate_Hook); - LONG lError = DetourTransactionCommit(); - if (lError == NO_ERROR) printf("Successfully detoured game functions\n\n"); - else printf("Detouring game functions failed: %d\n", lError); - - // Wait for thread exit and then clean up - WaitForSingleObject(hExit, INFINITE); - closeMumble(); - printf("Unloading done\n"); } From 381b665f40b7634e26d7464271f3026b9e9989e5 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 11 Nov 2020 22:45:13 +0100 Subject: [PATCH 22/27] Start console window minimized --- AUMInjector/framework/helpers.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/AUMInjector/framework/helpers.cpp b/AUMInjector/framework/helpers.cpp index 9e376c5..e8f9ccf 100644 --- a/AUMInjector/framework/helpers.cpp +++ b/AUMInjector/framework/helpers.cpp @@ -31,4 +31,5 @@ void LogWrite(std::string text) { void NewConsole() { AllocConsole(); freopen_s((FILE**) stdout, "CONOUT$", "w", stdout); + ShowWindow(GetConsoleWindow(), SW_MINIMIZE); } \ No newline at end of file From 976bf868807cafaf1f8e0b4462ba8414db0acf1d Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Thu, 12 Nov 2020 03:25:58 +0100 Subject: [PATCH 23/27] Add tool for dynamic analysis --- AUMInjector/user/.gitignore | 1 + dynamic_analysis.py | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 AUMInjector/user/.gitignore create mode 100644 dynamic_analysis.py diff --git a/AUMInjector/user/.gitignore b/AUMInjector/user/.gitignore new file mode 100644 index 0000000..e1f01d9 --- /dev/null +++ b/AUMInjector/user/.gitignore @@ -0,0 +1 @@ +dynamic_analysis.h \ No newline at end of file diff --git a/dynamic_analysis.py b/dynamic_analysis.py new file mode 100644 index 0000000..1ed0b5a --- /dev/null +++ b/dynamic_analysis.py @@ -0,0 +1,46 @@ +import os, pathlib, sys, re + + +basepath = os.path.join(pathlib.Path(__file__).parent.absolute(), "AUMInjector") +functions_file = os.path.join(basepath, "appdata", "il2cpp-functions.h") +output_file = os.path.join(basepath, "user", "dynamic_analysis.h") +if(len(sys.argv) < 2): + print("Specify search token as first CLI argument, excluding tokens as following arguments") + exit(1) +needle = sys.argv[1] +exclude = sys.argv[2:] + +print("Tool to generate hooking code for dynamic analysis") +print("Using definition file: " + functions_file) +print("Using output file: " + output_file) +print("Matching on: " + needle + "\n") + +hooks = [] +with open(output_file, "w") as ofp: + ofp.write("#include \"il2cpp-appdata.h\"\n#include \n#include \n\nusing namespace app;\n\n") + with open(functions_file) as fp: + line = fp.readline() + cnt = 1 + while line: + if needle in line: + is_excluded = False + for ex in exclude: + if ex in line: + is_excluded = True + break + if not is_excluded: + m = re.search(r',\W*([^,]*),\W*([^,]*)\W*\((.*)\)\);.*', line) + returntype = str(m.group(1)) + name = str(m.group(2)) + params = str(m.group(3)) + print(name) + hooks.append(name) + signature = returntype + " " + name + "_Hook(" + params + ")" + trampoline_call = name + "(" + ", ".join(list(map(lambda x: x.split(" ")[-1], params.split(",")))) + ");" + if(returntype != "void"): trampoline_call = "return " + trampoline_call + ofp.write(signature + " { printf(\"" + name + "\\n\"); " + str(trampoline_call) + " }\n") + line = fp.readline() + cnt += 1 + ofp.write("\nvoid dynamic_analysis_attach() {\n") + for hook in hooks: ofp.write("\tDetourAttach(&(PVOID&)" + hook + ", " + hook + "_Hook);\n") + ofp.write("}\n") From 2d9078d63c2de2830a56af0047a8fa6acef26a9d Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Thu, 12 Nov 2020 05:55:52 +0100 Subject: [PATCH 24/27] Add server disconnect hook, should fix #22 --- AUMInjector/user/deobfuscate.h | 2 ++ AUMInjector/user/main.cpp | 38 ++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/AUMInjector/user/deobfuscate.h b/AUMInjector/user/deobfuscate.h index 1808497..7cb3b90 100644 --- a/AUMInjector/user/deobfuscate.h +++ b/AUMInjector/user/deobfuscate.h @@ -32,6 +32,7 @@ using namespace app; using Player_Die_Reason__Enum = CCCHKEBONBN__Enum; using MeetingHud = GPOHFPAIEMA; using InnerNetClient = DNAFMCDBMCI; + using InnerNet_DisconnectReasons__Enum = NCBONGGBCNE__Enum; InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Joined = DNAFMCDBMCI_JPCEFDHGHAK__Enum_Joined; InnerNetClient_GameState__Enum InnerNetClient_GameState__Enum_Ended = DNAFMCDBMCI_JPCEFDHGHAK__Enum_Ended; #define PlayerControl_FixedUpdate_Trampoline GLHCHLEDNBA_FixedUpdate @@ -40,6 +41,7 @@ using namespace app; #define MeetingHud_Close_Trampoline GPOHFPAIEMA_Close #define MeetingHud_Start_Trampoline GPOHFPAIEMA_Start #define InnerNetClient_FixedUpdate_Trampoline DNAFMCDBMCI_FixedUpdate + #define InnerNetClient_Disconnect_Trampoline DNAFMCDBMCI_GPKBCOKMFHK #elif GAME_VERSION == GAME_VERSION_2020_11_4s #define version_text "2020.11.4s" using InnerNetClient_GameState__Enum = DBDDAJAICFN_DKEKFCCGGEO__Enum; diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index df59ffc..28b99d4 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -11,6 +11,7 @@ #include "mumble-link.h" #include "deobfuscate.h" #include "settings.h" +//#include "dynamic_analysis.h" using namespace app; @@ -19,7 +20,7 @@ extern HANDLE hExit; // Thread exit event // Game state float cache_x = 0.0f; float cache_y = 0.0f; -bool voting = false; +bool send_position = true; InnerNetClient_GameState__Enum last_game_state = InnerNetClient_GameState__Enum_Joined; @@ -28,7 +29,7 @@ void PlayerControl_FixedUpdate_Hook(PlayerControl* __this, MethodInfo* method) { PlayerControl_FixedUpdate_Trampoline(__this, method); - if (__this->fields.LightPrefab != nullptr && !voting) + if (__this->fields.LightPrefab != nullptr && send_position) { // Cache position Vector2 pos = PlayerControl_GetTruePosition_Trampoline(__this, method); @@ -54,7 +55,7 @@ void MeetingHud_Close_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Close_Trampoline(__this, method); printf("Meeting ended\n"); - voting = false; + send_position = true; } // Gets called when a meeting starts @@ -62,7 +63,7 @@ void MeetingHud_Start_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Start_Trampoline(__this, method); printf("Meeting started\n"); - voting = true; + send_position = false; } // Fixed loop for the game client @@ -76,6 +77,7 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) __this->fields.GameState == InnerNetClient_GameState__Enum_Ended)) { printf("Game joined or ended\n"); + send_position = true; muteMumble(false); } last_game_state = __this->fields.GameState; @@ -89,24 +91,32 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) lm->uiVersion = 2; } lm->uiTick++; - if (voting) - { - // When voting, all players can hear each other -> same position - lm->fAvatarPosition[0] = 0.0f; - lm->fCameraPosition[0] = 0.0f; - lm->fAvatarPosition[2] = 0.0f; - lm->fCameraPosition[2] = 0.0f; - } - else + if (send_position) { lm->fAvatarPosition[0] = cache_x; lm->fCameraPosition[0] = cache_x; lm->fAvatarPosition[2] = cache_y; lm->fCameraPosition[2] = cache_y; } + else + { + // When voting or in menu, all players can hear each other + lm->fAvatarPosition[0] = 0.0f; + lm->fCameraPosition[0] = 0.0f; + lm->fAvatarPosition[2] = 0.0f; + lm->fCameraPosition[2] = 0.0f; + } } } +void InnerNetClient_Disconnect_Hook(InnerNetClient* __this, InnerNet_DisconnectReasons__Enum reason, String* stringReason, MethodInfo* method) +{ + InnerNetClient_Disconnect_Trampoline(__this, reason, stringReason, method); + printf("Disconnected from server\n"); + send_position = false; + muteMumble(false); +} + // Entrypoint of the injected thread void Run() { @@ -155,6 +165,8 @@ void Run() DetourAttach(&(PVOID&)MeetingHud_Close_Trampoline, MeetingHud_Close_Hook); DetourAttach(&(PVOID&)MeetingHud_Start_Trampoline, MeetingHud_Start_Hook); DetourAttach(&(PVOID&)InnerNetClient_FixedUpdate_Trampoline, InnerNetClient_FixedUpdate_Hook); + DetourAttach(&(PVOID&)InnerNetClient_Disconnect_Trampoline, InnerNetClient_Disconnect_Hook); + //dynamic_analysis_attach(); LONG lError = DetourTransactionCommit(); if (lError == NO_ERROR) printf("Successfully detoured game functions\n\n"); else printf("Detouring game functions failed: %d\n", lError); From a673ea87962744ad1580c320f24891c5ab59abb2 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Fri, 13 Nov 2020 06:48:22 +0100 Subject: [PATCH 25/27] Clean up, enable same-line printing, add some config options --- AUMInjector/AUMInjector.vcxproj | 8 +- AUMInjector/AUMInjector.vcxproj.filters | 20 +-- AUMInjector/framework/helpers.cpp | 6 +- AUMInjector/framework/helpers.h | 12 +- AUMInjector/user/LoggingSystem.cpp | 44 +++-- AUMInjector/user/LoggingSystem.h | 71 ++++---- AUMInjector/user/MumbleLink.cpp | 83 +++++++++ .../user/{mumble-link.h => MumbleLink.h} | 28 ++-- AUMInjector/user/main.cpp | 158 +++++++++--------- AUMInjector/user/mumble-link.cpp | 82 --------- AUMInjector/user/settings.cpp | 40 ++--- AUMInjector/user/settings.h | 18 +- 12 files changed, 294 insertions(+), 276 deletions(-) create mode 100644 AUMInjector/user/MumbleLink.cpp rename AUMInjector/user/{mumble-link.h => MumbleLink.h} (60%) delete mode 100644 AUMInjector/user/mumble-link.cpp diff --git a/AUMInjector/AUMInjector.vcxproj b/AUMInjector/AUMInjector.vcxproj index 2783554..a460624 100644 --- a/AUMInjector/AUMInjector.vcxproj +++ b/AUMInjector/AUMInjector.vcxproj @@ -14,9 +14,9 @@ - + - + @@ -35,10 +35,10 @@ - + - + diff --git a/AUMInjector/AUMInjector.vcxproj.filters b/AUMInjector/AUMInjector.vcxproj.filters index 272f548..bb2bab1 100644 --- a/AUMInjector/AUMInjector.vcxproj.filters +++ b/AUMInjector/AUMInjector.vcxproj.filters @@ -21,19 +21,19 @@ Quelldateien - - Quelldateien - Quelldateien Quelldateien - + + Quelldateien + + Quelldateien - + Quelldateien @@ -68,9 +68,6 @@ Headerdateien - - Headerdateien - Headerdateien @@ -83,10 +80,13 @@ Headerdateien - + + Headerdateien + + Headerdateien - + Headerdateien diff --git a/AUMInjector/framework/helpers.cpp b/AUMInjector/framework/helpers.cpp index d04c9f4..56a4a23 100644 --- a/AUMInjector/framework/helpers.cpp +++ b/AUMInjector/framework/helpers.cpp @@ -6,10 +6,8 @@ #include #include "helpers.h" -// Log file location -extern const LPCWSTR LOG_FILE; - // Helper function to get the module base address -uintptr_t GetBaseAddress() { +uintptr_t GetBaseAddress() +{ return (uintptr_t) GetModuleHandleW(L"GameAssembly.dll"); } diff --git a/AUMInjector/framework/helpers.h b/AUMInjector/framework/helpers.h index b2f78f7..cb427ee 100644 --- a/AUMInjector/framework/helpers.h +++ b/AUMInjector/framework/helpers.h @@ -7,20 +7,12 @@ #include #include -// Assert macro: M_ASSERT(Condition to check, message if condition is false) -#define M_ASSERT(condition, message) do { if (! (condition)) { std::cerr << "Assertion `" #condition "` failed in " << __FILE__ << " line " << __LINE__ << ": " << message << std::endl; std::terminate(); } } while (false) - // Helper function to get the module base address uintptr_t GetBaseAddress(); -// Helper function to append text to a file -void LogWrite(std::string text); - -// Helper function to open a new console window and redirect stdout there -void NewConsole(); - // Helper function to convert a pointer to hex -template std::string to_hex_string(T i) { +template std::string to_hex_string(T i) +{ std::stringstream stream; stream << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex << i; return stream.str(); diff --git a/AUMInjector/user/LoggingSystem.cpp b/AUMInjector/user/LoggingSystem.cpp index 407dd86..e5f6b25 100644 --- a/AUMInjector/user/LoggingSystem.cpp +++ b/AUMInjector/user/LoggingSystem.cpp @@ -1,11 +1,9 @@ -#include "LoggingSystem.h" -#include - -#define WIN32_LEAN_AND_MEAN - #include +#include #include #include "helpers.h" +#include "LoggingSystem.h" + // Global externs for the logging system LoggingSystem logger; @@ -34,7 +32,7 @@ void LoggingSystem::EnableConsoleLogging() } // Enables logging to file -void LoggingSystem::EnableFileLogging() +void LoggingSystem::EnableFileLogging(const std::string& logFilePath) { // Only open the file if not already opened if (!logToFile) @@ -43,7 +41,7 @@ void LoggingSystem::EnableFileLogging() // Open the log file, based on the pre-defined location // Placement new because std::ofstream is NOT copyable - new(&logFile) std::ofstream(LOGGING_FILE, std::ios::out); + new(&logFile) std::ofstream(logFilePath, std::ios::out | std::ios::trunc); if (!logFile.is_open()) { @@ -67,15 +65,29 @@ std::string LoggingSystem::GetLogCodeString(LOG_CODE logCode) return ("[" + logPrefixes[(unsigned) logCode] + "] "); } +// Checks if the cursor is at the end of the line +bool LoggingSystem::CursorAtEnd() +{ + if (logToConsole) + { + CONSOLE_SCREEN_BUFFER_INFO cbsi; + if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cbsi)) + return (cbsi.dwCursorPosition.X != 0); + } + return false; +} + + // Logs a message to the console window // Newline is ensured (for flushing) -void LoggingSystem::Log(LOG_CODE logCode, std::string message) +void LoggingSystem::Log(LOG_CODE logCode, std::string message, bool includePrefix) { // Don't log due to set verbosity level if (logCode > verbosity) return; - // Build the whole string in one go, to prevent thread cross-printing - std::string finalText = GetLogCodeString(logCode) + message + "\n"; + // Build the whole string in advance, to prevent thread cross-printing + std::string finalText = (CursorAtEnd()? "\n":"") + (includePrefix? GetLogCodeString(logCode) : "") + + message + "\n"; // Print the message, if needed if (logToConsole) @@ -91,7 +103,7 @@ void LoggingSystem::Log(LOG_CODE logCode, std::string message) // Logs a message to the console window, using the familiar "printf" format // Newline is ensured (for flushing) -void LoggingSystem::LogVariadic(LOG_CODE logCode, const char* formatString, ...) +void LoggingSystem::LogVariadic(LOG_CODE logCode, bool sameLine, const char* formatString, ...) { // Don't log due to set verbosity level if (logCode > verbosity) return; @@ -118,15 +130,15 @@ void LoggingSystem::LogVariadic(LOG_CODE logCode, const char* formatString, ...) va_end(argp); // Add the prefix to the gives format string - std::string message = GetLogCodeString(logCode) + newString + "\n"; + // Do not print a new line if current line should be overwritten + std::string message = (sameLine? "\r":(CursorAtEnd()? "\n":"")) + + GetLogCodeString(logCode) + newString + (sameLine? "":"\n"); // Print the message, if needed - if (logToConsole) - std::cout << message.c_str() << std::flush; + if (logToConsole) std::cout << message.c_str() << std::flush; // Log to file, if needed - if (logToFile) - logFile << message << std::flush; + if (logToFile) logFile << message << std::flush; // Clean up dynamic memory free(newString); diff --git a/AUMInjector/user/LoggingSystem.h b/AUMInjector/user/LoggingSystem.h index 08cbbd8..6925d88 100644 --- a/AUMInjector/user/LoggingSystem.h +++ b/AUMInjector/user/LoggingSystem.h @@ -1,11 +1,10 @@ +#pragma once + #include #include #include #include -// File to use for logging messages from the logging system -#define LOGGING_FILE "ProximityLogFile.txt" - enum class LOG_CODE { // Something went wrong @@ -30,49 +29,53 @@ enum class LOG_CODE // Basic logging system class LoggingSystem { -public: - // Closes the file, if needed - ~LoggingSystem(); - // Enables logging to console - void EnableConsoleLogging(); + public: + // Closes the file, if needed + ~LoggingSystem(); + + // Enables logging to console + void EnableConsoleLogging(); + + // Enables logging to file + void EnableFileLogging(const std::string& logFilePath); - // Enables logging to file - void EnableFileLogging(); + // Sets the max verbosity to print (anything above will not be printed) + void SetVerbosity(LOG_CODE verbosity); - // Sets the max verbosity to print (anything above will not be printed) - void SetVerbosity(LOG_CODE verbosity); + // Logs a message to the console window + // Newline is ensured (for flushing) + void Log(LOG_CODE logCode, std::string message, + bool includePrefix = true); - // Logs a message to the console window - // Newline is ensured (for flushing) - void Log(LOG_CODE logCode, std::string message); + // Logs a message to the console window, using the familiar "printf" format + // Newline is ensured (for flushing) + void LogVariadic(LOG_CODE logCode, bool sameLine, const char* formatString, ...); - // Logs a message to the console window, using the familiar "printf" format - // Newline is ensured (for flushing) - void LogVariadic(LOG_CODE logCode, const char* formatString, ...); + private: + // Returns the string for the code to the log (and possibly the file) + std::string GetLogCodeString(LOG_CODE logCode); -private: - // Returns the string for the code to the log (and possibly the file) - std::string GetLogCodeString(LOG_CODE logCode); + // Checks if the cursor is at the end of a line + bool CursorAtEnd(); - // Lookup tabe to be used with the LOG_CODE enum for message prefixes - std::string logPrefixes[(unsigned) LOG_CODE::COUNT] = { - "ERR", "WRN", "INF", "MSG", "DBG" - }; + // Lookup tabe to be used with the LOG_CODE enum for message prefixes + std::string logPrefixes[(unsigned) LOG_CODE::COUNT] = { + "ERR", "WRN", "INF", "MSG", "DBG" + }; - // If the logging system should log to file - bool logToFile = false; + // If the logging system should log to file + bool logToFile = false; - // If the logging system should log to console - bool logToConsole = false; + // If the logging system should log to console + bool logToConsole = false; - // Output log file - std::ofstream logFile; + // Output log file + std::ofstream logFile; - // Verbosity level, anything above will not be logged - LOG_CODE verbosity = LOG_CODE::DBG; + // Verbosity level, anything above will not be logged + LOG_CODE verbosity = LOG_CODE::DBG; - friend class ThreadSafeLogger; }; // Global extern logging system diff --git a/AUMInjector/user/MumbleLink.cpp b/AUMInjector/user/MumbleLink.cpp new file mode 100644 index 0000000..39d69cd --- /dev/null +++ b/AUMInjector/user/MumbleLink.cpp @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include "MumbleLink.h" +#include "Settings.h" + + +MumbleLink mumbleLink; + +// Initializes mumble IPC and RPC +DWORD MumbleLink::Init() +{ + // Open shared memory file IPC + mapHandle = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); + if (mapHandle == NULL) return GetLastError(); + linkedMem = (LinkedMem*)MapViewOfFile(mapHandle, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinkedMem)); + if (linkedMem == NULL) + { + DWORD err = GetLastError(); + CloseHandle(mapHandle); + mapHandle = NULL; + return err; + } + + // Write inital state to IPC + if (linkedMem->uiVersion != 2) + { + wcsncpy_s(linkedMem->name, L"Among Us", 256); + wcsncpy_s(linkedMem->description, L"Among Us support via the Link plugin.", 2048); + linkedMem->uiVersion = 2; + } + linkedMem->uiTick++; + // Write identity and context + wcsncpy_s(linkedMem->identity, L"Default", 256); + memcpy(linkedMem->context, "TEAM", 4); + linkedMem->context_len = 4; + // Write position + linkedMem->fAvatarFront[0] = 0.0f; + linkedMem->fAvatarFront[1] = 0.0f; + linkedMem->fAvatarFront[2] = 1.0f; + linkedMem->fAvatarTop[0] = 0.0f; + linkedMem->fAvatarTop[1] = 1.0f; + linkedMem->fAvatarTop[2] = 0.0f; + linkedMem->fAvatarPosition[0] = 0.0f; + linkedMem->fAvatarPosition[1] = 0.0f; + linkedMem->fAvatarPosition[2] = 0.0f; + for (int i = 0; i < 3; i++) + { + linkedMem->fCameraFront[i] = linkedMem->fAvatarFront[i]; + linkedMem->fCameraTop[i] = linkedMem->fAvatarTop[i]; + linkedMem->fCameraPosition[i] = linkedMem->fAvatarPosition[i]; + } + + return NO_ERROR; +} + +// Cleans up mumble IPC and RPC +void MumbleLink::Close() +{ + // Unmap IPC and close handles + if (linkedMem != NULL) + { + UnmapViewOfFile(linkedMem); + linkedMem = NULL; + } + if (mapHandle != NULL) + { + CloseHandle(mapHandle); + mapHandle = NULL; + } +} + +// Mutes or unmutes mumble via RPC +void MumbleLink::Mute(bool mute) +{ + std::thread t([mute] + { + if (mute) system(("\"" + appSettings.mumbleExe + "\" rpc mute").c_str()); + else system(("\"" + appSettings.mumbleExe + "\" rpc unmute").c_str()); + }); + t.detach(); +} diff --git a/AUMInjector/user/mumble-link.h b/AUMInjector/user/MumbleLink.h similarity index 60% rename from AUMInjector/user/mumble-link.h rename to AUMInjector/user/MumbleLink.h index fa99661..b9d3fa3 100644 --- a/AUMInjector/user/mumble-link.h +++ b/AUMInjector/user/MumbleLink.h @@ -1,13 +1,10 @@ #pragma once -#ifdef _WIN32 + #include -#else -#include -#include /* For O_* constants */ -#endif // _WIN32 #include -struct LinkedMem { +struct LinkedMem +{ #ifdef _WIN32 UINT32 uiVersion; DWORD uiTick; @@ -32,8 +29,19 @@ struct LinkedMem { wchar_t description[2048]; }; -extern LinkedMem* lm; +class MumbleLink +{ + + public: + LinkedMem* linkedMem = nullptr; + DWORD Init(); + void Close(); + void Mute(bool mute = true); + + private: + HANDLE mapHandle = nullptr; + void ExecCommand(const char* cmd); + +}; -int initMumble(); -void closeMumble(); -void muteMumble(bool mute = true); \ No newline at end of file +extern MumbleLink mumbleLink; diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index d895739..0b316bb 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -9,7 +9,7 @@ #include "il2cpp-appdata.h" #include "helpers.h" #include -#include "mumble-link.h" +#include "MumbleLink.h" #include "deobfuscate.h" #include "settings.h" #include "LoggingSystem.h" @@ -17,38 +17,37 @@ using namespace app; -extern const LPCWSTR LOG_FILE = L"il2cpp-log.txt"; extern HANDLE hExit; // Thread exit event // Game state -float cache_x = 0.0f; float cache_y = 0.0f; -bool send_position = true; -InnerNetClient_GameState__Enum last_game_state = InnerNetClient_GameState__Enum_Joined; +float posCache[2] = { 0.0f, 0.0f }; +bool sendPosition = true; +InnerNetClient_GameState__Enum lastGameState = InnerNetClient_GameState__Enum_Joined; -// Ints for tracking when to print the position -int frameCounter = 0; -const int timeToPrintPosition = 15; +// Couters for tracking when to print the position +unsigned int frameCounter = 0; +const unsigned int framesToPrintPosition = 15; // Start old cache as an impossible limit, for first-frame printing -float cacheXOld = std::numeric_limits::lowest(); -float cacheYOld = std::numeric_limits::lowest(); -// Floating-point epsilon for position printing +float prevPosCache[2] = { std::numeric_limits::lowest(), std::numeric_limits::lowest() }; +// Position difference treshold for printing float cachePosEpsilon = 0.001f; // Will log the position, if needed -void TryLogPosition() +void TryLogPosition(bool isLinked) { // Only print the player position every so many frames, and if it has changed - if (++frameCounter > timeToPrintPosition && ( - std::abs(cacheXOld - cache_x) > cachePosEpsilon || - std::abs(cacheYOld - cache_y) > cachePosEpsilon - )) + if (++frameCounter > framesToPrintPosition && + (std::abs(prevPosCache[0] - posCache[0]) > cachePosEpsilon || + std::abs(prevPosCache[1] - posCache[1]) > cachePosEpsilon) + ) { frameCounter = 0; // Store the old position - cacheXOld = cache_x; - cacheYOld = cache_y; + prevPosCache[0] = posCache[0]; + prevPosCache[1] = posCache[1]; // Log the current player position to let the player know it is working - logger.LogVariadic(LOG_CODE::INF, "Position: (% 7.3f, % 7.3f)", cache_x, cache_y); + logger.LogVariadic(LOG_CODE::MSG, true, "%s - Position: (%.3f, %.3f) ", + (isLinked ? "Linked" : "Not linked"), posCache[0], posCache[1]); } } @@ -57,12 +56,12 @@ void PlayerControl_FixedUpdate_Hook(PlayerControl* __this, MethodInfo* method) { PlayerControl_FixedUpdate_Trampoline(__this, method); - if (__this->fields.LightPrefab != nullptr && send_position) + if (__this->fields.LightPrefab != nullptr && sendPosition) { // Cache position Vector2 pos = PlayerControl_GetTruePosition_Trampoline(__this, method); - cache_x = pos.x; - cache_y = pos.y; + posCache[0] = pos.x; + posCache[1] = pos.y; } } @@ -74,7 +73,7 @@ void PlayerControl_Die_Hook(PlayerControl* __this, Player_Die_Reason__Enum reaso if (__this->fields.LightPrefab != nullptr) { logger.Log(LOG_CODE::MSG, "You died\n"); - muteMumble(true); + mumbleLink.Mute(true); } } @@ -83,7 +82,7 @@ void MeetingHud_Close_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Close_Trampoline(__this, method); logger.Log(LOG_CODE::MSG, "Meeting ended\n"); - send_position = true; + sendPosition = true; } // Gets called when a meeting starts @@ -91,7 +90,9 @@ void MeetingHud_Start_Hook(MeetingHud* __this, MethodInfo* method) { MeetingHud_Start_Trampoline(__this, method); logger.Log(LOG_CODE::MSG, "Meeting started\n"); - send_position = false; + sendPosition = false; + posCache[0] = 0.0f; + posCache[1] = 0.0f; } // Fixed loop for the game client @@ -100,53 +101,56 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) InnerNetClient_FixedUpdate_Trampoline(__this, method); // Check if game state changed to lobby - if (__this->fields.GameState != last_game_state && + if (__this->fields.GameState != lastGameState && (__this->fields.GameState == InnerNetClient_GameState__Enum_Joined || - __this->fields.GameState == InnerNetClient_GameState__Enum_Ended)) + __this->fields.GameState == InnerNetClient_GameState__Enum_Ended) + ) { - send_position = true; + sendPosition = true; logger.Log(LOG_CODE::MSG, "Game joined or ended"); - muteMumble(false); + mumbleLink.Mute(false); } - last_game_state = __this->fields.GameState; + lastGameState = __this->fields.GameState; - if (lm != NULL) + if (mumbleLink.linkedMem != nullptr) { - if (lm->uiVersion != 2) + if (mumbleLink.linkedMem->uiVersion != 2) { - wcsncpy_s(lm->name, L"Among Us", 256); - wcsncpy_s(lm->description, L"Among Us support via the Link plugin.", 2048); - lm->uiVersion = 2; + wcsncpy_s(mumbleLink.linkedMem->name, L"Among Us", 256); + wcsncpy_s(mumbleLink.linkedMem->description, L"Among Us support via the Link plugin.", 2048); + mumbleLink.linkedMem->uiVersion = 2; } - lm->uiTick++; - if (send_position) + mumbleLink.linkedMem->uiTick++; + if (sendPosition) { - lm->fAvatarPosition[0] = cache_x; - lm->fCameraPosition[0] = cache_x; - lm->fAvatarPosition[2] = cache_y; - lm->fCameraPosition[2] = cache_y; + mumbleLink.linkedMem->fAvatarPosition[0] = posCache[0]; + mumbleLink.linkedMem->fCameraPosition[0] = posCache[0]; + mumbleLink.linkedMem->fAvatarPosition[2] = posCache[1]; + mumbleLink.linkedMem->fCameraPosition[2] = posCache[1]; } else { // When voting or in menu, all players can hear each other - lm->fAvatarPosition[0] = 0.0f; - lm->fCameraPosition[0] = 0.0f; - lm->fAvatarPosition[2] = 0.0f; - lm->fCameraPosition[2] = 0.0f; - // Reset cached position - cache_x = 0.0f; - cache_y = 0.0f; + mumbleLink.linkedMem->fAvatarPosition[0] = 0.0f; + mumbleLink.linkedMem->fCameraPosition[0] = 0.0f; + mumbleLink.linkedMem->fAvatarPosition[2] = 0.0f; + mumbleLink.linkedMem->fCameraPosition[2] = 0.0f; + // Reset cached position for logging + posCache[0] = 0.0f; + posCache[1] = 0.0f; } - TryLogPosition(); } + TryLogPosition(mumbleLink.linkedMem != nullptr); } void InnerNetClient_Disconnect_Hook(InnerNetClient* __this, InnerNet_DisconnectReasons__Enum reason, String* stringReason, MethodInfo* method) { InnerNetClient_Disconnect_Trampoline(__this, reason, stringReason, method); logger.Log(LOG_CODE::MSG, "Disconnected from server"); - send_position = false; - muteMumble(false); + sendPosition = false; + mumbleLink.Mute(false); + posCache[0] = 0.0f; + posCache[1] = 0.0f; } // Entrypoint of the injected thread @@ -156,35 +160,35 @@ void Run() // If loaded into the wrong process, exit injected thread TCHAR hostExe[MAX_PATH]; GetModuleFileName(NULL, hostExe, MAX_PATH); - char fname[_MAX_FNAME]; - _splitpath_s(hostExe, NULL, 0, NULL, 0, fname, _MAX_FNAME, NULL, 0); - if (strcmp(fname, "Among Us") == 0) + char filename[_MAX_FNAME]; + _splitpath_s(hostExe, NULL, 0, NULL, 0, filename, _MAX_FNAME, NULL, 0); + if (strcmp(filename, "Among Us") == 0) { // Load settings - app_settings.parse(); - app_settings.print_usage(); - logger.Log(LOG_CODE::MSG, "Current configuration:\n----\n"); - app_settings.print_config(); - printf("----\n\n"); - - // Enable the logger - if (!app_settings.noConsole) logger.EnableConsoleLogging(); - logger.EnableFileLogging(); // File logging enabled by defa + appSettings.Parse(); + // Setup the logger + logger.SetVerbosity(appSettings.logVerbosity); + if (!appSettings.disableLogConsole) logger.EnableConsoleLogging(); + if (!appSettings.disableLogFile) logger.EnableFileLogging(appSettings.logFileName); // Credits & Info - logger.Log(LOG_CODE::MSG, "AmongUs-Mumble mod by:"); - logger.Log(LOG_CODE::MSG, "\tStarGate01 (chrz.de): Proxy DLL, Framework, Setup, Features."); - logger.Log(LOG_CODE::MSG, "\tAlisenai (Alien): Fixes, More Features."); - logger.Log(LOG_CODE::MSG, "\tBillyDaBongo (Billy): Management, Testing."); - logger.Log(LOG_CODE::MSG, "\tLelouBi:\t\tDeobfuscation.\n\n"); + logger.Log(LOG_CODE::ERR, "AmongUs-Mumble mod by:", false); + logger.Log(LOG_CODE::ERR, " StarGate01 (chrz.de):\tProxy DLL, Framework, Setup, Features.", false); + logger.Log(LOG_CODE::ERR, " Alisenai (Alien):\tFixes, More Features.", false); + logger.Log(LOG_CODE::ERR, " BillyDaBongo (Billy):\tManagement, Testing.", false); + logger.Log(LOG_CODE::ERR, " LelouBi:\t\tDeobfuscation.\n\n", false); + + logger.LogVariadic(LOG_CODE::INF, false, "Compiled for game version %s", version_text); + logger.Log(LOG_CODE::INF, "DLL hosting successful"); - logger.LogVariadic(LOG_CODE::MSG, "Compiled for game version %s", version_text); - logger.Log(LOG_CODE::INF, "DLL hosting successful"); + // Print current config + logger.Log(LOG_CODE::MSG, "Current configuration:\n"); + logger.Log(LOG_CODE::MSG, appSettings.app.config_to_str(true, false) + "\n", false); // Setup mumble - int lErrMumble = initMumble(); - if (lErrMumble == NO_ERROR) logger.Log(LOG_CODE::INF, "Mumble link init successful"); - else logger.LogVariadic(LOG_CODE::ERR, "Cannot init Mumble link: ", lErrMumble); + DWORD errMumble = mumbleLink.Init(); + if (errMumble == NO_ERROR) logger.Log(LOG_CODE::INF, "Mumble link init successful"); + else logger.LogVariadic(LOG_CODE::ERR, false, "Cannot init Mumble link: %d", errMumble); // Setup type and memory info logger.Log(LOG_CODE::MSG, "Waiting 10s for Unity to load"); @@ -203,13 +207,13 @@ void Run() DetourAttach(&(PVOID&)InnerNetClient_Disconnect_Trampoline, InnerNetClient_Disconnect_Hook); //dynamic_analysis_attach(); - LONG lError = DetourTransactionCommit(); - if (lError == NO_ERROR) logger.Log(LOG_CODE::INF, "Successfully detoured game functions"); - else logger.LogVariadic(LOG_CODE::ERR, "Detouring game functions failed: ", lError); + LONG errDetour = DetourTransactionCommit(); + if (errDetour == NO_ERROR) logger.Log(LOG_CODE::INF, "Successfully detoured game functions"); + else logger.LogVariadic(LOG_CODE::ERR, false, "Detouring game functions failed: %d", errDetour); // Wait for thread exit and then clean up WaitForSingleObject(hExit, INFINITE); - closeMumble(); + mumbleLink.Close(); logger.Log(LOG_CODE::MSG, "Unloading done\n"); } } diff --git a/AUMInjector/user/mumble-link.cpp b/AUMInjector/user/mumble-link.cpp deleted file mode 100644 index 2e66751..0000000 --- a/AUMInjector/user/mumble-link.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include -#include "mumble-link.h" -#include "settings.h" - - -LinkedMem* lm = NULL; -HANDLE hMapObject = NULL; - -// Initializes mumble IPC and RPC -int initMumble() -{ - // Open shared memory file IPC - hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); - if (hMapObject == NULL) return GetLastError(); - lm = (LinkedMem*)MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinkedMem)); - if (lm == NULL) - { - int err = GetLastError(); - CloseHandle(hMapObject); - hMapObject = NULL; - return err; - } - - // Write inital state to IPC - if (lm->uiVersion != 2) - { - wcsncpy_s(lm->name, L"Among Us", 256); - wcsncpy_s(lm->description, L"Among Us support via the Link plugin.", 2048); - lm->uiVersion = 2; - } - lm->uiTick++; - // Write identity and context - wcsncpy_s(lm->identity, L"Default", 256); - memcpy(lm->context, "TEAM", 4); - lm->context_len = 4; - // Write position - lm->fAvatarFront[0] = 0.0f; - lm->fAvatarFront[1] = 0.0f; - lm->fAvatarFront[2] = 1.0f; - lm->fAvatarTop[0] = 0.0f; - lm->fAvatarTop[1] = 1.0f; - lm->fAvatarTop[2] = 0.0f; - lm->fAvatarPosition[0] = 0.0f; - lm->fAvatarPosition[1] = 0.0f; - lm->fAvatarPosition[2] = 0.0f; - for (int i = 0; i < 3; i++) { - lm->fCameraFront[i] = lm->fAvatarFront[i]; - lm->fCameraTop[i] = lm->fAvatarTop[i]; - lm->fCameraPosition[i] = lm->fAvatarPosition[i]; - } - - return NO_ERROR; -} - -// Cleans up mumble IPC and RPC -void closeMumble() -{ - // Unmap IPC and close handles - if (lm != NULL) - { - UnmapViewOfFile(lm); - lm = NULL; - } - if (hMapObject != NULL) - { - CloseHandle(hMapObject); - hMapObject = NULL; - } -} - -// Mutes or unmutes mumble via RPC -void muteMumble(bool mute) -{ - std::thread t([mute] { - if (mute) system(("\"" + app_settings.mumble_exe + "\" rpc mute").c_str()); - else system(("\"" + app_settings.mumble_exe + "\" rpc unmute").c_str()); - }); - t.detach(); -} diff --git a/AUMInjector/user/settings.cpp b/AUMInjector/user/settings.cpp index 4f75750..8de6cf9 100644 --- a/AUMInjector/user/settings.cpp +++ b/AUMInjector/user/settings.cpp @@ -5,28 +5,31 @@ #include "helpers.h" Settings::Settings(): - mumble_exe("C:\\Program Files\\Mumble\\mumble.exe"), - noConsole(false), - app("AmongUs-Mumble", "Among Us.exe") + app("AmongUs-Mumble", "Among Us.exe"), + mumbleExe("C:\\Program Files\\Mumble\\mumble.exe"), + disableLogConsole(false), + disableLogFile(false), + logVerbosity(LOG_CODE::MSG), + logFileName("ProximityLog.txt") { } -void Settings::parse() +void Settings::Parse() { // Setup argument parser app.allow_extras(true); app.allow_config_extras(true); - app.set_config("-c,--config", "config.ini", "Read an INI configuration file", false); - app.add_option("-m,--mumble", mumble_exe, "Mumble executable path", true); - app.add_flag("-n,--no-console", noConsole, "Disable the console"); + app.set_config("-c,--config", "ProximityConfig.ini", "Read an INI configuration file", false); + app.add_option("-m,--mumble", mumbleExe, "Mumble executable path", true); + app.add_flag("--no-log-console", disableLogConsole, "Disable logging to the console"); + app.add_flag("--no-log-file", disableLogFile, "Disable logging to a file"); + app.add_option("--log-file-path", logFileName, "Path to the log file", true); + app.add_option("--log-verbosity", logVerbosity, "Log verbosity", true); // Get arguments from OS int argc; LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); // Convert arguments from unicode to narrow _bstr_t** argv_bstr = (_bstr_t**)malloc(argc * sizeof(_bstr_t*)); - M_ASSERT(argv_bstr != nullptr, "Could not allocate sufficient memory."); char** argv_narrow = (char**)malloc(argc * sizeof(char*)); - M_ASSERT(argv_narrow != nullptr, "Could not allocate sufficient memory."); - for (int i = 0; i < argc; i++) { argv_bstr[i] = (_bstr_t*)new _bstr_t(argv[i]); @@ -43,16 +46,13 @@ void Settings::parse() } free(argv_bstr); free(argv_narrow); -} - -void Settings::print_usage() -{ - std::cout << app.help(); -} -void Settings::print_config() -{ - std::cout << app.config_to_str(true, true); + // Write out config file + std::ofstream configFileOut; + configFileOut.open(app.get_config_ptr()->as(), std::ios::out | std::ios::trunc); + // Serialize settings with annotations + configFileOut << app.config_to_str(true, true); + configFileOut.close(); } -Settings app_settings; \ No newline at end of file +Settings appSettings; \ No newline at end of file diff --git a/AUMInjector/user/settings.h b/AUMInjector/user/settings.h index 38fc84d..8a8f59e 100644 --- a/AUMInjector/user/settings.h +++ b/AUMInjector/user/settings.h @@ -2,20 +2,20 @@ #include #include "CLI11.hpp" +#include "LoggingSystem.h" class Settings { public: - std::string mumble_exe; - bool noConsole; + CLI::App app; + std::string mumbleExe; + bool disableLogConsole; + bool disableLogFile; + LOG_CODE logVerbosity; + std::string logFileName; Settings(); - void parse(); - void print_usage(); - void print_config(); - - private: - CLI::App app; + void Parse(); }; -extern Settings app_settings; +extern Settings appSettings; From 5388b3ca3aa942af45870e1bd25511b50a7dfc37 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Fri, 13 Nov 2020 08:13:46 +0100 Subject: [PATCH 26/27] Add directional audio option, fixes #24 --- AUMInjector/user/LoggingSystem.cpp | 1 + AUMInjector/user/main.cpp | 21 ++++++++++++--------- AUMInjector/user/settings.cpp | 19 ++++++++++++++++++- AUMInjector/user/settings.h | 2 ++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/AUMInjector/user/LoggingSystem.cpp b/AUMInjector/user/LoggingSystem.cpp index e5f6b25..eed8ffe 100644 --- a/AUMInjector/user/LoggingSystem.cpp +++ b/AUMInjector/user/LoggingSystem.cpp @@ -131,6 +131,7 @@ void LoggingSystem::LogVariadic(LOG_CODE logCode, bool sameLine, const char* for // Add the prefix to the gives format string // Do not print a new line if current line should be overwritten + sameLine = sameLine && logToConsole; std::string message = (sameLine? "\r":(CursorAtEnd()? "\n":"")) + GetLogCodeString(logCode) + newString + (sameLine? "":"\n"); diff --git a/AUMInjector/user/main.cpp b/AUMInjector/user/main.cpp index 0b316bb..edb8eb6 100644 --- a/AUMInjector/user/main.cpp +++ b/AUMInjector/user/main.cpp @@ -20,7 +20,7 @@ using namespace app; extern HANDLE hExit; // Thread exit event // Game state -float posCache[2] = { 0.0f, 0.0f }; +float posCache[3] = { 0.0f, 0.0f, 0.0f }; bool sendPosition = true; InnerNetClient_GameState__Enum lastGameState = InnerNetClient_GameState__Enum_Joined; @@ -123,18 +123,21 @@ void InnerNetClient_FixedUpdate_Hook(InnerNetClient* __this, MethodInfo* method) mumbleLink.linkedMem->uiTick++; if (sendPosition) { - mumbleLink.linkedMem->fAvatarPosition[0] = posCache[0]; - mumbleLink.linkedMem->fCameraPosition[0] = posCache[0]; - mumbleLink.linkedMem->fAvatarPosition[2] = posCache[1]; - mumbleLink.linkedMem->fCameraPosition[2] = posCache[1]; + // Map player position to mumble according to directional / non directional setting + for (int i = 0; i < 3; i++) + { + mumbleLink.linkedMem->fAvatarPosition[i] = posCache[appSettings.audioCoordinateMap[i]]; + mumbleLink.linkedMem->fCameraPosition[i] = posCache[appSettings.audioCoordinateMap[i]]; + } } else { // When voting or in menu, all players can hear each other - mumbleLink.linkedMem->fAvatarPosition[0] = 0.0f; - mumbleLink.linkedMem->fCameraPosition[0] = 0.0f; - mumbleLink.linkedMem->fAvatarPosition[2] = 0.0f; - mumbleLink.linkedMem->fCameraPosition[2] = 0.0f; + for (int i = 0; i < 3; i++) + { + mumbleLink.linkedMem->fAvatarPosition[i] = 0.0f; + mumbleLink.linkedMem->fCameraPosition[i] = 0.0f; + } // Reset cached position for logging posCache[0] = 0.0f; posCache[1] = 0.0f; diff --git a/AUMInjector/user/settings.cpp b/AUMInjector/user/settings.cpp index 8de6cf9..2481428 100644 --- a/AUMInjector/user/settings.cpp +++ b/AUMInjector/user/settings.cpp @@ -10,7 +10,8 @@ Settings::Settings(): disableLogConsole(false), disableLogFile(false), logVerbosity(LOG_CODE::MSG), - logFileName("ProximityLog.txt") + logFileName("ProximityLog.txt"), + directionalAudio(false) { } void Settings::Parse() @@ -24,6 +25,7 @@ void Settings::Parse() app.add_flag("--no-log-file", disableLogFile, "Disable logging to a file"); app.add_option("--log-file-path", logFileName, "Path to the log file", true); app.add_option("--log-verbosity", logVerbosity, "Log verbosity", true); + app.add_flag("--directional-audio", directionalAudio, "Enable directional audio"); // Get arguments from OS int argc; LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); @@ -53,6 +55,21 @@ void Settings::Parse() // Serialize settings with annotations configFileOut << app.config_to_str(true, true); configFileOut.close(); + + // Generate audio coordinate map + // Mumble -> Ingame + if (directionalAudio) + { + audioCoordinateMap[0] = 0; // X -> X + audioCoordinateMap[1] = 2; // Y -> 0 + audioCoordinateMap[2] = 1; // Z -> Y + } + else + { + audioCoordinateMap[0] = 2; // X -> 0 + audioCoordinateMap[1] = 0; // Y -> X + audioCoordinateMap[2] = 1; // Z -> Y + } } Settings appSettings; \ No newline at end of file diff --git a/AUMInjector/user/settings.h b/AUMInjector/user/settings.h index 8a8f59e..6caede7 100644 --- a/AUMInjector/user/settings.h +++ b/AUMInjector/user/settings.h @@ -13,6 +13,8 @@ class Settings bool disableLogFile; LOG_CODE logVerbosity; std::string logFileName; + bool directionalAudio; + int audioCoordinateMap[3]; Settings(); void Parse(); From 64500094302e6f2a5d70499876876b2e8013e9bd Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Fri, 13 Nov 2020 08:17:00 +0100 Subject: [PATCH 27/27] Bump version string --- AUMInjector/AUMInjector.rc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AUMInjector/AUMInjector.rc b/AUMInjector/AUMInjector.rc index 12e988a..9dcd7ae 100644 --- a/AUMInjector/AUMInjector.rc +++ b/AUMInjector/AUMInjector.rc @@ -51,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,4 - PRODUCTVERSION 1,0,0,4 + FILEVERSION 1,0,0,5 + PRODUCTVERSION 1,0,0,5 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -69,12 +69,12 @@ BEGIN BEGIN VALUE "CompanyName", "chrz.de" VALUE "FileDescription", "Among Us to Mumble VoIP adapter" - VALUE "FileVersion", "1.0.0.4" + VALUE "FileVersion", "1.0.0.5" VALUE "InternalName", "winhttp.dll" VALUE "LegalCopyright", "Copyright (C) chrz.de 2020" VALUE "OriginalFilename", "winhttp.dll" VALUE "ProductName", "AmongUs-Mumble" - VALUE "ProductVersion", "1.0.0.4" + VALUE "ProductVersion", "1.0.0.5" END END BLOCK "VarFileInfo"