I’m using the TResourceStream class to read a resource, know I want to modify the resource in memory, but the documentation of the Write method of the above class says:
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.
The question is, is there a way to modify a resource in my running application using any WinApi funcion? or are the resources stictly read-only?
Resources are just pointers to some executable part mapped in memory.
So you may be able to change this memory by using
VirtualProtectEx, just as you can patch any part of the code.See Ok to use VirtualProtect to change resource in Delphi? about this technique (here about resourcestring, but the same API can be used over any locked resource).