是否可以从运行应用程序中获取类属性的值?

发布于 2025-02-10 01:54:01 字数 472 浏览 1 评论 0原文

有一个模拟器。在此模拟器中,我们必须通过走廊。在走廊里有一扇门和一个难题,其解决方案打开了这扇门。一旦我们解决了难题,班级的布尔属性(类似于等法)的价值

就需要多次穿越该走廊。走廊本身不会改变,但是每次难题都是随机的。

因此,我决定创建一个宏应用程序,该应用程序达到拼图并等到我解决它,

并且由于模拟具有我需要的布尔变量,我想知道:我可以得到它,以便在宏中创建一个延迟,直到是真的?

这里的主要问题是两个程序均未以任何方式连接。

我还想注意到,我有一个了解,所有变量在编译后都丢失了他们的名字,并且变量值随后也占据了记忆中的随机位置

,我具有诸如cheatengine之类的程序的经验,这是为了通过它的价值

,但我可能只是不知道所有细节,认为这是不可能的,即使实际上有一些方法可以做到这一点。

因此,如果您可以向我解释如何完成,或者,如果不可能解释原因,我将不胜感激。

另外,我不介意像“阅读”这样的回应

There is a simulator. In this simulator we have to pass a corridor. In the corridor there is a door and a puzzle, the solution of which opens this door. As soon as we solve the puzzle, the value of the boolean attribute of the class (something like isOpen) changes to true

This corridor needs to be traversed several times. The corridor itself doesn't change, but the puzzle is random each time.

So, I decided to create a macro application that reaches the puzzle and waits until I solve it

And since the simulation has the boolean variable I need, I was wondering: can I get it, in order to then create a delay in the macro until it is true?

The main problem here is that the two programs are not connected in any way.

I also want to note that I have an understanding that all variables lose their names after compilation, and that variable values subsequently occupy a random place in memory

Also, I have experience with programs like CheatEngine, which is to find the address of a value by its value

But I may just not know all the details, thinking that it's impossible, even if in reality there are ways to do it.

For this reason, I would appreciate it if you could explain to me how this can be done, or, if it is not possible, explain why.

Also, I wouldn't mind a response like "Read this "

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任性一次 2025-02-17 01:54:01

我了解您要在运行时检查对象实例的一个或多个属性,并且可以使用所谓的反射

后者提供的功能使您可以在运行时检查对象,获取其类型,阅读其属性并调用其方法。它应仔细使用。

使用反射可以做

// retrieves the value of the property "NameOfProperty" for the instance of object myobj

bool myFlag = myobj.GetType().GetProperty("NameOfProperty").GetValue(myobj, null);

I understand that you want to inspect one or more properties of an instance of an object at runtime and this can be achieved by using the so-called Reflection.

The latter provides functionalities that allow you to examine objects at runtime, get their Type, read their properties and invoke their methods. It should be used carefully.

Using reflection you can do

// retrieves the value of the property "NameOfProperty" for the instance of object myobj

bool myFlag = myobj.GetType().GetProperty("NameOfProperty").GetValue(myobj, null);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文