retdec
IatDirectory.h
Go to the documentation of this file.
1 /*
2 * IatDirectory.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_IATDIRECTORY_H
14 #define RETDEC_PELIB_IATDIRECTORY_H
15 
16 #include "retdec/pelib/PeLibInc.h"
18 
19 namespace PeLib
20 {
22 
26  {
27  protected:
28  std::vector<std::uint32_t> m_vIat;
29 
30  public:
31  virtual ~IatDirectory() = default;
32 
34  int read(const void * buffer, std::size_t buffersize); // EXPORT
36  int read(PeLib::ImageLoader & imageLoader); // EXPORT
38  unsigned int calcNumberOfAddresses() const; // EXPORT
40  void addAddress(std::uint32_t dwValue); // EXPORT
42  void removeAddress(unsigned int index); // EXPORT
44  void clear(); // EXPORT
45  // Rebuilds the IAT.
46  void rebuild(std::vector<std::uint8_t>& vBuffer) const; // EXPORT
48  unsigned int size() const; // EXPORT
50  int write(const std::string& strFilename, unsigned int uiOffset) const; // EXPORT
51 
53  std::uint32_t getAddress(unsigned int index) const; // EXPORT
55  void setAddress(std::uint32_t dwAddrnr, std::uint32_t dwValue); // EXPORT
56  };
57 }
58 
59 #endif
60 
Class that handles the Import Address Table (IAT)
Definition: IatDirectory.h:26
void removeAddress(unsigned int index)
Removes an address from the IAT.
Definition: IatDirectory.cpp:129
void rebuild(std::vector< std::uint8_t > &vBuffer) const
Definition: IatDirectory.cpp:147
unsigned int size() const
Returns the size of the current IAT.
Definition: IatDirectory.cpp:158
std::vector< std::uint32_t > m_vIat
Stores the individual IAT fields.
Definition: IatDirectory.h:28
int write(const std::string &strFilename, unsigned int uiOffset) const
Writes the current IAT to a file.
Definition: IatDirectory.cpp:164
unsigned int calcNumberOfAddresses() const
Returns the number of fields in the IAT.
Definition: IatDirectory.cpp:91
void setAddress(std::uint32_t dwAddrnr, std::uint32_t dwValue)
Change the value of a field in the IAT.
Definition: IatDirectory.cpp:111
void clear()
Empties the IAT.
Definition: IatDirectory.cpp:138
virtual ~IatDirectory()=default
void addAddress(std::uint32_t dwValue)
Adds another address to the IAT.
Definition: IatDirectory.cpp:120
std::uint32_t getAddress(unsigned int index) const
Retrieve the value of a field in the IAT.
Definition: IatDirectory.cpp:101
int read(const void *buffer, std::size_t buffersize)
Reads the Import Address Table from a PE file.
Definition: IatDirectory.cpp:22
Definition: ImageLoader.h:138
Definition: BoundImportDirectory.h:21