Software protection example

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

edk
Posts: 954
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Software protection example

Post by edk »

It's the same
ezgif.com-optimize.gif
ezgif.com-optimize.gif (1.46 MiB) Viewed 1192 times
Last edited by edk on Wed Jun 19, 2024 8:49 am, edited 1 time in total.
brunellopulix
Posts: 80
Joined: Sat Apr 24, 2010 10:17 am

Re: Software protection example

Post by brunellopulix »

too fast I can't understand. Why did you try to change without asking first? you also confused the program and it doesn't work. Try resetting and try to understand why it doesn't work for you.
edk
Posts: 954
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Software protection example

Post by edk »

Sorry, I looped the GIF unnecessarily.
In my previous post, I added a comment and turned off the loop to better illustrate what I do to make it work for me.

To play the gif from the beginning, click this link: http://hmgforum.com/viewtopic.php?p=71131

List of step by step I perform:
  • I delete the demoprot.exe file as you asked
  • unpack the demoprot.exe file from the demoprot.zip file
  • I run the demoprot.exe file in the usual way
  • array range error appears
  • I am trying to fix the problem by restoring the system to the state it was in before running demoprot.exe, for this purpose I delete the damaged entries in the registry and the demoprot.dat file, which contains corrupt or incomplete security data
  • I run the demoprot.exe file again, but this time as Administrator. The program works, the registry entries are correct and the demoprot.dat file contains the correct security data.
brunellopulix
Posts: 80
Joined: Sat Apr 24, 2010 10:17 am

Re: Software protection example

Post by brunellopulix »

OK, if you think it might be of interest and right for you, send me an email and I'll send you the missing file.
As I already said, the source code cannot be published but I can share it if it is usable.
You can find my email in the forum

Brunello Pulix
edk
Posts: 954
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Software protection example

Post by edk »

I don't need your source code. I know more or less how it works. Generally, if you store your own data in the Windows registry, in some environments you need administrator privileges to access the registry.
Therefore, I think it is enough to force the application to run in administrator mode.
The code below checks whether the application is running in administrator mode, if not, it runs it in this mode (the same as "Run as Administrator")

Code: Select all

#include <hmg.ch>

PROCEDURE MAIN
   
PRIVATE lIsAdmin := wapi_IsUserAnAdmin()
   
IF .Not. lIsAdmin .AND. MsgYesNo ( "The application does not run in administrator mode, do you want to run it as an administrator?", "Run As Administrator" )
   RunApiAsAdministrator()
   RETURN
ENDIF

Msgdebug ( "Does the application run in administrator mode?" , lIsAdmin )
  
/* rest of prg */

RETURN


Function RunApiAsAdministrator()
ShellExecuteEx( wapi_GetActiveWindow(), 'runas', hb_ProgName(), , , SW_SHOWNORMAL )
Return Nil

#pragma BEGINDUMP

#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

#include <windows.h>
#include <hbapi.h>
#include <shlobj.h>

HB_FUNC( SHELLEXECUTEEX )
{
    SHELLEXECUTEINFO SHExecInfo;
    ZeroMemory(&SHExecInfo, sizeof(SHExecInfo));

    SHExecInfo.cbSize       = sizeof(SHExecInfo);
    SHExecInfo.fMask        = SEE_MASK_NOCLOSEPROCESS;
    SHExecInfo.hwnd         = HB_ISNIL( 1 ) ? GetActiveWindow() : (HWND) HMG_parnl( 1 );
    SHExecInfo.lpVerb       = (LPCSTR) HMG_parc( 2 );
    SHExecInfo.lpFile       = (LPCSTR) HMG_parc( 3 );
    SHExecInfo.lpParameters = (LPCSTR) HMG_parc( 4 );
    SHExecInfo.lpDirectory  = (LPCSTR) HMG_parc( 5 );
    SHExecInfo.nShow        = hb_parni( 6 );
    
    if( ShellExecuteEx(&SHExecInfo) )
    {
        // hb_retnl( (LONG) SHExecInfo.hProcess );
        CloseHandle(SHExecInfo.hProcess);
    }
}
#pragma ENDDUMP
P.S. An array error also appears when you delete the demoprot.dat file after registering the application. In this case, just running it as Administrator does not help, you need to delete the keys from the Windows registry.
franco
Posts: 841
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Software protection example

Post by franco »

I have not downloaded this. But just by reading through what happens if person gets a new computer.
This is the same as giving the program to a friend.
All The Best,
Franco
Canada
User avatar
serge_girard
Posts: 3195
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Software protection example

Post by serge_girard »

You can also protect PC by 'Allowed Hosts', in case there is a database connection.
See image
Attachments
Allowed hosts.png
Allowed hosts.png (86.29 KiB) Viewed 590 times
There's nothing you can do that can't be done...
Post Reply