kursovik (Разработка антивирусного монитора), страница 3
Описание файла
Документ из архива "Разработка антивирусного монитора", который расположен в категории "". Всё это находится в предмете "информатика" из , которые можно найти в файловом архиве . Не смотря на прямую связь этого архива с , его также можно найти и в других разделах. Архив можно найти в разделе "рефераты, доклады и презентации", в предмете "информатика, программирование" в общих файлах.
Онлайн просмотр документа "kursovik"
Текст 3 страницы из документа "kursovik"
Form1->FileListBox1->Directory=Form1->CDirectoryOutline1->Items[j]->FullPath;
String vrem;
for(int i=0; iFileListBox1->Count; i++)
{
vrem=Form1->FileListBox1->Items->Strings[i];
if(vrem!="Trap1.exe")if(vrem!="Trap2.exe")if(vrem!="Trap3.exe")
{
String Rassh=AnsiLowerCase(ExtractFileExt(Form1->FileListBox1->Items->Strings[i]));
if(Rassh==".exe")
{
M[glob]=FileOpen(Form1->FileListBox1->Items->Strings[i] ,fmShareDenyWrite);
glob++;
ExeFiles++;
FileSetAttr(Form1->FileListBox1->Items->Strings[i], NULL);
}
else if(Rassh==".com")
{
M[glob]=FileOpen(Form1->FileListBox1->Items->Strings[i] ,fmShareDenyWrite);
glob++;
ComFiles++;
FileSetAttr(Form1->FileListBox1->Items->Strings[i], NULL);
}
else if(Rassh==".bat")
{
M[glob]=FileOpen(Form1->FileListBox1->Items->Strings[i] ,fmShareDenyWrite);
glob++;
FileSetAttr(Form1->FileListBox1->Items->Strings[i], NULL);
}
}
}
}
Form1->CDirectoryOutline1->Refresh();
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
WinExec("Creator.exe",SW_MAXIMIZE);
DeleteFile("Creator.exe");
String DataBiosFileName="dbpg.ini";
if(FileExists(DataBiosFileName))
{
String Itog=OpenAndReadFile(DataBiosFileName);
String Itog1=Gammirovanie(DataBios());
if(Itog1!=Itog)
{
Application->MessageBoxA("Нелегальная копия программы!!!","Защита",MB_ICONSTOP);
exit(1);
}
else
{
Form1->CDirectoryOutline1->Items[1]->Collapse();
}
_sopen(DataBiosFileName.c_str(),O_RDONLY,SH_DENYRW); //обеспечивает экскл. доступ к файлу
}
else
{
Application->MessageBoxA("Нарушение целостности программы!!!","Защита",MB_ICONSTOP);
exit(1);
}
StelsProgram();
CDirectoryOutline1->Items[1]->Collapse();
}
//---------------------------------------------------------------------------
void SecuritySystemsBootFiles(void)
{
String CmdCom="C:/Windows/Command.com";
String CmdComOsn="C:/Command.com";
String AutoExecBat="C:/AutoExec.bat";
hndsys[0]=FileOpen(CmdCom ,fmShareExclusive);
hndsys[1]=FileOpen(CmdComOsn ,fmShareExclusive);
hndsys[2]=FileOpen(AutoExecBat ,fmShareExclusive);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
Form4->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
Form3->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Form2->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
Form1->Hide();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form5->Visible=true;
ZashDrives=ZashDrives+" "+DriveComboBox1->Drive;
Form4->Label8->Caption=ZashDrives;
ExclusiveOpenAllExeAndComFilesOnDrive();
OpenTraps();
ZashFiles=ComFiles+ExeFiles;
Form4->Label9->Caption=ZashFolders;
Form4->Label10->Caption=ZashFiles;
Form4->Label11->Caption=ExeFiles;
Form4->Label12->Caption=ComFiles;
Form5->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DriveComboBox1Change(TObject *Sender)
{
CDirectoryOutline1->Drive=DriveComboBox1->Drive;
CDirectoryOutline1->Items[1]->Collapse();
CDirectoryOutline1->Items[1]->Expand();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
FileClose(hndsys[0]);
FileClose(hndsys[1]);
FileClose(hndsys[2]);
SecuritySystemsBootFiles();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
FileClose(hndsys[0]);
FileClose(hndsys[1]);
FileClose(hndsys[2]);
}
void __fastcall TForm1::OnClose(TWMClose& a)
{
Form2->Visible=true;
}
//---------------------------------------------------------------------------
void CloseTimer(void)
{
Form1->Timer1->Enabled=false;
}
//---------------------------------------------------------------------------
void OpenTimer(void)
{
Form1->Timer1->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
SecondProcess = new TFScan(true);
SecondProcess->Resume();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
Form5->Visible=true;
for(int j=1; jCDirectoryOutline1->Lines->Count; j++)
{
if(Form1->CDirectoryOutline1->Items[j]->Expanded==false)
{
Form1->CDirectoryOutline1->Items[j]->Expand();
}
Form1->FileListBox1->Directory=Form1->CDirectoryOutline1->Items[j]->FullPath;
String vrem;
for(int i=0; iFileListBox1->Count; i++)
{
vrem=Form1->FileListBox1->Items->Strings[i];
if(vrem!="Trap1.exe")if(vrem!="Trap2.exe")if(vrem!="Trap3.exe")
{
M[glob]=FileOpen(Form1->FileListBox1->Items->Strings[i] ,fmShareDenyWrite);
}
}
}
Form1->CDirectoryOutline1->Refresh();
Form5->Visible=false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
Form5->Visible=true;
for(int j=1; jCDirectoryOutline1->Lines->Count; j++)
{
if(Form1->CDirectoryOutline1->Items[j]->Expanded==false)
{
Form1->CDirectoryOutline1->Items[j]->Expand();
}
Form1->FileListBox1->Directory=Form1->CDirectoryOutline1->Items[j]->FullPath;
String vrem;
for(int i=0; iFileListBox1->Count; i++)
{
vrem=Form1->FileListBox1->Items->Strings[i];
if(vrem!="Trap1.exe")if(vrem!="Trap2.exe")if(vrem!="Trap3.exe")
{
M[glob]=FileOpen(Form1->FileListBox1->Items->Strings[i] ,fmShareExclusive);
}
}
}
Form1->CDirectoryOutline1->Refresh();
Form5->Visible=false;
}
//---------------------------------------------------------------------------
C++ файл формы парольного окна (Unit2.cpp)
#include
#pragma hdrstop
#include "Unit1.cpp"
#include "Unit2.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::Button1Click(TObject *Sender)
{
String Itog1=Gammirovanie(Edit1->Text)+"m";
String Itog=OpenAndReadFile("A:/Прога/pif.ini");
Edit1->Text="";
if(Itog!=Itog1)
{
Application->MessageBoxA("Не верный пароль!!!","Защита",MB_ICONSTOP);
Form2->Close();
}
else
{
for(int i=0; i { FileClose(M[glob]); } exit(1); } } //--------------------------------------------------------------------------- void __fastcall TForm2::Button2Click(TObject *Sender) { Form2->Close(); } //--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.cpp" #include "Unit3.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm3 *Form3; //--------------------------------------------------------------------------- String GamOldPass=""; String GamNuwPass=""; String SaveGamPass=""; __fastcall TForm3::TForm3(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm3::Button1Click(TObject *Sender) { GamOldPass=Gammirovanie(Edit1->Text)+"m"; SaveGamPass=OpenAndReadFile("A:/Прога/pif.ini"); if(GamOldPass==SaveGamPass) { if(Edit2->Text==Edit3->Text) { GamNuwPass=Gammirovanie(Edit2->Text)+"m"; OpenAndWriteFile("A:/Прога/pif.ini",GamNuwPass); Form3->Close(); } else { Application->MessageBoxA("Введены разные пароли!!!","Отмена операции",MB_ICONSTOP); } } else { Application->MessageBoxA("Введён не верный действующий пароль!!!","Защита",MB_ICONSTOP); } } //--------------------------------------------------------------------------- void __fastcall TForm3::Button2Click(TObject *Sender) { Form3->Close(); } //--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.cpp" #include "Unit6.h" #include "Unit1.h" #pragma package(smart_init) void Zapolnenie(String FName1,String FName2) { FILE *F1; FILE *F2; F1=fopen(FName1.c_str(), "rb"); F2=fopen(FName2.c_str(), "wb"); for(int s=0;s { putc(getc(F1),F2); } fclose(F1); fclose(F2); } //---------------------------------------------------------------------- void Proverka(String FName1,String FName2) { FILE *F1; FILE *F2; F1=fopen(FName1.c_str(), "rb"); F2=fopen(FName2.c_str(), "rb"); if(F1!=NULL) { if(F2!=NULL) { int LengthTrap1=filelength(_fileno(F1)); int LengthTrap2=filelength(_fileno(F1)); if(LengthTrap1!=LengthTrap2) { Application->MessageBoxA("Внимание!!! Произошла перезапись .EXE или .COM файла!","Извещение!",MB_ICONSTOP); fclose(F1); fclose(F2); Zapolnenie(FName1,FName2); } else { for(int j=0;j { if(getc(F1)!=getc(F2)) { fclose(F1); fclose(F2); Zapolnenie(FName1,FName2); Application->MessageBoxA("Внимание!!! Произошла запись в .EXE или .COM файл!","Извещение!",MB_ICONSTOP); j=LengthTrap1; } } } } else { if(!FileExists(FName2)) { int DelFileHnd=0; DelFileHnd=FileCreate(FName2); FileClose(DelFileHnd); fclose(F1); fclose(F2); Zapolnenie(FName1,FName2); Application->MessageBoxA("Внимание!!! Была предпринята попытка удалить файл!!!","Извещение!",MB_ICONSTOP); } } } else { Application->MessageBoxA("Не удаётся открыть программный файл!!!","Ошибка",MB_ICONSTOP); exit(1); } fclose(F1); fclose(F2); } //---------------------------------------------------------------------- __fastcall TFScan::TFScan(bool CreateSuspended) : TThread(CreateSuspended) { } //--------------------------------------------------------------------------- void __fastcall TFScan::Execute() { CloseTimer(); CloseTraps(); Proverka(PathTrapsDir("Trap1.exe"),"C:\\Windows\\Trap1.exe"); Proverka(PathTrapsDir("Trap2.exe"),"C:\\Windows\\Trap2.exe"); Proverka(PathTrapsDir("Trap3.exe"),"C:\\Trap3.exe"); OpenTraps(); OpenTimer(); } //--------------------------------------------------------------------------- #include #include #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //---------------------------------------------------------------------------C++ файл формы окна изменения пароля (Unit3.cpp)
C++ файл параллельной нити (Unit6.cpp)
C++ файл тестирующего приложения (Вирус.cpp)