I'm trying to make a plugin for sound positioning for EDF 4.1 (Earth Defence Force).
Did everything like said in https://wiki.mumble.info/wiki/Pluginguide. Found promising vectors and so on,
but when i try out the plugin, it seems that the initialise function (and getModuleAddr / peekProc) does not work properly.
MumblePAHelper don't seem to work for VS2015 builds.
I also tried to set some fixed adresses without initialize/getModuleAddr/peekProc, that seems to work.
Here's the source code so far:
- Code: Select all
// Copyright 2005-2016 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>.
#include "../mumble_plugin_win32_64bit.h" // Include standard plugin header.
#include "../mumble_plugin.h"
static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &context, std::wstring &identity) {
for (int i=0;i<3;i++)
avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
// Boolean values to check if game addresses retrieval is successful and if the player is in-game
bool ok, state;
byte status;
// Create containers to stuff our raw data into, so we can convert it to Mumble's coordinate system
float avatar_pos_corrector[3], avatar_front_corrector[3], avatar_top_corrector[3];
procptr64_t mod = getModuleAddr(L"EDF41.exe");
procptr64_t avatar_base = peekProc<procptr64_t>(pModule + 0x00CC8540);
if (!avatar_base)
return false;
avatar_base = peekProc<procptr64_t>(avatar_base + 0x60);
if (!avatar_base)
return false;
mod = getModuleAddr(L"umbra_sandlot.dll");
//Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok = peekProc(mod + 0x7D9E5, &status, 1) && // Magical state value: 1 when in-game and 0 when in main menu.
peekProc(avatar_base + 0x00, avatar_pos_corrector, 12) && // Avatar Position values (X, Z and Y, respectively).
peekProc(avatar_base + 0x10, avatar_front_corrector, 12) && // Avatar Front Vector values (X, Z and Y, respectively).
peekProc(avatar_base + 0x20, avatar_top_corrector, 12); // Avatar Top Vector values (X, Z and Y, respectively).
if(status == 0)
state = false;
else
state = true;
//peekProc(0x18007D9E5, &status, 1);
peekProc(avatar_base + 0x00, avatar_pos_corrector, 12);
peekProc(avatar_base + 0x10, avatar_front_corrector, 12);
peekProc(avatar_base + 0x20, avatar_top_corrector, 12);
// This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
if (! ok)
return false;
if (! state) { // If not in-game
context.clear(); // Clear context
identity.clear(); // Clear identity
// Set vectors values to 0.
for (int i=0;i<3;i++)
avatar_pos[i] = avatar_front[i] = avatar_top[i] = camera_pos[i] = camera_front[i] = camera_top[i] = 0.0f;
return true; // This tells Mumble to ignore all vectors.
}
/*
Mumble | Game
X | X
Y | Y
Z | Z
*/
avatar_pos[0] = avatar_pos_corrector[0];
avatar_pos[1] = avatar_pos_corrector[1];
avatar_pos[2] = avatar_pos_corrector[2];
avatar_front[0] = avatar_front_corrector[0];
avatar_front[1] = avatar_front_corrector[1];
avatar_front[2] = avatar_front_corrector[2];
avatar_top[0] = avatar_top_corrector[0];
avatar_top[1] = avatar_top_corrector[1];
avatar_top[2] = avatar_top_corrector[2];
// Sync camera with avatar
for (int i=0;i<3;i++) {
camera_pos[i] = avatar_pos[i];
camera_front[i] = avatar_front[i];
camera_top[i] = avatar_top[i];
}
return true;
}
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
if (! initialize(pids, L"EDF41.exe")) // Retrieve game executable's memory address
return false;
// Check if we can get meaningful data from it
float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3];
std::wstring sidentity;
std::string scontext;
if (fetch(apos, afront, atop, cpos, cfront, ctop, scontext, sidentity)) {
return true;
} else {
generic_unlock();
return false;
}
}
static const std::wstring longdesc() {
return std::wstring(L"Supports Earth Defense Force 4.1 without context or identity support."); // Plugin long description
}
static std::wstring description(L"Earth Defense Force (v4.1)"); // Plugin short description
static std::wstring shortname(L"EDF 4.1"); // Plugin short name
static int trylock1() {
return trylock(std::multimap<std::wstring, unsigned long long int>());
}
static MumblePlugin edf41plug = {
MUMBLE_PLUGIN_MAGIC,
description,
shortname,
NULL,
NULL,
trylock1,
generic_unlock,
longdesc,
fetch
};
static MumblePlugin2 edf41plug2 = {
MUMBLE_PLUGIN_MAGIC_2,
MUMBLE_PLUGIN_VERSION,
trylock
};
extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin *getMumblePlugin() {
return &edf41plug;
}
extern "C" MUMBLE_PLUGIN_EXPORT MumblePlugin2 *getMumblePlugin2() {
return &edf41plug2;
}
Any idea what the problem is or how to get better debug information?
Edit: Some more Information:
It seems like initialize(pids, L"EDF41.exe"); and getModuleAddr(L"EDF41.exe"); are returning 0, which
causes the call of trylock() to abort before any positions can be read out (and of course the adress for reading out the position would be wrong too).
I tried this building with VS2010/VS2015, x64/x86 and on Mumble 1.2.19 and 1.3.0
Thanks for help,
Best Regards.