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.
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:
Win32 GUI application
Dynamic linked library
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
Unique identifier of your application for licensing system
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.
Number of days license is valid. This is also default value and used only when otherwise not specified during license data generation.
All licenses are saved in the Windows registry. Key to which registry path relates. User can select between HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER.
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)
if(ipdGetLicenseInfo(LT_CUSTOMER, &info) == 0)
customer = wxString::From8BitData((const char *)info.value, info.length);
customer = _T("could not get customer info");
days = ipdGetExpiryDays();
if(days == 0)
expiration = _T("has expired");
else if(days < 0)
expiration = _T("expires never");
expiration.Printf(_T("expires in %u days"), days);
wxSizerItem *item = GetSizer()->GetItem(4);
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)
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_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.