forked from IDontCode/Theodosius
parent
e028a5877b
commit
dd78f5309a
@ -1,3 +1,5 @@
|
|||||||
[target.linux-pe]
|
[target.linux-pe]
|
||||||
type = "interface"
|
type = "interface"
|
||||||
include-directories = ["linux-pe/includes/"]
|
include-directories = ["linux-pe/includes/"]
|
||||||
|
|
||||||
|
[subdir.spdlog]
|
@ -0,0 +1 @@
|
|||||||
|
Subproject commit fc51c095bae108490bf62c3345a5e3b37a5e7630
|
@ -1,3 +1,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <comp/comp.hpp>
|
#include <comp/comp.hpp>
|
||||||
#include <decomp/decomp.hpp>
|
#include <decomp/decomp.hpp>
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace theo {
|
||||||
|
using lnk_fns_t =
|
||||||
|
std::tuple<comp::allocator_t, comp::copier_t, comp::resolver_t>;
|
||||||
|
|
||||||
|
class theo_t {
|
||||||
|
public:
|
||||||
|
explicit theo_t(
|
||||||
|
std::vector<std::uint8_t>& lib, lnk_fns_t lnkr_fns);
|
||||||
|
|
||||||
|
std::optional<std::uint32_t> decompose();
|
||||||
|
std::uintptr_t compose(const std::string&& entry_sym);
|
||||||
|
std::uintptr_t resolve(const std::string&& sym);
|
||||||
|
private:
|
||||||
|
decomp::decomp_t m_dcmp;
|
||||||
|
comp::comp_t m_cmp;
|
||||||
|
comp::symbol_table_t m_sym_tbl;
|
||||||
|
};
|
||||||
|
} // namespace theo
|
@ -0,0 +1,33 @@
|
|||||||
|
#include <Windows.h>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <theo.hpp>
|
||||||
|
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
spdlog::info("this is info...");
|
||||||
|
spdlog::error("this is an error...");
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// read in lib file...
|
||||||
|
std::ifstream f(argv[1], std::ios::binary);
|
||||||
|
auto fsize = fs::file_size(fs::path(argv[1]));
|
||||||
|
std::vector<std::uint8_t> fdata;
|
||||||
|
fdata.resize(fsize);
|
||||||
|
f.read((char*)fdata.data(), fsize);
|
||||||
|
|
||||||
|
theo::theo_t t(fdata, {});
|
||||||
|
auto res = t.decompose();
|
||||||
|
|
||||||
|
if (!res.has_value()) {
|
||||||
|
spdlog::error("decomposition failed...\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
spdlog::info("decomposed {1} symbols...", res.value());
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
#include <theo.hpp>
|
||||||
|
|
||||||
|
namespace theo {
|
||||||
|
theo_t::theo_t(std::vector<std::uint8_t>& lib, lnk_fns_t lnkr_fns)
|
||||||
|
: m_dcmp(lib, &m_sym_tbl), m_cmp(&m_dcmp) {}
|
||||||
|
|
||||||
|
std::optional<std::uint32_t> theo_t::decompose() {
|
||||||
|
auto res = m_dcmp.decompose();
|
||||||
|
|
||||||
|
if (!res.has_value()) {
|
||||||
|
spdlog::error("failed to decompose...\n");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
spdlog::info("decompose successful... {1} symbols", res.value()->size());
|
||||||
|
return res.value()->size();
|
||||||
|
}
|
||||||
|
} // namespace theo
|
Loading…
Reference in new issue