From 615abc0d10adb42df1db16f8216fc4b377d584a5 Mon Sep 17 00:00:00 2001 From: rukaimi <rukaimi@985867f9-ca9c-e1f6-822d-e8a4186388af> Date: Fri, 5 Oct 2012 15:36:56 +0000 Subject: [PATCH] Some new functions to work with PE header --- pe_lib/pe_32_64.cpp | 28 ++++++++++++++++++++++++++++ pe_lib/pe_32_64.h | 12 ++++++++++++ pe_lib/pe_base.h | 13 +++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/pe_lib/pe_32_64.cpp b/pe_lib/pe_32_64.cpp index b54aa3b..fc1a9f2 100644 --- a/pe_lib/pe_32_64.cpp +++ b/pe_lib/pe_32_64.cpp @@ -394,6 +394,20 @@ WORD pe<PEClassType>::get_dll_characteristics() const return nt_headers_.OptionalHeader.DllCharacteristics; } +//Returns timestamp of PE file from header +template<typename PEClassType> +DWORD pe<PEClassType>::get_time_date_stamp() const +{ + return nt_headers_.FileHeader.TimeDateStamp; +} + +//Sets timestamp of PE file +template<typename PEClassType> +void pe<PEClassType>::set_time_date_stamp(DWORD timestamp) +{ + nt_headers_.FileHeader.TimeDateStamp = timestamp; +} + //Sets DLL Characteristics template<typename PEClassType> void pe<PEClassType>::set_dll_characteristics(WORD characteristics) @@ -401,6 +415,20 @@ void pe<PEClassType>::set_dll_characteristics(WORD characteristics) nt_headers_.OptionalHeader.DllCharacteristics = characteristics; } +//Returns Machine field value of PE file from header +template<typename PEClassType> +WORD pe<PEClassType>::get_machine() const +{ + return nt_headers_.FileHeader.Machine; +} + +//Sets Machine field value of PE file +template<typename PEClassType> +void pe<PEClassType>::set_machine(WORD machine) +{ + nt_headers_.FileHeader.Machine = machine; +} + //Sets PE characteristics template<typename PEClassType> void pe<PEClassType>::set_characteristics(WORD ch) diff --git a/pe_lib/pe_32_64.h b/pe_lib/pe_32_64.h index c5f2c5e..23b3175 100644 --- a/pe_lib/pe_32_64.h +++ b/pe_lib/pe_32_64.h @@ -156,6 +156,18 @@ public: //PE HEADER //Sets checksum of PE file virtual void set_checksum(DWORD checksum); + + //Returns timestamp of PE file from header + virtual DWORD get_time_date_stamp() const; + + //Sets timestamp of PE file + virtual void set_time_date_stamp(DWORD timestamp); + + //Returns Machine field value of PE file from header + virtual WORD get_machine() const; + + //Sets Machine field value of PE file + virtual void set_machine(WORD machine); //Returns DLL Characteristics virtual WORD get_dll_characteristics() const; diff --git a/pe_lib/pe_base.h b/pe_lib/pe_base.h index da6c1e5..48b797c 100644 --- a/pe_lib/pe_base.h +++ b/pe_lib/pe_base.h @@ -12,7 +12,7 @@ //Please don't remove this information from header //PE Library (c) DX 2011 - 2012, http://kaimi.ru -//Version: 0.1.10 +//Version: 0.1.11 //Free to use, modify and distribute // == more important == @@ -358,10 +358,19 @@ public: //PE HEADER //Returns checksum of PE file from header virtual DWORD get_checksum() const = 0; - //Sets checksum of PE file virtual void set_checksum(DWORD checksum) = 0; + //Returns timestamp of PE file from header + virtual DWORD get_time_date_stamp() const = 0; + //Sets timestamp of PE file + virtual void set_time_date_stamp(DWORD timestamp) = 0; + + //Returns Machine field value of PE file from header + virtual WORD get_machine() const = 0; + //Sets Machine field value of PE file + virtual void set_machine(WORD machine) = 0; + //Returns data from the beginning of image //Size = SizeOfHeaders const std::string& get_full_headers_data() const; -- GitLab