Obfuscating enum names when enum is .ToString()'d
CodeGuru
Posts: 13
The bug I described here:
http://www.red-gate.com/MessageBoard/vi ... hp?t=12231
STILL exists in the latest version of 6.
Its pretty frustrating have to put my exe's through IDA just to make sure SmartAssembly is obfuscating all of my names.
Just to make it even more clear whats going on here.
It's pretty obvious what you're trying to do. You detect if an enum is being printed out as a string. If it is, you're omitting it from obfuscation.
In this example though only the numerical value is being output though, not the actual enum name.
Also, you should have a policy of ALWAYS obfuscate unless the user EXPLICITLY chooses otherwise.
We should have confidence that SmartAssembly is obfuscating everything but your method to omit obfuscation on variables that you think we might want unobfuscated leaves us with zero confidence and full of doubt.
http://www.red-gate.com/MessageBoard/vi ... hp?t=12231
STILL exists in the latest version of 6.
Its pretty frustrating have to put my exe's through IDA just to make sure SmartAssembly is obfuscating all of my names.
Just to make it even more clear whats going on here.
public class Test { enum BitStateFlags { state1 = 1, state2 = 2, } void SomeFunction() { BitStateFlags flags = BitStateFlags.state1; MessageBox.Show(flags.ToString("X")); } }
It's pretty obvious what you're trying to do. You detect if an enum is being printed out as a string. If it is, you're omitting it from obfuscation.
In this example though only the numerical value is being output though, not the actual enum name.
Also, you should have a policy of ALWAYS obfuscate unless the user EXPLICITLY chooses otherwise.
We should have confidence that SmartAssembly is obfuscating everything but your method to omit obfuscation on variables that you think we might want unobfuscated leaves us with zero confidence and full of doubt.
Comments
If you want the string representation of this enum to be ("X"), maybe telling the enum to derive from the type long and using ((long)MyEnum).ToString("X")
That's exactly what I do to get SmartAssembly obfuscating the names properly.
I have not tried the [Flags] attribute as an alternative fix.
Thanks for the reply.