Question

I am using XNA 4 and Monogame to develop an application. Furthermore, I use EasFuscator to obfuscate the C# source code. Is it possible and what would be the best way to make the filenames in the content folder non-human readable?

Basically, a filename like "title_image.xnb" should automatically be renamed to something like "hdRv4EEdx.xnb" (just as an example). Encryption of the content is not necessarily needed.

Was it helpful?

Solution

There is no built-in way to do this that I am aware of.

You can create a powershell script that will recursively go through all of your content files, then use regular expressions to find the appropriate Content.Load functions in your code and replace those with randomly generated hashes. You would then run this script as part of obfuscation.

It would probably even be simple to write if you have all of your Content.Load<> calls in a single file. Then the pseudocode would be something like:

For All Files in Content directory (and subdirectories, recursively):
  String hash = CreateRandomHash()
  File.renameTo(hash)
  "LoadContent.cs" = "LoadContent.cs".replace("Content.Load<Texture2D>(" + File.original.Name + ")", "Content.Load<Texture2D>(" + hash + ")");

But, you know, "pseudocode." :). It would take some work.

OTHER TIPS

Why not adding all resources with those names into content manager, from code you will know that this is title_image and will not be readable from end users if they open folder.

title_image = Content.Load<Texture2D>("hdRv4EEdx");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top