Skip to content

Instantly share code, notes, and snippets.

@kohnakagawa
Created January 3, 2019 10:42
Show Gist options
  • Save kohnakagawa/65e0f596f3e6a6766ea947a047d52561 to your computer and use it in GitHub Desktop.
Save kohnakagawa/65e0f596f3e6a6766ea947a047d52561 to your computer and use it in GitHub Desktop.
LIEFのC++バインディングの例
#include <iostream>
#include <fstream>
#include <memory>
#include <LIEF/LIEF.hpp>
int main() {
const size_t size = 245761;
std::ifstream fin("/mnt/c/Windows/System32/notepad.exe", std::ios::binary);
std::vector<uint8_t> buffer(size);
fin.read((char*)buffer.data(), size);
std::unique_ptr<LIEF::PE::Binary> pe{LIEF::PE::Parser::parse(buffer)};
for (const auto& section : pe->sections()) {
std::cout << section.name() << std::endl;
const auto& content = section.content();
std::cout << std::hex;
std::cout << (int)content[0] << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment