Skip to content
Permalink
Browse files

Merge PR #2349: plugins: update memory addresses retrieval to use pro…

…cptr32_t/procptr64_t.
  • Loading branch information...
mkrautz committed Jun 23, 2016
2 parents 51af785 + ed8748d commit f28e9b7332aeb8710f6cf7020f28841096da365f
@@ -34,14 +34,11 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "../mumble_plugin_win32.h"
#include "../mumble_plugin_win32_x86.h"

using namespace std;

BYTE *posptr;
BYTE *rotptr;
BYTE *stateptr;
BYTE *hostptr;
procptr32_t posptr, rotptr, stateptr, hostptr;

static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
float h = rot[0];
@@ -131,7 +128,7 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
if (! initialize(pids, L"hl2.exe", L"client.dll"))
return false;

BYTE *mod_engine=getModuleAddr(L"engine.dll");
procptr32_t mod_engine=getModuleAddr(L"engine.dll");
if (!mod_engine)
return false;

@@ -34,11 +34,9 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "../mumble_plugin_win32.h"
#include "../mumble_plugin_win32_x86.h"

BYTE *posptr;
BYTE *frontptr;
BYTE *topptr;
procptr32_t posptr, frontptr, topptr;

static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, float *camera_pos, float *camera_front, float *camera_top, std::string &, std::wstring &) {
for (int i=0;i<3;i++)
@@ -125,11 +123,11 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
if (!pModule)
*/

BYTE *ptr1 = peekProc<BYTE *>((BYTE *) 0x00C500FC);
procptr32_t ptr1 = peekProc<procptr32_t>(0x00C500FC);

BYTE *ptr2 = peekProc<BYTE *>(ptr1 + 0x88);
procptr32_t ptr2 = peekProc<procptr32_t>(ptr1 + 0x88);

BYTE *base = ptr2 + 0x10;
procptr32_t base = ptr2 + 0x10;

posptr = base + 0x18;
frontptr = base;
@@ -34,10 +34,9 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "../mumble_plugin_win32.h"
#include "../mumble_plugin_win32_x86.h"

BYTE *faceptr;
BYTE *topptr;
procptr32_t faceptr, topptr;
//BYTE *stateptr;
//BYTE *contextptr;

@@ -59,7 +58,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa

//peekProc(contextptr, ccontext, 128);

ok = peekProc((BYTE *) 0x00976274, avatar_pos, 12) &&
ok = peekProc(0x00976274, avatar_pos, 12) &&
peekProc(faceptr, avatar_front, 12) &&
peekProc(topptr, avatar_top, 12);

@@ -88,8 +87,8 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
if (! initialize(pids, L"BF1942.exe"))
return false;

BYTE *ptr1 = peekProc<BYTE *>((BYTE *) 0x009A9468);
BYTE *ptr2 = peekProc<BYTE *>(ptr1 + 0x98);
procptr32_t ptr1 = peekProc<procptr32_t>(0x009A9468);
procptr32_t ptr2 = peekProc<procptr32_t>(ptr1 + 0x98);

faceptr = ptr2 + 0x5C;
topptr = ptr2 + 0x4C;
@@ -3,47 +3,41 @@
// 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.h"
#include "../mumble_plugin_win32_x86.h"
using namespace std;


bool ptr_chain_valid = false;

// Modules
BYTE *pmodule_bf2;
BYTE *pmodule_renddx9;
procptr32_t pmodule_bf2, pmodule_renddx9;

// Magic ptrs
BYTE* const login_ptr = (BYTE*)0x30058642;
BYTE* const state_ptr = (BYTE*)0x00A1D0A8;
procptr32_t const login_ptr = 0x30058642;
procptr32_t const state_ptr = 0x00A1D0A8;

// Vector ptrs
BYTE *pos_ptr;
BYTE *face_ptr;
BYTE *top_ptr;
procptr32_t pos_ptr, face_ptr, top_ptr;

// Context ptrs
BYTE* const ipport_ptr = (BYTE*)0x009A80B8;
procptr32_t const ipport_ptr = 0x009A80B8;

// Identity ptrs
BYTE *commander_ptr;
BYTE *squad_leader_ptr;
BYTE *squad_state_ptr;
BYTE *team_state_ptr;
procptr32_t commander_ptr, squad_leader_ptr, squad_state_ptr, team_state_ptr;

inline bool resolve_ptrs() {
pos_ptr = face_ptr = top_ptr = commander_ptr = squad_leader_ptr = squad_state_ptr = team_state_ptr = NULL;
//
// Resolve all pointer chains to the values we want to fetch
//

BYTE *base_bf2audio = pModule + 0x4645c;
BYTE *base_bf2audio_2 = peekProc<BYTE *>(base_bf2audio);
procptr32_t base_bf2audio = pModule + 0x4645c;
procptr32_t base_bf2audio_2 = peekProc<procptr32_t>(base_bf2audio);
if (!base_bf2audio_2) return false;

pos_ptr = peekProc<BYTE *>(base_bf2audio_2 + 0xb4);
face_ptr = peekProc<BYTE *>(base_bf2audio_2 + 0xb8);
top_ptr = peekProc<BYTE *>(base_bf2audio_2 + 0xbc);
pos_ptr = peekProc<procptr32_t>(base_bf2audio_2 + 0xb4);
face_ptr = peekProc<procptr32_t>(base_bf2audio_2 + 0xb8);
top_ptr = peekProc<procptr32_t>(base_bf2audio_2 + 0xbc);
if (!pos_ptr || !face_ptr || !top_ptr) return false;

/*
@@ -62,17 +56,17 @@ inline bool resolve_ptrs() {
Squad state: RendDX9.dll+00244AE0 + 0x60 -> 10C BYTE 0 is not in squad; 1 is in Alpha squad, 2 Bravo, ... , 9 India
Team state: BF2.exe+0058734C + 0x239 BYTE 0 is blufor (US team, for example), 1 is opfor (Insurgents)
*/
BYTE *base_renddx9 = peekProc<BYTE *>(pmodule_renddx9 + 0x00244AE0);
procptr32_t base_renddx9 = peekProc<procptr32_t>(pmodule_renddx9 + 0x00244AE0);
if (!base_renddx9) return false;

BYTE *base_renddx9_2 = peekProc<BYTE *>(base_renddx9 + 0x60);
procptr32_t base_renddx9_2 = peekProc<procptr32_t>(base_renddx9 + 0x60);
if (!base_renddx9_2) return false;

commander_ptr = base_renddx9_2 + 0x110;
squad_leader_ptr = base_renddx9_2 + 0x111;
squad_state_ptr = base_renddx9_2 + 0x10C;

BYTE *base_bf2 = peekProc<BYTE *>(pmodule_bf2 + 0x0058734C);
procptr32_t base_bf2 = peekProc<procptr32_t>(pmodule_bf2 + 0x0058734C);
if (!base_bf2) return false;

team_state_ptr = base_bf2 + 0x239;
@@ -3,11 +3,9 @@
// 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.h"
#include "../mumble_plugin_win32_x86.h"

BYTE *posptr;
BYTE *faceptr;
BYTE *topptr;
procptr32_t posptr, faceptr, topptr;

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 &) {
for (int i=0;i<3;i++)
@@ -18,7 +16,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
char logincheck;
bool ok;

ok = peekProc((BYTE *) 0x00A1D908, &logincheck, 1);
ok = peekProc(0x00A1D908, &logincheck, 1);
if (! ok)
return false;

@@ -31,14 +29,14 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
usually 1, never 0 if you create your own server ingame; this value will switch to 1 the instant you click "Join Game"
usually 3, never 0 if you load into a server; this value will switch to 3 the instant you click "Join Game"
*/
ok = peekProc((BYTE *) 0x00B47968, &state, 1); // Magical state value
ok = peekProc(0x00B47968, &state, 1); // Magical state value
if (! ok)
return false;

ok = peekProc(posptr, avatar_pos, 12) &&
peekProc(faceptr, avatar_front, 12) &&
peekProc(topptr, avatar_top, 12) &&
peekProc((BYTE *) 0x00B527B8, ccontext, 128);
peekProc(0x00B527B8, ccontext, 128);

if (! ok)
return false;
@@ -68,12 +66,12 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
if (! initialize(pids, L"BF2142.exe", L"BF2142Audio.dll"))
return false;

BYTE *cacheaddr = pModule + 0x4745c;
BYTE *cache = peekProc<BYTE *>(cacheaddr);
procptr32_t cacheaddr = pModule + 0x4745c;
procptr32_t cache = peekProc<procptr32_t>(cacheaddr);

posptr = peekProc<BYTE *>(cache + 0xc0);
faceptr = peekProc<BYTE *>(cache + 0xc4);
topptr = peekProc<BYTE *>(cache + 0xc8);
posptr = peekProc<procptr32_t>(cache + 0xc0);
faceptr = peekProc<procptr32_t>(cache + 0xc4);
topptr = peekProc<procptr32_t>(cache + 0xc8);

float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3];
std::string context;
@@ -36,24 +36,22 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "../mumble_plugin_win32.h"
#include "../mumble_plugin_win32_x86.h"
static bool ptr_chain_valid = false;

// Magic ptrs
static BYTE* const state_ptr = (BYTE *) 0x238ABDC;
static procptr32_t const state_ptr = 0x238ABDC;

// Vector ptrs
static BYTE* const avatar_pos_ptr = (BYTE *) 0x0238AB70;
static BYTE* const avatar_front_ptr = (BYTE *) 0x0238ABA0;
static BYTE* const avatar_top_ptr = (BYTE *) 0x0238AB90;
static procptr32_t const avatar_pos_ptr = 0x0238AB70;
static procptr32_t const avatar_front_ptr = 0x0238ABA0;
static procptr32_t const avatar_top_ptr = 0x0238AB90;

// Context ptrs
static BYTE* const ipport_ptr = (BYTE *) 0x0235DB90;
static procptr32_t const ipport_ptr = 0x0235DB90;

// Identity ptrs
static BYTE *team_state_ptr;
static BYTE *squad_state_ptr;
static BYTE *squad_lead_state_ptr;
static procptr32_t team_state_ptr, squad_state_ptr, squad_lead_state_ptr;

// Offsets
static const int base_offset = 0x01EF25C4;
@@ -102,17 +100,17 @@ inline bool resolve_ptrs() {
Team state: BF3.exe+0x01EF25C4 + 0x1C + 0xBC + 0x31C BYTE 1 is blufor (US team, for example), 2 is opfor (RU), 0 is probably upcoming spec mode
*/

BYTE *base_bf3 = peekProc<BYTE *>(pModule + base_offset);
procptr32_t base_bf3 = peekProc<procptr32_t>(pModule + base_offset);
if (!base_bf3)
return false;

BYTE *offset_ptr1 = peekProc<BYTE *>(base_bf3 + identity_offset1);
procptr32_t offset_ptr1 = peekProc<procptr32_t>(base_bf3 + identity_offset1);
if (!offset_ptr1) return false;
BYTE *offset_ptr2 = peekProc<BYTE *>(offset_ptr1 + identity_offset2);
procptr32_t offset_ptr2 = peekProc<procptr32_t>(offset_ptr1 + identity_offset2);
if (!offset_ptr2) return false;
BYTE *offset_ptr3 = peekProc<BYTE *>(offset_ptr2 + identity_offset3);
procptr32_t offset_ptr3 = peekProc<procptr32_t>(offset_ptr2 + identity_offset3);
if (!offset_ptr3) return false;
BYTE *offset_ptr4 = peekProc<BYTE *>(offset_ptr3 + identity_offset4);
procptr32_t offset_ptr4 = peekProc<procptr32_t>(offset_ptr3 + identity_offset4);
if (!offset_ptr4) return false;

squad_state_ptr = offset_ptr4 + squad_state_offset;
@@ -3,7 +3,7 @@
// 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.h" // Include standard plugin header.
#include "../mumble_plugin_win32_x64.h" // Include standard plugin header.
#include "../mumble_plugin_utils.h" // Include plugin header for special functions, like "escape".

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) {
@@ -16,37 +16,37 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
BYTE squad, squad_leader, squad_state;

// Server ID pointers
BYTE *serverid_base = peekProc<BYTE *>(pModule + 0x02210658);
procptr64_t serverid_base = peekProc<procptr64_t>(pModule + 0x02210658);
if (!serverid_base) return false;
BYTE *serverid_offset_0 = peekProc<BYTE *>(serverid_base + 0x18);
procptr64_t serverid_offset_0 = peekProc<procptr64_t>(serverid_base + 0x18);
if (!serverid_offset_0) return false;
BYTE *serverid_offset_1 = peekProc<BYTE *>(serverid_offset_0 + 0x28);
procptr64_t serverid_offset_1 = peekProc<procptr64_t>(serverid_offset_0 + 0x28);
if (!serverid_offset_1) return false;
BYTE *serverid_offset = peekProc<BYTE *>(serverid_offset_1 + 0x350);
procptr64_t serverid_offset = peekProc<procptr64_t>(serverid_offset_1 + 0x350);
if (!serverid_offset) return false;

// Squad pointers
BYTE *squad_base = peekProc<BYTE *>(pModule + 0x02210718);
procptr64_t squad_base = peekProc<procptr64_t>(pModule + 0x02210718);
if (!squad_base) return false;
BYTE *squad_offset_0 = peekProc<BYTE *>(squad_base + 0xD8);
procptr64_t squad_offset_0 = peekProc<procptr64_t>(squad_base + 0xD8);
if (!squad_offset_0) return false;
BYTE *squad_offset_1 = peekProc<BYTE *>(squad_offset_0 + 0x100);
procptr64_t squad_offset_1 = peekProc<procptr64_t>(squad_offset_0 + 0x100);
if (!squad_offset_1) return false;
BYTE *squad_offset_2 = peekProc<BYTE *>(squad_offset_1 + 0x58);
procptr64_t squad_offset_2 = peekProc<procptr64_t>(squad_offset_1 + 0x58);
if (!squad_offset_2) return false;

// Peekproc and assign game addresses to our containers, so we can retrieve positional data
ok = peekProc((BYTE *) pModule + 0x21CAFF0, &state, 1) && // Magical state value: 0 when in-game and 1 when in menu/dead.
peekProc((BYTE *) pModule + 0x21C6D40, avatar_pos, 12) && // Avatar Position values (X, Y and Z).
peekProc((BYTE *) pModule + 0x21CAF80, camera_pos, 12) && // Camera Position values (X, Y and Z).
peekProc((BYTE *) pModule + 0x21CAF60, avatar_top, 12) && // Avatar Top Vector values (X, Y and Z).
peekProc((BYTE *) pModule + 0x21CAF70, avatar_front, 12) && // Avatar Front Vector values (X, Y and Z).
peekProc((BYTE *) serverid_offset, serverid) && // Server ID (36 characters).
peekProc((BYTE *) pModule + 0x21B80C0, host) && // Host value: "IP:Port" when in a server, "bot" when loading and empty when it's hidden.
peekProc((BYTE *) pModule + 0x24AFAE5, team) && // Team value: US (United States); RU (Russia); CH (China).
peekProc((BYTE *) squad_offset_2 + 0x230, squad) && // Squad value: 0 (not in a squad); 1 (Alpha); 2 (Bravo); 3 (Charlie)... 26 (Zulu).
peekProc((BYTE *) squad_offset_2 + 0x234, squad_leader) && // Squad leader value: 0 (False); 1 (True).
peekProc((BYTE *) squad_offset_2 + 0x235, squad_state); // Squad state value: 0 (Public); 1 (Private).
ok = peekProc(pModule + 0x21CAFF0, &state, 1) && // Magical state value: 0 when in-game and 1 when in menu/dead.
peekProc(pModule + 0x21C6D40, avatar_pos, 12) && // Avatar Position values (X, Y and Z).
peekProc(pModule + 0x21CAF80, camera_pos, 12) && // Camera Position values (X, Y and Z).
peekProc(pModule + 0x21CAF60, avatar_top, 12) && // Avatar Top Vector values (X, Y and Z).
peekProc(pModule + 0x21CAF70, avatar_front, 12) && // Avatar Front Vector values (X, Y and Z).
peekProc(serverid_offset, serverid) && // Server ID (36 characters).
peekProc(pModule + 0x21B80C0, host) && // Host value: "IP:Port" when in a server, "bot" when loading and empty when it's hidden.
peekProc(pModule + 0x24AFAE5, team) && // Team value: US (United States); RU (Russia); CH (China).
peekProc(squad_offset_2 + 0x230, squad) && // Squad value: 0 (not in a squad); 1 (Alpha); 2 (Bravo); 3 (Charlie)... 26 (Zulu).
peekProc(squad_offset_2 + 0x234, squad_leader) && // Squad leader value: 0 (False); 1 (True).
peekProc(squad_offset_2 + 0x235, squad_state); // Squad state value: 0 (Public); 1 (Private).

// This prevents the plugin from linking to the game in case something goes wrong during values retrieval from memory addresses.
if (! ok) {

0 comments on commit f28e9b7

Please sign in to comment.
You can’t perform that action at this time.