Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
StarGate01 committed Nov 13, 2020
2 parents de9c0ee + 6450009 commit 233aeec
Show file tree
Hide file tree
Showing 20 changed files with 771 additions and 289 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,11 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

tmp
tmp
/cmake-build-release/
/cmake-build-debug/
/.idea/

Il2CppInspector*

setup.bat
8 changes: 4 additions & 4 deletions AUMInjector/AUMInjector.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
11 changes: 8 additions & 3 deletions AUMInjector/AUMInjector.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand All @@ -13,8 +13,10 @@
<ItemGroup>
<ClCompile Include="framework\helpers.cpp" />
<ClCompile Include="framework\il2cpp-init.cpp" />
<ClCompile Include="user\LoggingSystem.cpp" />
<ClCompile Include="user\MumbleLink.cpp" />
<ClCompile Include="user\main.cpp" />
<ClCompile Include="user\mumble-link.cpp" />
<ClCompile Include="user\Settings.cpp" />
<ClCompile Include="user\winhttp.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -32,8 +34,11 @@
<ClInclude Include="framework\il2cpp-init.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="user\CLI11.hpp" />
<ClInclude Include="user\LoggingSystem.h" />
<ClInclude Include="user\MumbleLink.h" />
<ClInclude Include="user\main.h" />
<ClInclude Include="user\mumble-link.h" />
<ClInclude Include="user\deobfuscate.h" />
<ClInclude Include="user\Settings.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AUMInjector.rc" />
Expand Down
27 changes: 21 additions & 6 deletions AUMInjector/AUMInjector.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@
<ClCompile Include="framework\il2cpp-init.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="user\mumble-link.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="user\winhttp.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="framework\helpers.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="user\LoggingSystem.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="user\MumbleLink.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="user\Settings.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down Expand Up @@ -62,9 +68,6 @@
<ClInclude Include="appdata\il2cpp-types-ptr.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="user\mumble-link.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Headerdateien</Filter>
</ClInclude>
Expand All @@ -74,6 +77,18 @@
<ClInclude Include="framework\helpers.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="user\deobfuscate.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="user\LoggingSystem.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="user\MumbleLink.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="user\Settings.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AUMInjector.rc">
Expand Down
25 changes: 2 additions & 23 deletions AUMInjector/framework/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,8 @@
#include <string>
#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");
}

// 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);
}
9 changes: 2 additions & 7 deletions AUMInjector/framework/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@
// 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<typename T> std::string to_hex_string(T i) {
template<typename T> 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();
Expand Down
1 change: 1 addition & 0 deletions AUMInjector/user/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dynamic_analysis.h
146 changes: 146 additions & 0 deletions AUMInjector/user/LoggingSystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include <windows.h>
#include <iostream>
#include <string>
#include "helpers.h"
#include "LoggingSystem.h"


// Global externs for the logging system
LoggingSystem logger;

// Closes the file, if needed
LoggingSystem::~LoggingSystem()
{
// Close the file, if needed
if (logToFile)
logFile.close();
}

// Enables logging to console
void LoggingSystem::EnableConsoleLogging()
{
// Only open the console if not already opened
if (!logToConsole)
{
logToConsole = true;

// Open a console (to log to)
AllocConsole();
freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
ShowWindow(GetConsoleWindow(), SW_MINIMIZE);
}
}

// Enables logging to file
void LoggingSystem::EnableFileLogging(const std::string& logFilePath)
{
// 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(logFilePath, std::ios::out | std::ios::trunc);

if (!logFile.is_open())
{
// Don't log to file, something went wrong
Log(LOG_CODE::LOG_CODE_WARNING, "Could not initialize the log file - will not log to file");
logToFile = false;
}
}
}

// Sets the max verbosity to print (anything above will not be printed)
void LoggingSystem::SetVerbosity(LOG_CODE verbosity)
{
this->verbosity = verbosity;
}

// Prints the string for the code to the log (and possibly the file)
std::string LoggingSystem::GetLogCodeString(LOG_CODE logCode)
{
// Return the log code string
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, bool includePrefix)
{
// Don't log due to set verbosity level
if (logCode > verbosity) return;

// 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)
std::cout << finalText << std::flush;

// Log to file, if needed
if (logToFile)
{
logFile << finalText;
logFile.flush();
}
}

// Logs a message to the console window, using the familiar "printf" format
// Newline is ensured (for flushing)
void LoggingSystem::LogVariadic(LOG_CODE logCode, bool sameLine, const char* formatString, ...)
{
// Don't log due to set verbosity level
if (logCode > verbosity) return;

va_list argp = { nullptr };

// 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);

// Create a buffer for the string
char* newString = (char*)malloc(bufferLen);

// 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
// 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");

// Print the message, if needed
if (logToConsole) std::cout << message.c_str() << std::flush;

// Log to file, if needed
if (logToFile) logFile << message << std::flush;

// Clean up dynamic memory
free(newString);
}
Loading

0 comments on commit 233aeec

Please sign in to comment.