Add interface to tweak the PE parser (resolve #839)

This commit also removes the Binary's name attribute.
This commit is contained in:
Romain Thomas
2023-04-28 06:14:35 +02:00
parent 227665312b
commit 8908fe4a45
45 changed files with 292 additions and 166 deletions
@@ -128,6 +128,10 @@ void create<Binary>(py::module& m) {
&Binary::has_filesets,
"Return ``True`` if the binary has filesets")
.def_property_readonly("fileset_name",
&Binary::fileset_name,
"Name associated with the LC_FILESET_ENTRY binary")
.def_property_readonly("imagebase",
&Binary::imagebase,
R"delim(
+2 -4
View File
@@ -44,14 +44,13 @@ void create<Parser>(py::module& m) {
m.def("parse",
static_cast<std::unique_ptr<FatBinary> (*) (const std::vector<uint8_t>&, const std::string&, const ParserConfig&)>(&LIEF::MachO::Parser::parse),
static_cast<std::unique_ptr<FatBinary> (*) (const std::vector<uint8_t>&, const ParserConfig&)>(&LIEF::MachO::Parser::parse),
R"delim(
Parse the given binary (from raw bytes) and return a :class:`~lief.MachO.FatBinary` object
One can configure the parsing with the ``config`` parameter. See :class:`~lief.MachO.ParserConfig`
)delim",
"raw"_a,
"name"_a = "",
"config"_a = ParserConfig::quick(),
py::return_value_policy::take_ownership);
@@ -65,7 +64,7 @@ void create<Parser>(py::module& m) {
py::return_value_policy::take_ownership);
m.def("parse",
[] (py::object byteio, std::string name, const ParserConfig& config) -> py::object {
[] (py::object byteio, const ParserConfig& config) -> py::object {
if (auto stream = PyIOStream::from_python(byteio)) {
auto ptr = std::make_unique<PyIOStream>(std::move(*stream));
return py::cast(MachO::Parser::parse(std::move(ptr), config));
@@ -79,7 +78,6 @@ void create<Parser>(py::module& m) {
One can configure the parsing with the ``config`` parameter. See :class:`~lief.MachO.ParserConfig`
)delim",
"io"_a,
"name"_a = "",
"config"_a = ParserConfig::quick(),
py::return_value_policy::take_ownership);
}