gpt4 book ai didi

c# - 读取一 block 内存,将其存储到本地结构

转载 作者:行者123 更新时间:2023-11-30 12:12:33 24 4
gpt4 key购买 nike

<分区>

所以我正在读取另一个程序的内存以进行逆向工程。我正在使用 kernel32.dll 中的函数。

函数如下所示:

ReadProcessMemory(Handle, new IntPtr(Address), buffer, BytesToRead, out ptrBytesRead);

我正在用它一点一点地读取内存,就像这样:

    public static int ReadInt32(IntPtr Handle, long Address)
{
return BitConverter.ToInt32(ReadBytes(Handle, Address, 4), 0);
}

然后使用程序句柄和我要读取的地址调用 ReadInt32,添加程序的基地址,因为它不是静态的。

我想做的是读取整 block 内存(最多 1300 条记录,每条记录的内存步长为 0xB0)。

我不确定最好的方法是什么。我已经研究过它,看起来我可以做一些事情,我把整个事情都拿走,然后基本上把它转储到我自己的结构中。我遇到的问题是我不太清楚我实际需要做什么。我可以在脑海中看到它,但无法在纸上落笔。

我将展开以表明它实际上是一个二维数组,在结构上看起来像这样:

    int OFFSET_CREATURE_ID = 0;
int OFFSET_CREATURE_TYPE = 3;
int OFFSET_CREATURE_NAME = 4;
int OFFSET_CREATURE_Z = 36;
int OFFSET_CREATURE_Y = 40;
int OFFSET_CREATURE_X = 44;
int OFFSET_CREATURE_IS_WALKING = 80;
int OFFSET_CREATURE_DIRECTION = 84;
int OFFSET_CREATURE_OUTFIT = 100;
int OFFSET_CREATURE_OUTFIT_HEAD = 104;
int OFFSET_CREATURE_OUTFIT_BODY = 108;
int OFFSET_CREATURE_OUTFIT_LEGS = 112;
int OFFSET_CREATURE_OUTFIT_FEET = 116;
int OFFSET_CREATURE_OUTFIT_ADDON = 120;
int OFFSET_CREATURE_LIGHT = 124;
int OFFSET_CREATURE_LIGHT_COLOR = 128;
int OFFSET_CREATURE_HP_BAR = 140;
int OFFSET_CREATURE_WALK_SPEED = 144;
int OFFSET_CREATURE_IS_VISIBLE = 148;
int OFFSET_CREATURE_SKULL = 152;
int OFFSET_CREATURE_PARTY = 156;
int OFFSET_CREATURE_WARICON = 164;
int OFFSET_CREATURE_ISBLOCKING = 168;

这些偏移量中的每一个都需要分配给我的结构中的不同元素。其中一些是 bool,一些是 int,还有一些是 string。我有结构。我不能保证长度会消耗每个偏移量的整个“步长”,尽管当我读取这些值时我认为我每次都需要声明一个新的结构实例(我将每 500 毫秒左右读取一次,也许更多!250 条记录的总读取时间约为 50 毫秒,这正是我希望读取的时间!不过我确实需要能够读取多达 1300 条记录)。

拜托,不要混淆代码,只要解释我应该做什么就足够了。当我处理这么多代码时,我很费力,所以除非有人将一个类来读取所有这些,并用一个结构来存储它(这样我就可以将它转换为与我一起工作),我会很感激真正最少的代码。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com