/* Copyright 2017 - 2022 R. Thomas * Copyright 2017 - 2022 Quarkslab * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "LIEF/ART/Header.hpp" #include "LIEF/ART/hash.hpp" #include "pyART.hpp" namespace LIEF { namespace ART { template using getter_t = T (Header::*)(void) const; template using setter_t = void (Header::*)(T); template<> void create
(py::module& m) { py::class_(m, "Header", "ART Header representation") .def_property_readonly("magic", static_cast>(&Header::magic) ) .def_property_readonly("version", static_cast>(&Header::version) ) .def_property_readonly("image_begin", static_cast>(&Header::image_begin) ) .def_property_readonly("image_size", static_cast>(&Header::image_size) ) .def_property_readonly("oat_checksum", static_cast>(&Header::oat_checksum) ) .def_property_readonly("oat_file_begin", static_cast>(&Header::oat_file_begin) ) .def_property_readonly("oat_file_end", static_cast>(&Header::oat_file_end) ) .def_property_readonly("oat_data_end", static_cast>(&Header::oat_data_end) ) .def_property_readonly("patch_delta", static_cast>(&Header::patch_delta) ) .def_property_readonly("image_roots", static_cast>(&Header::image_roots) ) .def_property_readonly("pointer_size", static_cast>(&Header::pointer_size) ) .def_property_readonly("compile_pic", static_cast>(&Header::compile_pic) ) .def_property_readonly("nb_sections", static_cast>(&Header::nb_sections) ) .def_property_readonly("nb_methods", static_cast>(&Header::nb_methods) ) .def_property_readonly("boot_image_begin", static_cast>(&Header::boot_image_begin) ) .def_property_readonly("boot_image_size", static_cast>(&Header::boot_image_size) ) .def_property_readonly("boot_oat_begin", static_cast>(&Header::boot_oat_begin) ) .def_property_readonly("boot_oat_size", static_cast>(&Header::boot_oat_size) ) .def_property_readonly("storage_mode", static_cast>(&Header::storage_mode) ) .def_property_readonly("data_size", static_cast>(&Header::data_size) ) .def("__eq__", &Header::operator==) .def("__ne__", &Header::operator!=) .def("__hash__", [] (const Header& header) { return Hash::hash(header); }) .def("__str__", [] (const Header& header) { std::ostringstream stream; stream << header; std::string str = stream.str(); return str; }); } } }