added vmp2 file format version 4 logic... See merge request vmp2/vmprofiler!16merge-requests/17/merge
commit
38aea67518
@ -0,0 +1,27 @@
|
||||
#include <nt/image.hpp>
|
||||
|
||||
/// <summary>
|
||||
/// small namespace that contains function wrappers to determine the validity of linear virtual addresses...
|
||||
/// </summary>
|
||||
namespace scn
|
||||
{
|
||||
/// <summary>
|
||||
/// determines if a pointer lands inside of a section that is readonly...
|
||||
///
|
||||
/// this also checks to make sure the section is not discardable...
|
||||
/// </summary>
|
||||
/// <param name="module_base">linear virtual address of the module....</param>
|
||||
/// <param name="ptr">linear virtual address</param>
|
||||
/// <returns>returns true if ptr lands inside of a readonly section of the module</returns>
|
||||
bool read_only( std::uint64_t module_base, std::uint64_t ptr );
|
||||
|
||||
/// <summary>
|
||||
/// determines if a pointer lands inside of a section that is executable...
|
||||
///
|
||||
/// this also checks to make sure the section is not discardable...
|
||||
/// </summary>
|
||||
/// <param name="module_base"></param>
|
||||
/// <param name="ptr"></param>
|
||||
/// <returns></returns>
|
||||
bool executable( std::uint64_t module_base, std::uint64_t ptr );
|
||||
} // namespace scn
|
@ -0,0 +1,34 @@
|
||||
#include <scn.hpp>
|
||||
|
||||
namespace scn
|
||||
{
|
||||
bool read_only( std::uint64_t module_base, std::uint64_t ptr )
|
||||
{
|
||||
auto win_image = reinterpret_cast< win::image_t<> * >( module_base );
|
||||
auto section_count = win_image->get_file_header()->num_sections;
|
||||
auto sections = win_image->get_nt_headers()->get_sections();
|
||||
|
||||
for ( auto idx = 0u; idx < section_count; ++idx )
|
||||
if ( ptr >= sections[ idx ].virtual_address + module_base &&
|
||||
ptr < sections[ idx ].virtual_address + sections[ idx ].virtual_size + module_base )
|
||||
return !( sections[ idx ].characteristics.mem_discardable ) &&
|
||||
!( sections[ idx ].characteristics.mem_write );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool executable( std::uint64_t module_base, std::uint64_t ptr )
|
||||
{
|
||||
auto win_image = reinterpret_cast< win::image_t<> * >( module_base );
|
||||
auto section_count = win_image->get_file_header()->num_sections;
|
||||
auto sections = win_image->get_nt_headers()->get_sections();
|
||||
|
||||
for ( auto idx = 0u; idx < section_count; ++idx )
|
||||
if ( ptr >= sections[ idx ].virtual_address + module_base &&
|
||||
ptr < sections[ idx ].virtual_address + sections[ idx ].virtual_size + module_base )
|
||||
return !( sections[ idx ].characteristics.mem_discardable ) &&
|
||||
sections[ idx ].characteristics.mem_execute;
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace scn
|
Loading…
Reference in new issue