/* Copyright 2017 R. Thomas * Copyright 2017 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 "pyPE.hpp" #include "LIEF/visitors/Hash.hpp" #include "LIEF/PE/TLS.hpp" #include #include template using getter_t = T (TLS::*)(void) const; template using setter_t = void (TLS::*)(T); template using no_const_getter = T (TLS::*)(void); void init_PE_TLS_class(py::module& m) { py::class_(m, "TLS") .def(py::init<>()) .def_property("callbacks", static_cast&>>(&TLS::callbacks), static_cast&>>(&TLS::callbacks)) .def_property("addressof_index", static_cast>(&TLS::addressof_index), static_cast>(&TLS::addressof_index)) .def_property("addressof_callbacks", static_cast>(&TLS::addressof_callbacks), static_cast>(&TLS::addressof_callbacks)) .def_property("sizeof_zero_fill", static_cast>(&TLS::sizeof_zero_fill), static_cast>(&TLS::sizeof_zero_fill)) .def_property("characteristics", static_cast>(&TLS::characteristics), static_cast>(&TLS::characteristics)) .def_property("addressof_raw_data", static_cast>>(&TLS::addressof_raw_data), static_cast>>(&TLS::addressof_raw_data)) .def_property("data_template", static_cast&>>(&TLS::data_template), static_cast&>>(&TLS::data_template)) .def_property_readonly("has_section", &TLS::has_section) .def_property_readonly("has_data_directory", &TLS::has_data_directory) .def_property_readonly("directory", static_cast>(&TLS::directory), py::return_value_policy::reference) .def_property_readonly("section", static_cast>(&TLS::section), py::return_value_policy::reference) .def("__eq__", &TLS::operator==) .def("__ne__", &TLS::operator!=) .def("__hash__", [] (const TLS& tls) { return LIEF::Hash::hash(tls); }) .def("__str__", [] (const TLS& tls) { std::ostringstream stream; stream << tls; std::string str = stream.str(); return str; }); }