Packing a .NET executable inside a C/C++ executable


I built a C# WPF (.NET Core 3.1) application using that has got some interest and I'm about to monetize it. However, building any kind of license check in C# is pretty much useless, and any user would be able to use a decompiler such as ILSpy to crack it, thus rendering my work pretty much useless.

I took a long hard look on the .NET obfuscators, but ultimately concluded they did not fit my requirements because there are decompilers that can still retrieve the code from Dotfuscator, Babel, Obfuscar, etc. Simply obfuscating names and whatnot isn't really useful, as one could simple debug the code to the point where a license is required.

What I'm trying to do now is build a C/C++ launcher that will execute my .NET from memory. My plan is to stream the bytes from a server, load them in memory, and run the program. I, however, don't know a whole lot about how I could achieve this.

I've tried VirtualAlloc to allocate all the bytes and changed set memory page to be executable, but it didn't work.

I've tried adjustments based on a few pieces of code that run PE from memory:

The closes I got was a 0xc0000005 error when trying to run the executable from memory (an array of bytes that makeup my program).

How can this be done? I'd really like to avoid having to rewrite the whole thing in C/C++, specially because of the complex UI.

asked on Stack Overflow May 8, 2021 by victor • edited May 8, 2021 by victor

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0