Click here to Skip to main content
Click here to Skip to main content

Tagged as

IPDefend Toolkit plugin for Code::Blocks IDE

, 31 May 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Short guide to create licensed applications using the Code::Blocks IDE incorporating the IPDefend Toolkit plugin.

Editorial Note

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.

Introduction

This guide is aimed to make introduction to IPDefend Toolkit plugin for Code::Blocks IDE. His purpose is to allow for users of this excellent IDE to create licensed binary images such as EXEs, DLLs and native plugins for this IDE.

The Code::Blocks IDE 

For those who are not familiar or never heard about Code::Blocks IDE is an open source IDE for software development written in C++ using wxWidgets library.

Background 

Till nowadays was this IDE lacking of capability to enable creation of licensed executable images in easy way. We decided to change this and have create simple plugin + necessary supporting tools.  Here described solution does not require strict usage of this IDE but it is more comfortable than using raw command line version only. Binaries required for this framework found at Code::Blocks website and IPDefend Toolkit plugin website.

The IPDefend Toolkit 

is a wizard class plugin. The Code::Blocks IDE allows to extend his capability via plugins. The wizard class plugins are helpers which can build basic skeletons of build targets. You can create skeletons for these binary images:


Console application

Win32 GUI application

wxWidgets application

Dynamic linked library

Code::Blocks plugin

Step by step 

In present discussion some steps of the wizard are intentionally skipped and we focus on those that relates to licensing part.

First prerequisite is that Code::Blocks IDE and IPDefend Toolkit are already installed. When this is met initiate new project creation via menu bar. 

IPDefend Toolkit step

Product ID:

Unique identifier of your application for licensing system

Default features:

This field has custom format and must be parsed by the target application. Its intent is to enumerate features provided by the license. As his caption describes it is used only when otherwise not specified.

Default expiration:

Number of days license is valid. This is also default value and used only when otherwise not specified during license data generation.

Registry key:  

All licenses are saved in the Windows registry.  Key to which registry path relates.  User can select between HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER.

Registry path: 

Path to registry location where license information is stored. 

Naturally we people want always everything to change.  Way to for updating these information is leads via project/target options

Here we must make mention about Encryption keys Update checkbox. This updates license data encryption keys stored in license template file so as is written in red text older releases will not recognize licenses created after this update.

The license dependence

Most important part of licensed application is make some parts of target code license dependent. To achieve this we use blocks of code that are specially marked for example:   

if(ipdValidateLicense() == 0)
{
    IPD_CRYPT_START

    if(ipdGetLicenseInfo(LT_CUSTOMER, &info) == 0)
      customer = wxString::From8BitData((const char *)info.value, info.length);
    else
      customer = _T("could not get customer info");

    days = ipdGetExpiryDays();
    if(days == 0)
    {
      expiration = _T("has expired");
    }
    else if(days < 0)
    {
      expiration = _T("expires never");
    }
    else
    {
      expiration.Printf(_T("expires in %u days"), days);
      m_btnRenew->Show(true);
    }

    IPD_CRYPT_END

    page.Printf(aboutTxt,
                customer.c_str(), expiration.c_str());
    if(days)
    {
      // hide license entry controls
      wxSizerItem *item = GetSizer()->GetItem(4);
      item->Show(false);
      Fit();
      Layout();
    }
}

The licensed blocks markers are:

  • IPD_CRYPT_START - start of licensed block
  • IPD_CRYPT_END - end of licensed block 

Blocks marked in this way are encoded by ipdconde.exe tool. When execution enters into such block then the licensed code is decrypted before execution and encrypted after it.

These markers must be surrounded by  

if(ipdValidateLicense() == 0)
{
  IPD_CRYPT_START

  //
  // the licensed code goes here
  //
  ...

  IPD_CRYPT_END
}

to prevent execution attempt for case when there is no license present or it is invalid. Use as much as you need of these blocks. The IPD_CRYPT_START and IPD_CRYPT_END in non-encoded (plain) file acts as empty command ; in C/C++. To utilize effect of licensing/protection the plain file must encoded with ipdencode.exe tool. This is appended to target post-build step:

The license data

are used to active certain features in your target file. These data consists from serial number and key. To obtain these data use ipdlicgen.exe tool at command line or integrate provided ipdlicgen CGI version with your web server to automate the license generation process.

License entry dialog

Your software must be equipped with license data entry interface which can for example look like this:

Points of Interest

Why does Windows still need the MS-DOS header? One can think this is some obsolete part of file but the OS makes funny things inside it when a process starts.

History 

  • 2012/8/21-1.0 
  • 2013/5/31-1.1

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

vatai38
Software Developer (Senior)
Slovakia Slovakia
Code::Blocks developer, wxWidgets developer, Debugger developer, Embedded developer, Hardware engineer, Amiga fan, FPGA developer, Video card developer

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150305.1 | Last Updated 31 May 2013
Article Copyright 2013 by vatai38
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid