include ..\..\Inc&Lib\apimacro.mac
include ..\..\Inc&Lib.inc
INCLUDELIB ..\..\Inc&Lib\iKERNEL32.lib
INCLUDELIB ..\..\Inc&Lib\iUSER32.lib
;there are defined include file and library for SVKP's special functions
include ..\..\Inc&Lib\special.inc
INCLUDELIB ..\..&Lib\ispecial.lib
.DATA?
registration_information db 255 dup (?) ;buffer for registration information
.DATA
capture db "API functions example.",0
message db "Now I will try some API functions",0
registered db "Registration data from key:",0
unregistered db "Unregistered version!",0
unregistered_user db "Please register to www...",0
;now we will check for debuggers
iWin32 SVKP_KillDebugger
;then we will lock keyboard
iWin32 SVKP_LockKeyboard
;now we will read registration information
iWin32 SVKP_GetRegistrationInformation, offset registration_information
test eax, eax
jz jmp_unregistered_user ;if there is not registration key, jump
jmp_unregistered_user:
;if you want to do special action for unregistered version, You can do it there.
push 0
push offset unregistered
push offset unregistered_user
push 0
iWin32 MessageBoxA
;end of part for non registered users
skip_unregistered_part:
back_to_win:
;now we will unlock keyboard
iWin32 SVKP_UnLockKeyboard
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
char *message = "SVKP's API functions example!";
char* registration_information=(char*)malloc(255*sizeof(char));
int flag;
MessageBox(0,message,"",0);
SVKP_KillDebugger(); // now we will check for debuggers
SVKP_LockKeyboard(); // then we will lock keyboard
// if was registered flag=1
if(flag = SVKP_GetRegistrationInformation(registration_information)==0) {
// This is part for unregistered users
message = "Unregistered version!";
MessageBox(0,message,"",0);
}
else {
message = "Registration data from key:";
MessageBox(0,registration_information,message,0);
}
SVKP_UnLockKeyboard(); // now we will unlock keyboard
return 0;
}
var
RegMessage : String;
registration_information : String;
procedure Start;
begin
try
registration_information := '';
SVKP_KillDebugger; // now we will check for debuggers
SVKP_LockKeyboard; // then we will lock keyboard
if SVKP_GetRegistrationInformation(registration_information)= 0 then
begin
// This is part for unregistered users
RegMessage := 'Unregistered version!';
MessageBox(0,PChar (RegMessage),'',0)
end
else
begin
// This is part for registered users
RegMessage := 'Registration data from key:';
MessageBox(0,PChar (registration_information),PChar (RegMessage),0);
end;
SVKP_UnLockKeyboard(); // now we will unlock keyboard
except
end;
end;
end.
VB:
Attribute VB_Name = "Module1"
Option Explicit
'There we declare SVKP's special functions'
Public Declare Function SVKP_GetRegistrationInformation Lib "SPECIAL.DLL" _
(ByVal reginfoptr As String) As Long
Public Declare Function SVKP_LockKeyboard Lib "SPECIAL.DLL" _
() As Long
Public Declare Function SVKP_UnLockKeyboard Lib "SPECIAL.DLL" _
() As Long
Public Declare Function SVKP_KillDebugger Lib "SPECIAL.DLL" _
() As Long
Sub Main()
Dim RegistrationInformation As String
Dim Flag As Boolean
'first we will lock keyboard'
SVKP_LockKeyboard
'now we will check for debuggers'
SVKP_KillDebugger
RegistrationInformation = String$(255, 0)
Flag = False
Flag = SVKP_GetRegistrationInformation(RegistrationInformation)
If Flag = True Then
MsgBox RegistrationInformation, vbInformation, "Registered Action!"
Else
MsgBox "Unregistered user!", vbInformation, "UnRegistered Action!"
End If
SVKP_ENCRYPTED_BLOCK_START ;start of encrypted block
;this code will encrypted and it will decrypted only if user have correct registration key
push 0
push offset special_capture
push offset special_message
push 0
iWin32 MessageBoxA ;display message box for registered users
jmp skip_text
special_capture db "Message for registered users!",0
special_message db "This message box will show only if you have registered version!",0
skip_text:
SVKP_ENCRYPTED_BLOCK_END ;end of encrypted block
;now we will read registration information
iWin32 SVKP_GetRegistrationInformation, offset registration_information
test eax, eax
jnz skip_unregistered_part ;if there is registration key, jump
;if you want to do special action for unregistered version, You can do it there.
push 0
push offset special_capture2
push offset special_message2
push 0
iWin32 MessageBoxA
;end of part for non registered users
SVKP_ENCRYPTED_BLOCK_END // End of encrypted block
// if was registered flag=1
if(flag = SVKP_GetRegistrationInformation(registration_information)==0) {
// This is part for unregistered users
message = "Unregistered version!";
MessageBox(0,message,"",0);
}
var
RegMessage : String;
// This procedure will encrypted and it will decrypted only if user have correctregistration key
procedure ActionForRegisteredUsers;
begin
{$I include\delphi_svkp_block_begin.inc}
RegMessage := 'Registered version!';
MessageBox(0,PChar (RegMessage),'',0);
{$I include\delphi_svkp_block_end.inc}
end;
procedure Start;
begin
try
RegMessage := 'Encryption blocks example';
MessageBox(0,PChar (RegMessage),'',0);
ActionForRegisteredUsers; // this procedure is only for registered users
SVKP_ENCRYPTED_FEATURE1_START ;start of feature 1
;this code will encrypted and it will decrypted only if user have correct registration key with this feature unlocked
push 0
push offset special_capture1
push offset special_message1
push 0
iWin32 MessageBoxA ;display message box for registered users
jmp skip_text
special_capture1 db "Message for registered users!",0
special_message1 db "Feature 1 is unlocked in license!",0
skip_text:
mov [feature1_unlocked_flag], 1 ;set flag, because feature is unlocked in license
SVKP_ENCRYPTED_FEATURE1_END ;end of feature 1
;display text for users with feature 1 not unlocked
push 0
push offset capture_feature1
push offset message_feature1
push 0
iWin32 MessageBoxA
skip_unregistered_feature1:
;now we will read registration information
iWin32 SVKP_GetRegistrationInformation, offset registration_information
test eax, eax
jnz skip_unregistered_part ;if there is registration key, jump
;if you want to do special action for unregistered version, You can do it there.
push 0
push offset special_capture2
push offset special_message2
push 0
iWin32 MessageBoxA
;end of part for non registered users
skip_unregistered_part:
;action for users with Feature 2 activated
SVKP_ENCRYPTED_FEATURE2_START
push 0
push offset special_capture3
push offset special_message3
push 0
iWin32 MessageBoxA ;display message box for registered users
jmp skip_text2
special_capture3 db "Message for registered users!",0
special_message3 db "Feature 2 is unlocked in license!",0
skip_text2:
SVKP_ENCRYPTED_FEATURE2_END
;is possible select more than one part of code for one feature
SVKP_ENCRYPTED_FEATURE1_START
push 0
push offset special_capture4
push offset special_message4
push 0
iWin32 MessageBoxA ;display message box for registered users
jmp skip_text3
special_capture4 db "Message for registered users!",0
special_message4 db "Feature 1 second part of code!",0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
char *message = "Features example!";
char* registration_information=(char*)malloc(255*sizeof(char));
int flag;
MessageBox(0,message,"Now I will try run some features!",0);
SVKP_ENCRYPTED_FEATURE1_START // Start of feature 1
// this code will encrypted and it will decrypted only if user have correct registration key with this feature unlocked
MessageBox(0,"Feature 1 is unlocked in license!","Message for registered users!",0); // display message box for registered users
SVKP_ENCRYPTED_FEATURE1_END // end of feature 1
// if was registered flag=1
if(flag = SVKP_GetRegistrationInformation(registration_information)==0) {
// This is part for unregistered users
message = "Unregistered version!";
MessageBox(0,message,"",0);
}
// action for users with Feature 2 activated
SVKP_ENCRYPTED_FEATURE2_START
MessageBox(0,"Feature 2 is unlocked in license!","Message for registered users!",0); // display message box for registered users
SVKP_ENCRYPTED_FEATURE2_END
// is possible select more than one part of code for one feature
SVKP_ENCRYPTED_FEATURE1_START
MessageBox(0,"Feature 1 second part of code!","Message for registered users!",0); //display message box for registered users
var
RegMessage : String;
procedure ActionForRegisteredUsers;
begin
// this code will encrypted and it will decrypted only if user have correct registration key with this feature unlocked
{$I include\delphi_svkp_block_feature1_begin.inc}
RegMessage := 'Feature 1 is unlocked in license!';
MessageBox(0,PChar (RegMessage),'Message for registered users!',0);
{$I include\delphi_svkp_block_feature1_end.inc}
// action for users with Feature 2 activated
$I include_svkp_block_feature2_begin.inc
RegMessage := 'Feature 2 is unlocked in license!';
MessageBox(0,PChar (RegMessage),'Message for registered users!',0);
{$I include\delphi_svkp_block_feature2_end.inc}
// is possible select more than one part of code for one feature
$I include_svkp_block_feature1_begin.inc
RegMessage := 'Feature 1 second part of code!';
MessageBox(0,PChar (RegMessage),'Message for registered users!',0);
{$I include\delphi_svkp_block_feature1_end.inc}
end;
procedure Start;
begin
try
RegMessage := 'Encryption blocks example';
MessageBox(0,PChar (RegMessage),'',0);
ActionForRegisteredUsers; //this procedure is only for registered users
使用SVK Protector可以快速和简单的为被保护的程序创建一个时间限制的试用版本.只要选
上"TimeLock"选项中的"Limited functional time of unregistered version of protected
program".然后选择时间限制的类型"执行次数"或者"天数".当然两个都可以选上."Number of
executions"选项是说未注册的版本可以使用多少次."Number of days"选项是说未注册的版本可以
使用多少天.
除此这外你也可以使用"Reminder message",是说被保护的程序在每次启动的时候都会显示
"This is a shareware version.Please register your copy.".
如果用户购买了被保护的程序并得到了正确的注册密钥,时间限制将被解除.
include ..\..\Inc&Lib\apimacro.mac
include ..\..\Inc&Lib\windows.inc
INCLUDELIB ..\..\Inc&Lib\iKERNEL32.lib
INCLUDELIB ..\..\Inc&Lib\iUSER32.lib
;there are defined include file and library for SVKP's special functions
include ..\..\Inc&Lib\special.inc
INCLUDELIB ..\..\Inc&Lib\ispecial.lib
.DATA?
registration_information db 255 dup (?) ;buffer for registration information
HWInformation dd 4 dup (?)
.DATA
special_message2 db "You can buy our product at www....",0dh,0dh
db "Please send us your Hardware ID:", 0dh, 0dh
hardware_key db 32 dup (?)
hardware_key_end db 0dh,0dh,0dh
db "Your Hardware ID was copied to clipboard, please paste it to e-mail!",0dh
db "Now try to create registration key for this project and Hardware ID in SVKP.",0
capture db "Encryption blocks example.",0
message db "Now I will try run encrypted block!",0
special_capture2 db "Message for unregistered users!",0
SVKP_ENCRYPTED_BLOCK_START ;start of encrypted block
;this code will encrypted and it will decrypted only if user have correct registration key
push 0
push offset special_capture
push offset special_message
push 0
iWin32 MessageBoxA ;display message box for registered users
jmp skip_text
special_capture db "Message for registered users!",0
special_message db "This message box will show only if you have registered version!",0
skip_text:
SVKP_ENCRYPTED_BLOCK_END ;end of encrypted block
;now we will read registration information
iWin32 SVKP_GetRegistrationInformation, offset registration_information
test eax, eax
jnz skip_unregistered_part ;if there is registration key, jump
;if you want to do special action for unregistered version, You can do it there.
lea esi, HWInformation
iWin32 SVKP_GetHWInfo, esi
; mov esi, edi
lea edi, hardware_key
lodsd
call HexWrite32
HexWrite32:
push eax
shr eax, 16
call HexWrite16
pop eax
call HexWrite16
ret
HexWrite16:
push ax
xchg al, ah
call HexWrite8
pop ax
call HexWrite8
ret
HexWrite8:
mov ah, al
and al, 0fh
shr ah, 4
or ax, 3030h
xchg al, ah
cmp ah, 39h
ja a4
a1:
cmp al, 39h
ja a3
a2:
stosw
ret
a3:
sub al, 30h
add al,'A' - 10
jmp a2
a4:
sub ah, 30h
add ah, 'A' - 10
jmp a1
endik:
}
}
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
char *message = "Encryption blocks example!";
char* registration_information=(char*)malloc(255*sizeof(char));
char* HWInformation=(char*)malloc(20*sizeof(char));
int flag;
char* unregister_message=(char*)malloc(255*sizeof(char));
char* hardware_key=(char*)malloc(35*sizeof(char));
char *first_message="You can buy our product at www....";
char *second_message="Please send us your Hardware ID:";
char *third_message="Your Hardware ID was copied to clipboard, please paste it to e-mail";
char *fourth_message="Now try to create registration key for this project and Hardware ID in SVKP.";
LPVOID allocated_memory;
LPVOID locked_mem;
MessageBox(0,message,"",0);
SVKP_ENCRYPTED_BLOCK_START // Start of encrypted block
// This code will encrypted and it will decrypted only if user have correct registration key
SVKP_ENCRYPTED_BLOCK_END // End of encrypted block
// if was registered flag=1
if(flag = SVKP_GetRegistrationInformation(registration_information)==0) {
// This is part for unregistered users
message = "Unregistered version!";
// Get Hardware ID
SVKP_GetHWInfo(HWInformation);
// Prepare message for display
TraslateToASCII(hardware_key,HWInformation);
TraslateToASCII(hardware_key+8,HWInformation+4);
TraslateToASCII(hardware_key+16,HWInformation+8);
TraslateToASCII(hardware_key+24,HWInformation+12);
hardware_key[32]=0x0d;
hardware_key[33]=0x0d;
hardware_key[34]=0x00;
unregister_message=first_message;
lstrcat(unregister_message,second_message);
lstrcat(unregister_message,hardware_key);
lstrcat(unregister_message,third_message);
lstrcat(unregister_message,fourth_message);
// copy Hardware ID to clipboard
hardware_key[32]=0x00;
allocated_memory=GlobalAlloc(0x2002, 0x32);
locked_mem=GlobalLock(allocated_memory);
lstrcpy((char*)locked_mem,hardware_key);
GlobalUnlock(allocated_memory);
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(1,allocated_memory);
CloseClipboard();
}
return 0;
}
Delphi:
function TraslateToHex(Buf:pchar; sz:integer):string;
var I:integer;
var D:integer;
var M:integer;
begin
result:='';
M:=0;
for I:=0 to sz-1 do
begin
M:=I*4;
for D:=3 downto 0 do result:=result+IntToHex(ord(Buf[D+M]),2);
end;
end;
procedure CopyToClipboard(const s:string);
var m:dword;
begin
m:=GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE,length(s)+1);
lstrcpy(GlobalLock(m),pchar(s));
GlobalUnlock(m);
OpenClipboard(0);
EmptyClipboard;
SetClipboardData(cf_text,m);
CloseClipboard;
end;
procedure Test;
var
hardware_key,unregistered_msg:string;
registration_info,HWInformation:array[0..255] of char;
begin
messagebox(0,'Encryption blocks example!','',0);
{$I .\include\delphi_svkp_block_begin.inc} // Start of encrypted block
// Code inside this block will be decrypted only for users with valid registration key
messagebox(0,'Registered version!','',0); // a message for registered users
// Add here an useful code available only for registered users...
{$I .\include\delphi_svkp_block_end.inc} //End of encrypted block
if SVKP_GetRegistrationInformation(registration_info)<>1 then begin
// This is part for unregistered users
SVKP_GetHWInfo(HWInformation); //Get Hardware ID
hardware_key:=TraslateToHex(HWInformation,4);
unregistered_msg:=
'You can buy our product at www...'#10#10+
'Please send us your Hardware ID:'#10+hardware_key+#10#10+
'Your Hardware ID was copied to clipboard, please paste it to e-mail'#10#10+
'Now try to create registration key for this project and Hardware ID in SVKP.';
messagebox(0,pchar(unregistered_msg),'Unregistered version!',0);
CopyToClipboard(hardware_key); //copy Hardware ID to clipboard
end;
end;
include ..\..\Inc&Lib\apimacro.mac
include ..\..\Inc&Lib\windows.inc
INCLUDELIB ..\..\Inc&Lib\iKERNEL32.lib
INCLUDELIB ..\..\Inc&Lib\iUSER32.lib
;there are defined include file and library for SVKP's special functions
include ..\..\Inc&Lib\special.inc
INCLUDELIB ..\..\Inc&Lib\special.lib
.DATA?
registration_information db 255 dup (?) ;buffer for registration information
.DATA
capture db "Encryption blocks example.",0
message db "Now I will try run encrypted block!",0
special_capture2 db "Message for unregistered users!",0
special_message2 db "You can buy our product at www....",0
.code
assume fs :flat
Start:
;int 3 ;only for debug version
;this code will decrypted before using and after use removed
;tip: This type of blocks is very good use in initialize part of program
;(load DLL(s), initialize data, fill some special variables and etc.)
SVKP_ENCRYPTED_BLOCK_TYPE2_START
push 0
push offset capture
push offset message
push 0
iWin32 MessageBoxA
SVKP_ENCRYPTED_BLOCK_TYPE2_END
SVKP_ENCRYPTED_BLOCK_START ;start of encrypted block RSA
;this code will encrypted and it will decrypted only if user have correct registration key
push 0
push offset special_capture
push offset special_message
push 0
iWin32 MessageBoxA ;display message box for registered users
jmp skip_text
special_capture db "Message for registered users!",0
special_message db "This message box will show only if you have registered version!",0
skip_text:
SVKP_ENCRYPTED_BLOCK_END ;end of encrypted block
;This code will decrypted before using and encrypted again after use
SVKP_ENCRYPTED_BLOCK_TYPE1_START
;now we will read registration information
iWin32 SVKP_GetRegistrationInformation, offset registration_information
test eax, eax
jnz skip_unregistered_part ;if there is registration key, jump
;if you want to do special action for unregistered version, You can do it there.
push 0
push offset special_capture2
push offset special_message2
push 0
iWin32 MessageBoxA
;end of part for non registered users
skip_unregistered_part:
SVKP_ENCRYPTED_BLOCK_TYPE1_END
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
char *message = "Encryption blocks example!";
char* registration_information=(char*)malloc(255*sizeof(char));
int flag;
// this code will decrypted before using and after use removed
// tip: This type of blocks is very good use in initialize part of program
// (load DLL(s), initialize data, fill some special variables and etc.)
SVKP_ENCRYPTED_BLOCK_TYPE2_START
MessageBox(0,message,"",0);
SVKP_ENCRYPTED_BLOCK_TYPE2_END
SVKP_ENCRYPTED_BLOCK_START // Start of encrypted block
// This code will encrypted and it will decrypted only if user have correct registration key
message = "Registered version!";
MessageBox(0,message,"",0); // display message box for registered users
SVKP_ENCRYPTED_BLOCK_END // End of encrypted block
// This code will decrypted before using and encrypted again after use
SVKP_ENCRYPTED_BLOCK_TYPE1_START
// if was registered flag=1
if(flag = SVKP_GetRegistrationInformation(registration_information)==0) {
// This is part for unregistered users
message = "Unregistered version!";
MessageBox(0,message,"",0);
}
SVKP_ENCRYPTED_BLOCK_TYPE1_END
var
RegMessage : String;
// This procedure will encrypted and it will decrypted only if user have correct registration key
procedure ActionForRegisteredUsers;
begin
{$I include\delphi_svkp_block_begin.inc}
RegMessage := 'Registered version!';
MessageBox(0,PChar (RegMessage),'',0);
{$I include\delphi_svkp_block_end.inc}
end;
procedure Start;
begin
try
// this code will decrypted before using and after use removed
// tip: This type of blocks is very good use in initialize part of program
// (load DLL(s), initialize data, fill some special variables and etc.)
{$I include\delphi_svkp_block_type2_begin.inc}
RegMessage := 'Encryption blocks example';
{$I include\delphi_svkp_block_type2_end.inc}
// This code will decrypted before using and encrypted again after use
{$I include\delphi_svkp_block_type1_begin.inc}
MessageBox(0,PChar (RegMessage),'',0);
ActionForRegisteredUsers; //this procedure is only for registered users
{$I include\delphi_svkp_block_type1_end.inc}
except
end;
end;
end