I think I'm somewhat confused about compiling .NET bytecode with native code, or maybe I'm confused about the end result. So please be with me when I try to figure out what I think I understand so that you can help me figure out what I am missing.
What I would like to do is compile my application written in C # to the usual native code , as I would understand if I wrote it in C. My reasoning has nothing to do with performance, but rather with some degree of protection. I understand that my ultimate goal is not impossible (or even very difficult) to get around, but I just feel that reversing the x86 assembly is harder than reversing what Reflector gives me.
Right now, if I drop my C # application in Reflector, I basically return the source code. Usually, when I drop my unmanaged C / C ++ applications into IDAPro and use the HexRays decompiler, I don't quite get the same degree of decompilation, and I have to resort to wading through x86 parsing to understand the logical flow. I understand that such excellent decompilation comes from Reflector because the application is in MSIL instead of the more complex code that HexRays is trying to decompile.
I have no problem with a client machine still requiring .NET runtime. I am not trying to get around this. I would like to run regular obfuscation programs like upx
in my program and do it like a .NET binary.
It was my understanding from this related question that ngen
doing what I want. I tried using ngen
. But after copying the output file from the directory C:\Windows\assemblies\...\applicationName.ni.exe
somewhere, I can double-click somewhere, and trying to start it leads to an error about the absence of a “valid Win32 application”. Also, when I throw applicationName.ni.exe
into Reflector, I get the same result as me, only with applicationName.exe
. Since applicationName.ni.exe
should be native code, I expected Reflector to fail, but it is not. If so, how should I do this, why did Reflector give me such a great decompilation anyway?
So, just to summarize my main question again: how can I compile my .NET program into a native binary that Reflector will not decompile so easily? Or some recommendations on how to protect a product written in .NET from newcomers-reversers?
If I need another tool, I would prefer something free rather than something like Codewall .
Thank!
UPDATE: I understand that what I'm looking for may limit some language features, such as Reflection, but I think I'm fine with that. None of my codes have explicit calls to Assembly.Load
or anything like that. But could they just replace with GetProcAddress/LoadLibrary
calls?