188 lines
5.5 KiB
C++
188 lines
5.5 KiB
C++
#ifndef _IMAGE_IMAGEIMPORTDESCRIPTOR_HPP_
|
|
#define _IMAGE_IMAGEIMPORTDESCRIPTOR_HPP_
|
|
#ifndef _COMMON_WINDOWS_HPP_
|
|
#include <common/windows.hpp>
|
|
#endif
|
|
#ifndef _COMMON_PUREVIEWOFFILE_HPP_
|
|
#include <common/pview.hpp>
|
|
#endif
|
|
#ifndef _IMAGE_IMAGESECTIONHEADERS_HPP_
|
|
#include <image/sctnhdrs.hpp>
|
|
#endif
|
|
#ifndef _IMAGE_IMAGEIMPORTDESCRIPTOREXPAND_HPP_
|
|
#include <image/impexp.hpp>
|
|
#endif
|
|
|
|
class ImageImportDescriptor : public ImageImportDescriptorExpand, private IMAGE_IMPORT_DESCRIPTOR
|
|
{
|
|
public:
|
|
ImageImportDescriptor(void);
|
|
ImageImportDescriptor(const ImageImportDescriptor &someImageImportDescriptor);
|
|
virtual ~ImageImportDescriptor();
|
|
ImageImportDescriptor &operator=(const ImageImportDescriptor &someImageImportDescriptor);
|
|
WORD operator==(const ImageImportDescriptor &someImageImportDescriptor)const;
|
|
operator IMAGE_IMPORT_DESCRIPTOR &(void);
|
|
ImageImportDescriptor &operator<<(PureViewOfFile &pureView);
|
|
DWORD characteristicsRVA(void)const;
|
|
void characteristicsRVA(DWORD characteristicsRVA);
|
|
DWORD originalFirstThunkRVA(void)const;
|
|
void originalFirstThunkRVA(DWORD originalFirstThunkRVA);
|
|
DWORD timeDateStamp(void)const;
|
|
void timeDateStamp(DWORD timeDateStamp);
|
|
DWORD forwarderChainIndex(void)const;
|
|
void forwarderChainIndex(DWORD forwarderChainIndex);
|
|
DWORD nameRVA(void)const;
|
|
void nameRVA(DWORD nameRVA);
|
|
DWORD firstThunkRVA(void)const;
|
|
void firstThunkRVA(DWORD firstThunkRVA);
|
|
WORD isOkay(void)const;
|
|
void loadImageImportThunks(DWORD deltaOffset,PureViewOfFile &pureView,ImageSectionHeaders &imageSectionHeaders);
|
|
void loadImageFirstThunk(DWORD deltaOffset,PureViewOfFile &pureView,ImageSectionHeaders &imageSectionHeaders);
|
|
private:
|
|
void loadImageImportThunk(DWORD virtualAddress,DWORD deltaOffset,Block<ImageThunkData> &imageThunkImportOrdinals,Block<ImageThunkName> &imageThunkImportNames,PureViewOfFile &pureView,ImageSectionHeaders &imageSectionHeaders);
|
|
void setZero(void);
|
|
};
|
|
|
|
inline
|
|
ImageImportDescriptor::ImageImportDescriptor(void)
|
|
{
|
|
setZero();
|
|
}
|
|
|
|
inline
|
|
ImageImportDescriptor::ImageImportDescriptor(const ImageImportDescriptor &someImageImportDescriptor)
|
|
{
|
|
*this=someImageImportDescriptor;
|
|
}
|
|
|
|
inline
|
|
ImageImportDescriptor::~ImageImportDescriptor()
|
|
{
|
|
}
|
|
|
|
inline
|
|
ImageImportDescriptor::operator IMAGE_IMPORT_DESCRIPTOR &(void)
|
|
{
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
ImageImportDescriptor &ImageImportDescriptor::operator=(const ImageImportDescriptor &someImageImportDescriptor)
|
|
{
|
|
characteristicsRVA(someImageImportDescriptor.characteristicsRVA());
|
|
originalFirstThunkRVA(someImageImportDescriptor.originalFirstThunkRVA());
|
|
timeDateStamp(someImageImportDescriptor.timeDateStamp());
|
|
forwarderChainIndex(someImageImportDescriptor.forwarderChainIndex());
|
|
nameRVA(someImageImportDescriptor.nameRVA());
|
|
firstThunkRVA(someImageImportDescriptor.firstThunkRVA());
|
|
(ImageImportDescriptorExpand&)*this=(ImageImportDescriptorExpand&)someImageImportDescriptor;
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
ImageImportDescriptor &ImageImportDescriptor::operator<<(PureViewOfFile &pureView)
|
|
{
|
|
pureView.read((char*)&((IMAGE_IMPORT_DESCRIPTOR&)*this),sizeof(IMAGE_IMPORT_DESCRIPTOR));
|
|
return *this;
|
|
}
|
|
|
|
inline
|
|
WORD ImageImportDescriptor::operator==(const ImageImportDescriptor &someImageImportDescriptor)const
|
|
{
|
|
return (characteristicsRVA()==someImageImportDescriptor.characteristicsRVA()&&
|
|
originalFirstThunkRVA()==someImageImportDescriptor.originalFirstThunkRVA()&&
|
|
timeDateStamp()==someImageImportDescriptor.timeDateStamp()&&
|
|
forwarderChainIndex()==someImageImportDescriptor.forwarderChainIndex()&&
|
|
nameRVA()==someImageImportDescriptor.nameRVA()&&
|
|
firstThunkRVA()==someImageImportDescriptor.firstThunkRVA());
|
|
}
|
|
|
|
inline
|
|
DWORD ImageImportDescriptor::characteristicsRVA(void)const
|
|
{
|
|
return IMAGE_IMPORT_DESCRIPTOR::Characteristics;
|
|
}
|
|
|
|
inline
|
|
DWORD ImageImportDescriptor::originalFirstThunkRVA(void)const
|
|
{
|
|
return (DWORD)IMAGE_IMPORT_DESCRIPTOR::OriginalFirstThunk;
|
|
}
|
|
|
|
inline
|
|
DWORD ImageImportDescriptor::timeDateStamp(void)const
|
|
{
|
|
return IMAGE_IMPORT_DESCRIPTOR::TimeDateStamp;
|
|
}
|
|
|
|
inline
|
|
DWORD ImageImportDescriptor::forwarderChainIndex(void)const
|
|
{
|
|
return IMAGE_IMPORT_DESCRIPTOR::ForwarderChain;
|
|
}
|
|
|
|
inline
|
|
DWORD ImageImportDescriptor::nameRVA(void)const
|
|
{
|
|
return IMAGE_IMPORT_DESCRIPTOR::Name;
|
|
}
|
|
|
|
inline
|
|
DWORD ImageImportDescriptor::firstThunkRVA(void)const
|
|
{
|
|
return (DWORD)IMAGE_IMPORT_DESCRIPTOR::FirstThunk;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::characteristicsRVA(DWORD characteristicsRVA)
|
|
{
|
|
IMAGE_IMPORT_DESCRIPTOR::Characteristics=characteristicsRVA;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::originalFirstThunkRVA(DWORD originalFirstThunkRVA)
|
|
{
|
|
IMAGE_IMPORT_DESCRIPTOR::OriginalFirstThunk=(unsigned long)(PIMAGE_THUNK_DATA)originalFirstThunkRVA;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::timeDateStamp(DWORD timeDateStamp)
|
|
{
|
|
IMAGE_IMPORT_DESCRIPTOR::TimeDateStamp=timeDateStamp;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::forwarderChainIndex(DWORD forwarderChainIndex)
|
|
{
|
|
IMAGE_IMPORT_DESCRIPTOR::ForwarderChain=forwarderChainIndex;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::nameRVA(DWORD nameRVA)
|
|
{
|
|
IMAGE_IMPORT_DESCRIPTOR::Name=nameRVA;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::firstThunkRVA(DWORD firstThunkRVA)
|
|
{
|
|
IMAGE_IMPORT_DESCRIPTOR::FirstThunk=(unsigned long)(PIMAGE_THUNK_DATA)firstThunkRVA;
|
|
}
|
|
|
|
inline
|
|
WORD ImageImportDescriptor::isOkay(void)const
|
|
{
|
|
if(!characteristicsRVA()&&!originalFirstThunkRVA()&&
|
|
!timeDateStamp()&&!forwarderChainIndex()&&
|
|
!nameRVA()&&!firstThunkRVA())return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
inline
|
|
void ImageImportDescriptor::setZero(void)
|
|
{
|
|
::memset(&((IMAGE_IMPORT_DESCRIPTOR&)*this),0,sizeof(IMAGE_IMPORT_DESCRIPTOR));
|
|
}
|
|
#endif
|
|
|