/* Copyright 2017 - 2021 R. Thomas * Copyright 2017 - 2021 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/PE/hash.hpp" #include "LIEF/PE/CodeIntegrity.hpp" #include #include namespace LIEF { namespace PE { template using getter_t = T (CodeIntegrity::*)(void) const; template using setter_t = void (CodeIntegrity::*)(T); template<> void create(py::module& m) { py::class_(m, "CodeIntegrity") .def(py::init<>()) .def_property("flags", static_cast>(&CodeIntegrity::flags), static_cast>(&CodeIntegrity::flags), "Flags to indicate if CI information is available, etc.") .def_property("catalog", static_cast>(&CodeIntegrity::catalog), static_cast>(&CodeIntegrity::catalog), "``0xFFFF`` means not available") .def_property("catalog_offset", static_cast>(&CodeIntegrity::catalog_offset), static_cast>(&CodeIntegrity::catalog_offset), "") .def_property("reserved", static_cast>(&CodeIntegrity::reserved), static_cast>(&CodeIntegrity::reserved), "Additional bitmask to be defined later") .def("__eq__", &CodeIntegrity::operator==) .def("__ne__", &CodeIntegrity::operator!=) .def("__hash__", [] (const CodeIntegrity& code) { return Hash::hash(code); }) .def("__str__", [] (const CodeIntegrity& code) { std::ostringstream stream; stream << code; std::string str = stream.str(); return str; }); } } }