微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我正在使用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?关于此技术(此处有关resourcestring,但可以在任何锁定的资源上使用相同的API).

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐