「 硬核分享」 ❤️ FPS类游戏CSGO透视外挂完整源码❤️「 复制即用」

目录

效果展示视频

游戏下载地址

程序下载地址

纯c/c++源码 


效果展示视频

纯C++ FPS类游戏的透视编写

游戏下载地址

链接:https://pan.baidu.com/s/1vAJUGPS5gdq_RLfJflIW_Q 
提取码:Love

程序下载地址

链接:https://pan.baidu.com/s/1sjT0XSduZQ8fxjAddzNrMA 
提取码:Love

纯c/c++源码 

 :未经允许,禁止转载!

//Author:See QQ3492625357
//分享源码仅为技术交流,请勿用于非法用途
//若你对代码有任何疑问,欢迎交流!博主非常乐意为你解答疑问
#include<windows.h>
#include<time.h>
#include "Data.h"
LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
const int MAXSIZE = 32;

HWND gameHwnd;
RECT gameRect;
DWORD pid;
DWORD serverModuleAddr; 
DWORD engineMpdoleAddr;
HANDLE proHandle;
DWORD myselfBaseAddr;

bool initGameInfo()
{
	gameHwnd = FindWindow(TEXT("Valve001"), TEXT("Counter-Strike Source"));
	if (NULL == gameHwnd)
	{
		MessageBox(NULL, TEXT("请打开游戏后重试!"), TEXT("<未检测游戏>"), MB_OK);
		return false;
	}
	GetWindowRect(gameHwnd, &gameRect);
	gameRect.top += 25;

	GetWindowThreadProcessId(gameHwnd, &pid);
	if (NULL == pid)
	{
		return false;
	}

	if (!getModuleAddr(pid, TEXT("server.dll"), serverModuleAddr))
	{
		return false;
	}
	if (!getModuleAddr(pid, TEXT("engine.dll"), engineMpdoleAddr))
	{
		return false;
	}
	proHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

	if (proHandle == NULL)
	{
		return false;
	}

	if (!getRoleBase(proHandle, serverModuleAddr, myselfBaseAddr))
	{
		return false;
	}


	return true;
}

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lCmdLine,int nCmdShow)
{
	if (!initGameInfo())
	{
		return -1;
	}

	const TCHAR lpszWndName[] = TEXT("overlay");
	HWND overlayHwnd;
	WNDCLASS wc;
	wc.style = CS_HREDRAW|CS_VREDRAW;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.lpfnWndProc = WinProc;
	wc.hIcon = NULL;
	wc.hCursor = NULL;
	wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
	wc.hInstance = hInstance;
	wc.lpszMenuName = NULL;
	wc.lpszClassName = lpszWndName;

	if (!RegisterClass(&wc))
	{
		return -1;
	}
	
	overlayHwnd = CreateWindowEx(WS_EX_LAYERED|WS_EX_TRANSPARENT,wc.lpszClassName, TEXT("overlay"), WS_POPUP, 
		    gameRect.left,gameRect.top, gameRect.right-gameRect.left, gameRect.bottom-gameRect.top,
		NULL, NULL, hInstance, NULL);
   
  
	if (overlayHwnd==NULL)
   {
	   return -1;
   }
	SetLayeredWindowAttributes(overlayHwnd, RGB(0, 0, 0),0, ULW_COLORKEY);
	ShowWindow(overlayHwnd, nCmdShow);
	UpdateWindow(overlayHwnd);
	
	MSG msg;
	HDC hdc;
	
	RECT ovelayRect = { 0,0,gameRect.right - gameRect.left,gameRect.bottom - gameRect.top };
	RoleInfo myselfInfo;
	TCHAR buffer[128] ;
    vector<RoleInfo> enemyInfo;
	vector<DrawData> drawEnemy;
	while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);

		GetWindowRect(gameHwnd, &gameRect);
		gameRect.top += 25;

		SetWindowPos(overlayHwnd, HWND_TOPMOST,
			gameRect.left, gameRect.top, gameRect.right - gameRect.left, gameRect.bottom - gameRect.top,
			SWP_SHOWWINDOW);
		MoveWindow(overlayHwnd,
			gameRect.left, gameRect.top, gameRect.right - gameRect.left, gameRect.bottom - gameRect.top,true);
		//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓在这里更新数据↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
		
		if (!getTRoleInfo(proHandle, myselfBaseAddr, myselfInfo))
		{
			return -1;
		}
		saveEnemyInfo(enemyInfo, myselfInfo, serverModuleAddr, proHandle);
	    getEnemyPos(drawEnemy, proHandle, engineMpdoleAddr, gameRect, enemyInfo);

		
	    //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
		HPEN pen = CreatePen(PS_SOLID, 3, RGB(38, 188, 213));
		HBRUSH hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
		HDC hdc = GetDC(gameHwnd);//申请资源
		SelectObject(hdc, pen);
		SelectObject(hdc, hBrush);

		//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓在这里绘制↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

		for (vector<DrawData>::iterator it= drawEnemy.begin();it!= drawEnemy.end();it++)
		{
			Rectangle(hdc, it->left, it->top, it->right, it->bottom);
		}
		Sleep(20);
	
		//InvalidateRect(gameHwnd, &gameRect, true);
		HBRUSH cBrush = (HBRUSH)GetStockObject(BLACK_BRUSH);
		SelectObject(hdc, hBrush);
		FillRect(hdc, &gameRect, cBrush);
		
		//DeleteObject(hBrush);
		DeleteObject(pen);
		DeleteObject(hBrush);
		ReleaseDC(overlayHwnd, hdc);//释放资源。

	}
	return 0;
}


LRESULT CALLBACK WinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

	switch (msg)
	{
	case WM_PAINT:
		break;
	case WM_CLOSE:
			DestroyWindow(hwnd);	
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
		break;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
#pragma once

#include <Windows.h>
#include "TlHelp32.h"
#include <vector>
using namespace std;
typedef struct RoleInfo
{
	float _3dx, _3dy, _3dz;
	int flag;
	int HP;
}RoleInfo;

typedef struct DrawData
{
	float left, right, top, bottom;
}DrawData;


bool getRoleBase(HANDLE  proHandle, DWORD moduleAddr, DWORD &rolebase);
BOOL WordToScreen(float from[3], float to[2], float &height, HANDLE proHandle, DWORD mEngineAddr, RECT g_WinRect);
bool getTRoleInfo(HANDLE  proHandle, DWORD roleBse, RoleInfo &roleInfo);
bool getModuleAddr(DWORD pid, LPCTSTR moduleName, DWORD &moduleAddr);
bool getEnemyBase(HANDLE  proHandle, DWORD moduleAddr, DWORD &rolebase);
void saveEnemyInfo(vector<RoleInfo> &enemyInfo, RoleInfo roleInfo, DWORD BaseAddr, HANDLE  g_PHandle);//遍历房间内所有玩家,并保存敌人信息

void getEnemyPos(vector<DrawData> &enemy2Dpos, HANDLE ProHandle, DWORD engineModuleAddr, RECT rect, vector<RoleInfo> &enemyInfo);

bool getAllPlayInfo(RoleInfo & allPlayInfo, int index, DWORD BaseAddr, HANDLE  g_PHandle);
#include "Data.h"

bool getModuleAddr(DWORD pid, LPCTSTR moduleName, DWORD &moduleAddr)
{
	
	if (NULL== pid)
	{
		return false;
	}

	MODULEENTRY32 mEntity;
	mEntity.dwSize = sizeof(mEntity);

	HANDLE mSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);

	if (NULL==mSnap)
	{
		return false;
	}

	if (!Module32First(mSnap, &mEntity))
	{
		return false;
	}
	

	do {
		if (wcscmp(mEntity.szModule, moduleName)==0)
		{
			moduleAddr = (DWORD)mEntity.modBaseAddr;
			return true;
		}
	} while (Module32Next(mSnap, &mEntity));
	
	return false;
	
}


bool getRoleBase(HANDLE  proHandle, DWORD moduleAddr,  DWORD &rolebase)
{
	
	if (!ReadProcessMemory(proHandle, (PBYTE)(moduleAddr + 0x4F2FEC), &rolebase, 4, 0))
	{
		return false;
	}
	
	return true;
}

bool getEnemyBase(HANDLE  proHandle, DWORD moduleAddr, DWORD &rolebase)
{

	if (!ReadProcessMemory(proHandle, (PBYTE)(moduleAddr + 0x4F2FFC), &rolebase, 4, 0))
	{
		return false;
	}

	return true;
}

bool getTRoleInfo(HANDLE  proHandle,DWORD roleBse , RoleInfo &roleInfo)
{

	if (!ReadProcessMemory(proHandle, (LPBYTE)(roleBse + 0x280), &(roleInfo._3dx), 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(proHandle, (LPBYTE)(roleBse + 0x284), &(roleInfo._3dy), 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(proHandle, (LPBYTE)(roleBse + 0x288), &(roleInfo._3dz), 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(proHandle, (LPBYTE)(roleBse + 0x1F4), &(roleInfo.flag), 4, 0))
	{
		return false;
	}
	if (!ReadProcessMemory(proHandle, (LPBYTE)(roleBse + 0xE4), &(roleInfo.HP), 4, 0))
	{
		return false;
	}

	return true;
}

//世界坐标转屏幕坐标
BOOL WordToScreen(float from[3], float to[2],float &height, HANDLE proHandle,DWORD mEngineAddr,RECT g_WinRect)
{


	float Matrix[4][4] = { 0 };//人物矩阵
	if (!ReadProcessMemory(proHandle, (PBYTE)(mEngineAddr + 0x596EF0), &Matrix, sizeof(Matrix), 0))
	{
		return false;
	}

	//计算与玩家的相机比较的角度。
	float w = Matrix[3][0] * from[0] + Matrix[3][1] * from[1] + Matrix[3][2] * from[2] + Matrix[3][3];
	if (w > 0.001) //如果对象在视图中.
	{
		float fl1DBw = 1 / w; //Divide 1 by the angle.
		to[0] = ((g_WinRect.right - g_WinRect.left) / 2) + (0.5f * ((Matrix[0][0] * from[0] + Matrix[0][1] * from[1] + Matrix[0][2] * from[2] + Matrix[0][3]) * fl1DBw) * (g_WinRect.right - g_WinRect.left) + 0.5f); //Get the X dimension and push it in to the Vector.
		to[1] = ((g_WinRect.bottom - g_WinRect.top) / 2) - (0.5f * ((Matrix[1][0] * from[0] + Matrix[1][1] * from[1] + Matrix[1][2] * from[2] + Matrix[1][3]) * fl1DBw) * (g_WinRect.bottom - g_WinRect.top) + 0.5f); //Get the Y dimension and push it in to the Vector.
		float y = ((g_WinRect.bottom - g_WinRect.top) / 2) - (0.5f * ((Matrix[1][0] * from[0] + Matrix[1][1] * from[1] + Matrix[1][2] * (from[2] + 80) + Matrix[1][3]) * fl1DBw) * (g_WinRect.bottom - g_WinRect.top) + 0.5f);
		
		height = to[1] - y;
	
		return true;
	}

	return false;
}

void saveEnemyInfo(vector<RoleInfo> &enemyInfo, RoleInfo roleInfo, DWORD BaseAddr, HANDLE  g_PHandle) //遍历房间内所有玩家,并保存敌人信息
{
	

	for (int i = 1; i < 32; i++)
	{
		RoleInfo allPlayerInfo;

		if (!getAllPlayInfo(allPlayerInfo, i, BaseAddr, g_PHandle))
		{
			return;
		}

		if (allPlayerInfo.flag != roleInfo.flag)
		{
			enemyInfo.push_back(allPlayerInfo);
		}
	}
}


bool getAllPlayInfo(RoleInfo & allPlayInfo, int index,DWORD serverModuleAddr,HANDLE  g_PHandle)
{


	
	DWORD BaseAddr = 0;


	if (!ReadProcessMemory(g_PHandle, (PBYTE)(serverModuleAddr + 0x4F2FEC + (index * 0x10)), &BaseAddr, 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(g_PHandle, (LPBYTE)(BaseAddr + 0x280), &(allPlayInfo._3dx), 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(g_PHandle, (LPBYTE)(BaseAddr + 0x284), &(allPlayInfo._3dy), 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(g_PHandle, (LPBYTE)(BaseAddr + 0x288), &(allPlayInfo._3dz), 4, 0))
	{
		return false;
	}

	if (!ReadProcessMemory(g_PHandle, (LPBYTE)(BaseAddr + 0x1F4), &(allPlayInfo.flag), 4, 0))
	{
		return false;
	}
	if (!ReadProcessMemory(g_PHandle, (LPBYTE)(BaseAddr + 0xE4), &(allPlayInfo._3dz), 4, 0))
	{
		return false;
	}

	return true;
}

void getEnemyPos(vector<DrawData> &enemy2Dpos,HANDLE ProHandle,DWORD engineModuleAddr ,RECT rect, vector<RoleInfo> &enemyInfo)
{
	enemy2Dpos.clear();


	for (vector<RoleInfo>::iterator it = enemyInfo.begin(); it != enemyInfo.end(); it++)
	{
		float height;
		DrawData element;
		float from[3] = { it->_3dx,it->_3dy,it->_3dz };
		float to[2] = { 0 };

		if (!WordToScreen(from, to, height, ProHandle, engineModuleAddr, rect))
		{
			return;
		}
		element.left= to[0] - 0.25*height;
		element.right= to[0] + 0.25*height;
		element.top = to[1]-height;
		element.bottom = to[1];
		enemy2Dpos.push_back(element);
	}

}

おすすめ

転載: blog.csdn.net/weixin_40582034/article/details/119068626