This example shows how to hide Colock library
(CLK.DLL) inside protected executable file and load it later at run-time.
1) Create a resource script file (*.RC) with a simple text editor like Notepad
and add the following line:
CLKDLL DLL CLK.dll
2) Use Borland's Resource Compiler, BRCC32.EXE, to compile it into a .RES file
(BRCC32.EXE is located in "C:\Program Files\Borland\Delphi7\Bin" folder, this
can be different based on your
Borland Delphi installation directory).
Write at the MS-DOS command line:
BRCC32 HiddenDLL.rc
This will create a resource file called HiddenDLL.RES.
3) Add a compiler directive to the source code of your program. It should
immediately follow the form directive,
as shown here:
{$R *.DFM}
{$R HiddenDLL.RES}
4) Extract and load CLK.DLL at run-time (for example at OnCreate event of main
form)
5) Set main form properties
6) Add first button and set its properties
7) Add second button and set its properties
8) Set OnClick event of first button to call cCheckLock function
9) Set OnClick event of second button to call ShowLockWindow function
10) Finally, on the form close event, free extracted Colock library and delete
it
Notes for better protection:
* CLK.DLL can be encrypted before attaching to the EXE file and later, at
run-time, can be decrypted before loading.
* By using GetFileID function before attaching Clk.DLL to the exe and after
loading into the memory, we can ensure
that CLK.DLL is an original one with no change.
* Use PAnsiChar instead of PChar in Delphi 2007 and 2009 for Colock library
functions and typecasts.