1. 程式人生 > >C++ 獲取PE檔案自校驗值的程式碼

C++ 獲取PE檔案自校驗值的程式碼

將寫程式碼過程比較重要的一些程式碼收藏起來,下邊資料是關於C++ 獲取PE檔案自校驗值的程式碼。


#include
#include <imagehlp.h>
#pragma comment(lib,"imagehlp")

{
char szFileName[] = "d:\newupdate.exe";
DWORD dwCheckSum1,dwCheckSum2;
if (MapFileAndCheckSum(szFileName,&dwCheckSum1,&dwCheckSum2) == CHECKSUM_SUCCESS)
{
std::cout<<hex<<"PIMAGE_OPTIONAL_HEADER.CheckSum = "<<dwCheckSum1<<std::endl;
std::cout<<hex<<"重新計算得到CheckSum = "<<dwCheckSum2<<std::endl;
}
return 0;
}