retdec
RelocationsDirectory.h
Go to the documentation of this file.
1 /*
2 * Relocations.h - Part of the PeLib library.
3 *
4 * Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
5 * All rights reserved.
6 *
7 * This software is licensed under the zlib/libpng License.
8 * For more details see http://www.opensource.org/licenses/zlib-license.php
9 * or the license information file (license.htm) in the root directory
10 * of PeLib.
11 */
12 
13 #ifndef RETDEC_PELIB_RELOCATIONSDIRECTORY_H
14 #define RETDEC_PELIB_RELOCATIONSDIRECTORY_H
15 
17 
18 namespace PeLib
19 {
21 
25  {
26  protected:
27  std::vector<IMG_BASE_RELOC> m_vRelocations;
29 
30  public:
33  virtual ~RelocationsDirectory() = default;
34 
36  int read(ImageLoader & imageLoader); // EXPORT
37 
39  LoaderError loaderError() const;
40  void setLoaderError(LoaderError ldrError);
41 
43  unsigned int calcNumberOfRelocations() const; // EXPORT
45  unsigned int calcNumberOfRelocationData(unsigned int ulRelocation) const; // EXPORT
46 
48  void read(const std::uint8_t * data, std::uint32_t uiSize, std::uint32_t sizeOfImage);
50  unsigned int size() const; // EXPORT
51 
53  std::uint32_t getVirtualAddress(unsigned int ulRelocation) const; // EXPORT
55  std::uint32_t getSizeOfBlock(unsigned int ulRelocation) const; // EXPORT
57  std::uint16_t getRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber) const; // EXPORT
58 
60  void setRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber, std::uint16_t wData); // EXPORT
61 
63  void setVirtualAddress(unsigned int ulRelocation, std::uint32_t dwValue); // EXPORT
65  void setSizeOfBlock(unsigned int ulRelocation, std::uint32_t dwValue); // EXPORT
66 
67  void addRelocation(); // EXPORT
69  void addRelocationData(unsigned int ulRelocation, std::uint16_t wValue); // EXPORT
71  void removeRelocationData(unsigned int ulRelocation, std::uint16_t wValue); // EXPORT
72  void removeRelocation(unsigned int index); // EXPORT
73  void removeRelocationData(unsigned int relocindex, unsigned int dataindex); // EXPORT
74  };
75 }
76 
77 #endif
Definition: ImageLoader.h:138
Class that handles the relocations directory.
Definition: RelocationsDirectory.h:25
void addRelocation()
Definition: RelocationsDirectory.cpp:213
LoaderError m_ldrError
Definition: RelocationsDirectory.h:28
void setLoaderError(LoaderError ldrError)
Definition: RelocationsDirectory.cpp:63
std::uint32_t getSizeOfBlock(unsigned int ulRelocation) const
Returns the SizeOfBlock value of a relocation.
Definition: RelocationsDirectory.cpp:188
void setVirtualAddress(unsigned int ulRelocation, std::uint32_t dwValue)
Changes the VirtualAddress of a relocation.
Definition: RelocationsDirectory.cpp:203
unsigned int calcNumberOfRelocationData(unsigned int ulRelocation) const
Returns the number of relocation data entries of a specific relocation.
Definition: RelocationsDirectory.cpp:193
virtual ~RelocationsDirectory()=default
int read(ImageLoader &imageLoader)
Read a file's relocations directory.
Definition: RelocationsDirectory.cpp:24
unsigned int calcNumberOfRelocations() const
Returns the number of relocations in the relocations directory.
Definition: RelocationsDirectory.cpp:178
LoaderError loaderError() const
Retrieve the loader error.
Definition: RelocationsDirectory.cpp:58
RelocationsDirectory()
Error detected by the import table parser.
Definition: RelocationsDirectory.cpp:21
void removeRelocationData(unsigned int ulRelocation, std::uint16_t wValue)
Removes data from a relocation.
void removeRelocation(unsigned int index)
Definition: RelocationsDirectory.cpp:231
void setSizeOfBlock(unsigned int ulRelocation, std::uint32_t dwValue)
Changes the SizeOfBlock of a relocation.
Definition: RelocationsDirectory.cpp:208
void setRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber, std::uint16_t wData)
Changes the relocation data of a relocation.
Definition: RelocationsDirectory.cpp:72
std::uint16_t getRelocationData(unsigned int ulRelocation, unsigned int ulDataNumber) const
Returns the RelocationData of a relocation.
Definition: RelocationsDirectory.cpp:198
std::vector< IMG_BASE_RELOC > m_vRelocations
Used to store the relocation data.
Definition: RelocationsDirectory.h:27
std::uint32_t getVirtualAddress(unsigned int ulRelocation) const
Returns the VA of a relocation.
Definition: RelocationsDirectory.cpp:183
void addRelocationData(unsigned int ulRelocation, std::uint16_t wValue)
Adds new data to a relocation.
Definition: RelocationsDirectory.cpp:219
unsigned int size() const
Returns the size of the relocations directory.
Definition: RelocationsDirectory.cpp:166
Definition: BoundImportDirectory.h:21
LoaderError
Definition: PeLibAux.h:47