我正在使用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.
解决方法
资源只是指向映射到内存中的某些可执行部分的指针.
因此,您可以使用VirtualProtectEx更改此内存,就像您可以修补代码的任何部分一样.
请参阅Ok to use VirtualProtect to change resource in Delphi?关于此技术(此处有关resourcestring,但可以在任何锁定的资源上使用相同的API).