Created
January 3, 2019 10:42
-
-
Save kohnakagawa/65e0f596f3e6a6766ea947a047d52561 to your computer and use it in GitHub Desktop.
LIEFのC++バインディングの例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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