loader [skip ci]

This commit is contained in:
Skull Merlin 2022-03-18 02:54:50 +02:00
parent 1ed4f717f6
commit 34b2fcd4cc
2 changed files with 3 additions and 6 deletions

View File

@ -31,7 +31,7 @@ FARPROC loader::load(const utils::nt::library& library, const std::string& buffe
return FARPROC(library.get_ptr() + source.get_relative_entry_point()); return FARPROC(library.get_ptr() + source.get_relative_entry_point());
} }
FARPROC loader::load_library(const std::string& filename) const FARPROC loader::load_library(const std::string& filename, uint64_t* base_address) const
{ {
const auto target = utils::nt::library::load(filename); const auto target = utils::nt::library::load(filename);
if (!target) if (!target)
@ -40,10 +40,7 @@ FARPROC loader::load_library(const std::string& filename) const
} }
const auto base = size_t(target.get_ptr()); const auto base = size_t(target.get_ptr());
if(base != 0x140000000) *base_address = base;
{
throw std::runtime_error{utils::string::va("Binary was mapped at 0x%llX (instead of 0x%llX). Something is severely broken :(", base, 0x140000000)};
}
this->load_imports(target, target); this->load_imports(target, target);
this->load_tls(target, target); this->load_tls(target, target);

View File

@ -5,7 +5,7 @@ class loader final
{ {
public: public:
FARPROC load(const utils::nt::library& library, const std::string& buffer) const; FARPROC load(const utils::nt::library& library, const std::string& buffer) const;
FARPROC load_library(const std::string& filename) const; FARPROC load_library(const std::string& filename, uint64_t* base_address) const;
void set_import_resolver(const std::function<void*(const std::string&, const std::string&)>& resolver); void set_import_resolver(const std::function<void*(const std::string&, const std::string&)>& resolver);