C# 从进程中读取内存(在这种情况下是游戏)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8804954/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 04:30:48  来源:igfitidea点击:

Reading memory from a process (game in this case)

c#memory-management

提问by Gideon

I'm making a autoclicker atm to get back into C# before my school starts again. I've been playing with php as an intern the last 5 months, when we get back to school php will be gone and C# will come looking around the corner.

我正在制作一个自动点击器 atm,以便在我的学校再次开学之前重新使用 C#。在过去的 5 个月里,我作为实习生一直在玩 php,当我们回到学校时,php 将消失,而 C# 即将到来。

I have played with C# for a long time, just some fun things whenever I get an idea, nothing special. Now I was making a autoclicker with record function so I could automate some things in a game, but I wanna take it a step further, memory reading!

我玩 C# 已经很长时间了,只要有想法就做一些有趣的事情,没什么特别的。现在我正在制作一个带有记录功能的自动点击器,这样我就可以在游戏中自动化一些东西,但我想更进一步,读取内存!

Untill right now I found it so hard to find some decent info on it (dont know exactly where to look for) that im stuck. I want to make something that you can compare to an aimbot, but nothing commercial or anything, just want to experiment. I want to know the location of lets say ghosts from pacman, or the bal in pinball, or even airplanes in a flying game.

直到现在我发现很难找到一些关于它的体面信息(不知道在哪里寻找),我卡住了。我想做一些可以与瞄准机器人相提并论的东西,但没有商业性或任何东西,只是想尝试一下。我想知道吃豆人的鬼魂,弹球中的球,甚至飞行游戏中的飞机的位置。

How do I start with this? I've read some things about how memory works and some functions to actually get it. But I dont know how to FIND the addresses. Also I dont know how to use them in a if statement for example.

我该如何开始?我已经阅读了一些关于内存如何工作的内容以及一些实际获取它的功能。但我不知道如何找到地址。例如,我也不知道如何在 if 语句中使用它们。

Can someone point me in the right direction here?

有人可以在这里指出我正确的方向吗?

采纳答案by Bawss

I suggest you check (C#)ReadProcessMemoryout.

我建议您检查(C#)ReadProcessMemory

回答by kev

Cheat Enginecan help you find the memory adresses you need, although it is a rather tedious task. It also lets you change stuff if you want to experiment. There are also Tutorials on Youtubeand on the CheatEngine forum

Cheat Engine可以帮助您找到所需的内存地址,尽管这是一项相当乏味的任务。如果您想进行实验,它还可以让您更改内容。YoutubeCheatEngine 论坛上也有教程

回答by Петър Петров

Your best bet for writing trainers is to go native directly. Learn some C and C++ then use ReadProcessMemory. Working with native pointers in C# even in unsafe mode is terribly hard and ugly. Working with P/Invoke is not that terrible but for your case the only cool thing C# is giving to you is WinForms. Managed C++ is the best option if you need WinForms and native pointers in other processes in the same place :)

编写培训师的最佳选择是直接使用本地语言。学习一些 C 和 C++,然后使用 ReadProcessMemory。即使在不安全模式下在 C# 中使用本机指针也非常困难和丑陋。使用 P/Invoke 并没有那么糟糕,但就您而言,C# 提供给您的唯一很酷的东西是 WinForms。如果您在同一位置的其他进程中需要 WinForms 和本机指针,托管 C++ 是最佳选择:)