FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Protection Plus
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Protection Plus
Posted: Wed May 04, 2011 02:43 PM

Hi,

Anyone is using Protection Plus with FHW?.

Is it possible to avoid reinstallation of a demo version?.

Thank you.

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Re: Protection Plus
Posted: Wed May 04, 2011 04:53 PM

Hi,
Protection Plus is, in my opinion, the best protection scheme for [x]Harbour language.
You have total control of your application, including avoid reinstalling a Demo version.

Regards

George

Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: Protection Plus
Posted: Wed May 04, 2011 05:10 PM

Hi Geoge,

Thank you for reply.

Do you have a sample of it?.

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Re: Protection Plus
Posted: Wed May 04, 2011 06:21 PM
UkService,
You need to use a supplied software: LFEDIT in order to create a special file and the parameters to be used in your protection's scheme.
Protection Plus has good documentation and samples about how to use LFEDIT as well multiples functions to interact with the the file that is going to protect your application.

Let's cal "YOUR_SECURITY_FILE.DAT" (you can rename this file any name that you want) to thre generated LFEDIT special file,
After that, you can retrieve and do any changes to the parameters inside YOUR_SECURITY_FILE.DAT by using [x]Harbour language.

Code (fw): Select all Collapse
FUNCTION CkSeguridad()
    LOCAL nDaysLeft := 0
    PRIVATE errorcode := 0, lfhandle := 0, nResult := 0, nTimes2Run := 0

    // "YOUR_SECURITY_FILE.DAT" is a special file generated by LFEDIT.EXE software

    nResult := pp_eztrial1( "YOUR_SECURITY_FILE.DAT",  "your_password",  @errorcode, @lfhandle)

    IF nResult = 2
        // SUCCESS: Application is in Demo mode and has days left
        RETURN TRUE
    ENDIF

    IF nResult <> 1
        pp_daysleft(lfhandle, @nDaysLeft)
        ShowDaysLeft(nDaysLeft, nResult)
        lRetu := KeyRegScreen(nResult, nDaysLeft, nTimes2Run)
        IF lRetu = 0
            fRegistration()
        ENDIF
    ELSE
        RETURN TRUE
    ENDIF


    DO CASE
    CASE nResult = 1
        // SUCCESS: Application has been unlocked. Not demo mode; it's a valid version

    CASE nResult = 2
        // SUCCESS: Application is in Demo mode and has days left

    CASE nResult = 3
        // FAIL: Application is illegal. Conver at Demo mode
        CkIsDemoOver1000(nResult)

    CASE  nResult = 4
        // FAIL: Application is in Expired mode. Demo Expired or Period Expired
        CkIsDemoOver1000(nResult)

    CASE  nResult = 5
        // FAIL: Clock turned back
        CkIsDemoOver1000(nResult)

    CASE nResult = 6
        // SUCCESS: Application is in Expired mode. Valid version
        CkIsDemoOver1000(nResult)

    CASE  nResult = 7
        // FAIL: LAN users over limits
        CkIsDemoOver1000(nResult)

    OTHERWISE
        dbselectarea("TRANSACT")
        IF lastrec() > 1000
            fin()
        ENDIF
    ENDCASE

    IF nResult = 0
        Fin()
    ELSEIF nDaysLeft = 0
        Fin()
    ENDIF

RETURN (.T.)


FUNCTION KeyRegScreen(nResult, nDaysLeft, nTimes2Run)
    LOCAL  oDlg, oRadio, nRadio := 1, oIcon, oFont, oFont1, oSay1, oSay2, lRetu := 0
    PRIVATE oSayDaysLeft   := "Days until program expires: "+ alltrim(str(nDaysLeft))
    PRIVATE oSayTimeToRun := "Times to run: "+ alltrim(str(nTimes2Run))

    DEFINE DIALOG oDlg RESOURCE "DIALOG_19"
    DEFINE FONT oFont NAME "MS SANS SERIF" SIZE 0,-10 BOLD
    DEFINE FONT oFont1 NAME "MS SANS SERIF" SIZE 0,-9 BOLD
    DEFINE FONT oFont2 NAME "VERDANA" SIZE 0,-10 //BOLD

    oDlg:SetFont(oFont)

    REDEFINE RADIO oRadio VAR nRadio ID 30, 40 of oDlg

    REDEFINE ICON oIcon ID 60 of oDlg RESOURCE "KEY01"
    REDEFINE SAY ID 610 of oDlg FONT oFont1
    REDEFINE SAY ID 620 of oDlg FONT oFont1
    REDEFINE SAY ID 630 of oDlg FONT oFont1
    REDEFINE SAY oSay1  ID 640 of oDlg FONT oFont1 PROMPT oSayDaysLeft
    //REDEFINE SAY oSay2  ID 650 of oDlg FONT oFont1 PROMPT oSayTimeToRun

    REDEFINE BUTTON ID 10 OF oDlg;               // OK
        ACTION (oFont:End(), oFont1:End(), oFont2:End(),  lRetu := CkIsDemoOver1000(nResult, nRadio), oDlg:End() )  CANCEL

    REDEFINE BUTTON ID 20 OF oDlg ;              // EXIT
        ACTION (oFont:End(), oFont1:End(), oFont2:End(), Fin()) // Cancel

    oDlg:lHelpIcon := .F.
    ACTIVATE DIALOG oDlg CENTER ON INIT (SetFocus(oDlg) )
    oFont:End()
    oFont1:End()
    oFont2:End()
    oDlg:End()


RETURN (lRetu)

FUNCTION CkIsDemoOver1000(nResult, nRadio)
    LOCAL nDaysLeft := 0, errorcode := 0, lRetu := 0
    

    IF nRadio = 2
        fRegistration()
    ENDIF

    DO CASE
    CASE nResult = 1
        // SUCCESS: Application has been unlocked. Not demo mode; it's a valid version

    CASE nResult = 2
        // SUCCESS: Application is in Demo mode and has days left
        // DEMO MODE
        pp_daysleft(lfhandle, @nDaysLeft)
        ShowDaysLeft(nDaysLeft, nResult)

    CASE nResult = 3
        // FAIL: Application is illegal. Conver at Demo mode
        // ILLEGAL COPY; MUST TO CONNVER TO DEMO MODE

    CASE  nResult = 4
        // FAIL: Application is in Expired mode. Demo Expired or Period Expired
        // ILLEGAL COPY; MUST TO CONVERT TO DEMO MODE If Records < 500 in Transact

    CASE  nResult = 5
        // FAIL: Clock turned back
        // ILLEGAL COPY; MUST TO CONVERT TO DEMO MODE

    CASE nResult = 6
        // SUCCESS: Application is in Expired mode. Valid version

        pp_daysleft(lfhandle, @nDaysLeft)
        ShowDaysLeft(nDaysLeft)

    CASE  nResult = 7
        // FAIL: LAN users over limits
        // ILLEGAL COPY; MUST TO CONVERT TO DEMO MODE
    OTHERWISE
        nResult := 99
    ENDCASE

    //msginfo(nResult)

    IF nResult >= 3 .AND. nResult <= 5
        // Show Registration Dialog
        nResultReg := pp_eztrig1(App.Path & "\license.ini", "password", @errorcode)

        If nResultReg = PP_SUCCESS
            MsgInfo("Registration Completed!")
        Else
            MsgInfo("Registration Unsuscefully")
            dbselectarea("TRANSACT")
            IF lastrec() > 1000
                msgbeep()
                MsgStop("Error Code: " + alltrim(str(nResult)), "Security Critical Violation!")
                fin()
            ENDIF
        EndIf
    ENDIF

    IF nResult >= 7
        nResultReg := pp_eztrig1(App.Path & "\license.ini", "password",   @errorcode)
        If nResultReg = PP_SUCCESS
            MsgInfo("Registration Completed!")
        Else
            MsgInfo("Registration Unsuscefully")
            dbselectarea("TRANSACT")
            IF lastrec() > 1000
                msgbeep()
                MsgStop("Error Code: " + alltrim(str(nResult)), "Security Critical Violation!")
                fin()
            ENDIF
        ENDIF
    ENDIF

    lRetu := nResult

RETURN (lRetu)

FUNCTION  ShowDaysLeft(nDaysLeft)
    Msginfo("This application has: "+alltrim(str(nDaysLeft))+ " days left")
RETURN (.T.)


FUNCTION CkIsDemo()
    LOCAL lRetu := TRUE, nCheckSum := 0, lfHandle := 0, nResult := 0
    nResult := PP_lfopen("YOUR_SECURITY_FILE.DAT", 0, LF_FILE, "YOUR_PASSWORD", @lfHandle)

    IF pp_copycheckth(LFhandle, COPYCHK_ENHANCED, 0, 20) = 1
        lDemo_ver := .f.                          // This computer already unlocked.
    ELSE
        lDemo_ver := .t.                          // Use demo mode for this computer.
    ENDIF
    lRetu := lDemo_ver
    PP_lfclose(lfHandle)
    IF lRetu
        MsgInfo("This program is in DEMO mode")
    ENDIF

RETURN (lRetu)


FUNCTION fRegistration()
    LOCAL errorcode :=0, nResult, nResultReg, lfhandle := 0
    nResult := pp_eztrial1( "YOUR_SECURITY_FILE.DAT", "YOUR_PASSWORD",  @errorcode, @lfhandle)

    IF nResult = 1
        IF cLang = "ENG"
            MsgInfo('This computer is already registered!')
        ELSEIF cLang = "SPA"
            MsgInfo('Este computador ya esta registrado!')
        ENDIF

        RETURN TRUE
    ENDIF

    nResultReg := pp_eztrig1(0, "YOUR_SECURITY_FILE.DAT",  "YOUR_PASSWORD",  @errorcode)
    If nResultReg = PP_SUCCESS
        IF cLang = "ENG"
            MsgInfo("Registration Completed!")
        ELSEIF cLang = "SPA"
            MsgInfo("Registración Completada!")
        ENDIF

    Else
        IF cLang = "ENG"
            MsgInfo("Registration Unsuscefully")
        ELSEIF cLang = "SPA"
            MsgInfo("Registración no pudo se completada")
        ENDIF
        //MsgInfo("Registration Unsuscefully")
        IF (nResult >= 3 .AND. nResult <= 5) .OR. nResult >= 7
            dbselectarea("TRANSACT")
            IF lastrec() > 1000
                msgbeep()
                MsgStop("Error Code: " + alltrim(str(nResult)), "Security Critical Violation!")
                fin()
            ENDIF
        ENDIF
    EndIf
RETURN (.T.)
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: Protection Plus
Posted: Thu May 05, 2011 12:43 PM

George,

Thanks, I am going to test it and share my results.

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Protection Plus
Posted: Thu May 05, 2011 09:19 PM

George;

Do you have links with info on protection plus?

Thank you,

Reinaldo.

Posts: 729
Joined: Tue Oct 18, 2005 06:49 PM
Re: Protection Plus
Posted: Thu May 05, 2011 11:06 PM
Reinaldo,

http://www.softwarekey.com/

Regards

George

Continue the discussion