Programmatically Generate C Win32 DLL

I need to repeatedly generate a Win32 DLL with the function of registering information. This function uses literals to return specific client registration information, with a separate DLL created for each client.

I have a test version that works correctly, with hard-coded information for one client. The relevance for some sites dictates that I generate some DLL manually, but I would like to provide the client with an application that dynamically emits the C source and builds the DLL on demand.

What would be the best way to do this? I have VS 2008 C ++ Express and therefore the cl.exe compiler. My current approach would simply be to have a C # application with a string constant for the C source, and before the generation, replace the tokens with the required parameters, then build and link, bypassing and running cl.exe.

+3
source share
5 answers

Define literals as #define, and then all you have to do is generate a header file. An automatic build system takes care of the rest.

+1
source

.rc. .res DLL. DLL, , LoadString, .

( ) "UpdateDLL.exe", API Win32: BeginUpdateResource, UpdateResource ....., DLL .

:

  • DLL ( ) .

  • UpdateDLL.exe, DLL .

  • "UpdateDLL.exe customer.dll myinfo.txt", DLL .

+5

, ​​:

string UserName = "PLACEHOLDER UserName                     ";
string RegCode  = "PLACEHOLDER RegCode                      ";
bool CheckRegistration(string UserName, RegCode) {
  ...
}

.dll. .dll, PLACEHOLDER . , .

+2

.NET( ) .NET Framework. , DLL Win32, DOM DLL.

Win32 .NET, COM - , . dll, , dll, COM, . ( ) dll.

, , Win32 SDK ( ) cl.exe link.exe.

+2

, DLL, , , , , , , . , - . - "MYSTART-------------MYEND" DLL.
DLL , DLL, . , , , , , , .
You can perform this search and replace manually using a hex editor or using a 3-line python / perl script.

0
source

Source: https://habr.com/ru/post/1707995/


All Articles