Just a little C + + base, Novice can also make a stand-alone game memory modifier

Source: Internet
Author: User

Statement: This article is only for beginners to learn C + +, can make some practical things, out of the shackles of management system, enhance the interest of learning, here to choose a single-machine game, please do not try online games, the violation of the hair is not necessarily feasible.
Preface: First we need a QT+VS environment
QT downloads from http://download.qt.io/archive/, first and third, select the corresponding version inside. Then is the environment, here provide 2013+qt5.5.1 environment configuration, if the environment is different, please own Baidu. This problem solving ability is not, do not learn C + + ...
My environment is 2013+qt5.5.1, different versions may vary slightly, but they are very similar.
First open vs Create Project, point to OK, then always next

Select Qwidget, click Finish

Then we created a project, and we talked about the project.

One:the main function is very similar to C + +

and then look at what you just created. Qt window class

First file, first.

then the CPP File

and look at some "weird" files.

The following two are the MOC file for Qt is automatically generated and updated at compile time, so no tube

the first one below is the code for the resource file CPP, Auto-generated, no tube

the second one is header files for UI files, automatically generated, without tube

Resource files, used to load pictures and other resources, it's useless here.

This is what we mentioned above. UI file, which is equivalent to the Visual interface designer, used to design the interface.

double tap to open Xxxxx. UI Files

Second: Next start interface design

In the control box, left-click to select a file label, a text input box, a button, and then drag inside the interface designer. The file tag is on the left, the text input box is in, and a button is on the right.

CTRL + left mouse button to select three controls, then right-click on any one of the controls to choose Layout -- Horizontal layout

Start interface layout

Right-click the large window and choose Layout-- Vertical Layout

Then mouse over the edge of the interface designer's border, press and hold the left key to drag to the appropriate size

in the Object Viewer, left-click to select the Large window, then drag the Properties window down, WindowTitle edit window title

Double-click the control to modify the control's text

Record the correspondence of the control and record the input boxes and buttons corresponding to the money skills and attributes.

Here my Money input box is lineEdit, Money Change button is pushbutton, skill Point is lineedit_2 and Pushbutton_2, The attribute point is Lineedit_3 and the Pushbutton_3

Then click Save, and be sure to save

Third: knowledge popularization before realization

1: Knowledge popularization of game memory modification

General game data has an address value, but this address value is dynamic, each time the game restarts will change, so we have to find a constant base address, and two constant offsets, to get the latest game data address.

2:Qt signal slot knowledge popularization

①Qt signal

signal refers to a kind of notice, figuratively: for example, you bring a lot of chocolate to the company, and then in the group to tell you,"I brought a lot of chocolate, to my station to take", here the company is your application, the group is the program of the instantiation object, you say this is a signal , maybe some people will ignore, some people do not see, some people will come, some people will tell others, you are only responsible for sending a notice, you do not care how others see your notice will react.

② Qt slot function

A slot is a behavior function that defines what should be done after receiving a signal notification, and the above example of chocolate, ignoring, telling, and chocolate, is a response to a signal notification.

③ Qt 's connect function

is to correlate signals and slots, A sends a signal to notify B to make some kind of response behavior.

④ Qt 's qtimer

Timer, the timeout () signal is sent uninterrupted at the interval you set .

⑤ qmessagebox::information()

Display a prompt window

⑥ How to find pointers to UI controls

the pointer to the UI control has the same name as objectname , and objectname is the interface designer to select the corresponding control, the first of the properties

use ui.objectname or ui->objectname, depending on the H file UI Whether the variable is an object or a pointer. This is ui.objectname.

Four: base and offset lookups

① now we need to use a software, called cheat engine, my is 6.6 Chinese version. The game takes horse riding and hacking as an example, first to modify money.

② Enter the Money data into CE, click on the new scan

③ try to change the number of money, enter the CE, click to scan again, repeat this, until the data only one

(Note: It is possible to encounter the situation has been 2 , such a situation try to change the data on the line, which is the effective which is which)

④ here is a game data memory, you can change the game data values, but he is dynamic, the game restart is invalid, we need to find the base address.

⑤ right mouse button This game data address, find what changed this value.

⑥ then appears this interface, in the beginning there is no data, need to change the game data (here is the number of money)

⑦ Double-click this data, here 5d0 is the first offset,4b4c1024 is the next address to find.

⑧ to open a new scan

⑨ Select the address you need to find out what access to this address, sometimes there are many, usually the more special one (that is, the other address at the beginning is the same, he is not the same), or a look, there is data is we need the address (note that there is no need to change the game data on the data)

⑩ casually double-click a MOV instruction data, here 140EC is the second offset value,48d2e010 is the next address to find

①① Repeat step ⑧ with the new referral address, the green address is the first address.

①② started the base.

①③ change the value of this address, and if the money changes, you'll find the right one.

Similarly, use this method to find the skill points

find out the first level base is 009d5e2c, offset is 5d0 2BC, found no, the first base address and the second offset is the same, so after searching, find an offset on it.

"Special attention" some of the tips on the web and the second offset + the first offset is the game data address, in fact, it is wrong, should be a primary address in the saved value + the second offset to get a two-level base, two-level base address of the value + the first offset is the game data address.

Five: The Code Implementation section, the tutorial is presented in comments

Only skill points and money are realized

#ifndef gameeditor_h#define gameeditor_h#include <QtWidgets/QWidget> #include "ui_gameeditor.h"// The header files required to read and write game memory include <windows.h>class Qtimer;class gameeditor:public qwidget{q_objectpublic:gameeditor ( Qwidget *parent = 0); ~gameeditor ();//slots is the expression slot function protected slots:void connectgame (); void Updategamemoney (); void Updategameperks ();p rivate:ui::gameeditorclass ui;//timer pointer, see 5-2-4qtimer* timer;//Money address DWORD moueyadress;//Skill Point address DWORD perksadress;//process Piddword pid; HWND hwnd;//process handle handle handle;}; #endif//Gameeditor_h

  

#include "gameeditor.h"//Timer header file # include <qtimer>//tip box header file # include <qmessagebox>gameeditor::gameeditor ( Qwidget *parent): Qwidget (parent) {UI.SETUPUI (this);p id = 0;hwnd = 0;handle = 0;//Money level base moueyadress = 0x009d5e2c;// Skill point First level base perksadress = 0x009d5e2c;//Create a timer, see 5-2-4timer = new qtimer;//set interval is 1000 milliseconds timer->setinterval (1000);// Timeout for the timer built-in signal, time one to automatically send//connect for the associated signal slot, detailed see the knowledge of the previous content//connect (signal sender pointer, SIGNAL (signal), this, slot (slot implementation function)); Connect ( Timer, SIGNAL (timeout ()), this, SLOT (Connectgame ())),//clicked for button built-in signal, click Auto Send//Remember, Ui.pushbutton is the Money modifier button, ui.pushbutton_2 is the skill point modifier button Connect (Ui.pushbutton, SIGNAL (clicked ()), this, SLOT (Updategamemoney ( )), connect (ui.pushbutton_2, SIGNAL (clicked ()), this, SLOT (Updategameperks ())), Ui.label_4->settext (QString:: Fromlocal8bit ("Waiting for the game program ...."));//Timer starts timing Timer->start ();} Gameeditor::~gameeditor () {}void gameeditor::connectgame () {//Lookup window and return window handle hwnd = FindWindow (0, L "Mount&blade Warband "); if (!hwnd) {return;} Get Pidgetwindowthreadprocessid through window handle (hwnd, &AMP;PID); if (!pid) {return;} Open a process through the PID and get the process handle handle = OpenProcess (Process_all_access, FALSE, PID); if (!handle) {return;} Read the data in DWORD newmoneyadress = 0 through the money level base address; ReadProcessMemory (handle, (LPVOID) moueyadress, &newmoneyadress, sizeof (newmoneyadress), 0);//Read No description you opened the game, But did not start if (moueyadress <= 0) {return;} Ui.label_4->settext (Qstring::fromlocal8bit ("Game program connected successfully!")); /Stop Timer timer->stop ();//Money level base value + Second offset = money two level base moueyadress = newmoneyadress;moueyadress + = 0x140ec;// Read the data inside the ReadProcessMemory (handle, (LPVOID) moueyadress, &newmoneyadress, sizeof (newmoneyadress), 0) via the money level two base;// Money two level base value + First offset = game data address (dynamic), game data address value is game data moueyadress = newmoneyadress;moueyadress + = 0x5d0;// Similarly, get Game data address DWORD newperksadress = 0 by Skill point first level base and offset; ReadProcessMemory (handle, (LPVOID) perksadress, &newperksadress, sizeof (newperksadress), 0);p erksadress = Newperksadress;perksadress + = 0X140EC; ReadProcessMemory (handle, (LPVOID) perksadress, &newperksadress, sizeof (newperksadress), 0);p erksadress = Newperksadress;peRksadress + = 0X2BC;} The change of Money button was clicked void Gameeditor::updategamemoney () {///Remember, Ui.lineedit is the money text input box, text () to get the input box, ToInt () Represents the conversion of data to int DWORD money = Ui.lineedit->text (). ToInt ();//Modify the value in the game data address DWORD Pref=writeprocessmemory (handle, (LPVOID) Moueyadress, &money, sizeof (money), 0);//qstring is the string in QT QString informationstr;if (pref) {informationstr = QString :: Fromlocal8bit ("modified successfully");} Else{informationstr = qstring::fromlocal8bit ("modification Failed");} Information Prompt box, the first parameter is the parent window, fill this or 0 can be, the second parameter is the title, the third parameter is the hint content qmessagebox::information (this, qstring::fromlocal8bit ("hint"), INFORMATIONSTR);} The modifier button of the skill point is clicked void Gameeditor::updategameperks () {DWORD perks = Ui.lineedit_2->text (). ToInt ();D Word pref = WriteProcessMemory (handle, (LPVOID) perksadress, &perks, sizeof (perks), 0); QString informationstr;if (pref) {informationstr = Qstring::fromlocal8bit ("modified successfully");} Else{informationstr = qstring::fromlocal8bit ("modification Failed");} Information Prompt box, the first parameter is the parent window, fill this or 0 can be, the second parameter is the title, the third parameter is the hint content qmessagebox::information (this, qstring::fromlocal8bit ("hint"), InformatiONSTR);} 

  

Just a little C + + base, Novice can also make a stand-alone game memory modifier

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.