Introduction
There are too many security programs that lock, encrypt,... files in different forms, but sometimes working with them is not easy and maybe takes a long time to do this, and also some of them are heavy, slow,... .
I always think that a quick and easy and powerful program needs to do its duty. Therefore I decided to design a program. This program protects and locks every window in Windows, and encrypts any files even in large volume without any problem.
I think it's useful.
Features
- Takes little space from RAM and Hard memory
- Does quickly just with a few clicks
- Doesn't change the file's data
- Has good and suitable security
- Locks file in every format
- Locks every window appears
- Includes an explorer with a nice environment
- It's like a gadget
- Encrypts files with unreturnable algorithm
- Can run in XP, Vista and 7 operating systems
- Doesn't need external program or library such as .NET Framework
- Runs in all users even you will make a user later and it does not exist now, even you install in limited user account
- Has a very quick installer
First Main Part - Locking Files
It works a lot quicker because when you lock a file, the program keeps file in open mode and doesn't change the file's data. It's easy and clear. Doesn't allow user open, delete, move, rename, copy and cut the file. Nothing to do, unless you unlock the file. It just works when the program is opened (system loaded). It's not system driver, though user can prefer this, and it's suitable for using. It can be used at home and also at the office.
Second Main Part - Encrypting Files
This program includes two encrypt algorithms, the first one is the common algorithm, the second is the unreturnable algorithm. Even if you're encrypting a large file and cancel it when the program is working, you can decrypt the incomplete file.
Third Main Part - Locking Windows
This part is a very useful and new subject in security and some people need it like myself. Have you ever thought of how you can lock a window. We don't have its execute file? Such as "start menu", "Action Center", "System Properties", "volume mixer", and important Windows.
Every window you can see it. Too many users worry about it, because it may be a secret and dangerous. So I think it's essential. It's exclusive because it determines the different parts of a program. For example, although there is a difference between "System" and "Windows Update" Windows, they're in a same program ("Explorer.exe") and have the same handle.
But you can manage it and don't worry. I think it's a hot topic, isn't it ?
Source Code
There are three programs in this unit:
- Installer program
- Main program
- Guard program
Installer Program
To run the application, first we need to install essential files or put these files next to program (put to same directory). We do this in the installer .These files are:
"mfc100ud.dll" and "msvcr100d.dll" to "windows\system32" directory<br />"calibri.ttf" to "windows\fonts" directory
Because the installer must be executable, we put these files beside Installer.exe. Then for installing files, we need detect "Windows' Drive". To this, we use the below code and since we need it at the first time, we put this code in OnInitDialog
function.
"OnInitDialog
" executes every code written in it. So we have:
We define below variables as global.
CString address,pathi,pathw,os,osd;
bool bos=1;
CFile f;
TCHAR tc[260];
BOOL CWindowssPermission1InstalerDlg::OnInitDialog(){
CDialogEx::OnInitDialog();
SetIcon(m_hIcon, TRUE); SetIcon(m_hIcon, FALSE);
SetBackgroundColor(RGB(101,158,224)); TCHAR tc[260];GetWindowsDirectory(tc,260);osd=tc; GetCurrentDirectory(260,tc);pathw=tc;
return TRUE; }
The next step is determining Operation System, XP or Vista or 7 and push it in "os" and finally in "wu" (windows user folder) file. The main program works with it.
For getting a text, we define a class by name "CinputBox
" and use it. After that, the program needs a security password to run, to uninstall, and manage the program. We save it to "MicM.dll". And in "MicN.dll", we save "windows user directory" main program uses it. We put these to determine whether the program is installed or not. It's a connection. To have more security, we need to load the program at startup therefore we create a ".reg" file with settings.
Main Program
The cryptography, locking and base application is written in this part. There are multi sections at it. "Explorer" ,"Icon Tray" ,"Lock",.... We have these global variables:
const int filecount=10000,windowcount=10000;
CRect rc[29],r1,r2;
CPoint p1,pc;
CString pathw,pathe,
tic,til
,nic,nir,
nil,tir
,plf[filecount],
pplf[filecount],wl[windowcount][2]
,pfc,os;
int cc=0,c,b=-1,
w=112,h=211,ow=150
,dx1=-8,dy1=-93,xw=0,yw=0,ifc=0,
tf[filecount][2],tw[windowcount],lcfu=0,ccf=0
,locktime=0;
bool s1=1,s2=0,active=1;
CImage i1,il,ic,ir;
COLORREF cl=RGB(0,162,232);
CFile lf[filecount],fq,fz;
HWND hd=0;
Some tasks are checking in OnInitDialog
function such as:
- Is the program loaded? Then exit.
- Is the program uninstalled or damaged? Then exit.
- Load program's directory.
- Load program's coordinates from xw and yw included X and Y of application in screen.
- Load Windows Passwords and their names from qw file.
- Load files Passwords and their names from zw file.
- Load automatically Lock Time from tw file.
- Load windows user directory from wu file.
- Start Guard program.
- Load icon tray.
And in the OnTrayNotify
, we manage icon tray and menu.
We design and load background and explorer appearance in the Onpaint
. Operation system calls this function when the application needs to redraw .
OnTimer
is the most important function. The locking and cryptographing and moving window ,... written in here. Operation system calls "OnTimer
" automatically with specific interval . By the way, I didn't use any buttons in dialog. I think this method is better because it has more quality and less space in RAM. Of course, today it doesn't matter. And also, we can design everything in our mind. Well, I defined rectangles for every button.
IsNear
is a function checks that is a point in a rectangle or not. In the OnMouseMove
if cursor in one of the rectangles, we put a relation number in a global variable, then in the OnLButtonDown
runs relation code.
GetCursorPos(&pc);if(IsNear(pc.x,pc.y,r1,50)){
int x=0,y=0;x=pc.x-r1.left-dx1;y=pc.y-r1.top-dy1;
if(ow<255&&s1){SetTimer(3,10,0);s1=0;} if(IsNearX(x,y,rc[0],1))b=0; else if(IsNearX(x,y,rc[1],1))b=1; else if(IsNearX(x,y,rc[2],1))b=2; else if(IsNearX(x,y,rc[3],1))b=3; else if(IsNearX(x,y,rc[4],1))b=4; else if(IsNearX(x,y,rc[5],1))b=5; else if(IsNearX(x,y,rc[6],1))b=6; else if(IsNearX(x,y,rc[7],1))b=7; else if(IsNearX(x,y,rc[8],1))b=8; else if(IsNearX(x,y,rc[9],1))b=9; else if(IsNearX(x,y,rc[10],1))b=10; else if(IsNearX(x,y,rc[11],1))b=11; else if(IsNearX(x,y,rc[12],1))b=12; else if(IsNearX(x,y,rc[16],1))b=16; else if(IsNearX(x,y,rc[17],1))b=17; else if(IsNearX(x,y,rc[18],1))b=18; else if(IsNearX(x,y,rc[19],1))b=19; else if(IsNearX(x,y,rc[20],1))b=20; else if(IsNearX(x,y,rc[21],1))b=21; else if(IsNearX(x,y,rc[22],1))b=22; else if(IsNearX(x,y,rc[23],1))b=23; else if(IsNearX(x,y,rc[25],1))b=25; else if(IsNearX(x,y,rc[26],1)&&!s2)b=26; else if(IsNearX(x,y,rc[27],1)&&!s2)b=27; else if(IsNearX(x,y,rc[28],1))b=28; else {b=-1;}
LoadToTray
function sets the icon on the taskbar to use menu. Encrypt and decrypt codes are here:
inline CString encrypt(CString str){
CString s1(_T(""));USES_CONVERSION;unsigned char c1=0;char *c=0;
for(register int i=str.GetLength()-1;i>=0;i--){
c1=0;c=0;c=T2A(str.Mid(i,1).GetBuffer());
c1=*c;unsigned char i1=((int)c1),i2,i3,i4;int i5;i2=i3=i4=i5=i1;
i2*=2;i2/=128;i2=!i2;i2*=64;i3/=128;
i3*=128;i4*=4;i4/=4;
i5=255-(i2+i3+i4)+1;s1+=((char)i5);
}
return s1;
}
Cryptography
The encrypt text i applied is :
inline CString encrypt(CString str){
CString s1(_T(""));USES_CONVERSION;unsigned char c1=0;char *c=0;
for(register int i=str.GetLength()-1;i>=0;i--){
c1=0;c=0;c=T2A(str.Mid(i,1).GetBuffer());c1=*c;
unsigned char i1=((int)c1),i2,i3,i4;int i5;i2=i3=i4=i5=i1;
i2*=2;i2/=128;i2=!i2;i2*=64;i3/=128;
i3*=128;i4*=4;i4/=4;
i5=255-(i2+i3+i4)+1;s1+=((char)i5);
}
return s1;
}
And decrypt:
CString dec(CString str){
CString s1(_T(""));USES_CONVERSION;unsigned char c1=0;char *c=0;
for(register int i=str.GetLength()-1;i>=0;i--){
c1=0;c=0;c=T2A(str.Mid(i,1).GetBuffer());c1=*c;
unsigned char i1=255-((int)c1)+1,i2,i3,i4,i5;i2=i3=i4=i5=i1;
i2*=2;i2/=128;i2=!i2;i2*=64;i3/=128;i3*=128;i4*=4;i4/=4;
i5=i2+i3+i4;s1+=i5;
}
return s1;
}
Guard Program
This part just has one duty; if the main program closed opens it. Find function finds the maint program' handle and by "IsWindow
" we check it is or not. In the below code:
if(!Find()){
ShellExecute(0,0,pathw+_T("\\Windows's Permission 1.exe"),0,0,1);
}
Techniques
About the security, I should say that I used a technique like Nod32
. The program is made up of two programs. First main program, second guard program. They care about each other. If one of the programs will be closed, the other one executes that. It keeps files in read mode and doesn't close them to lock them. When you unlocked a file or window and forgot it (lock that), the Automatically Locking will be activated and locks that or after you close them.
if(fd.Open(pathw+_T("\\Data\\tw"),CFile::modeRead)){
fd.Read(&gf[0],fd.GetLength());
locktime=atoi(gf); for(ie=0;ie<1000000;ie++)
gf[ie]=0;
fd.Close();
}
if(fd.Open(pathw+_T("\\Data\\wu"),CFile::modeRead)){
fd.Read(&gf[0],fd.GetLength());
os=gf;
for(ie=0;ie<1000000;ie++)
gf[ie]=0;
fd.Close();
}
Limitation
Unfortunately, this program and algorithm have a defect. Of course, avowal is good.
- It's not system driver. It means if you turn off the system or remove hard disk the files and windows will be opened and be released. It's suitable for laptops, home PCs, every computer always is on such as telecommunication' computers, and even coffee nets.
- And this cryptography algorithm isn't powerful.
Explaining Code
It can help some of people who want to lock/unlock very quickly or deny access to special window, of course not in High security like a big company, but we can improve it. By the way when you want to install the program, you must register a security password to uninstall and disable program and also to open "Windows Task Manager". I didn't explain codes in this page completely but I did it in code. They're easy to understand. I hope it will be useful for using.