Skip to content

Commit

Permalink
v2.0.0. upgrade LIEF.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Oct 19, 2024
1 parent 19dc398 commit c8b32a3
Show file tree
Hide file tree
Showing 2,199 changed files with 123,206 additions and 74,570 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fib-inject",
"version": "1.0.2",
"version": "2.0.0",
"description": "fibjs binding for inject representation and classification.",
"main": "index.js",
"scripts": {
Expand Down
15 changes: 0 additions & 15 deletions src/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,6 @@
#include <LIEF/LIEF.hpp>
#include "LIEF/BinaryStream/SpanStream.hpp"

namespace LIEF {
namespace ELF {
bool is_elf(BinaryStream& stream);
}

namespace PE {
bool is_pe(BinaryStream& stream);
}

namespace MachO {
bool is_macho(BinaryStream& stream);
}

}

Napi::Value get_executable_format(const Napi::CallbackInfo& info)
{
Napi::Env env = info.Env();
Expand Down
17 changes: 8 additions & 9 deletions src/inject_into_elf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Napi::Value inject_into_elf(const Napi::CallbackInfo& info)
}

LIEF::ELF::ARCH machine_type = binary->header().machine_type();
if (machine_type == LIEF::ELF::ARCH::EM_LOONGARCH || machine_type == LIEF::ELF::ARCH::EM_MIPS) {
if (machine_type == LIEF::ELF::ARCH::LOONGARCH || machine_type == LIEF::ELF::ARCH::MIPS) {
result.Set("result", Napi::Number::New(env, InjectResult::kError));
return result;
}
Expand All @@ -52,16 +52,15 @@ Napi::Value inject_into_elf(const Napi::CallbackInfo& info)
}
}

// std::unique_ptr<LIEF::ELF::Note> note = LIEF::ELF::Note::create(note_name, LIEF::ELF::Note::TYPE::UNKNOWN,
// std::vector<uint8_t>(data.Data(), data.Data() + data.ByteLength()));
// binary->add(*note);
std::unique_ptr<LIEF::ELF::Note> note = LIEF::ELF::Note::create(note_name, LIEF::ELF::Note::TYPE::GNU_BUILD_ATTRIBUTE_OPEN,
std::vector<uint8_t>(data.Data(), data.Data() + data.ByteLength()), "");
binary->add(*note);

LIEF::ELF::Note note;
note.name(note_name);
note.description(std::vector<uint8_t>(data.Data(), data.Data() + data.ByteLength()));
binary->add(note);
LIEF::ELF::Builder builder { *binary };
builder.config().notes = true;
builder.build();
std::vector<uint8_t> output = builder.get_build();

std::vector<uint8_t> output = binary->raw();
Napi::Uint8Array output_data = Napi::Uint8Array::New(env, output.size());
std::copy(output.begin(), output.end(), output_data.Data());

Expand Down
6 changes: 2 additions & 4 deletions src/inject_into_macho.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ Napi::Value inject_into_macho(const Napi::CallbackInfo& info)

if (!segment) {
LIEF::MachO::SegmentCommand new_segment(segment_name);
// new_segment.max_protection(static_cast<uint32_t>(LIEF::MachO::SegmentCommand::VM_PROTECTIONS::READ));
// new_segment.init_protection(static_cast<uint32_t>(LIEF::MachO::SegmentCommand::VM_PROTECTIONS::READ));
new_segment.max_protection(static_cast<uint32_t>(LIEF::MachO::VM_PROTECTIONS::VM_PROT_READ));
new_segment.init_protection(static_cast<uint32_t>(LIEF::MachO::VM_PROTECTIONS::VM_PROT_READ));
new_segment.max_protection(static_cast<uint32_t>(LIEF::MachO::SegmentCommand::VM_PROTECTIONS::READ));
new_segment.init_protection(static_cast<uint32_t>(LIEF::MachO::SegmentCommand::VM_PROTECTIONS::READ));
new_segment.add_section(section);
binary.add(new_segment);
} else {
Expand Down
6 changes: 2 additions & 4 deletions src/inject_into_pe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,14 @@ Napi::Value inject_into_pe(const Napi::CallbackInfo& info)
auto rcdata_node_iter = std::find_if(
std::begin(resources->childs()), std::end(resources->childs()),
[](const LIEF::PE::ResourceNode& node) {
// return node.id() == static_cast<uint32_t>(LIEF::PE::ResourcesManager::TYPE::RCDATA);
return node.id() == static_cast<uint32_t>(LIEF::PE::RESOURCE_TYPES::RCDATA);
return node.id() == static_cast<uint32_t>(LIEF::PE::ResourcesManager::TYPE::RCDATA);
});

if (rcdata_node_iter != std::end(resources->childs())) {
rcdata_node = &*rcdata_node_iter;
} else {
LIEF::PE::ResourceDirectory new_rcdata_node;
// new_rcdata_node.id(static_cast<uint32_t>(LIEF::PE::ResourcesManager::TYPE::RCDATA));
new_rcdata_node.id(static_cast<uint32_t>(LIEF::PE::RESOURCE_TYPES::RCDATA));
new_rcdata_node.id(static_cast<uint32_t>(LIEF::PE::ResourcesManager::TYPE::RCDATA));
rcdata_node = &resources->add_child(new_rcdata_node);
}

Expand Down
62 changes: 0 additions & 62 deletions vender/LIEF/.circleci/config.yml

This file was deleted.

35 changes: 0 additions & 35 deletions vender/LIEF/.clang-tidy

This file was deleted.

1 change: 0 additions & 1 deletion vender/LIEF/.dockerignore

This file was deleted.

Loading

0 comments on commit c8b32a3

Please sign in to comment.