Plugin: Run the file during trial

Questions, downloads, issues related to plugins for Enigma Protector
Post Reply
Enigma
Site Admin
Posts: 2939
Joined: Wed Aug 20, 2008 2:24 pm

Plugin: Run the file during trial

Post by Enigma »

Continue sharing experience on protection improvement using plugin system.

This was a request from a customer, the feature that does not exist in protection. I will show how it can be implemented via plugins system.

Enigma Protector has an option that allows to run external file when trial has expired. The option names "TRIAL CONTROL - Common - Open file if trial is expired". Customer asked for a way to run the file when the trial is active. This feature is well suitable for plugins.

To create a plugin, do the following:
  • - To create a plugin dll I recommend to use freeware Lazarus (for x86 or for x64), this is a pascal compiler that allows us to compile a dll file. Download it and install https://www.lazarus-ide.org/
    - Download the sources of plugin attached to this post, open it in Lazarus, change if needed, compile a plugin dll
    - Put the compiled dll to the "plugins" folder of installed Enigma protector and restart it. If everything is well, the plugin should be shown at Miscellaneous - Plugins panel. Enable it.
    - Then protect the file. The plugin functions will be called by protection while the file is running
Back to the initial request - make a feature that runs a file if trial is active. The trial is active when the application is registered. If so, we can use the Enigma API function EP_RegLoadAndCheckKey, if the function returns false, this means it is not registered and so the trial is counting (of course, necessary trial control limitations should be enabled in protection). So using this simple code:

Code: Select all

procedure Enigma_Plugin_OnInit;
begin
  // This function is calling when the protected file is being initialized
  // when main program is not initialized yet

  // Check if application is registered.
  // If it is not registered then the trial period is going,
  // So run the file.
  if not EP_RegLoadAndCheckKey then
  begin
    ShellExecuteW(0, 'open', 'myexe.exe', nil, nil, SW_SHOW);
  end;
end;      
we check if application is registered, and if no - run the file myexe.exe.

You could change the sources to use any custom file name (it could be not only exe, but any other kind of documents too).
You do not have the required permissions to view the files attached to this post.
Post Reply