Commit Graph

18 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
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
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
Robert
af7dac72f4 FORMAT: Run clang-format 10 on all C/CXX source-files 2020-09-11 18:29:33 +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
Davide Beatrici
4e67a2fafb Auto-update LICENSE.header in source files 2020-01-07 03:09:22 +01: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
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
Mikkel Krautz
f6ba3a52bf Auto-update LICENSE.header in source files. 2018-01-01 23:05:37 +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
91ebb8b0b5 Update tree copyrights to 2017. 2017-01-08 21:05:57 +01:00
Davide Beatrici
685b5d6c17 plugins: fix compile error on Linux
This fixes #2615, introduced by #2611.
2016-11-03 16:25:57 +01:00
Mikkel Krautz
2a049e6cd9 mumble_plugin_linux.h: align API of the Windows and Linux plugin headers. 2016-08-13 10:04:12 +00:00
Mikkel Krautz
5b5167646d pugins/mumble_plugin_linux.h: convert C-style casts to C++-style casts. 2016-08-12 20:37:31 +00:00
Mikkel Krautz
ee0c6a2739 plugins/mumble_plugin_linux.h: use non-C++11 std::ifstream::open().
Fixes the C++03 build.
2016-08-12 20:36:20 +00:00
davidebeatrici
2da60f96e0 Linux support for positional audio plugins 2016-08-11 20:53:10 +02:00