创世战车透视自瞄源码
Posted miraculousb
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了创世战车透视自瞄源码相关的知识,希望对你有一定的参考价值。
只包含主程序,比较简陋,仅供参考。
1 #include <Windows.h> 2 #include <stdio.h> 3 #include <WINBASE.H> 4 #include <string.h> 5 #include <tchar.h> 6 #include <psapi.h> 7 #include <tlhelp32.h> 8 #include <math.h> 9 //定义全局变量 10 COLORREF SnapLineCOLOR; 11 COLORREF TextCOLOR; 12 HANDLE _hGameHandle; 13 RECT m_rect; 14 DWORD ProcessId; 15 HDC HDC_Desktop; 16 HBRUSH EnemyBrush = CreateSolidBrush(RGB(255, 0, 0)); 17 HWND Handle; 18 HFONT Font; 19 float cx=1380; 20 float fovX = 3.1415 * 84 / 180; 21 float fovY = 3.1415 * 60 / 180; 22 #define BasePtr 0x204D6D0 23 #define ArrayPtr 0x2635890 24 #define mousexptr 0x264AAA4 25 #define crmeraptr 0x264A4A0 26 27 void DrawFilledRect(int x, int y, int w, int h) 28 { 29 //We create our rectangle to draw on screen 30 RECT rect = { x, y, x + w, y + h }; 31 //We clear that portion of the screen and display our rectangle 32 FillRect(HDC_Desktop, &rect, EnemyBrush); 33 } 34 35 36 void DrawBorderBox(int x, int y, int w, int h, int thickness) 37 { 38 //Top horiz line 39 DrawFilledRect(x, y, w, thickness); 40 //Left vertical line 41 DrawFilledRect(x, y, thickness, h); 42 //right vertical line 43 DrawFilledRect((x + w), y, thickness, h); 44 //bottom horiz line 45 DrawFilledRect(x, y + h, w + thickness, thickness); 46 } 47 48 49 //Here is where we draw our line from point A to Point B 50 void DrawLine(float StartX, float StartY, float EndX, float EndY, COLORREF Pen) 51 { 52 int a, b = 0; 53 HPEN hOPen; 54 // penstyle, width, color 55 HPEN hNPen = CreatePen(PS_SOLID, 2, Pen); 56 hOPen = (HPEN)SelectObject(HDC_Desktop, hNPen); 57 // starting point of line 58 MoveToEx(HDC_Desktop, StartX, StartY, NULL); 59 // ending point of line 60 a = LineTo(HDC_Desktop, EndX, EndY); 61 DeleteObject(SelectObject(HDC_Desktop, hOPen)); 62 } 63 64 //Draw our text with this function 65 void DrawString(int x, int y, COLORREF color, const char* text) 66 { 67 SetTextAlign(HDC_Desktop, TA_CENTER | TA_NOUPDATECP); 68 69 SetBkColor(HDC_Desktop, RGB(0, 0, 0)); 70 SetBkMode(HDC_Desktop, TRANSPARENT); 71 72 SetTextColor(HDC_Desktop, color); 73 74 SelectObject(HDC_Desktop, Font); 75 76 TextOutA(HDC_Desktop, x, y, text, strlen(text)); 77 78 DeleteObject(Font); 79 } 80 81 //********************************************************************************************************************************** 82 83 //自己封装的函数 84 85 //取进程ID函数 86 DWORD _GetProcessId(char* ClassName, char* WindowName) 87 { 88 //取游戏窗口的句柄 89 DWORD _pid; 90 HWND hGameWindow; 91 hGameWindow = FindWindowA(ClassName, WindowName); 92 GetWindowThreadProcessId(hGameWindow, &_pid); 93 return _pid; 94 } 95 96 //获取进程的句柄 97 HANDLE _GetProcessHandle(DWORD _pid) 98 { 99 HANDLE hGameHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, _pid); 100 return hGameHandle; 101 } 102 103 //读内存4字节整数型 104 DWORD _ReadMemeryInt(HANDLE hGameHandle, DWORD _address) 105 { 106 DWORD buffer; 107 ReadProcessMemory(hGameHandle, LPCVOID(_address), &buffer, sizeof(buffer), NULL); 108 return buffer; 109 } 110 111 //读内存小数型 112 FLOAT _ReadMemeryFloat(HANDLE hGameHandle, DWORD _address) 113 { 114 FLOAT buffer; 115 ReadProcessMemory(hGameHandle, LPCVOID(_address), &buffer, sizeof(buffer), NULL); 116 return buffer; 117 } 118 119 //读内存文本型 120 char* _ReadMemeryString(HANDLE hGameHandle, DWORD _address) 121 { 122 char read[256]; 123 char* pa; 124 125 pa = read; 126 127 ReadProcessMemory(hGameHandle, LPCVOID(_address), read, sizeof(read), NULL); 128 129 for (pa; *pa != ‘