mirror of
https://github.com/vtil-project/VTIL-Core
synced 2026-08-17 08:23:03 -04:00
Added image_descriptor::get_entry_point().
This commit is contained in:
parent
29f9c1c872
commit
d8c906ba1d
3 changed files with 17 additions and 0 deletions
|
|
@ -177,6 +177,10 @@ namespace vtil
|
|||
//
|
||||
virtual uint64_t get_image_base() const = 0;
|
||||
|
||||
// Returns the entry point if relevant.
|
||||
//
|
||||
virtual std::optional<uint64_t> get_entry_point() const = 0;
|
||||
|
||||
// Returns the image size and the raw byte array.
|
||||
//
|
||||
virtual size_t get_image_size() const = 0;
|
||||
|
|
|
|||
|
|
@ -626,6 +626,18 @@ namespace vtil
|
|||
return dos_header->get_nt_headers<false>()->optional_header.image_base;
|
||||
}
|
||||
|
||||
std::optional<uint64_t> pe_image::get_entry_point() const
|
||||
{
|
||||
// Get the entry point from optional header, return nullopt if zero.
|
||||
//
|
||||
auto dos_header = ( const dos_header_t* ) cdata();
|
||||
uint64_t ep = is_pe64()
|
||||
? dos_header->get_nt_headers<true>()->optional_header.entry_point
|
||||
: dos_header->get_nt_headers<false>()->optional_header.entry_point;
|
||||
if ( ep ) return ep;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
bool pe_image::is_valid() const
|
||||
{
|
||||
// Get image boundaries and the dos header.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ namespace vtil
|
|||
virtual void add_section( section_descriptor& in_out, const void* data, size_t size ) override;
|
||||
virtual void enum_relocations( const function_view<bool( const relocation_descriptor& )>& fn ) const override;
|
||||
virtual uint64_t get_image_base() const override;
|
||||
virtual std::optional<uint64_t> get_entry_point() const override;
|
||||
virtual size_t get_image_size() const override { return raw_bytes.size(); }
|
||||
virtual void* data() override { return raw_bytes.data(); }
|
||||
virtual const void* cdata() const override { return raw_bytes.data(); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue