Introduction
If you're shareware programmer, you may need to lock some functions of your product from unauthorized access. Problem is that hackers can unlock these functions without your permission. :-) In this article I'll show how to lock shareware functions and to reduce of risk of a hacker cracking your product.
Background
Basic idea is that we call hidden shareware functions by its address, which we pass to user in key file. In this case, hacker can't crack the program because he cannot determine the necessary address of a protected function. In the provided demo project, the address of function is stored in an open kind ( pass.txt file), but nothing hinders you to encrypt this address by user's hard disk serial number, for example.
The required Steps
- Let's find out the address of the function:
void HiddenPaintFunc(DWORD pv,DWORD pp)
{
}
BOOL CSharewareDialog::OnInitDialog()
{
CString strAddress;
strAddress.Format("0x%X",HiddenPaintFunc);
AfxMessageBox(strAddress);
...
- Create a key file in hex editor and write an address to it ( don't forget about the return order - for example: 00401602 -> 02164000)
- At last, instead of a customary function call, we write the following :
void CSharewareDialog::INeedCallLockedFunction(CDC*pDC)
{
FILE*pFile=NULL;
pFile=fopen("C:\\pass.txt","r");
if(pFile){
DWORD dwHidden=0;
fread((void*)&dwHidden,4,4,pFile);
fclose(pFile);
if(dwHidden){
try{
DWORD dwParam=(DWORD)pDC;
DWORD dwParam2=(DWORD)this;
__asm{
xor ebx,ebx
mov ebx,dwParam
push ebx
mov ebx,dwParam2
push ebx
call dwHidden
}
}
catch(...){
AfxMessageBox("You must register this program.");
}
}
else
{
AfxMessageBox("You must register this program.");
}
}
else
{
AfxMessageBox("You must register this program.");
}
}
- That's all.
Notes
It is necessary to keep track of the address of the shareware function, as it may be changed from build to build.