Node.JS and ElectronJS, protection dialogs
Posted: 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):
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
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:
For avoid duplication of message dialogs, we may Enigma_Plugin_OnShowMessage plugin function, the following code does what we need:
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).
And in Registration Features - Registration Dialog we need to uncheck options that shows dialog at application start
Chromium browser run mutiple copies of itself (you can check it in task manager when running the file):
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;
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;
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;