Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Beatrici <davidebeatrici@gmail.com>2019-07-25 08:29:19 +0300
committerDavide Beatrici <davidebeatrici@gmail.com>2019-08-09 00:51:13 +0300
commite8afc3872a09472e444b41c92a98f307b27b4efc (patch)
tree5aa17cf36b3a4139e08436cdd2cbb4635640bf6b /plugins/mumble_plugin_main.h
parent4f0a40423b3474e67458ff644f676324b0ec9984 (diff)
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).
Diffstat (limited to 'plugins/mumble_plugin_main.h')
-rw-r--r--plugins/mumble_plugin_main.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/plugins/mumble_plugin_main.h b/plugins/mumble_plugin_main.h
new file mode 100644
index 000000000..26539a6a6
--- /dev/null
+++ b/plugins/mumble_plugin_main.h
@@ -0,0 +1,43 @@
+// Copyright 2005-2019 The Mumble Developers. All rights reserved.
+// Use of this source code is governed by a BSD-style license
+// that can be found in the LICENSE file at the root of the
+// Mumble source tree or at <https://www.mumble.info/LICENSE>.
+
+#ifndef MUMBLE_PLUGIN_MAIN_H_
+#define MUMBLE_PLUGIN_MAIN_H_
+
+#include "mumble_plugin.h"
+
+static procid_t pPid;
+static bool is64Bit;
+static procptr_t pModule;
+
+static inline bool peekProc(const procptr_t &addr, void *dest, const size_t &len);
+static inline procptr_t getModuleAddr(const procid_t &pid, const wchar_t *modname);
+
+static inline procptr_t getModuleAddr(const wchar_t *modname) {
+ return getModuleAddr(pPid, modname);
+}
+
+template<class T>
+static inline bool peekProc(const procptr_t &addr, T &dest) {
+ return peekProc(addr, &dest, sizeof(T));
+}
+
+static inline procptr_t peekProcPtr(const procptr_t &addr) {
+ procptr_t v = 0;
+
+ if (!peekProc(addr, &v, is64Bit ? 8 : 4)) {
+ return 0;
+ }
+
+ return v;
+}
+
+#ifdef WIN32
+# include "../mumble_plugin_win32.h"
+#else
+# include "../mumble_plugin_linux.h"
+#endif
+
+#endif