Rename all method names in an assembly

C

Caroline

I have a CF app and I haven't found a decent obfuscator for it. I want to
write a simple obfuscator, that replaces variables and methods names. Is
there any way to rename all method names returned by Assembly.GetMethods,
for instance, method names, my own methods and other methods such as
GetType, GetHashCode, Equals, ToString - in order to scramble the code? Any
ideas on how to do this?

Thanks!
 
N

Nicholas Paldino [.NET/C# MVP]

Caroline,

What is it that you don't like about the other obfuscators? You know
that if you change those method names, you will have to change all the
references to your libraries (if that matters to you), since the signatures
are different (if you change the signature names, you have to recompile).
 
C

Caroline

They simply don't work well with CF. I've tried xenocode, the resulting
assembly is more than twice the size, and my resulting exe doesn't work, or
others are way too expensive to even consider. Do you know of a simple thing
I could do to obfuscate my code? I don't really need anything fancy. I've
researched writing the key license code in unmanaged and loading from a dll
using reflection, etc.


Nicholas Paldino said:
Caroline,

What is it that you don't like about the other obfuscators? You know
that if you change those method names, you will have to change all the
references to your libraries (if that matters to you), since the
signatures are different (if you change the signature names, you have to
recompile).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Caroline said:
I have a CF app and I haven't found a decent obfuscator for it. I want to
write a simple obfuscator, that replaces variables and methods names. Is
there any way to rename all method names returned by Assembly.GetMethods,
for instance, method names, my own methods and other methods such as
GetType, GetHashCode, Equals, ToString - in order to scramble the code?
Any ideas on how to do this?

Thanks!
 
J

Jon Skeet [C# MVP]

Caroline said:
I have a CF app and I haven't found a decent obfuscator for it. I want to
write a simple obfuscator, that replaces variables and methods names. Is
there any way to rename all method names returned by Assembly.GetMethods,
for instance, method names, my own methods and other methods such as
GetType, GetHashCode, Equals, ToString - in order to scramble the code? Any
ideas on how to do this?

For one thing, you *can't* rename methods like GetHashCode. They're
inherited from System.Object, and the runtime will be assuming they're
there (or rather, your code will be assuming that what you've written
as GetHashCode will be overriding Object.GetHashCode).

The best you'd be able to do is rename all of the names you've
introduced yourself.

This isn't a trivial task, however - I suspect you'd find it's cheaper
to work with obfuscator vendors to get something working based on their
existing codebase rather than writing your own.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top