Skip to content

Commit

Permalink
Merge branch 'master' into dx11
Browse files Browse the repository at this point in the history
  • Loading branch information
nyetwurk committed Jun 5, 2012
2 parents 73d134b + 7f38f3a commit fa6c37d
Show file tree
Hide file tree
Showing 31 changed files with 385 additions and 193 deletions.
4 changes: 2 additions & 2 deletions installer/Plugins.wxs
Expand Up @@ -74,7 +74,7 @@
<Component Id="gtaiv.dll">
<File Source="$(var.SourceDir)\release\plugins\gtaiv.dll" KeyPath="yes" />
</Component>
<Component Id="gw.dll">
<Component Id="gw.dll">
<File Source="$(var.SourceDir)\release\plugins\gw.dll" KeyPath="yes" />
</Component>
<Component Id="hl2dm.dll">
Expand Down Expand Up @@ -145,7 +145,7 @@
<ComponentRef Id="etqw.dll" />
<ComponentRef Id="gmod.dll" />
<ComponentRef Id="gtaiv.dll" />
<ComponentRef Id="gw.dll" />
<ComponentRef Id="gw.dll" />
<ComponentRef Id="hl2dm.dll" />
<ComponentRef Id="insurgency.dll" />
<ComponentRef Id="l4d.dll" />
Expand Down
2 changes: 1 addition & 1 deletion opus-src
Submodule opus-src updated from 17c596 to 9ce27c
10 changes: 5 additions & 5 deletions plugins/bf3/bf3.cpp
Expand Up @@ -40,7 +40,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
char state;
bool ok;

ok = peekProc((BYTE *) 0x0238CC2C, &state, 1); // State value
ok = peekProc((BYTE *) 0x023C7A9C, &state, 1); // State value
if (! ok)
return false;

Expand All @@ -65,9 +65,9 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
if ( state != 2 )
return true; // This results in all vectors being zero which tells Mumble to ignore them.

ok = peekProc((BYTE *) 0x0238CBC0, avatar_pos, 12) &&
peekProc((BYTE *) 0x0238CBF0, avatar_front, 12) &&
peekProc((BYTE *) 0x0238CBE0, avatar_top, 12);
ok = peekProc((BYTE *) 0x023C7A30, avatar_pos, 12) &&
peekProc((BYTE *) 0x023C7A60, avatar_front, 12) &&
peekProc((BYTE *) 0x023C7A50, avatar_top, 12);

if (! ok)
return false;
Expand Down Expand Up @@ -112,7 +112,7 @@ static const std::wstring longdesc() {
return std::wstring(L"Supports Battlefield 3. No identity or context support.");
}

static std::wstring description(L"Battlefield 3 v936211");
static std::wstring description(L"Battlefield 3 v944019");
static std::wstring shortname(L"Battlefield 3");

static int trylock1() {
Expand Down
29 changes: 15 additions & 14 deletions plugins/gw/gw.cpp
Expand Up @@ -26,9 +26,9 @@
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/

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

static BYTE *posptr;
static BYTE *camptr;
Expand All @@ -40,15 +40,14 @@ static BYTE *areaptr;
static BYTE *characternameptr;

static bool calcout(float *pos, float *front, float *cam, float *camfront, float *opos, float *ofront, float *ocam, float *ocamfront) {

// Seems Guild Wars is in... inches, yeah :) ---> same as in GW2, proof here: http://www.guildwars2guru.com/topic/21519-reddit-ama-all-questions-answers (question #31)
// coordinate Y is swapped with Z
// Y is negative (looks like somewhere underground is 0.00 and land is for example -120. When we climb up a hill, it goes down (e.g. -130), and when we walk downhill, it goes up (e.g. -100)

opos[0] = pos[0] / 39.37f;
opos[1] = -pos[2] / 39.37f;
opos[2] = pos[1] / 39.37f;

ocam[0] = cam[0] / 39.37f;
ocam[1] = -cam[2] / 39.37f;
ocam[2] = cam[1] / 39.37f;
Expand All @@ -69,7 +68,7 @@ static bool refreshPointers(void)
// We can find all vectors (camera position, camera front, avatar position, avatar front) in just one place, yay!

camfrontptr = camptr = posptr = frontptr = magicptr = characternameptr = areaptr = NULL;

camptr = (BYTE *) 0xd551b8;
posptr = (BYTE *) 0xd551c4; // camptr + 0xC
camfrontptr = (BYTE *) 0xd551d0; // posptr + 0xC
Expand All @@ -96,11 +95,11 @@ static bool refreshPointers(void)
}

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++)
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 cam[3],pos[3],front[3],camfront[3];
float cam[3], pos[3], front[3], camfront[3];
char state;
int areaid;
wchar_t charactername [20];
Expand All @@ -116,8 +115,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
if (!ok)
return false;

if (state == 0 || state == 1 || areaid == 0) // Player not in world
{
if (state == 0 || state == 1 || areaid == 0) { // Player not in world
context.clear();
identity.clear();
return true;
Expand All @@ -130,7 +128,7 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
camera_top[1] = avatar_top[1] = 1; // This isn't FPS, you can't tilt your head :)
std::ostringstream _context;
_context << "{\"areaid\": " << areaid << ","
<< "\"magic\": " << int(state) << "}";
<< "\"magic\": " << int(state) << "}";
context = _context.str();

charactername[sizeof(charactername)-1]=0; // make sure string is null-terminated
Expand All @@ -140,13 +138,16 @@ 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) {

if (! initialize(pids, L"Gw.exe"))
return false;

if (!refreshPointers()) { generic_unlock(); return false; }// unlink plugin if this fails
// unlink plugin if this fails
if (!refreshPointers()) {
generic_unlock();
return false;
}

float cam[3],pos[3],front[3],camfront[3],top[3],camtop[3];
float cam[3], pos[3], front[3], camfront[3], top[3], camtop[3];
std::string context;
std::wstring identity;

Expand All @@ -170,7 +171,7 @@ static int trylock1() {
}

static MumblePlugin gwplug = {
MUMBLE_PLUGIN_MAGIC,
MUMBLE_PLUGIN_MAGIC ^ MUMBLE_PLUGIN_MAGIC,
description,
shortname,
NULL,
Expand Down
2 changes: 0 additions & 2 deletions plugins/gw/gw.pro
Expand Up @@ -3,5 +3,3 @@ include(../plugins.pri)
TARGET = gw
SOURCES = gw.cpp
LIBS += -luser32


114 changes: 67 additions & 47 deletions plugins/wolfet/wolfet.cpp
@@ -1,5 +1,6 @@
/* Copyright (C) 2009-2012, Stefan Hacker <dD0t@users.sourceforge.net>
Copyright (C) 2005-2012, Thorvald Natvig <thorvald@natvig.com>
Copyright (C) 2012, Jan Klass <kissaki@kcode.de>
All rights reserved.
Expand Down Expand Up @@ -29,70 +30,80 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
This plugin scans the following address locations:
Address Type Description
===================================
0x013E8CF4 float X-Coordinate
0x013E8CF8 float Y-Coordinate
0x013E8CFC float Z-Coordinate
// The XYZ coordinates repeat at 0x013F79C8, 0x013F79CC, 0x013F79D0
// and seem to always hold the same values. It is not the camera vs
// character, as with third person they still hold the same values.
0x013F9E20 float Horizontal view in degree
0x013F9E1C float Vertical view in degree
0x013E8DFC byte Team; 0: not in-game (in menu etc), 1: allies, 2: axis, 3: spectator
0x009FFD30 char[40] last connected to host IP
0x010B4908 char[32] map shortname only
As reference, as help for future manual mem scanning:
0x010B48C8 char[32] map fullpath (relative to gamedir)
0x03A54C9C char[16] last download host IP (wwwdownload)
There seem to be a ton of memory addresses valid for the team value.
For position coordinates:
X-Value is increasing when heading east
decreasing when heading west
Y-Value is increasing when heading north
decreasing when heading south
Z-Value is increasing when going up
decreasing when going down
1 unit = 1 meter (not confirmed)
For the view angle values:
Vertical view 0 when centered
-90 when looking up
+90 when looking down
Increasing when looking down.
Horizontal is 90 when facing north
0 when facing east
-90 when facing south
+/-180 when facing west
Increasing when turning left.
*/

#include "../mumble_plugin_win32.h"

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 &) {
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 &) {
float viewHor, viewVer;
char state;
char team;

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;

/*
This plugin uses the following Variables:
Address Type Description
===================================
0x013F79CC float Y-Coordinate
0x013E8CF4 float X-Coordinate
0x013E8CF8 float Z-Coordinate
0x013F9E20 float Horizontal view
0x013F9E1C float Vertical view
0x013E8D18 byte Magic value (32 ingame / 0 spectating)
*/
ok = peekProc((BYTE *) 0x013E8D18, &state, 1);
if (! ok)
ok = peekProc((BYTE *) 0x013E8DFC, &team, 1);
if (!ok)
return false;

if (state != 32)
return true; // If this magic value is !=32 we are spectating, so switch off PA
// We dont use pos-audio in menus
if (team == 0 || team == 3)
return true;

ok = peekProc((BYTE *) 0x013F79CC, avatar_pos+1, 4) && //Y
peekProc((BYTE *) 0x013E8CF4, avatar_pos, 4) && //X
peekProc((BYTE *) 0x013E8CF8, avatar_pos+2, 4) && //Z
peekProc((BYTE *) 0x013F9E20, &viewHor, 4) && //Hor
peekProc((BYTE *) 0x013F9E1C, &viewVer, 4); //Ver
ok = peekProc((BYTE *) 0x013E8CF4, avatar_pos, 4) && // X
peekProc((BYTE *) 0x013E8CF8, avatar_pos+1, 4) && // Y
peekProc((BYTE *) 0x013E8CFC, avatar_pos+2, 4) && // Z
peekProc((BYTE *) 0x013F9E20, &viewHor, 4) && // Hor-Angle
peekProc((BYTE *) 0x013F9E1C, &viewVer, 4); // Ver-Angle

if (! ok)
if (!ok)
return false;

avatar_top[2] = -1; // Head movement is in front vector

/*
Z-Value is increasing when heading north
decreasing when heading south
X-Value is increasing when heading east
decreasing when heading west
Y-Value is increasing when going up
decreasing when going down
1 unit = 1 meter (not confirmed)
*/

// Calculate view unit vector
/*
Vertical view 0 when centered
-90 when looking up
+90 when looking down
Increasing when looking down.
Horizontal is 90 when facing north
0 when facing east
-90 when facing south
+/-180 when facing west
Increasing when turning left.
*/
viewVer *= static_cast<float>(M_PI / 180.0f);
viewHor *= static_cast<float>(M_PI / 180.0f);

Expand All @@ -106,6 +117,15 @@ static int fetch(float *avatar_pos, float *avatar_front, float *avatar_top, floa
camera_top[i] = avatar_top[i];
}

// Context - concatenated server-ip mapname and team value
char hostip[32];
char mapname[40];
ok = peekProc((BYTE *) 0x009FFD30, hostip, sizeof(hostip)) &&
peekProc((BYTE *) 0x010B4908, mapname, sizeof(hostip));
hostip[sizeof(hostip)] = '\0';
mapname[sizeof(mapname)] = '\0';
context = std::string(hostip) + mapname + (char)(team + 0x30);

return true;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Connection.cpp
Expand Up @@ -147,6 +147,12 @@ void Connection::socketRead() {
if ((iPacketLength == -1) || (iAvailable < iPacketLength))
return;

if (iPacketLength > 0x7fffff) {
qWarning() << "Host tried to send huge packet";
disconnectSocket(true);
return;
}

QByteArray qbaBuffer = qtsSocket->read(iPacketLength);
iPacketLength = -1;
iAvailable -= iPacketLength;
Expand Down
70 changes: 70 additions & 0 deletions src/SignalCurry.h
@@ -0,0 +1,70 @@
/* Copyright (C) 2012, Stefan Hacker <dd0t@users.sourceforge.net>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of the Mumble Developers nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef SIGNAL_CURRY_H_
#define SIGNAL_CURRY_H_

#include <QObject>
#include <QVariant>

/**
* \brief Small class for binding a QVariant parameter to a parameterless signal.
* Static usage:
* SignalCurry::curry(sender, SIGNAL(emitted()), receiver, SLOT(called(QVariant)), curryParameter);
*/
class SignalCurry : public QObject {
Q_OBJECT
Q_DISABLE_COPY(SignalCurry)
private:
bool bDeleteAfterFirstUse;
QVariant qvData;
public:
SignalCurry(QVariant data, bool deleteAfterFirstUse = false, QObject *parent = 0) :
QObject(parent),
bDeleteAfterFirstUse(deleteAfterFirstUse),
qvData(data) {}

static void curry(QObject *sender, const char *signal, QObject *receiver, const char *slot, QVariant data) {
SignalCurry *c = new SignalCurry(data);
connect(receiver, slot, c, SIGNAL(called(QVariant)));
connect(sender, signal, c, SLOT(call));
}

signals:
void called(QVariant data);
public slots:
void call() {
emit called(qvData);
if (bDeleteAfterFirstUse) deleteLater();
}
};


#endif

0 comments on commit fa6c37d

Please sign in to comment.