Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mumble-voip/mumble
base: 2ff3d34c60
...
head fork: mumble-voip/mumble
compare: eef9a67d18
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on May 14, 2012
@d-rez d-rez Added context support for the l4d2 plugin.
Changed global pointers to static (as thorvald requested in one of my
previous commits. Context contains provides ipport as json attribute.
f81049d
@d-rez d-rez context support for League of Legends plugin 840487d
@d-rez d-rez updated plugin for Team Fortress 2 b4934
fixed memory addresses
changed global variables to static
changed how context is handled
removed all calls to engine.dll module - we can get everything from client.dll nicely

Wrapped context in JSON. Context passing is disabled when running localhost (loopback:0) server and when not in game (fixed - now only in state=0)
eef9a67
Showing with 104 additions and 53 deletions.
  1. +34 −13 plugins/l4d2/l4d2.cpp
  2. +31 −4 plugins/lol/lol.cpp
  3. +39 −36 plugins/tf2/tf2.cpp
View
47 plugins/l4d2/l4d2.cpp
@@ -1,4 +1,5 @@
/* Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
+ Copyright (C) 2012, dark_skeleton (d-rez) <dark.skeleton@gmail.com>
All rights reserved.
@@ -30,9 +31,10 @@
#include "../mumble_plugin_win32.h"
-BYTE *posptr;
-BYTE *rotptr;
-BYTE *stateptr;
+static BYTE *posptr;
+static BYTE *rotptr;
+static BYTE *stateptr;
+static BYTE *contextptr;
static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
float h = rot[0];
@@ -67,7 +69,7 @@ static bool calcout(float *pos, float *rot, float *opos, float *front, float *to
}
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
- posptr = rotptr = stateptr= NULL;
+ posptr = rotptr = stateptr = contextptr = NULL;
if (! initialize(pids, L"left4dead2.exe", L"client.dll"))
return false;
@@ -75,13 +77,16 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
posptr = pModule + 0x641A4C;
rotptr = pModule + 0x641A08;
stateptr = pModule + 0x6A1AF4;
-
+ contextptr = pModule + 0x6f487c;
+
float pos[3];
float rot[3];
float opos[3], top[3], front[3];
-
+ char state, _context[21];
bool ok = peekProc(posptr, pos, 12) &&
- peekProc(rotptr, rot, 12);
+ peekProc(rotptr, rot, 12) &&
+ peekProc(stateptr, &state, 1) &&
+ peekProc(contextptr, _context);
if (ok)
return calcout(pos, rot, opos, top, front);
@@ -91,21 +96,25 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
return false;
}
-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) {
+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;
float ipos[3], rot[3];
bool ok;
char state;
+ char _context[21];
// stateptr returns byte values: 0 when map is not loaded; 8 when loaded
ok = peekProc(posptr, ipos, 12) &&
peekProc(rotptr, rot, 12) &&
- peekProc(stateptr, &state, 1);
+ peekProc(stateptr, &state, 1) &&
+ peekProc(contextptr, _context);
- if (state == 0)
+ if (state == 0) {
+ context = std::string(""); // clear context
return true; // This results in all vectors beeing zero which tells Mumble to ignore them.
+ }
if (ok) {
int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
@@ -116,8 +125,20 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
camera_top[i] = avatar_top[i];
// Example only -- only set these when you have sane values, and make sure they're pretty constant (every change causes a sever message).
- context = std::string("server/map/blah");
- identity = std::wstring(L"STEAM_1:2:3456789");
+ //context = std::string("server/map/blah");
+ //identity = std::wstring(L"STEAM_1:2:3456789");
+ }
+ std::string sHost(_context);
+ // This string can be either "xxx.xxx.xxx.xxx:yyyyy" (or shorter), "loopback:0" or "" (empty) when in menus. Hence 21 size for char.
+ if (!sHost.empty())
+ {
+ if (sHost.find("loopback") == std::string::npos)
+ {
+ std::ostringstream newcontext;
+ newcontext << "{\"ipport\": \"" << sHost << "\"}";
+ context = newcontext.str();
+ }
+
}
return res;
}
@@ -127,7 +148,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
}
static const std::wstring longdesc() {
- return std::wstring(L"Supports L4D2 build 4777. No identity or context support yet.");
+ return std::wstring(L"Supports L4D2 build 4777 with context support. No identity support yet.");
}
static std::wstring description(L"Left 4 Dead 2 (Build 4777)");
View
35 plugins/lol/lol.cpp
@@ -37,6 +37,9 @@ static BYTE *camfrontptr;
static BYTE *camtopptr;
static BYTE *afrontptr;
+static BYTE *hostipptr;
+static BYTE *hostportptr;
+
static BYTE *gameptr;
static bool calcout(float *pos, float *cam, float *opos, float *ocam) {
@@ -57,6 +60,8 @@ static bool refreshPointers(void)
// camera top vector @ 0xb5631c
// avatar position vector @ 0x2eafae8
// avatar front vector @ 0xe00f88 -> +0x2a54
+ // host ip (text) @ 0xaf4f028
+ // host port (4 bytes) @ 0xaf4f044
posptr = camptr = camfrontptr = camtopptr = afrontptr = NULL;
@@ -79,14 +84,23 @@ static bool refreshPointers(void)
// Avatar position vector
posptr = (BYTE *) 0x2eafae8; // NOTE: This consists of all zeros right after game is loaded until your avatar moves, but we don't have to worry about it since (0,0,0) is close to our spawning position
+ // Host IP:PORT. It is kept in 3 places in memory, but 1 of them looks the coolest, so let's use it, ha!
+ // IP is kept as text @ hostipptr
+ // PORT is kept as a 4-byte decimal value @ hostportptr
+
+ hostipptr = (BYTE *) 0xaf4f028;
+ hostportptr = (BYTE *) 0xaf4f044;
+
return true;
}
-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*/) {
+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;
float ipos[3], cam[3];
+ int hostport;
+ char hostip[15];
bool ok;
if (!peekProc<BYTE *>(gameptr)) return false; // Player not in game (or something broke), unlink
@@ -95,7 +109,9 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
peekProc(camtopptr, camera_top, 12) &&
peekProc(camptr, cam, 12) &&
peekProc(posptr, ipos, 12) &&
- peekProc(afrontptr, avatar_front, 12);
+ peekProc(afrontptr, avatar_front, 12) &&
+ peekProc(hostipptr, hostip) &&
+ peekProc(hostportptr,&hostport,4);
if (ok) {
int res = calcout(ipos, cam, avatar_pos, camera_pos);
@@ -104,6 +120,13 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
avatar_top[1] = 1; // Your character is always looking straight ahead ;)
avatar_top[2] = 0;
+ std::string sHost(hostip);
+ if (!sHost.empty())
+ {
+ std::ostringstream _context;
+ _context << "{\"ipport\": \"" << sHost << ":" << hostport << "\"}";
+ context = _context.str();
+ }
// Example only -- only set these when you have sane values, and make sure they're pretty constant (every change causes a sever message).
//context = std::string(" serverip:port:team");
//identity = std::wstring(L"STEAM ID");
@@ -123,6 +146,8 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
float cam[3], ocam[3];
float afront[3];
float camfront[3], camtop[3];
+ char hostip[15];
+ int hostport;
if (!refreshPointers()) { generic_unlock(); return false; }// unlink plugin if this fails
@@ -130,7 +155,9 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
peekProc(camtopptr,camtop,12) &&
peekProc(posptr,pos,12) &&
peekProc(camptr,cam,12) &&
- peekProc(afrontptr,afront,12);
+ peekProc(afrontptr,afront,12) &&
+ peekProc(hostipptr, hostip) &&
+ peekProc(hostportptr,&hostport,4);
if (ok) {
return calcout(pos,cam,opos,ocam); // make sure values are OK
@@ -141,7 +168,7 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
}
static const std::wstring longdesc() {
- return std::wstring(L"Supports League of Legends v1.0.0.139. No identity/context support yet (feel free to contribute).");
+ return std::wstring(L"Supports League of Legends v1.0.0.139 with context. No identity support yet (feel free to contribute).");
}
static std::wstring description(L"League of Legends (v1.0.0.139)");
View
75 plugins/tf2/tf2.cpp
@@ -1,4 +1,5 @@
-/* Copyright (C) 2009-2012, Snares <snares@users.sourceforge.net>
+/* Copyright (C) 2012, dark_skeleton (d-rez) <dark.skeleton@gmail.com>
+ Copyright (C) 2009-2012, Snares <snares@users.sourceforge.net>
Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
All rights reserved.
@@ -31,20 +32,22 @@
#include "../mumble_plugin_win32.h"
-BYTE *posrotptr;
-BYTE *stateptr;
-BYTE *hostptr;
+static BYTE *posrotptr;
+static BYTE *stateptr;
+static BYTE *hostptr;
/*
note that these are just examples of memory values, and may not be updated or correct
- position tuple: client.dll+0x6F76C0 (x,y,z, float)
- orientation tuple: client.dll+0x6F76CC (v,h float)
- spawn state: client.dll+0x607C64 (0 when at main menu, 1 when spectator, 3 when at team selection menu, and 6 or 9 when on a team (depending on the team side and gamemode), byte)
- host string: engine.dll+0x3D3E94 (ip:port zero-terminated string; localhost:27015 if create a server ingame)
- ID string: engine.dll+0x54E668 = "DemomanTaunts" (13 characters, text)
+ position tuple: client.dll+0x... (x,y,z, float)
+ orientation tuple: client.dll+0x... (v,h float)
+ spawn state: client.dll+0x... (0 when at main menu, 1 when spectator, 3 when at team selection menu, and 6 or 9 when on a team (or 4,5,8 etc. depending on the team side and gamemode), byte)
+ host string: client.dll+0x... (ip:port or loopback:0 when created own server or blank when not ingame)
+ ID string: client.dll+0x... = "Demoman" (13 characters, text - somerhing that lets us know it's TF2 and not for example HL2)
note that memory addresses in this comment are for example only; the real ones are defined below
note: the spec_pos console command is rather useful
+ note: so is the cl_showpos command
+ NOTE: from my experience, using engine.dll module is a rather bad idea since it's very dynamic. And since we can get everything we need from client.dll, it is no longer required :)
*/
static bool calcout(float *pos, float *rot, float *opos, float *front, float *top) {
@@ -75,14 +78,14 @@ static bool calcout(float *pos, float *rot, float *opos, float *front, float *to
return true;
}
-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 &) {
+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;
bool ok;
float posrot[5];
char state;
- char chHostStr[40];
+ char chHostStr[21]; // We just need 21 [xxx.xxx.xxx.xxx:yyyyy]
ok = peekProc(posrotptr, posrot) &&
peekProc(stateptr, state) &&
@@ -91,24 +94,28 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
if (!ok)
return false;
- chHostStr[39] = 0;
-
- std::string sHost;
- sHost.assign(chHostStr);
- if (!sHost.empty()) {
- if (sHost.find(':') == std::string::npos)
- sHost.append(":27015");
-
- std::ostringstream new_context;
- new_context << "{ \"ipport\": \"" << sHost << "\"}";
- context = new_context.str();
+ std::string sHost(chHostStr);
+
+ // Possible values of chHostStr:
+ // xxx.yyy.zzz.aaa:ccccc (or shorter, e.g. x.y.z.a:cc - but it doesn't really change anything)
+ // loopback:0 (when a local server is started)
+ if (!sHost.empty())
+ {
+ if (sHost.find("loopback") == std::string::npos)
+ {
+ std::ostringstream newcontext;
+ newcontext << "{\"ipport\": \"" << sHost << "\"}";
+ context = newcontext.str();
+ }
}
//TODO: Implement identity
// Check to see if you are in a server and spawned
- if (state == 0 || state == 1 || state == 3)
+ if (state == 0 || state == 1 || state == 3) {
+ if (state == 0) context = std::string(""); // clear context if not connected to server
return true; // Deactivate plugin
+ }
ok = calcout(posrot, posrot+3, avatar_pos, avatar_front, avatar_top);
if (ok) {
@@ -124,23 +131,19 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
}
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
- posrotptr = NULL;
+ posrotptr = stateptr = hostptr = NULL;
if (! initialize(pids, L"hl2.exe", L"client.dll"))
return false;
- BYTE *mod_engine=getModuleAddr(L"engine.dll");
- if (!mod_engine)
- return false;
-
// Remember addresses for later
- posrotptr = pModule + 0x8D8694;
- stateptr = pModule + 0x849284;
- hostptr = mod_engine + 0x3EA20C;
+ posrotptr = pModule + 0x8F9334;
+ stateptr = pModule + 0x869034;
+ hostptr = pModule + 0x918044;
- // Gamecheck
- char sMagic[13];
- if (!peekProc(mod_engine + 0x564C78, sMagic) || strncmp("DemomanTaunts", sMagic, sizeof(sMagic))!=0)
+ // Gamecheck - check if we're looking at the right game
+ char sMagic[7];
+ if (!peekProc(pModule + 0x882CE2, sMagic) || strncmp("Demoman", sMagic, sizeof(sMagic))!=0)
return false;
// Check if we can get meaningful data from it
@@ -158,10 +161,10 @@ static int trylock(const std::multimap<std::wstring, unsigned long long int> &pi
}
static const std::wstring longdesc() {
- return std::wstring(L"Supports TF2 build 4785. No identity support yet.");
+ return std::wstring(L"Supports TF2 build 4934 with context. No identity support yet.");
}
-static std::wstring description(L"Team Fortress 2 (Build 4785)");
+static std::wstring description(L"Team Fortress 2 (Build 4934)");
static std::wstring shortname(L"Team Fortress 2");
static int trylock1() {

No commit comments for this range

Something went wrong with that request. Please try again.