towi_parallelism
towi_parallelism

Reputation: 1481

Create an application that generates a DLL

Currently, I have an MFC C++ visual studio project that is built to a DLL. Let's call it the FinalDLL.

I need this FinalDLL to be configurable. So, I want a GUI such that the users can generate the FinalDLL based on the information the enter via GUI. Please consider that I don't want to make the sources available at any points.

I do not have a clear idea how to integrate these steps. The solution I came up with was to have something like a button in my GUI, so that when it is clicked, the FinalDLL gets generated based on the information entered via GUI. Is it possible to do something like that? Probably I need another DLL library, as the information entered via GUI can be calls to functions that are used inside the FinalDLL source.

Upvotes: 1

Views: 75

Answers (1)

Cristik
Cristik

Reputation: 32904

The solution to this would be very complex and complicated, mainly due to the fact that you don't want to disclose the source code of the DLL.

Basically you need to compile those source files every time you want to generate the DLL, and without the user having access to them.

Firstly, this is also required for the users that you want your DLL-generator app distributed to.

Secondly, you'll need to store those files somewhere in the app, and in an encrypted form, so that hackers won't just look at you app binaries and extract the source code for the DLL.

As a prerequisite on the user side, he will need to have a compatible Visual Studio installation, which will be used to compile on the fly the source code files.

What the DLL-generator application will need to do is to compile on the fly those source code files along with the customised ones via the form that the application will present.

So what you will need to do (the list might not be exhaustive due to the complex requirements):

  1. Gather all compiler/linker commands that Visual Studio executes when building your project
  2. Store all source code files into your application, in an encrypted form. Now if you want to allow your application to decode the files then you need to either store the encryption key within the application, and obfuscate it so its not that easy to find, or have the app communicate with your server and ask for the encryption key via https (this is a more secure approach, however neither this is 100% bullet-proof, insistent/trained hackers can still peek into the memory used by your app)
  3. After the user fills all DLL generating details, the app will need to decrypt the source code files, updated the ones affected by the customised parameters, and start the build process by using the commands gathered at step #1. The compiler/linker should allow reading from stdin, so you'll use pipes to write the source code contents to the compiler/linker stdin, and to obtain the compiled/linked objects from stdout.

As I said, the solution is not pretty, and the main problem will be having the users install a Visual Studio that comes with a compiler compatible with the one from your machine, otherwise the commands you gathered at step #1 will not work.

Upvotes: 2

Related Questions