⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exehashstore.cpp

📁 BVB杀毒软件的引擎代码,可以学习这种杀毒软件的核心 帮助自己设计杀毒软件
💻 CPP
字号:
#include <string>
 #include <vector>
 #include <fstream>
 
 
 
 using namespace std;
 
 #include "ExeHashStore.h"
 #include "Globals.h"
 #include "Sha1.h"
 
 #ifdef WRITE_PROGRESS_TO_CONSOLE
 #include <iostream>
 #endif
 
 string ExeHashStore::getExecutableHash( string exePath )
 /*
 Description: Copies the first few hundred bytes of the executable described by exePath and returns it as a string
 */
 {
 string hash;
 CSHA1 hasher;
 
 hasher.HashFile( exePath.c_str() );
 hasher.Final();
 
 hasher.ReportHash( hash );
 
 return hash;
 }
 
 ExeHashStore::ExeHashStore( vector<string> V )
 {
 FileNames = V;
 }
 
 ExeHashStore::ExeHashStore( void )
 {
 
 }
 
 void ExeHashStore::setFileNamesVector( vector<string> V )
 {
 FileNames = V;
 }
 
 int ExeHashStore::storeAllHashes( string TargetFileName )
 /*
 Description: Stores all Hashs in the member vector FileNames to the file described by TargetFileName.
 */
 {
 
 ofstream TargetFileHandle( TargetFileName.c_str(), ios_base::trunc );
 unsigned int i;
 
 for(i=0;i<FileNames.size() && TargetFileHandle.good();i++)
 {
 TargetFileHandle 
 << i << endl
 << FileNames[i] << endl
 << getExecutableHash( FileNames[i] ) << endl;
 #ifdef WRITE_PROGRESS_TO_CONSOLE
 cout << FileNames[i] << endl;
 #endif
 }
 
 TargetFileHandle.close();
 
 return i;
 } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -