Home Tools

How to create Antivirus using C++ programming language

This project is developed based on the console user interface (CUI). It has own scanning algorithm for finding malicious code in each file during the scan. The core idea is to search/match the virus signatures in all scan files or directory. Usually, 90% of viruses/worm having own signature (Some repeat text founded in all affected binary files or archive files) and remain 10% Viruses are identified based on execution behavior. Here I wrote code for signature-based scan algorithm, so I stored Virus signatures in separate databases and it organizes in file flat system format.Antivirus Tool execution starts from below script.
little17.cpp
1#include<iostream.h>
2#include<conio.h>
3#include<process.h>
4#include<dir.h>
5#include<dirent.h>
6#include<alloc.h>
7#include<io.h>
8
9FILE *dp;
10unsigned char ch;
11struct ffblk dfile;
12int i,j=0,k=0,total,mode=0;
13char *sign = (char *) malloc(9);
14char *drive = (char *) malloc(27);
15char *drivefound= (char *) malloc(27);
16
17void scan();
18void info();
19void dump(char *);
20
21void main(int a,char *arg[],char *env[])
22{    
23	if(access"cscan.exe",0!=0)
24	{  
25	    free(drive); 
26	    free(drivefound);  
27		exit(0);
28	}
29	
30	if(access"hscan.exe",0!=0)
31	{  
32	    free(drive); 
33	    free(drivefound);  
34		exit(0);
35	}
36	char *dirlist = (char *) malloc(53);
37	
38    i = findfirst("*.db",&dfile,0);                  
39    while (!i)                                        
40    { 
41		dp = fopen(dfile.ff_name,"rb");  
42        fread(sign,8,1,dp); 
43        if(!strcmpsign,"LITTLE17")
44	    {  
45			j=1;
46			fclose(dp);
47		    break;
48		}
49		else
50	    fclose(dp);
51	    i=findnext(&dfile);
52	}
53	
54	if(j!=1)
55	{ 
56		cout<<"\nError : Supporting database not found"; 
57	    free(drive); free(drivefound);
58		getch();
59        exit(0);  			
60	}
61		
62	scan();
63	while(1)
64    {	
65	    while(1)
66		{	        
67				cout<<"\nSystem: Drive Found\n\n\n";
68                for(i=0;i<total;i++)
69                cout<<drivefound[i]<<":   ";
70				
71				while(1)
72                {
73                    cout<<"\n\nPress  1-Cool Mode &  2-Hot Mode";
74		            cout<<"\n\nEnter your mode:";
75                    ch=getche(); 		
76                    if(ch==49)
77                    { mode=49; break; }
78                    else if(ch==50)
79                    { mode=50; break; }
80                    else
81                    {
82                        clrscr();
83			            cout<<"\nWarning: Sorry your mode is invalid";
84                        cout<<"\nWarning: Please select right mode\n";
85                        cout<<"\nSystem: Drive Found\n\n\n";
86                        for(i=0;i<total;i++)
87                        cout<<drivefound[i]<<":   ";						
88                    }  		
89                }    	
90				
91                cout<<"\n\nEnter drive to scan:";
92                cin>>dirlist;
93                j=strlen(dirlist);
94				dump(dirlist);
95            
96			    if(j==5 && !strcmpdirlist,"RESET")
97		        scan();
98		        
99				else if(j==3 && !strcmpdirlist,"ALL")
100			    {
101			        char *passdata = (char *) malloc(13); 
102				    strcpy(passdata,"XYVRGRASEWXC");
103				    for(j=0;j<total;j++)
104			        {
105					    *(passdata+0)=drivefound[j];
106				        arg[1]=passdata;
107				        if(mode==49)
108					    spawnve(P_WAIT,"CSCAN.EXE",arg,env);
109					    if(mode==50)
110					    spawnve(P_WAIT,"HSCAN.EXE",arg,env);
111				    }       
112			        free(passdata); 
113			    }
114			    
115				else if(j==4 && !strcmpdirlist,"EXIT")
116                { 
117				    free(drive); 
118					free(drivefound);  
119					free(dirlist);  
120					exit(0); 
121				} 	
122		        else
123		        break;
124		}
125        
126		if(j%2!=0)
127        {
128			for(i=1;i<j;i=i+2)
129            {
130		        if (dirlist[i]!='\,') 
131		        break;
132            }
133
134		    if(i>=j)
135            {
136                k=strlen(dirlist);
137                char *passdata = (char *) malloc(13); 
138				strcpy(passdata,"XYVRGRASEWXC");
139				for(j=0;j<k;j=j+2)
140				{
141					*(passdata+0)=dirlist[j];
142				    arg[1]=passdata;
143				    if(mode==49)
144					spawnve(P_WAIT,"CSCAN.EXE",arg,env);
145					if(mode==50)
146					spawnve(P_WAIT,"HSCAN.EXE",arg,env);
147				}
148				free(passdata);
149		    }
150            else
151			{   clrscr();
152			    cout<<"\nWarning: Comma missing between drives"; 
153			    cout<<"\nEg: C,F,G - Valid"; 
154				cout<<"\nEg: CFG  - Invalid\n";
155				info();
156			}
157		} 
158        else
159        { 
160		    clrscr();
161			cout<<"\nWarning: Command should be odd size"; 
162			cout<<"\nEg: C,F,G - Valid"; 
163			cout<<"\nEg: C,FG  - Invalid\n";
164			info();		
165		}
166        clrscr();
167	}    
168}
169
170void scan()
171{ 
172    j=0;
173	char dir[]="VOL X:";
174	clrscr();
175	cout<<"\nSystem: Welcome to Little17 Antivirus";
176    for(i=0;i<=25;i++)
177    {
178        strcpy(drive,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
179		dir[4]=drive[i];
180        ch=system(dir);
181        clrscr();
182        if(ch==0)
183        { 
184		    drivefound[j]=drive[i];  
185		    j++; 
186		}      
187        drivefound[j]='\0';
188	}
189    total=j;
190}
191
192void info()
193{
194cout<<"\n\nInformation:\n";
195cout<<"\n1.Hello user i give information to use this software";
196cout<<"\n2.Suppose you want to scan particular drive"; 
197cout<<"\n  Eg: type  \" C,D,W,I \" ";
198cout<<"\n3.If you scan all drive type \" ALL \" ";
199cout<<"\n4.Want to close type \" EXIT \" ";
200getch();
201}
202
203void dump(char *dump)
204{
205    for(i=0;i<j;i++)
206	{
207	    if( dump[i]!='\,' && dump[i]>=97 && dump[i]<=122 )
208	    dump[i]=dump[i]-32;
209	}  
210}
Please find below script which uses to upload new virus signature which not already exist in databases.
updater.cpp
1#include<iostream.h>
2#include<conio.h>
3#include<string.h>
4#include<process.h>
5#include<io.h>
6#include<alloc.h>
7#include<dir.h>
8#include<ctype.h>
9
10struct ffblk dblist,list;
11FILE *temp_p,*dp,*vp;
12char *sign =  (char *) malloc(9);
13
14char ch;
15unsigned int count,first=0,found=0;
16unsigned long int start,udata1,udata2,udata3;
17
18void set_virus_name(char *);
19void update_signature(char *,char *,int,int);
20void set_data(char *,char *,int);
21
22void main()
23{
24	clrscr();
25	char *vfile = (char *) malloc(40);
26	char *dfile = (char *) malloc(40);
27	cout<<"\nSystem: Enter the infected filename: ";
28	cin>>vfile;
29	
30	if(accessvfile,0!=0)
31	{  
32		cout<<"\nError : File not exist"; 
33		free(sign);  
34		free(vfile); 
35		free(dfile); 
36		getch(); 
37		exit(0); 
38	}
39	strcpy(sign,"LITTLE17"); 
40
41	udata1 = findfirst("*.db",&dblist,0);
42	while (!udata1)
43	{   
44		first=1;
45		temp_p= fopen(dblist.ff_name,"r");  
46		fread(sign,8,1,temp_p); 
47		if(!strcmpsign,"LITTLE17");
48		update_signature(vfile,dblist.ff_name,1,0);  
49		fclose(temp_p);
50		udata1=findnext(&dblist);
51	}
52			
53	if(first==0)
54	{
55		cout<<"\nSystem: Enter the database name :";
56		cin>>dfile;
57		udata1=strlen(dfile);
58		if(dfile[udata1-3]=='\.'&& dfile[udata1-2]=='D'||dfile[udata1-2]=='d' &&  dfile[udata1-1]=='B'||dfile[udata1-1]=='b' )      
59		update_signature(vfile,dfile,0,1); 
60		else
61		{ 
62			cout<<"\n\nError : Create .DB extension file type"; 
63			free(sign); 
64			free(vfile); 
65			free(dfile); 
66			getch(); 
67			exit(0);  
68		} 
69	}
70	else
71	{
72		if(found==0)  
73		{   
74			cout<<"\nSystem: Enter the database name :";
75			cin>>dfile;
76			udata1=strlen(dfile);
77			if(dfile[udata1-3]=='\.'&& dfile[udata1-2]=='D'||dfile[udata1-2]=='d' &&  dfile[udata1-1]=='B'||dfile[udata1-1]=='b' )
78			{
79				if(!accessdfile,0)
80				{   
81					dp = fopen(dfile,"r");  
82					fread(sign,8,1,dp); 
83					fclose(dp);
84					if(!strcmpsign,"LITTLE17")
85					update_signature(vfile,dfile,1,1); 
86					else
87					{ 
88						cout<<"\n\nError : Database not supported with "<<vfile;  
89						free(sign); 
90						free(vfile); 
91						free(dfile); 
92						exit(0);  
93					}  
94				
95				}
96				else
97				update_signature(vfile,dfile,0,1); 
98			}
99			else
100			{   
101				cout<<"\n\nError: Create .DB extension file type"; 
102				free(sign);  
103				free(vfile); 
104				free(dfile); 
105				exit(0); 
106			}  
107		
108		}
109	} 
110	free(sign);
111	free(vfile); 
112	free(dfile); 
113	getch();
114}
115
116void update_signature(char *vfile,char *dfile,int check,int add)
117{		
118	if(check==1)
119	{	
120		char *temp = (char *) malloc(strlendfile+1);
121		strcpy(temp,dfile);
122		char *turn = (char *) malloc(40+2+400+1); 	
123		
124		dp = fopen(dfile,"r");
125		fread(sign,8,1,dp);	
126		fread(&start,sizeofstart,1,dp);
127		while(1)
128		{  
129			udata1=0;     
130			while(1)
131			{
132				ch=fgetc(dp);
133				if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t')
134				{
135					if(ch==20)
136					udata2=udata1;
137					if(ch!=22)  				
138					{   
139						turn[udata1]=ch; 
140						udata1=udata1+1;
141						continue; 
142					}
143					else
144					break;
145				}
146			}  
147			turn[udata1]='\0';
148			udata2=udata2+1;
149			udata3=udata2;
150			
151			count=0;
152			udata1=0; 
153			udata2=udata3;
154			vp=fopen(vfile,"r");
155			findfirst(vfile,&list,0);
156			while(udata1<list.ff_fsize)
157			{
158				
159				fseek(vp,udata1,SEEK_SET);
160				ch=fgetc(vp);
161				if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t' && ch!= 20 && ch!= 22)
162				{
163					if(ch!=turn[udata2])
164					{   
165						if(count>=2)
166						udata1=udata1-count;
167						count=0;
168						udata2=udata3;
169					}
170					else
171					{   
172						count=count+1;
173						udata2=udata2+1;
174						if(turn[udata2]==0)
175						{   
176							
177							cout<<"\n\n\nError : Unsuccessfully ! ";
178							cout<<"\n\nError : Virus were Already added on "<<temp;  
179							cout<<"  [ ";
180							udata3--;
181							for(count=0;count<udata3;count++)
182							{
183								if(turn[count]!=32)
184								cout<<turn[count];
185								else
186								cout<<" ";									
187							}
188							cout<<" ]";
189							found=1; 
190							break; 
191						}	        
192					}
193				}					
194				fflush(vp);
195				udata1=udata1+1;
196				
197			}
198			fclose(vp);
199			
200			if(found==1)
201			break;
202			ch=fread(&start,sizeofstart,1,dp);
203			if(ch+1==1)
204			break;
205		}
206		fclose(dp);
207		free(temp);
208		free(turn);
209		
210		if(found==0&&add==1)
211		{
212			set_data(vfile,dfile,check);   
213		}					
214	}
215	else
216	{       
217		set_data(vfile,dfile,check);    
218	}						
219}
220
221                            
222void set_data(char *vfile,char *dfile,int check)
223{
224	char *temp = (char *) malloc(40);
225	cout<<"\n\nSystem: Set the name of virus :";
226	gets(temp);
227	cout<<"\nEnter first index :";
228	cin>>udata1;
229	start=udata1;
230	cout<<"\nEnter last  index :";
231	cin>>udata2;
232	char *vdata = (char *) malloc(udata2-udata1+2+2+2+1); 
233	vdata[0]=20;
234	udata3=1;
235	
236	vp=fopen(vfile,"r");
237	while(udata1<=udata2)
238	{   
239		fseek(vp,udata1,SEEK_SET);
240		ch=getc(vp);
241		cout<<udata1<<" "<<ch<<"\n";
242		if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t' && ch!=20 && ch!=22)
243		{
244			vdata[udata3]=ch;
245			udata3=udata3+1; 	
246			vdata[udata3]='\0'; 			
247		}
248		udata1=udata1+1;
249	}
250	fclose(vp);
251	vdata[udata3+1]='\0';
252	vdata[udata3]=22;
253	
254	dp=fopen(dfile,"a+"); 
255	if(check==0)
256	fwrite(sign,8,1,dp);
257	fwrite(&start,sizeofstart,1,dp);
258	fwrite(temp,strlentemp,1,dp);
259	free(temp);
260	fwrite(vdata,strlenvdata,1,dp);
261	free(vdata);
262	fclose(dp);
263	cout<<"\n\nSystem: Successfully Added on "<<dfile;
264}
This below source code search the virus signature in a specified location in victim files.
cscan.cpp
1#include<iostream.h>
2#include<conio.h>
3#include<dirent.h>
4#include<dir.h>
5#include<process.h>
6#include<string.h>
7#include<stdio.h>
8#include<io.h>
9#include<dos.h>
10#include<sys/stat.h>
11
12FILE *dp,*vp;
13unsigned int count;
14struct ffblk dfile;
15struct ffblk vfile;
16char base,ch,found=0;
17char present[MAXPATH];
18char *sign =  (char *) malloc(9);
19unsigned long int start,udata1,udata2,udata3;
20
21int next_directory(char *);
22void scan_directory(char *);
23void dump(char *);
24
25
26void main(int account,char *arg[],char *env[])
27{   
28    if( account==2 && !strcmparg[1]+1,"YVRGRASEWXC" )    
29	{	
30		DIR *dir; 
31		struct dirent *temp;  
32		for(found=0;found<32;found++)
33		{
34		    if(env[found][0]=='S' && env[found][1]=='y' && env[found][12]!=':')
35			break;			
36		}
37		
38		clrscr(); 
39	    base=env[found][12];
40	    found=0;
41		
42		getcwd(present,MAXPATH);
43		char drive[]="X:\\";
44        drive[0]=*(arg[1]+0);
45		if (dir = opendirdrive == NULL)
46        { 
47		    cout<<"\nError : Device not found";  
48		    free(sign);
49			sleep(2);
50		    exit(0); 
51		}
52        
53		scan_directory(drive);
54        while (temp = readdirdir != NULL)
55        {
56            char  *directory = (char *) malloc(3+strlentemp->d_name+1);
57		    strcpy(directory,drive);
58            strcat(directory,temp->d_name);
59            next_directory(directory);
60            free(directory);
61        }
62		free(sign);
63		closedir(dir);
64		clrscr();
65	}	
66}
67
68int next_directory(char *path)
69{
70    int count=0;
71    DIR *dirtemp; 
72    char *hold,*temp;
73    struct dirent *ptemp;  
74        
75    hold=path;
76    if (dirtemp = opendirpath != NULL)
77    scan_directory(path);
78    else
79    return 0;
80       
81    while (ptemp = readdirdirtemp != NULL)
82    {     
83        char *directory = (char *) malloc(1+strlenptemp->d_name+1);
84		directory[0]='\\';
85	    strcpy(directory+1,ptemp->d_name);
86		if(directory[1]!='\.')
87	    {	            
88			count=strlen(hold);
89	        temp = (char *) malloc(strlenhold+strlendirectory+1);
90            strcpy(temp,hold);
91            strcat(temp,directory);
92            free(directory);
93			if(opendirtemp!=NULL)
94			next_directory(temp); 
95            temp[count]='\0'; 
96            hold=temp;
97        }
98        else
99	    free(directory);
100    }
101    closedir(dirtemp);
102    return 0;
103}
104
105void scan_directory(char *tempo)
106{
107    char *dbsign = (char *) malloc(40+2+400+1); 		
108	udata1 = findfirst("*.db",&dfile,0x02);
109    while (!udata1)
110    {            
111			dp = fopen(dfile.ff_name,"r");
112            fread(sign,8,1,dp);
113			if(strcmpsign,"LITTLE17"==0)
114			{
115		        fread(&start,sizeofstart,1,dp);  
116	            while(1)
117                {
118		            udata1=0;     
119	                while(1)
120				    {    
121					    ch=fgetc(dp);
122	                    if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t')
123	                    {
124		                    if(ch==20)
125		                    udata2=udata1;
126		                    if(ch!=22)  				
127		                    {   
128                                dbsign[udata1]=ch;
129                                udata1=udata1+1;
130  			                    dbsign[udata1]='\0';
131			                    continue; 
132		                    }
133		                    else
134		                    break;
135                        }
136	                }    
137			        udata2=udata2+1;  
138			        udata3=udata2;
139				
140				    if(present[0]==tempo[0])
141		            chdir(tempo);  
142	                else
143		            {
144		                setdisk(tempo[0]-65);
145	                    chdir(tempo); 
146		            }
147		
148		            udata1 = findfirst("*.*",&vfile,0x02);
149		            while (!udata1)
150                    {  
151	                    clrscr();
152					    cout<<"\nNow scanning:"<<vfile.ff_name;
153					    cout<<"\nLocation     "<<tempo;
154					
155					    vp=fopen(vfile.ff_name,"r");
156					    udata1=start+(strlendbsign)-udata1;
157					    if( vp!=NULL && !accessvfile.ff_name,4 && udata1<vfile.ff_fsize )
158					    {
159					        udata1=start;
160						    udata2=udata3;
161					 	    while(udata1 < vfile.ff_fsize)
162                            {   
163		                        if(fseekvp,udata1,SEEK_SET!=0)
164							    break;
165				                ch=getc(vp);
166	                            if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t' && ch!=20 && ch!=22)
167		                        {
168		                            if(ch==dbsign[udata2])     
169					                {
170						                udata2=udata2+1;
171						                if(dbsign[udata2]==0)
172                                        {
173                                            found=1; 
174								            break;  
175							            }							
176						            }
177						            else
178						            break;
179						        }
180	                            udata1=udata1+1;
181	                        }
182						
183						    if(found==1)
184						    {
185						        cout<<"\n\n"<<tempo; 
186					            cout<<"\nFile: "<<vfile.ff_name<<"    ";
187						        for(udata1=0;1;udata1++)					                
188							    {
189							        if(dbsign[udata1]!=20)
190                                    cout<<dbsign[udata1];
191							        else
192							        break;										
193						        }
194							    cout<<" Virus found.\n";
195                                fflush(vp);
196			                    fclose(vp); 
197							    found=0;
198							}
199						    else
200						    fclose(vp);
201						}
202				        else
203				        fclose(vp);	    
204						udata1=findnext(&vfile);
205		            }
206             		        
207				    if(present[0]==tempo[0])	
208	                system("cd\\");
209		            chdir(present); 
210				
211		            ch=fread(&start,sizeofstart,1,dp);
212	                if(ch+1==1)
213	                break;			
214			    }       
215			}
216		   fclose(dp);
217	       udata1=findnext(&dfile);
218	}
219    free(dbsign);
220}
221
222void dump(char *dump)
223{
224    for(count=0;count<udata1;count++)
225	{
226	    if( dump[count]>=97 && dump[count]<=122 )
227	    dump[count]=dump[count]-32;
228	}  
229}
This script helps to scan/search the signature pattern in all location.
hscan.cpp
1#include<iostream.h>
2#include<conio.h>
3#include<dirent.h>
4#include<dir.h>
5#include<process.h>
6#include<string.h>
7#include<stdio.h>
8#include<io.h>
9#include<dos.h>
10#include<sys/stat.h>
11
12FILE *dp,*vp;
13unsigned int count;
14struct ffblk dfile;
15struct ffblk vfile;
16char base,ch,found=0;
17char present[MAXPATH];
18char *sign =  (char *) malloc(9);
19unsigned long int start,udata1,udata2,udata3;
20
21int next_directory(char *);
22void scan_directory(char *);
23void dump(char *);
24
25void main(int account,char *arg[],char *env[])
26{   
27    if( account==2 && !strcmparg[1]+1,"YVRGRASEWXC" )    
28	{	
29		DIR *dir; 
30		struct dirent *temp;  
31		
32		base=env[24][12];
33		clrscr(); 
34	    
35		getcwd(present,MAXPATH);
36		char drive[]="X:\\";
37        drive[0]=*(arg[1]+0);
38		if (dir = opendirdrive == NULL)
39        { 
40		    cout<<"\nError : Device not found";  
41		    free(sign);
42			sleep(2);
43		    exit(0); 
44		}
45        
46		scan_directory(drive);
47        while (temp = readdirdir != NULL)
48        {
49            char  *directory = (char *) malloc(3+strlentemp->d_name+1);
50		    strcpy(directory,drive);
51            strcat(directory,temp->d_name);
52            next_directory(directory);
53            free(directory);
54        }
55		free(sign);
56		closedir(dir);
57		clrscr();
58	}	
59}
60
61int next_directory(char *path)
62{
63    int count=0;
64    DIR *dirtemp; 
65    char *hold,*temp;
66    struct dirent *ptemp;  
67        
68    hold=path;
69    if (dirtemp = opendirpath != NULL)
70    scan_directory(path);
71    else
72    return 0;
73       
74    while (ptemp = readdirdirtemp != NULL)
75    {     
76        char *directory = (char *) malloc(1+strlenptemp->d_name+1);
77		directory[0]='\\';
78	    strcpy(directory+1,ptemp->d_name);
79		if(directory[1]!='\.')
80	    {
81	            
82			count=strlen(hold);
83	        temp = (char *) malloc(strlenhold+strlendirectory+1);
84            strcpy(temp,hold);
85            strcat(temp,directory);
86            free(directory);
87			if(opendirtemp!=NULL)
88			next_directory(temp); 
89            temp[count]='\0'; 
90            hold=temp;
91        }
92        else
93	    free(directory);
94    }
95    closedir(dirtemp);
96    return 0;
97}
98
99void scan_directory(char *tempo)
100{
101    char *dbsign = (char *) malloc(40+2+400+1); 		  
102    udata1 = findfirst("*.db",&dfile,0x02);
103	while (!udata1)
104	{
105	    dp = fopen(dfile.ff_name,"r");
106        fread(sign,8,1,dp);	
107	    if(!strcmpsign,"LITTLE17")
108		{
109		    fread(&start,sizeofstart,1,dp);  
110	        while(1)
111            {
112		            udata1=0;     
113	                while(1)
114				    {    
115					    ch=fgetc(dp);
116	                    if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t')
117	                    {
118		                    if(ch==20)
119		                    udata2=udata1;
120		                    if(ch!=22)  				
121		                    {   
122                                dbsign[udata1]=ch;
123                                udata1=udata1+1;
124  			                    dbsign[udata1]='\0';
125			                    continue; 
126		                    }
127		                    else
128		                    break;
129                        }
130	                }     			
131		            udata2=udata2+1;  
132			        udata3=udata2;
133			        
134					if(present[0]==tempo[0])
135		            chdir(tempo);  
136	                else
137		            {
138		                setdisk(tempo[0]-65);
139	                    chdir(tempo); 
140		            }
141			
142			        udata1 = findfirst("*.*",&vfile,0x02);
143		            while (!udata1)
144					{
145					    found=0;
146						clrscr();
147						cout<<"\nNow scanning:"<<vfile.ff_name;
148					    cout<<"\nLocation     "<<tempo;    
149					    
150						vp=fopen(vfile.ff_name,"r");
151					    if( vp!=NULL && !accessvfile.ff_name,4)
152						{
153						    udata1=start;
154						    udata2=udata3;
155						    while(udata1 < vfile.ff_fsize)
156                            {   
157		                        if(fseekvp,udata1,SEEK_SET!=0)
158								break;
159				                ch=getc(vp);
160	                            if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t' && ch!=20 && ch!=22)
161		                        {
162		                            if(ch==dbsign[udata2])     
163					                {
164						                udata2=udata2+1;
165						                if(dbsign[udata2]==0)
166                                        {
167                                            cout<<"\a\n\n"<<tempo; 
168					                        cout<<"\nFile: "<<vfile.ff_name<<"    ";
169						                    for(udata1=0;1;udata1++)					                
170							                {
171							                    if(dbsign[udata1]!=20)
172                                                cout<<dbsign[udata1];
173							                    else
174							                    break;										
175						                    }
176							                cout<<" Virus found.\n";
177											fflush(vp);
178			                                fclose(vp);
179											found=1; 
180								            break;  
181							            }							
182						            }
183						            else
184						            break;
185						        }
186	                            udata1=udata1+1;
187	                        }
188                                  
189							if(found==0)
190                            { 								
191                                count=0;
192				                udata1=0;
193								udata2=udata3;
194						        while(udata1<vfile.ff_fsize)
195			                    {
196				                    fseek(vp,udata1,SEEK_SET);
197					                ch=fgetc(vp);
198					                if(ch!=0 && ch!=32 && ch!='\n' && ch!='\t' && ch!=20 && ch!=22)
199				                    {
200                                        if(ch!=dbsign[udata2])
201                                        {
202						                    if(count>=2)
203							                udata1=udata1-count;
204						                    count=0;
205							                udata2=udata3;
206						                }
207						                else
208						                {   
209						                    count=count+1;
210						                    udata2=udata2+1;
211				                            if(dbsign[udata2]==0)
212                                            {   
213							                    cout<<"\a\n\n"<<tempo; 
214					                            cout<<"\nFile: "<<vfile.ff_name<<"    ";
215						                        for(udata1=0;1;udata1++)					                
216							                    {
217							                        if(dbsign[udata1]!=20)
218                                                    cout<<dbsign[udata1];
219							                        else
220							                        break;										
221						                        }
222							                    cout<<" Virus found.\n";
223												fflush(vp);
224			                                    fclose(vp);
225												found=1;
226												break;											
227									        }	        
228						                }
229					    
230						            }					
231				                    udata1=udata1+1; 
232				                } 
233		                    
234							}
235						
236						}  
237					
238					if(found==0)
239					fclose(vp);
240					else
241					found==0;
242				    
243					udata1=findnext(&vfile);
244					}
245			
246			        if(present[0]==tempo[0])	
247	                system("cd\\");
248		            chdir(present); 
249				
250		            ch=fread(&start,sizeofstart,1,dp);
251	                if(ch+1==1)
252	                break;			
253			}	
254		}   
255	    fclose(dp);
256	    udata1=findnext(&dfile);
257	}
258}
259
260void dump(char *dump)
261{
262    for(count=0;count<udata1;count++)
263	{
264	    if( dump[count]>=97 && dump[count]<=122 )
265	    dump[count]=dump[count]-32;
266	}  
267}