Commit Graph

580 Commits

Author SHA1 Message Date
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
Davide Beatrici
5db12321ac plugins: link to user32 in common project (only on Windows) 2019-10-11 22:48:06 +02:00
Davide Beatrici
ed6ff7ca9a plugins: convert UTF-16 to UTF-8 using C++11 features 2019-10-11 21:58:46 +02:00
Davide Beatrici
5e247f258c plugins: replace MSVC string functions with C++ ones 2019-10-11 21:58:39 +02:00
Davide Beatrici
d40fbe8c3b plugins: replace BYTE with uint8_t 2019-10-11 21:13:48 +02:00
Raven
1e2678e91e
Corrected error in doc 2019-09-20 21:27:31 +02:00
Davide Beatrici
9bf24dc210 plugins: add positional audio plugin for GTA: San Andreas
Supports the 1.0 version of Grand Theft Auto: San Andreas, the only one supported by multiplayer modifications.

The camera's vectors are synced with the avatar's ones; in future we should locate the camera's CMatrix in the game's memory and retrieve the proper values.

No context/identity support; in future we should at least add the context (e.g. server IP address + port) for Multi Theft Auto and San Andreas: MultiPlayer.
2019-08-28 09:29:00 +02:00
Davide Beatrici
1a95ad8ad1 mumble_plugin_main.h: include <cstring> for memset()
The MinGW builds failed with:

In file included from gtasa.cpp:6:0:
../mumble_plugin_main.h: In instantiation of 'T peekProc(const procptr_t&) [with T = unsigned char; procptr_t = long long unsigned int]':
gtasa.cpp:25:59:   required from here
../mumble_plugin_main.h:47:9: error: 'memset' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
   memset(&ret, 0, sizeof(ret));
         ^
In file included from /usr/lib/mxe/usr/x86_64-w64-mingw32.static/include/guiddef.h:154:0,
                 from /usr/lib/mxe/usr/x86_64-w64-mingw32.static/include/winnt.h:635,
                 from /usr/lib/mxe/usr/x86_64-w64-mingw32.static/include/minwindef.h:163,
                 from /usr/lib/mxe/usr/x86_64-w64-mingw32.static/include/windef.h:8,
                 from /usr/lib/mxe/usr/x86_64-w64-mingw32.static/include/windows.h:69,
                 from ./../mumble_plugin_win32.h:21,
                 from ../mumble_plugin_main.h:95,
                 from gtasa.cpp:6:
/usr/lib/mxe/usr/x86_64-w64-mingw32.static/include/string.h:53:18: note: 'void* memset(void*, int, size_t)' declared here, later in the translation unit
   void * __cdecl memset(void *_Dst,int _Val,size_t _Size);
                  ^
2019-08-28 09:28:53 +02:00
Davide Beatrici
6fb885c451 mumble_plugin_linux.h: detect process architecture by reading the process' memory instead of its binary
Aside from being faster, it also requires less code.

This commit also changes the way architecture is detected for Win32 processes.
Previously, we relied on the Wine's preloader binary's architecture because we read its ELF header; now we read the NT header(s) by calling isWin32Process64Bit() (implemented in 86154c8234).
2019-08-17 00:31:18 +02:00
Davide Beatrici
86154c8234 plugins: detect Win32 process architecture by reading NT header(s)
This is better than our current method because:
1. We don't need an extra handle (IsWow64Process() requires PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION).
2. It's more reliable: our current method consists in checking the result of IsWow64Process() (true if the process is 32 bit on 64 bit Windows) and the size of void * (4 bytes if 32 bit, 8 bytes if 64 bit).
It works correctly with a 32 bit plugin on 32 bit Windows and with a 64 bit plugin on 64 bit Windows; it doesn't work correctly when the plugin is 32 bit on 64 bit Windows: 64 bit processes are detected as 32 bit.
3. We can use the same method on Linux (the NT image is loaded in memory by Wine).
2019-08-17 00:30:23 +02:00
Davide Beatrici
28acde17af plugins: add Win32 internal structures in a dedicated header
These structures represent the header(s) of an NT image.

There are two ways to read the image:
- Loading the executable/library in memory and then reading the content at the beginning.
- Reading the process' memory at the beginning (base address).
  In the case of a loaded library, its header(s) can be found at its load (base) address.

By reading the header(s) we can gather useful info regarding the process, such as the architecture and, in the case of a library, the address of an exported symbol.
2019-08-17 00:30:06 +02:00
Magnus Groß
cecdf62adf plugins/gtav: update plugin to work with version 1.48 (Steam)
Game version: 1.48 (Steam)
https://support.rockstargames.com/articles/360033065553/GTAV-Title-Update-1-48-Notes-PS4-Xbox-One-PC
2019-08-16 01:29:50 +02:00
Davide Beatrici
9875c59b7a plugins: use new header 2019-08-08 23:51:13 +02:00
Davide Beatrici
e8afc3872a plugins: move common functions and variables from OS-specific headers to mumble_plugin_main.h
This is in preparation for the new Source Engine plugin which will add a few common functions.

This commit also improves the functions arguments so that they are passed by reference and marked as const (when possible).

A new data type called procid_t is created, intended to be a replacement for pid_t (Linux) and DWORD (Windows).
2019-08-08 23:51:13 +02:00
Davide Beatrici
b427333257 Auto-update LICENSE.header in source files 2019-01-25 04:56:19 +01:00
davidebeatrici
c45695cedf plugins/rl: update plugin and add avatar top vector support
Game version: 1.42
https://www.rocketleague.com/news/patch-notes-v1-42
2018-03-26 00:18:39 +02:00
davidebeatrici
ebb79eec97 plugins/rl: single source file for both Linux and Windows 2018-03-15 23:05:08 +01:00
davidebeatrici
b0974d75f2 plugins: set custom build directory in relation to the global one 2018-02-18 23:56:34 +01:00
Mikkel Krautz
f6ba3a52bf Auto-update LICENSE.header in source files. 2018-01-01 23:05:37 +01:00
davidebeatrici
2a51c7bff6 Accomplish changes in all the plugins 2017-11-19 21:48:55 +01:00
davidebeatrici
f397c40982 Replace legacy header with the new one
This commit removes the legacy header, with the new one taking its name.
2017-11-19 21:48:55 +01:00
davidebeatrici
7286fb0f68 Determine correct pointer size automatically, without the need of specific headers and variables
This commit removes the architecture-specific headers, by keeping only the OS-specific ones.
The different headers were needed to keep the legacy Windows header, after we created the "procptr32_t" (4 bytes) and "procptr64_t" (8 bytes) variables.
We created these variables because the "peekProc" functions read as many bytes as the variable can hold. A pointer is 4 bytes on 32 bit platforms and 8 bytes on 64 bit ones.

Now there's a new variable, called "procptr_t" and with a size of 8 bytes (unsigned long long).
We had a "peekProc" template function which returned the value stored at the specified memory address, but it has been used only to read pointers so far.
Since we needed a new function that checks the process architecture and sets the correct size of the memory to read, I decided to "recycle" it.
2017-11-19 21:48:49 +01:00
Mikkel Krautz
828d9301f5 Remove DIST directive from all .pro files.
We used to use DIST for referencing extra files that should be included
in our tarballs created by 'make dist'.

However, we've since migrated away relying on 'make dist' in release.pl.
Instead, we include everything, and have a list of items to exclude, such
as IETF RFC drafts distributed in 3rdparty/speex-src that do not adhere to
the Debian Free Software Guidelines.
2017-08-06 20:38:14 +02:00
Jan Klass
23e763888f Fix assignment spacing in pro files
Consistently use single space before assignment operator.
2017-08-05 20:44:00 +02:00
Jan Klass
27a983d094 Fix indentation in pro files
Make them consistently two spaces indentation.

In two places a wrong indentation level was fixed.
2017-08-05 20:37:19 +02:00
Mikkel Krautz
46fb405424 Merge PR #3077: plugins/bf1: update plugin to work with version 1.0.49.52296 2017-05-08 10:55:17 +02:00
Davide Beatrici
75c4de8cc1 plugins/bf1: update plugin to work with version 1.0.49.52296
https://www.battlefield.com/news/update-notes/spring-update
2017-05-07 23:03:26 +02:00
Flumble
b47bfc8544 Add target_squad_id and ipport to identity 2017-05-06 01:02:36 +02:00
Flumble
aa87489636 add VoiP state to Battlefield 2 identity 2017-05-05 20:37:46 +02:00