From 14c7f45cdae826f88dc539c8c38dd95caf305731 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 11 Jul 2008 15:50:46 +0000 Subject: Add zook's ZenUtils to SVN git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657 --- .../libraries/pelib-0.9/pelib/PeHeader.cpp | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100755 utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp') diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp b/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp new file mode 100755 index 0000000000..fe7011072c --- /dev/null +++ b/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp @@ -0,0 +1,90 @@ +/* +* PeHeader.cpp - Part of the PeLib library. +* +* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) +* All rights reserved. +* +* This software is licensed under the zlib/libpng License. +* For more details see http://www.opensource.org/licenses/zlib-license.php +* or the license information file (license.htm) in the root directory +* of PeLib. +*/ + +#include "PeLibInc.h" +#include "PeHeader.h" + +namespace PeLib +{ + template<> + void PeHeaderT<32>::readBaseOfData(InputBuffer& ibBuffer, PELIB_IMAGE_NT_HEADERS<32>& header) const + { + ibBuffer >> header.OptionalHeader.BaseOfData; + } + + template<> + void PeHeaderT<64>::readBaseOfData(InputBuffer&, PELIB_IMAGE_NT_HEADERS<64>&) const + { + } + + template<> + void PeHeaderT<32>::rebuildBaseOfData(OutputBuffer& obBuffer) const + { + obBuffer << m_inthHeader.OptionalHeader.BaseOfData; + } + + template<> + void PeHeaderT<64>::rebuildBaseOfData(OutputBuffer&) const + { + } + + template<> + bool PeHeaderT<32>::isValid() const + { + return true; + } + + template<> + bool PeHeaderT<64>::isValid() const + { + return true; + } + + template<> + bool PeHeaderT<32>::isValid(unsigned int pehf) const + { + /* + if (pehf == NtSignature) + { + return m_inthHeader.Signature == IMAGE_NT_SIGNATURE; + } + else if (pehf == NumberOfSections) + { + return getNumberOfSections() == calcNumberOfSections(); + } */ + return false; + } + + template<> + bool PeHeaderT<64>::isValid(unsigned int pehf) const + { + return false; + } + + /** + * @return The BaseOfData value from the PE header. + **/ + dword PeHeader32::getBaseOfData() const + { + return m_inthHeader.OptionalHeader.BaseOfData; + } + + /** + * Changes the file's BaseOfData. + * @param dwValue New value. + **/ + void PeHeader32::setBaseOfData(dword dwValue) + { + m_inthHeader.OptionalHeader.BaseOfData = dwValue; + } + +} -- cgit v1.2.3