delphi - 是否可以修改已加载的资源?

标签 delphi winapi resources

我正在使用TResourceStream类来读取资源,知道我想修改内存中的资源,但是Write的文档上面类的方法说:

Applications should not use a TResourceStream to write the resources of the running application. Write overrides the inherited method to raise an EStreamError exception when an application tries to write to the application's resources.

As all other data-writing methods of TResourceStream (WriteBuffer, WriteComponent) call Write to do the actual writing, calling any of the data-writing methods of TResourceStream will raise an exception.

问题是,有没有办法使用任何 WinApi 函数来修改正在运行的应用程序中的资源?或者资源严格是只读的?

最佳答案

资源只是指向内存中映射的某些可执行部分的指针。

因此,您可以使用VirtualProtectEx更改此内存,就像您可以修补代码的任何部分一样。

参见Ok to use VirtualProtect to change resource in Delphi?关于此技术(此处关于资源字符串,但可以对任何锁定的资源使用相同的 API)。

关于delphi - 是否可以修改已加载的资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8536862/

相关文章:

delphi - E2003 未声明的标识符 : 'Form1' - Out of Nowhere

delphi - 在delphi中合并两个字节

java - 如何在Java中从DB加载资源包消息?

delphi - 如何检测应用程序外部的拖放?

delphi - JCLDebug 堆栈跟踪缺少导致错误的实际代码行

winapi - 在 Rust 中使用 winapi 从窗口获取位图

c++ - 从右到左的阅读顺序 : why isn't this calculated automatically?

c++ - 如何从 Windows 注册表中读取值

asp.net MVC3 DefaultModelBinder 错误消息键

c++ - 微软 Visual Studio : Loading resources in Qt application (without plug-in)