Ephiriel Posted February 28, 2017 Share Posted February 28, 2017 Hi all, 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: // 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, whichcauses 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.0Thanks for help,Best Regards. Link to comment Share on other sites More sharing options...
Administrators davidebeatrici Posted March 1, 2017 Administrators Share Posted March 1, 2017 Hi,The MumblePAHelper binary we provide in the plugin guide only works with plugins built with MSVC 2010. We will provide the binary for MSVC 2015 soon.Meanwhile, you can clone the GitHub repository and compile it yourself: https://github.com/mumble-voip/mumble-pahelper ;)I edited your code: // 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" // Variable to contain module's memory address procptr64_t mod = 0; 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; procptr64_t avatar_base = 0; bool ok = peekProc<procptr64_t>(pModule + 0x00CC8540) && avatar_base = peekProc<procptr64_t>(avatar_base + 0x60); // This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses. if (! ok) return false; // Boolean values to check if game addresses retrieval is successful and if the player is in-game bool ok, state; // Peekproc and assign game addresses to our containers, so we can retrieve positional data ok = //peekProc(mod + 0x7D9E5, &state, 1) && // Magical state value: 1 when in-game and 0 when in main menu. peekProc(avatar_base + 0x00, avatar_pos, 12) && // Avatar Position values. peekProc(avatar_base + 0x10, avatar_front, 12) && // Avatar Front Vector values. peekProc(avatar_base + 0x20, avatar_top, 12); // Avatar Top Vector values. state = true; // We do this because the default value is false and we disabled the magical value retrieval // 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. } // 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; mod = getModuleAddr(L"umbra_sandlot.dll"); // Retrieve "umbra_sandlot.dll" module's memory address // This prevents the plugin from linking to the game in case something goes wrong during module's memory address retrieval. if (!mod) return false; 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; } Test it and let me know if it works. Feel free to ask me if you don't understand something. :)Regards,Davide Link to comment Share on other sites More sharing options...
Ephiriel Posted March 2, 2017 Author Share Posted March 2, 2017 Thank you DavidE,it seems to work now :D For completeness: I changed this line in your code, which produced a compilation error for me:From bool ok = peekProc<procptr64_t>(pModule + 0x00CC8540) && avatar_base = peekProc<procptr64_t>(avatar_base + 0x60);toavatar_base = peekProc<procptr64_t>(pModule + 0x00CC8540); if (!avatar_base) return false; avatar_base = peekProc<procptr64_t>(avatar_base + 0x60); // This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses. if (!avatar_base) return false; Regards,Ephiriel Link to comment Share on other sites More sharing options...
Administrators davidebeatrici Posted March 2, 2017 Administrators Share Posted March 2, 2017 Oh, sorry, my fault. The two lines are wrong because that specific variant of peekProc, which we use for pointers, doesn't return a boolean, but the retrieved value from the memory. ;)You're welcome, good luck with your plugin! :)Regards,Davide Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now