2. C++ anti-cheating and actual combat (advanced chapter - 16. How to realize game acceleration, teleportation and confrontation)


1. Implementation principle

   In many early games, I believe that many people have used gears to realize the accelerated teleportation function in the game. Its principle is the hook for API functions such as QueryPerformanceCounter, GetTickCount, and timeGetTime. This involves the concept of a clock. When they are hooked to the API, the new calculation method is as follows:

Clock = 上次时钟 + (当前返回时间 - 上次正常时间) * 倍数系数;

   In the minesweeper program, SetTimer will be used to set the timer, so after we hook, its timer will slow down, the sample code is as follows:

// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"

#include "EasyHook.h"

// timeGetTime使用到的
#include <MMSystem.h>
#pragma comment(lib, "Winmm.lib")

typedef BOOL (WINAPI *fun_QueryPerformanceCounter)( LARGE_INTEGER *lpPerformanceCount );
typedef DWORD (WINAPI *fun_GetTickCount)( VOID );
typedef DWORD (WINAPI *fun_timeGetTime)(void);
typedef UINT_PTR (WINAPI *fun_SetTimer)( HWND hWnd, UINT_PTR nIDEvent, UINT

Guess you like

Origin blog.csdn.net/wangningyu/article/details/123187717