Easy User code injection

cym13 via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 3 13:59:16 PDT 2016


On Sunday, 3 April 2016 at 20:51:47 UTC, Patience wrote:
> One problem with many applications is they are static once 
> compiled in the following sense:
>
> There are apps that have certain behaviors that may be 
> incomplete are undesirable. Usually it could be that the 
> designers used a hard coded value for something when it would 
> be better to have made that variable a "setting". The problem 
> is, the only way to change this is to re-compile the code.
>
> It would be extremely beneficial if the user themselves could 
> modify the code. Since they obviously can't recompile without 
> the source, i.e. all commercial apps, they have to ask the 
> developers for the enhancement or fix.
>
> The developers could write a complex object oriented design and 
> allow the user create objects that modify existing objects and 
> so forth(a plugin like system) but that creates way more 
> complexity than required for usually simple modifications(a few 
> lines of code).
>
> Does anyone see how it could be possible to make an efficient 
> way in D applications to allow for "user modifications" almost 
> as equivalent to having the source?
>
> Code injection/Hooks is probably the way to go about this but 
> one has to worry about performance in some cases, the 
> implementation details in D, and how to present this to the 
> user in the best possible way.
>
> A "scripting" like interface would probably be required but not 
> necessary as we could allow the user to create the code 
> somewhere else.
>
> Another idea:
>
> Suppose the source code is internally encrypted and when the 
> user wants to modify a part of it, the application can 
> recompile that part of the code and replace the original. 
> Doesn't seem like a great idea but probably only slightly worse 
> than reverse engineering the binary itself.

That sounds complicated... couldn't you just separate the parts 
you want the user to be able to change to be in a dynamic 
library? That way you can ship a working product and if someone 
wants to change it they recompile and replace the library by the 
new one. If you don't want to give the sources of that one part 
you can give a "dumb" interface file to lay down a skeleton for 
the user to change. Seems easier on both ends than encryption.


More information about the Digitalmars-d mailing list