Node.JS and ElectronJS, protection dialogs

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

Node.JS and ElectronJS, protection dialogs

Post by Enigma » Thu Dec 01, 2022 8:05 am

ElectronJS applications are rather specific, they are using Chromium browser to show the content.
Chromium browser run mutiple copies of itself (you can check it in task manager when running the file):
nw1.png
Since multiple copies of the same protected file runs, if you enable Registration Dialog, or Splash Screen, or any protection message will be shown, it show for all running instances of protected application. However, we need it for only first copy, others should skip this.

To make splash screen showing just for one first copy, we may use plugins system of Enigma Protector.
Following code creates a mutex object in Enigma_Plugin_OnInit function. If mutex already found, Enigma does nothing, if not found - show a splash screen

Code: Select all

procedure Enigma_Plugin_OnInit;
var
  errorcode : dword;
  hndl : THandle;
begin
  // This function is calling when the protected file is being initialized
  // when main program is not initialized yet
  
  hndl := CreateMutex(nil, false, '548fjwyn8vor8tmos8enyvlt5lw8gvnsehile');
  if hndl <> 0 then
  begin
    errorcode := GetLastError;
    if errorcode <> ERROR_ALREADY_EXISTS then
    begin
      EP_SplashScreenShow;
    end;
  end;
end; 
Note, in Enigma Protector settings we do not need to show a splash screen at program start, since it will be shown by API. So the settings may look as following:
nm2.png
For avoid duplication of message dialogs, we may Enigma_Plugin_OnShowMessage plugin function, the following code does what we need:

Code: Select all

var
  showalways : boolean = false;

function Enigma_Plugin_OnShowMessage(AMessageID : integer) : boolean; stdcall;
var
  errorcode : dword;
  hndl : THandle;
begin
  // This plugin function is being called all times when Enigma Protector
  // needs to show any information message. See manual for detailed information

  // If this function returns FALSE, the message which is set in Enigma Protector
  // will be shown, otherwise it will be supressed.
  Result := false;
  if AMessageID = MESSAGEID_TRIAL_REMINDER then
  begin
    if not showalways then
    begin
      hndl := CreateMutex(nil, false, 'c7rtr7iawtkrtn7kawvbrjcynfryakfjkry');
      if hndl <> 0 then
      begin
        errorcode := GetLastError;
        if errorcode = ERROR_SUCCESS then
        begin
          showalways := true;
        end else
        if errorcode = ERROR_ALREADY_EXISTS then
        begin
          Result := true;
        end;
      end;
    end;
  end;
end;  
For registration dialog, same as for splash screen, the function Enigma_Plugin_OnInit can be used. Please note, the code below can be used only if you show a registration dialog and allow user to skip it to try application. If you do not allow application to run without registration, then no changes should be made at all (in this case Enigma won't run application code if unregistered and only one copy of registration dialog will be shown).

Code: Select all

procedure Enigma_Plugin_OnInit;
var
  errorcode : dword;
  hndl : THandle;
begin
  // This function is calling when the protected file is being initialized
  // when main program is not initialized yet
  if EP_RegLoadAndCheckKey then
    Exit;

  hndl := CreateMutex(nil, false, 'of8a4lo8thje587ghifls8htJlo8hOIHo7hyi');
  if hndl <> 0 then
  begin
    errorcode := GetLastError;
    if errorcode <> ERROR_ALREADY_EXISTS then
    begin
      EP_RegShowDialog;
    end;
  end;
end;
And in Registration Features - Registration Dialog we need to uncheck options that shows dialog at application start
nw3.png
You do not have the required permissions to view the files attached to this post.

Enigma
Site Admin
Posts: 2802
Joined: Wed Aug 20, 2008 2:24 pm

Re: Node.JS and ElectronJS, protection dialogs

Post by Enigma » Thu Dec 01, 2022 8:12 am

This is sources and plugin.dll for registration dialog for Delphi x86 (can be compiled to x64 as well)
regdialog.zip
And this one is for splash screen, for Lazarus x64 (can be compiled to x84 as well)
splash.zip
You do not have the required permissions to view the files attached to this post.

Post Reply