refactor(nid): rename spec cpp + move utils

This commit is contained in:
boykopovar 2026-08-21 15:16:25 +03:00
parent c6550929e9
commit 6dfd5a9296
7 changed files with 10 additions and 10 deletions

View File

@ -1,8 +1,8 @@
add_executable(nid_patcher
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/Sha1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/NidCompute.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/ElfPatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/PePatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/ElfNidPatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/PeNidPatcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/BinaryPatcherFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nid/src/main.cpp
)

View File

@ -5,7 +5,7 @@
namespace Nid {
class ElfPatcher final : public IBinaryPatcher {
class ElfNidPatcher final : public IBinaryPatcher {
public:
void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName) const override;
};

View File

@ -5,7 +5,7 @@
namespace Nid {
class PePatcher final : public IBinaryPatcher {
class PeNidPatcher final : public IBinaryPatcher {
public:
void PatchNids(std::vector<std::uint8_t>& binary, const std::string& libraryName) const override;
};

View File

@ -7,9 +7,9 @@ namespace Nid {
std::unique_ptr<IBinaryPatcher> MakePatcher(const std::vector<std::uint8_t>& binary) {
if (binary.size() >= 4 && binary[0] == 0x7f && binary[1] == 'E' && binary[2] == 'L' && binary[3] == 'F')
return std::make_unique<ElfPatcher>();
return std::make_unique<ElfNidPatcher>();
if (binary.size() >= 2 && binary[0] == 'M' && binary[1] == 'Z')
return std::make_unique<PePatcher>();
return std::make_unique<PeNidPatcher>();
throw std::runtime_error("unrecognized binary format");
}

View File

@ -1,6 +1,6 @@
#include <nid/ElfPatcher.hpp>
#include <nid/NidCompute.hpp>
#include "NidPatcherUtils.hpp"
#include "nid/NidPatcherUtils.hpp"
#include <algorithm>
#include <cstdint>
#include <cstring>
@ -57,7 +57,7 @@ constexpr std::uint16_t kShnUndef = 0u;
}
void ElfPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string& libraryName) const {
void ElfNidPatcher::PatchNids(std::vector<std::uint8_t>& elf, const std::string& libraryName) const {
using namespace Internal;
if (elf.size() < sizeof(Elf64_Ehdr)) throw std::runtime_error("file too small");

View File

@ -1,6 +1,6 @@
#include <nid/PePatcher.hpp>
#include <nid/NidCompute.hpp>
#include "NidPatcherUtils.hpp"
#include "nid/NidPatcherUtils.hpp"
#include <algorithm>
#include <cstdint>
#include <cstring>
@ -65,7 +65,7 @@ std::size_t _rvaToOffset(const std::vector<std::uint8_t>& pe, std::uint32_t rva,
}
void PePatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& libraryName) const {
void PeNidPatcher::PatchNids(std::vector<std::uint8_t>& pe, const std::string& libraryName) const {
using namespace Internal;
if (pe.size() < 0x40) throw std::runtime_error("file too small");