1
/* Copyright (C) 2009-2010, Snares <snares@users.sourceforge.net>
2
Copyright (C) 2009-2010, Stefan Hacker <dD0t@users.sourceforge.net>
3
Copyright (C) 2005-2010, Thorvald Natvig <thorvald@natvig.com>
7
Redistribution and use in source and binary forms, with or without
8
modification, are permitted provided that the following conditions
11
- Redistributions of source code must retain the above copyright notice,
12
this list of conditions and the following disclaimer.
13
- Redistributions in binary form must reproduce the above copyright notice,
14
this list of conditions and the following disclaimer in the documentation
15
and/or other materials provided with the distribution.
16
- Neither the name of the Mumble Developers nor the names of its
17
contributors may be used to endorse or promote products derived from this
18
software without specific prior written permission.
20
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
#define _USE_MATH_DEFINES
43
#include "../mumble_plugin.h"
55
static DWORD getProcess(const wchar_t *exename) {
59
pe.dwSize = sizeof(pe);
60
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
61
if (hSnap != INVALID_HANDLE_VALUE) {
62
BOOL ok = Process32First(hSnap, &pe);
65
if (wcscmp(pe.szExeFile, exename)==0) {
66
pid = pe.th32ProcessID;
69
ok = Process32Next(hSnap, &pe);
76
static BYTE *getModuleAddr(DWORD pid, const wchar_t *modname) {
79
me.dwSize = sizeof(me);
80
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
81
if (hSnap != INVALID_HANDLE_VALUE) {
82
BOOL ok = Module32First(hSnap, &me);
85
if (wcscmp(me.szModule, modname)==0) {
86
addr = me.modBaseAddr;
89
ok = Module32Next(hSnap, &me);
97
static bool peekProc(VOID *base, VOID *dest, SIZE_T len) {
99
BOOL ok=ReadProcessMemory(h, base, dest, len, &r);
100
return (ok && (r == len));
103
static DWORD peekProc(VOID *base) {
105
peekProc(base, reinterpret_cast<BYTE *>(&v), sizeof(DWORD));
109
static BYTE *peekProcPtr(VOID *base) {
110
DWORD v = peekProc(base);
111
return reinterpret_cast<BYTE *>(v);
114
static void about(HWND h) {
115
::MessageBox(h, L"Reads audio position information from Enemy Territory: Quake Wars (v1.50). IP:Port context support.", L"Mumble ETQW plugin", MB_OK);
118
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) {
122
float viewHor, viewVer;
123
for (int i=0;i<3;i++)
124
avatar_pos[i]=avatar_front[i]=avatar_top[i]=0.0f;
129
This plugin uses the following Variables:
131
Address Type Description
132
===================================
133
0x013F79CC float Y-Coordinate
134
0x013E8CF4 float X-Coordinate
135
0x013E8CF8 float Z-Coordinate
136
0x013F9E20 float Horizontal view
137
0x013F9E1C float Vertical view
138
0x013E8D18 byte Magic value (32 ingame / 0 spectating)
140
ok = peekProc((BYTE *) 0x00801BA4, &menustate, 1);
146
ok = peekProc(pos1ptr, avatar_pos+1, 4) && //Y
147
peekProc(pos2ptr, avatar_pos, 4) && //X
148
peekProc(pos3ptr, avatar_pos+2, 4) && //Z
149
peekProc(rot1ptr, &viewHor, 4) && //Hor
150
peekProc(rot2ptr, &viewVer, 4) && //Ver
151
peekProc((BYTE *) 0x0122E0B8, ccontext, 128);
156
avatar_top[2] = -1; // Head movement is in front vector
159
context = std::string(ccontext);
161
if (context.find(':')==string::npos)
162
context.append(":27733");
165
Z-Value is increasing when heading north
166
decreasing when heading south
167
X-Value is increasing when heading east
168
decreasing when heading west
169
Y-Value is increasing when going up
170
decreasing when going down
171
1 unit = 1 meter (not confirmed)
174
// Calculate view unit vector
176
Vertical view 0 when centered
177
~+271 when looking up
178
~+88 when looking down
179
Increasing when looking down.
181
Horizontal is +90 when facing north
183
+270 when facing south
184
+180 when facing west
185
Increasing when turning left.
187
viewVer *= static_cast<float>(M_PI / 180.0f);
188
viewHor *= static_cast<float>(M_PI / 180.0f);
190
avatar_front[0] = -sin(viewHor) * cos(viewVer);
191
avatar_front[1] = -sin(viewVer);
192
avatar_front[2] = cos(viewHor) * cos(viewVer);
194
for (int i=0;i<3;i++) {
195
camera_pos[i] = avatar_pos[i];
196
camera_front[i] = avatar_front[i];
197
camera_top[i] = avatar_top[i];
203
static int trylock() {
205
pos1ptr = pos2ptr = pos3ptr = rot1ptr = rot2ptr = NULL;
207
DWORD pid=getProcess(L"etqw.exe");
210
BYTE *mod=getModuleAddr(pid, L"gamex86.dll");
214
pos1ptr = mod + 0x74EABC;
215
pos2ptr = mod + 0x74EAB4;
216
pos3ptr = mod + 0x74EAB8;
217
rot1ptr = mod + 0x75D2B4;
218
rot2ptr = mod + 0x75D30C;
220
h=OpenProcess(PROCESS_VM_READ, false, pid);
224
float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3];
226
std::wstring identity;
228
if (fetch(apos, afront, atop, cpos, cfront, ctop, context, identity))
236
static void unlock() {
243
static const std::wstring longdesc() {
244
return std::wstring(L"Supports Enemy Territory: Quake Wars v1.50. No identity support yet.");
247
static std::wstring description(L"Enemy Territory: Quake Wars v1.50");
248
static std::wstring shortname(L"Enemy Territory: Quake Wars");
250
static MumblePlugin etqwplug = {
262
extern "C" __declspec(dllexport) MumblePlugin *getMumblePlugin() {