Click here to Skip to main content
15,884,986 members
Articles / Programming Languages / C++

Protecting an Application's Unauthorized Copy

Rate me:
Please Sign up or sign in to vote.
4.16/5 (52 votes)
2 Aug 2013CPOL4 min read 124.4K   5.4K   161  
To protect your application's unauthorized copy by using image integrity functions (Platform SDK's ImageHlp APIs) and to manage certificates in a portable executable (PE) image file.
//
// CertificateMgr.h
//
// This is a helper class to manage certificates in your executable file.
//
// Compilation instruction:
//	1. Add imagehlp.lib file in your addtional libraries.
// Goto project Properties > Linker > Input > Additional Dependencies
//
// Author
//		Manish Agarwal (manish.k.agarwal@gmail.com)
//

#include <windows.h>

class CertificateMgr
{
public:
	CertificateMgr() : mFileHandle(INVALID_HANDLE_VALUE) {};
	~CertificateMgr();
	BOOL Init(const char * const imageName);
	BOOL IsValidCopy();
	BOOL SignDLL();
protected:
	BOOL IsCertificatePresent();
	BOOL AddCertificate(BOOL bSign = FALSE);
	void RemoveCertificate(); // prototype just for future
	int GetUniqueData(void *&pData);
	int GetSigningData(void *&pData);
private:
	HANDLE mFileHandle;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior) Oracle
India India
Working with Oracle. Using C/C++, VC++, MFC, STL, C#, Java etc. on various platform like Windows, Unix, Macintosh etc. from last 13+ years to convert various type of requirements into running software components. My core expertise is multithreaded desktop product and large scale enterprises software development.

Comments and Discussions