Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ modify resources at runtime

Is it possible to edit resources for an executable at runtime programmatically? If so, how? If not, is there another program that can easily be used to modify resources?

Thanks, Derek.

like image 382
user37875 Avatar asked Dec 04 '08 00:12

user37875


People also ask

How do you update a resource file?

To update the resource file, you must modify a copy of the resource file, and then add the updated resource file to the form template. When you add the updated resource file to your form template, you are actually replacing the existing resource file.

How do I edit a RESX file?

Go to Settings >> Site Settings >> Languages, then click the language editor symbol (the most right one in the line with the language that looks like some kind of letters). Select the resource file and make your changes.

What is ResX file in c#?

A . resx file contains a standard set of header information that describes the format of the resource entries, and specifies the versioning information for the XML code that parses the data. These files contain all the strings, labels, captions, and titles for all text in the three IBM Cognos Office components.


1 Answers

Yes, it is possible, though not especially easy. It basically requires writing a resource compiler (at least for the resource types you want to modify).

For example I once wrote a menu compiler that took its input out of a database at run-time (at then saved the result back to the DB). If the source tables were unchanged then the existing resource was used, otherwise it was rebuilt.

In the case of menu resources (and I believe dialogs) the tricky bit is that certain members are only present depending on flag settings, as well as strict alignment requirements.

In the case of modifying resources already present in your .exe you would need to copy the resource data into a memory buffer (with extra space available if you are adding new elements) (by using FindResource, LockResource, a memory copy then UnlockResource).

After making the changes you then use one of the indirect create functions (i.e. CreateMenuIndirect) and pass the buffer's address.

The resource API allows for writing such a buffer back to the application binary but that would break the signature if you use code signing so be very careful. I also do not know if that API works for a program that is actually running.

like image 95
SoronelHaetir Avatar answered Sep 22 '22 14:09

SoronelHaetir