Write access to symbols, exported from DLL or SO

It is legal to overwrite exported data in attached DLL/SO?

Example (win32):

t_Controller controller = (t_Controller*) GetProcAddress(SomeDLL, "Controller");
controller->Args = args; //  <--- here
controller->Run();

Answers


Ok - so you are exporting a struct of some kind.

Once a pointer to the struct is obtained, whether or not its legal to write to the struct from the exe, depends entirely on whether or not its legal, in the dll, to write to the struct.

i.e. is it a const struct? If its not defined as const, then you can write to it. If it is defined as const, then your GetProcAddress is just a complicated way of casting the const off, which will result - as always - in undefined behavior. i.e. it may, or may not work, depending on your compilers implementation - usually whether or not static objects declared at global scope are placed in a read-only data section.


Need Your Help

getstream.io - Is there a way to prevent activities from bouncing back to a user via another feed?

getstream-io

Say I have user who follows a football team. That user posts a message on that teams forum, which creates an activity on the teams feed. Since the user follows the team he also gets an activity in ...

Need to "refresh" app's screen on button press

ios iphone objective-c avfoundation calayer

I have an app that lets users capture photos. Right now, when a user presses the button to snap a photo, I create a CALayer object and set it's contents property to equal the image object that was ...