Commit Graph

608 Commits

Author SHA1 Message Date
Davide Beatrici
9d5feb54e6
Merge PR #5087: FIX(client): Use ReadProcessMemory() instead of Toolhelp32ReadProcessMemory() 2021-06-02 19:22:59 +02:00
Robert Adam
6fc8de5f31
Merge PR #5084: REFAC(client): Remove unnecessary include
The windows header was included for the definition of M_PI. However
given that we define _USE_MATH_DEFINES globally for all source files and
cmath is included already, this symbol is defined by cmath, making the
windows-specific header superfluous.
2021-06-02 11:20:55 +02:00
Davide Beatrici
198621f19c FIX(client): Use ReadProcessMemory() instead of Toolhelp32ReadProcessMemory()
I was wrong in d7f0302ce7.

Turns out Toolhelp32ReadProcessMemory() is simply a wrapper for ReadProcessMemory() that takes care of opening an handle to the process and closing it.

For reference: https://github.com/MicrosoftDocs/sdk-api/pull/793
2021-06-02 02:56:05 +02:00
Robert Adam
3a4d9df4ea REFAC(client): Remove unnecessary include
The windows header was included for the definition of M_PI. However
given that we define _USE_MATH_DEFINES globally for all source files and
cmath is included already, this symbol is defined by cmath, making the
windows-specific header superfluous.
2021-06-01 21:10:09 +02:00
jisopo
f9ded8415c BUILD(windows): Fix missing include
some of overlay source files such as: amongus, cod2 and se uses
std::unique_ptr
which requires include <memory>
2021-06-01 08:13:16 +02:00
Robert Adam
e9aa3c728a REFAC(plugin): Rename plugin ID parameter
Instead of passing the type name directly we pass the alias instead in
order to make code more easily portable between API versions.
2021-05-26 12:33:17 +02:00
Septarius
5f5024f723
BUILD(plugin): Add QT_CORE_LIB to QT_VERSION Check
PluginComponents uses this check to determine if Qt library is already used so we don't want to force a Qt include.
Unity build triggered this since I believe it moved the header into a different compilation unit or compiled it first.

QT_VERSION requires #include <QtGlobal> before using it.
From: https://stackoverflow.com/questions/24899558/how-to-check-qt-version-to-include-different-header

QT_CORE_LIB is set by CMake
From: https://stackoverflow.com/questions/30840176/what-preprocessor-can-i-used-to-detect-if-qt-is-used-to-build-my-codes

Alternate solution could be using __if_include per https://forum.qt.io/post/564320 . But that appears to require C++17 mode.

Error log:
In file included from src/mumble/CMakeFiles/mumble.dir/Unity/unity_1_cxx.cxx:4:
... /src/mumble/PluginInstaller.cpp: In member function ‘void PluginInstaller::init()’:
... /src/mumble/PluginInstaller.cpp:149:92: error: no matching function for call to ‘QString::QString(mumble_version_t&)’
  149 |    .arg(pluginVersion == VERSION_UNKNOWN ? "Unknown" : static_cast< QString >(pluginVersion))

Co-authored-by: Robert Adam <dev@robert-adam.de>
2021-05-18 16:26:28 -06:00
Robert Adam
923045ac60 FORMAT: Run clang-format 10 on all source files 2021-04-16 21:05:52 +02:00
Robert Adam
27dbee8e62 FEAT(client): Plugin framework
This commit introduces a new plugin framework into the codebase of the
Mumble client. Note that "plugin" here really refers to a (more or less)
general purpose plugin and is therefore not to be confused with the
previously available positional data plugins (only responsible for
fetching positional data from a running game and passing that to
Mumble).

The plugin interface is written in C, removing the compiler-dependence
the old "plugins" had. Instead plugins can now be written in an
arbitrary language as long as that language is capable of being compiled
into a shared library and also being capable of being C-compatible.

As already indicated a plugin is essentially a shared library that
provides certain functions that allow Mumble to interface with it.

Inside Mumble the so-called PluginManager is responsible for managing
the plugins and relaying events to the respective callbacks. Plugins
themselves can also interact with Mumble on their own initiative by
using the provided API functions.

Fixes #2455
Fixes #2148
Fixes #1594
Fixes #2051
Fixes #3742
Fixes #4575
Fixes #4751
2021-04-16 20:15:44 +02:00
Robert
56db3410c5 MAINT: Update copyright notice to 2021 (Part II)
Apparently the first commit (59ae429972)
did not include all files.

Furthermore the used script tended to produce funny results in certain
cases. This has been fixed and as a result thereof a few more changes
were made in this second run.
2021-04-09 15:41:49 +02:00
Davide Beatrici
6ceeef39ae FIX(positional-audio): Update Among Us plugin to work with v2021.3.31.3s
https://store.steampowered.com/news/app/945360/view/3021326294554201922
2021-04-03 07:26:02 +02:00
Davide Beatrici
ea69658bba FIX(positional-audio): Fix and revamp Call of Duty 2 plugin
It was not working because the camera position values were all set to 0.

This commit fixes the issue while also revamping the code.
2021-03-17 08:07:27 +01:00
Davide Beatrici
e152fa7603 FIX(positional-audio): Update Among Us plugin to work with v2021.3.5s
https://store.steampowered.com/news/app/945360/view/3050597789009577255
2021-03-15 07:47:26 +01:00
Robert Adam
678e872c21 BUILD(cmake): Always define _USE_MATH_DEFINES
This is needed in order for the <cmath> header to also define constants
like M_PI. Instead of manually defining the macro every time before
including <cmath>, the macro is now defined via cmake and thus always
defined.
2021-03-06 18:57:22 +01:00
Robert Adam
59ae429972 MAINT: Update copyright notice to 2021
This was done by running scripts/updateLicenseHeaders.py and then
manually editing the LICENSE file.
2021-03-02 10:15:01 +01:00
Davide Beatrici
f069abdf77 FIX(positional-audio): Update Among Us plugin to work with v2020.12.09s
The reason why the signature has to be stricter now is due to a very similar function being present at an earlier address:

il2cpp:10E99B02 83 C4 08          add     esp, 8
il2cpp:10E99B05 84 C0             test    al, al
il2cpp:10E99B07 74 39             jz      short loc_10E99B42
il2cpp:10E99B09 A1 AC 7C C5 11    mov     eax, HLBNNHFCNAJ__TypeInfo ; HLBNNHFCNAJ
il2cpp:10E99B0E 8B 40 5C          mov     eax, [eax+5Ch]
il2cpp:10E99B11 8B 38             mov     edi, [eax]

il2cpp:112CC4B8 83 C4 08          add     esp, 8
il2cpp:112CC4BB 84 C0             test    al, al
il2cpp:112CC4BD 74 39             jz      short loc_112CC4F8
il2cpp:112CC4BF A1 54 7F C5 11    mov     eax, FMLLKEACGIO__TypeInfo ; FMLLKEACGIO
il2cpp:112CC4C4 8B 40 5C          mov     eax, [eax+5Ch]
il2cpp:112CC4C7 8B 00             mov     eax, [eax]

FMLLKEACGIO is AmongUsClient, the object we need.

See https://wiki.weewoo.net/wiki/Translations for more info on the obfuscated names.
2021-01-01 21:16:18 +01:00
Nik Reist
88e1786849 REFAC(installer-msi) Simplify WiX component install
Remove CPack and previous WiX installer projects and sources
Add toolset and for WixSharp to facilitate client and server builds
individually or collectively.
Add multilanguage build with packaging=ON and translations=ON, and
standard build with packaging=ON. Builds are also aware of client and
server option settings.
Add correct LICENSE to installer
2020-12-11 22:07:25 -05:00
Benson Muite
71645e4c8c
FIX(plugin): initialize array to prevent warning
When building on CentOS 8 with default flags which includes Wall flag, 
build stops because array n[3] is not initialized. Initialize it to have all 
values to be zero.
2020-11-29 20:19:32 +03:00
Davide Beatrici
2feebe6801 FEAT(positional-audio): Add plugin for Among Us
Tested with v2020.10.22s and v2020.09.22s.

Unless the pattern we're searching for becomes invalid or the structures we're using change, the plugin should keep working.
2020-11-11 05:25:56 +01:00
Davide Beatrici
8542c9a857 FEAT(positional-audio): Add searchInBuffer() and findPattern()
searchInBuffer() searches for the specified pattern in the specified buffer. "?" is used as wildcard.

findPattern(), given a start address and the size of the area, reads memory in chunks of 32 KiB.

It stops when a match is found, the end is reached or an error is encountered (peek() fails).

There's also an overload which iterates through the specified module's readable regions.
2020-11-11 05:25:52 +01:00
Davide Beatrici
5cbd01f984 FIX(positional-audio): Fix Source Engine plugin using wrong player ID on Linux
The code was retrieving the wrong offset (GetLocalClient).

As a result, peek() always returned 0 and the player ID was always 1.

The plugin appeared to be working fine because the player ID is always 1 when playing locally.
2020-11-09 06:32:15 +01:00
Davide Beatrici
988b8417ac REFAC(positional-audio): Proper functions/classes for module-related operations
Previously, only module() was present: it retrieved the base address of the specified module.

It worked fine, but it iterated through the process' modules every time it was called.

This commit replaces it with modules(), which returns an std::unordered_map containing all modules.

The map uses the module name as key and Module as value.

Aside from the performance improvement, the new code also provides info for each module region:

- Start address.
- Size.
- Whether it's readable, writable and/or executable.
2020-11-06 21:37:06 +01:00
Davide Beatrici
68873e5ed0 FIX(positional-audio): Wrong character size used for wide strings
"wchar_t" is usually 4 bytes big. That's not the case on Windows, where it's 2 bytes instead.

We cannot rely on that type on Linux because the target process could be native or running through Wine.

Also, it's possible that a game uses the same size for "wchar_t" on both Linux and Windows.

This commit introduces two variants of utf16ToUtf8():

1. Accepts std::u16string, for Windows processes.
2. Accepts std::u32string, for Linux processes.

The old variant, which accepted std::wstring, is removed to prevent misuses.
2020-11-04 20:32:32 +01:00
Davide Beatrici
c96153e2c6 REFAC(plugins): Move "m_ok" variable from HostLinux and HostWindows to Process
HostWindows' constructor only initializes its variables now, like HostLinux'.
2020-11-02 09:15:54 +01:00
Davide Beatrici
d7f0302ce7 REFAC(plugins): Use Toolhelp32ReadProcessMemory() instead of ReadProcessMemory()
Toolhelp32ReadProcessMemory() takes the process ID, as opposed to ReadProcessMemory().

This allows us to read memory without the need for an handle (OpenProcess()).
2020-11-02 09:15:50 +01:00
Davide Beatrici
13cbf72877 REFAC(plugins): Use new C++ classes in Source Engine plugin 2020-10-28 19:27:01 +01:00
Davide Beatrici
0968efa7b4 BUILD(plugins): Add directory to include paths for each plugin
This allows to include the headers without the need to go up one level.
2020-10-28 19:27:01 +01:00
Davide Beatrici
253b814ba5 FEAT(plugins): Add classes for process-related functions
Since most of the functions are already using C++, why not use classes as well?

This commit introduces the following classes:

- HostLinux: can only be compiled on Linux.
Implements peek() and module().

- HostWindows: can only be compiled on Windows.
Implements peek() and module().

- Process: abstract (cannot be instantiated directly).
Inherits from HostLinux on Linux and from HostWindows on Windows.
Provides functions that can be used with both Linux and Windows processes.
Pure virtual functions are implemented in the following classes:

- ProcessLinux: meant to be used with Linux processes, inherits from Process.
Only implements exportedSymbol(), due to the other functions being universal.
The constructor detects the architecture through the ELF header.

- ProcessWindows: meant to be used with Windows processes, inherits from Process.
Only implements exportedSymbol(), due to the other functions being universal.
The constructor detects the architecture through the NT header.
2020-10-28 19:26:56 +01:00
Davide Beatrici
5debd105e3 FEAT/REFAC(plugins): Add utf8ToUtf16(), move and rename readAll()
The new function is going to be used in a later commit.

readAll() is moved to mumble_plugin_utils.h and is renamed to readFile(), to make its purpose clearer.

This commit also moves the <math.h> include to mumble_plugin_utils.h, because that's where it's required.
Also, it's now included as <cmath>, as recommended for C++.
2020-10-27 23:18:21 +01:00
Robert Adam
bf9550a68e
Merge pull request #4503: BUILD(cmake): Revamp install paths
Installation paths can now be fine-tuned by setting the respective
MUMBLE_INSTALLATION_* variables when invoking cmake.

Additionally some components that only had install rules for a certain
OS are now installed on all OSes as these components should be needed
there as well.
2020-10-24 17:38:56 +02:00
Robert
b9b41621c5 BUILD(cmake): Revamp install paths
Installation paths can now be fine-tuned by setting the respective
MUMBLE_INSTALLATION_* variables when invoking cmake.

Additionally some components that only had install rules for a certain
OS are now installed on all OSes as these components should be needed
there as well.
2020-10-24 15:57:01 +02:00
Davide Beatrici
4eee619eb1 REFAC(client): move common stuff from getExportedSymbol() to a template function
Thanks to @ZeroAbility for the idea.
2020-10-01 21:24:11 +02:00
Davide Beatrici
501072ef50 FEAT(client): add Source Engine plugin, retract Left 4 Dead 1 & 2 plugins
5df2bb2c0b explains how we gain access to the game's interfaces.

Once we have access to the interfaces, we retrieve the address of the variables' we're interested in by reading the assembly of one or more functions accessing them.

The process for each function is documented in the code.
2020-09-27 20:12:17 +02:00
Davide Beatrici
5df2bb2c0b FEAT(client): add getExportedSymbol() function for positional audio plugins
This function is of critical importance for the Source Engine plugin, let me elaborate on why.

Most games consist in an executable and maybe one or more libraries, but they don't have particular exported symbols we can use to easily access (existing) resources inside the process, which means we have to rely on hardcoded offsets and hex pattern scanning.

Source Engine games are special: the executable is nothing more than a manager that takes care of loading the core libraries, which are engine(.dll|.so) and client(.dll|.so) (or server(.dll|.so) in the case of a dedicated server).

Those libraries have a common exported symbol, which is CreateInterface(). The function takes the interface's name as argument (char *), creates the interface object if it doesn't exist yet and returns a pointer (void *) to it. The interfaces objects are stored in a list called s_pInterfaceList, which is usually an exported symbol on Linux.

getExportedSymbol() allows us to get the address to CreateInterface() (different for each loaded library) inside the process and read the function's assembly code in order to reach s_pInterfaceList.

If s_pInterfaceList is exported we can get its address with getExportedSymbol(), without the need of CreateInterface().
2020-09-27 20:12:02 +02:00
Davide Beatrici
d8c4b82efe FEAT(client): add several new functions to be used in positional audio plugins
- peekProcString(): reads the specified amount of data at the specified address and returns it as std::string. An empty std::string is returned in case of error.
If length is 0, the function reads one byte at a time and stops when either '\0' is found or 3 seconds have passed.
The successfully read data is returned, also in case of error.

- peekProcVector(): can be used to read a dynamic array (size known at runtime) from the process' memory.
Dynamic arrays are part of C99, which should be supported by most compilers nowadays, but std::vector provides many advantages (e.g. easy resize) over a raw array.

- getVirtualFunction(): gets the address of a virtual function given its index and the class object's base address.
A macro called GET_POINTER_SIZE is added because "is64Bit ? 8 : 4" is used in two places now. Also, it's useful and intuitive for plugin(s) programmers.

- sinCos(): calculates sine and cosine of the specified value. On Linux the calculation is guaranteed to be simultaneous.

- degreesToRadians(): converts degrees to radians.

- isBigEndian(): returns whether the architecture is big-endian, by checking how a 4-byte value is stored in memory.

- networkToHost() converts from network byte order to host byte order.
I decided to create our own function because ntohs() is part of winsock(2).h on Windows, which means we would have to link to "ws2_32".

This commit also adds and makes use of the new "OS_WINDOWS" and "OS_LINUX" definitions.
The reason behind their existence is the "_WIN32" and "__linux__" definitions not being intuitive, mainly because they don't follow the same naming convention.
2020-09-27 19:59:18 +02:00
Robert
a25e224122 BUILD(cmake): Don't build retracted plugins by default
As these plugins typically don't do anything anymore it doesn't make all
that much sense to include them by default.

If you still want to include retracted plugins, use
-Dretracted-plugins=ON when invoking cmake.
2020-09-26 09:14:39 +02:00
Davide Beatrici
557bf8d3f0
Merge PR #4481: BUILD(cmake): Fix plugins install directory 2020-09-11 20:09:27 +02:00
Robert
af7dac72f4 FORMAT: Run clang-format 10 on all C/CXX source-files 2020-09-11 18:29:33 +02:00
Robert Adam
40b28b03c1 FORMAT: Move explanatory comments to own line 2020-09-11 18:28:38 +02:00
Robert
ea63d4f197 BUILD(cmake): Fix plugins install directory
Mumble usually ships with all its plugins in /usr/lib/mumble/* but the
new make install target installs them directly into /usr/lib/*.
This however can lead to certain files being overwritten.

Therefore these paths are changed in order to install these libraries
into /usr/lib/mumble/* again.

Fixes #4477
2020-09-11 18:27:32 +02:00
Robert Adam
34c602c85b BUILD(qmake): Remove
This commit removes all qmake-related build-files from the system. We
have now migrated to cmake and are no longer maintaining qmake anyways
and therefore there is no reason to keep it.

Removing it also clearly states to any potential user/programmer that
this project is no longer intended to be compiled with qmake.

Given that the .pri files no longer exist, the mumble-version.py script
had to be adapted to read the version from the CMakeLists.txt file
instead.

Furthermore a few of the submodules support cmake natively and therefore
we no longer need the src/buid-directory approach in order to build
them. The respective build dirs have been removed and the src-dirs have
been renamed.
2020-09-02 08:29:45 +02:00
Nik Reist
261756a7e2 Add install() directives, for "install" step and CPack 2020-07-11 23:33:25 +02:00
Davide Beatrici
6b87ac6221 Plugins: add CMakeLists.txt files 2020-07-11 19:34:49 +02:00
Popkornium18
691c38736a REFAC(plugins): replace NULL with nullptr
This changes all occurances of NULL in the plugins source
dir to nullptr. Additionally explicit comparisons with NULL were
removed.
2020-06-28 19:04:27 +02:00
Davide Beatrici
e1da53f597 mumble_plugin_linux.h: free "path" only after we're done with "filename"
basename() returns a pointer to the position where the basename starts in the string passed as argument.
2020-04-24 07:59:24 +02:00
Magnus Groß
df14e1ae4e Update GTA V Plugin 2020-04-09 20:51:36 +02:00
Davide Beatrici
4e67a2fafb Auto-update LICENSE.header in source files 2020-01-07 03:09:22 +01:00
Davide Beatrici
243ece3659 plugins/bf1: fix sizeof() bug
Found thanks to GCC's warning:

../mumble_plugin_utils.h: In function ‘int fetch(float*, float*, float*, float*, float*, float*, std::string&, std::wstring&)’:
../mumble_plugin_utils.h:35:16: warning: array subscript 99 is outside array bounds of ‘char [4]’ [-Warray-bounds]
   35 |  str[size - 1] = 0;
      |  ~~~~~~~~~~~~~~^~~
bf1.cpp:15:25: note: while referencing ‘team’
   15 |  char server_name[100], team[4];
      |                         ^~~~
2019-10-12 09:01:28 +02:00
Davide Beatrici
7779447ee4 mumble_plugin_utils.h: declare escape() as inline, minor improvements
Fixes the following warning:

../mumble_plugin_utils.h:33:13: error: 'void escape(char*, size_t)' defined but not used [-Werror=unused-function]
 static void escape(char *str, size_t size) {
             ^

It appeared after bb248cc, due to "ut99.cpp" not using escape().

This commit also:

- Changes the "size" argument so that it is passed as reference.
- Indents the function using tabs.
2019-10-12 09:01:00 +02:00
Davide Beatrici
bb248ccf68 plugins.pro: compile plugins for Windows games also on Linux 2019-10-11 22:48:13 +02:00