summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/pelib-0.9/pelib/PeHeader.cpp
blob: 1199e6bdd1dad646a0e418320ec773dacc557e3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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;
	}

}