Esempio n. 1
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;

	float ipos[3], rot[3];
	bool ok;

	ok = peekProc(posptr, ipos, 12) &&
	     peekProc(rotptr, rot, 12);

	if (ok) {
		int res = calcout(ipos, rot, avatar_pos, avatar_front, avatar_top);
		if (res) {
			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];

				// 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");
			}
			return res;
		}
	}

	return false;
}
Esempio n. 2
0
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
	posptr = rotptr = stateptr = contextptr = NULL;

	if (! initialize(pids, L"left4dead2.exe", L"client.dll"))
		return false;

	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(stateptr, &state, 1) &&
			  peekProc(contextptr, _context);

	if (ok)
		return calcout(pos, rot, opos, top, front);

	generic_unlock();

	return false;
}
Esempio n. 3
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) {
	float ipos[3], rot[3];
	bool ok;
	char state;

	ok = peekProc(posptr, ipos, 12) &&
	     peekProc(rotptr, rot, 12) &&
	     peekProc(stateptr, &state, 1);

	if (state == 0)
		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);
		if (res) {
			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];

				// 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");
			}
			return res;
		}
	}

	return false;
}
Esempio n. 4
0
static int trylock() {
	h = NULL;
	posptr = rotptr = NULL;

	DWORD pid=getProcess(L"left4dead.exe");
	if (!pid)
		return false;

	BYTE *mod=getModuleAddr(pid, L"client.dll");
	if (!mod)
		return false;

	h=OpenProcess(PROCESS_VM_READ, false, pid);
	if (!h)
		return false;

	posptr = mod + 0x580588;
	rotptr = mod + 0x4FF024;
	stateptr = mod + 0x4F8E34;

	float pos[3];
	float rot[3];
	float opos[3], top[3], front[3];

	bool ok = peekProc(posptr, pos, 12) &&
	          peekProc(rotptr, rot, 12);

	if (ok)
		return calcout(pos, rot, opos, top, front);

	CloseHandle(h);
	h = NULL;
	return false;
}
Esempio n. 5
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;

	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(contextptr, _context);

	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);
		if (res) {
			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];

				// 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[sizeof(_context) - 1] = '\0';
			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;
		}
	}

	return false;
}
Esempio n. 6
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;

	bool ok;
	float posrot[5];
	char state;
	char chHostStr[21]; // We just need 21 [xxx.xxx.xxx.xxx:yyyyy]

	ok = peekProc(posrotptr, posrot) &&
	     peekProc(stateptr, state) &&
	     peekProc(hostptr, chHostStr);

	if (!ok)
		return false;

	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) 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) {
		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;
	}

	return false;
}
Esempio n. 7
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 &) {
    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];

    ok = peekProc(posrotptr, posrot) &&
         peekProc(stateptr, state) &&
         peekProc(hostptr, chHostStr);

    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();
    }

    //TODO: Implement identity

    // Check to see if you are in a server and spawned
    if (state == 0 || state == 1 || state == 3)
        return true; // Deactivate plugin

    ok = calcout(posrot, posrot+3, avatar_pos, avatar_front, avatar_top);
    if (ok) {
        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;
    }

    return false;
}
Esempio n. 8
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;

	float cam[3], camtop[3], camfront[3];
	bool ok;
	char hostipport[sizeof(prev_hostipport)];

	ok = peekProc(camfrontptr, camfront, 12) &&
	     peekProc(camtopptr, camtop, 12) &&
	     peekProc(hostipportptr, hostipport) &&
	     peekProc(camptr, cam);

	if (!ok)
		return false;
	
	hostipport[sizeof(hostipport) - 1] = '\0';
	if (strcmp(hostipport, prev_hostipport) != 0) {
		context.clear();
		state = 0;

		strcpy_s(prev_hostipport, sizeof(prev_hostipport), hostipport);

		if (strcmp(hostipport, "") != 0 && strcmp(hostipport, "bot") != 0) {
			char buffer[50];
			sprintf_s(buffer, sizeof(buffer), "{\"ipport\": \"%s\"}", hostipport);
			context.assign(buffer);
			state = 1;
		}
	}

	if (!state) // report positional data only when on a server!
		return true;

	calcout(cam, camfront, camtop, camera_pos, camera_front, camera_top); //calculate proper position values
	for (int i=0;i<3;i++) {
		avatar_front[i] = camera_front[i];
		avatar_pos[i] = camera_pos[i];
		avatar_top[i] = camera_top[i]; // copy values since we don't know avatar's vectors
	}

	return true;
}
Esempio n. 9
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;

	float ipos[3], cam[3];
	int hostport;
	char hostip[16];
	bool ok;

	// Player not in game (or something broke), unlink
	if (!peekProc<procptr32_t>(gameptr))
		return false;

	ok = peekProc(camfrontptr, camera_front, 12) &&
		 peekProc(camptr, cam, 12) &&
		 peekProc(posptr, ipos, 12) &&
		 peekProc(afrontptr, avatar_front, 12) &&
		 peekProc(hostipptr, hostip) &&
		 peekProc(hostportptr, &hostport, 4);

	if (!ok) 
		return false;

	// Ensure strings are zero terminated
	hostip[sizeof(hostip) - 1] = '\0';

	calcout(ipos, cam, avatar_pos, camera_pos); //calculate proper position values
	
	if (strcmp(hostip, prev_hostip) != 0 || hostport != prev_hostport) {
		context.clear();

		strcpy_s(prev_hostip, sizeof(prev_hostip), hostip);
		prev_hostport = hostport;

		if (strcmp(hostip, "") != 0) {
			char buffer[50];
			sprintf_s(buffer, sizeof(buffer), "{\"ipport\": \"%s:%d\"}", hostip, hostport);
			context.assign(buffer);
		}
	}
	return true;
}
Esempio n. 10
0
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
	posptr = rotptr = stateptr = contextptr = NULL;

	if (! initialize(pids, L"left4dead2.exe", L"client.dll"))
		return false;
	/*
	Some hints to make things easier next time valve updates this game:
	use Cheat Engine (non-network single player or non VAC-secured servers to be safe)
	type is Float
	use unknown initial value
	use value unchanged/ value changed
	speed things up by limiting the scan range to 40000000 to 90000000 (hex number)
	you need addresses relative to client.dll. You can get address by double clicking on the address.
	
	pos: float likely in a range of 0 to 10000 (changes if you move. constant if you view around)
	rot: float in range of -180 to 180. If you look up the value is -89.0 . If you look down it is 89.0 (changes if you viewaround. constant if you only move)
	state: single player: search for loopback. Go back to menu. There is likely only one instance which has the string when having a game running and empty when not running a game.
	context: same as state appearantly

	*/
	posptr = pModule + 0x818950;
	rotptr = pModule + 0x7D0D18;
	stateptr = pModule + 0x8169BC;
	contextptr = pModule + 0x8169BC;
	
	float pos[3];
	float rot[3];
	char state, _context[21];
	bool ok = peekProc(posptr, pos, 12) &&
	          peekProc(rotptr, rot, 12) &&
			  peekProc(stateptr, &state, 1) &&
			  peekProc(contextptr, _context);

	if (ok) {
		float opos[3], top[3], front[3];
		return calcout(pos, rot, opos, top, front);
	}

	generic_unlock();

	return false;
}
Esempio n. 11
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;

	bool ok;
	float cam[3], pos[3], front[3], camfront[3];
	char location;
	int areaid;

	ok = peekProc(camptr, cam) &&
		 peekProc(posptr, pos) &&
		 peekProc(camfrontptr, camfront) &&
		 peekProc(locationptr, location) &&
		 peekProc(areaptr, areaid);

	if (!ok) // First we check, if the game is even running or if we should unlink because it's not / it's broken
		return false;

	ok = refreshPointers(); // yes, we need to do this pretty often since the pointer gets wiped and changed evey time you leave a world instance (that means on loading screens etc)
	if (!ok) { // Next we check, if we're inside the game or in menus/in a loading screen
		context.clear();
		return true; // don't report positional data but stay linked to avoid unnecessary unlinking on loading screens
	}
	else { // If we're inside the game, try to peekProc the last value we need or unlink (again, in case something went wrong)
		if (!peekProc(frontptr, front))
			return false;
	}

	calcout(pos, front, cam, camfront, avatar_pos, avatar_front, camera_pos, camera_front);

	if (areaid != prev_areaid || location != prev_location) {
		context.clear();

		prev_areaid = areaid;
		prev_location = location;

		char buffer[50];
		sprintf_s(buffer, sizeof(buffer), "{\"instance\": \"%d:%d\"}", areaid, static_cast<int>(location));
		context.assign(buffer);
	}
	return true;
}
Esempio n. 12
0
static int trylock(const std::multimap<std::wstring, unsigned long long int> &pids) {
	posptr = rotptr = NULL;

	if (! initialize(pids, L"left4dead.exe", L"client.dll"))
		return false;

	posptr = pModule + 0x596E30;
	rotptr = pModule + 0x596E3C;

	float pos[3];
	float rot[3];

	bool ok = peekProc(posptr, pos, 12) &&
	          peekProc(rotptr, rot, 12);

	if (ok) {
		float opos[3], top[3], front[3];
		return calcout(pos, rot, opos, top, front);
	}

	generic_unlock();

	return false;
}