MCPcopy Create free account
hub / github.com/lief-project/LIEF / init_utils

Function init_utils

api/python/src/MachO/pyUtils.cpp:29–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace LIEF::MachO::py {
28
29void init_utils(nb::module_& m) {
30 lief_mod->def("is_macho",
31 [] (nb::PathLike path) { return is_macho(path); },
32 "Check if the given file is a ``MachO`` (from filename)"_doc,
33 "filename"_a
34 );
35
36 lief_mod->def("is_macho",
37 nb::overload_cast<const std::vector<uint8_t>&>(&is_macho),
38 "Check if the given raw data is a ``MachO``"_doc,
39 "raw"_a
40 );
41
42 m.def("is_fat",
43 [] (nb::PathLike path) { return is_fat(path); },
44 "Check if the given Mach-O is fat"_doc,
45 "file"_a
46 );
47
48 m.def("is_64",
49 [] (nb::PathLike path) { return is_64(path); },
50 "Check if the given Mach-O is 64-bits"_doc,
51 "file"_a
52 );
53
54 m.def("check_layout",
55 [] (const Binary& bin) {
56 std::string on_error;
57 const bool is_valid = check_layout(bin, &on_error);
58 return std::pair<bool, std::string>{is_valid, on_error};
59 },
60 "Check the layout of the given Mach-O binary. It checks if it can be signed "
61 "according to ``cctools-921/libstuff/checkout.c``"_doc,
62 "file"_a
63 );
64
65 m.def("check_layout",
66 [] (const FatBinary& bin) {
67 std::string on_error;
68 const bool is_valid = check_layout(bin, &on_error);
69 return std::pair<bool, std::string>{is_valid, on_error};
70 },
71 R"delim(
72 Check the layout of the given FAT Mach-O by checking individually the layout
73 of the binaries embedded in the FAT.
74 )delim"_doc, "file"_a);
75}
76}

Callers 1

initFunction · 0.70

Calls 4

is_fatFunction · 0.85
is_machoFunction · 0.50
is_64Function · 0.50
check_layoutFunction · 0.50

Tested by

no test coverage detected