Yes, it is possible, although not particularly easy. This basically requires writing a resource compiler (at least for the types of resources you want to change).
For example, I somehow wrote a menu compiler that, at run time, extracted it from the database (after that I saved the result back to the database). If the source tables have not changed, then the existing resource was used, otherwise it was rebuilt.
In the case of menu resources (and, I believe, dialogs), the hard bit is that some members are present only depending on the flag settings, as well as strict alignment requirements.
In case of changing the resources already present in your .exe, you will need to copy the resource data to the memory buffer (with additional space available if you add new elements) (using FindResource, LockResource, a copy of the memory, then UnlockResource).
After making the changes, you then use one of the indirect creation functions (i.e. CreateMenuIndirect) and pass the buffer address.
The resource API allows you to write such a buffer back to the application binary, but it can break the signature if you use code signing, so be very careful. I also do not know if this API works for an actually running program.
Soronelhaetir
source share