Is it possible to know the location of const variables within an exe? We were thinking of watermarking our program so that each user that downloads the program from our server will have some unique key embedded in the code.
Is there another way to do this?
Key consideration #1: Assembly signing
Since you are distributing your application, clearly you are signing it. As such, since you’re modifying the binary contents, you’ll have to integrate the signing process directly in the downloading process.
Key consideration #2:
constorreadonlyThere is a key difference between
constandreadonlyvariables that many people do not know about. In particular, if I do the following:Then it will compile to byte code like the following:
If you make the following:
Then it will compile to byte code like the following:
constvariables are [allowed to be] substituted and evaluated by the compiler instead of at run time, wherereadonlyvariables are always evaluated at run time. This makes a big difference when you expose fields to other assemblies, as a change to aconstvariable is a breaking change that forces a recompile of all dependent assemblies.My recommendation
I see two reasonably easy options for watermarking, though I’m not an expert in the area so don’t know how “good” they are overall.
Finally, Google reported the following article on watermarking software that you might want to take a look at.