吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6093|回复: 4
收起左侧

[C&C++ 转载] 利用C语言进行游戏内存修改

[复制链接]
这是昵称的昵称 发表于 2019-3-25 09:18
本帖最后由 wushaominkk 于 2019-3-25 09:27 编辑

[C] 纯文本查看 复制代码
#include <tchar.h>
#include "stdafx.h"
#include <Windows.h>
#include<iostream>
using namespace std;
int gameaddress = 0x0000000; //游戏基址;
HANDLE gameprocess; 


首先这里是一开始需要用到的。 gameaddress是游戏基址,也就是用CE找到的最后一个地址。






[C] 纯文本查看 复制代码
int _tmain(int argc, _TCHAR* argv[])
{
    //获取游戏窗口所在进程的进程ID,也就是PID
    HWND hWnd = FindWindow(NULL, TEXT("进程id"));
    if (NULL == hWnd)
    {
        printf("查找窗口失败\n");
        return 0;
    }
    
    DWORD dwProcessId;
    GetWindowThreadProcessId(hWnd, &dwProcessId);
    printf("进程ID:%d\n", dwProcessId);
    
    //获取进程句柄
    gameprocess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
    if (NULL == gameprocess)
    {
        printf("打开进程失败\n");
        return 0;
    }

这里是对进程ID的读取





[C] 纯文本查看 复制代码
int *get4point(int gameaddress,int p1,int p2,int p3,int p4)
{
        int iBase, iP1, iP2,iP3,iP4,*iP5;
    if (!ReadProcessMemory(gameprocess, (LPVOID)gameaddress, &iBase, 4, NULL))
    {
        return NULL;
    }

    if (!ReadProcessMemory(gameprocess, (LPVOID)(iBase + p1), &iP1, 4, NULL))
    {
        return NULL;
    }
    if (!ReadProcessMemory(gameprocess, (LPVOID)(iP1 + p2), &iP2, 4, NULL))
    {
        return NULL;
    }
        if (!ReadProcessMemory(gameprocess, (LPVOID)(iP2 + p3), &iP3, 4, NULL))
    {
        return NULL;
    }
    iP4=(int *)(iP4+p3);
        return iP4;
}


上面这段是对当前地址的读取,就是根据基址和偏移找到现在的地址,以4个偏移为例子。


[C] 纯文本查看 复制代码
int *pwx=get5point(gameaddress,0xD4,0x88,0x1D0,0x8,);//这里的话输入4个偏移。
        float  wx = 150;   
        cout<<pwx<<endl;
        WriteProcessMemory(gameprocess, pwx,&wx, 4, NULL);

对地址进行修改,就是在新的地址替换基址


新手入门,这是我当时在学c语言指针偏移的时候参考植物大战僵尸源码,写了一下中国式家长的修改器。

免费评分

参与人数 2吾爱币 +3 热心值 +2 收起 理由
苏紫方璇 + 3 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
ChinaBabyQ + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wushaominkk 发表于 2019-3-25 09:28
【公告】发帖代码插入教程
https://www.52pojie.cn/thread-713042-1-1.html
代码插入注意格式,已帮你编辑,下次注意!

免费评分

参与人数 2吾爱币 +2 热心值 +2 收起 理由
gogoforit + 1 + 1 热心回复!
这是昵称的昵称 + 1 + 1 谢谢哈

查看全部评分

huste 发表于 2019-3-25 10:09
boy7928 发表于 2019-3-25 10:19
正在学C语言,不过看楼主这个 应该是属于C++的范畴了吧
hewei000 发表于 2020-7-30 19:04
支持一下
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-5 10:27

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表