Skip to content

Commit

Permalink
remove wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Jun 2, 2024
1 parent 1a07d6b commit ab4f8a7
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 28 deletions.
4 changes: 1 addition & 3 deletions src/Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ Result<std::unique_ptr<Handler>> Handler::create(void* address, HandlerMetadata
// .m_convention = metadata.m_convention,
// .m_abstract = metadata.m_abstract,
// };
// TULIP_HOOK_UNWRAP_INTO(auto trampolineWrap, Wrapper::get().createWrapper(ret->m_trampoline, wrapperMetadata));
// ret->m_wrapped = trampolineWrap;
// std::cout << std::hex << "m_trampoline: " << (void*)ret->m_trampoline << std::endl;

return Ok(std::move(ret));
Expand All @@ -46,7 +44,7 @@ Result<> Handler::init() {
// printf("func addr: 0x%" PRIx64 "\n", (uint64_t)m_address);

auto generator =
Target::get().getHandlerGenerator(m_address, m_trampoline, m_handler, m_content, m_wrapped, m_metadata);
Target::get().getHandlerGenerator(m_address, m_trampoline, m_handler, m_content, m_metadata);

TULIP_HOOK_UNWRAP(generator->generateHandler());

Expand Down
2 changes: 0 additions & 2 deletions src/Handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ namespace tulip::hook {
void* m_trampoline = nullptr;
size_t m_trampolineSize = 0;

void* m_wrapped = nullptr;

void* m_handler = nullptr;
size_t m_handlerSize = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/generator/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
using namespace tulip::hook;

HandlerGenerator::HandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) :
m_address(address),
m_trampoline(trampoline),
m_handler(handler),
m_content(content),
m_wrapped(wrapped),
m_metadata(metadata) {}

WrapperGenerator::WrapperGenerator(void* address, WrapperMetadata const& metadata) :
Expand Down
3 changes: 1 addition & 2 deletions src/generator/Generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ namespace tulip::hook {
void* const m_trampoline;
void* const m_handler;
void* const m_content;
void* const m_wrapped;
HandlerMetadata const m_metadata;

HandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
);

virtual ~HandlerGenerator() = default;
Expand Down
4 changes: 2 additions & 2 deletions src/target/MacosIntelTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Result<csh> MacosIntelTarget::openCapstone() {
}

std::unique_ptr<HandlerGenerator> MacosIntelTarget::getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) {
return std::make_unique<X64HandlerGenerator>(address, trampoline, handler, content, wrapped, metadata);
return std::make_unique<X64HandlerGenerator>(address, trampoline, handler, content, metadata);
}

std::unique_ptr<WrapperGenerator> MacosIntelTarget::getWrapperGenerator(void* address, WrapperMetadata const& metadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/MacosIntelTarget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tulip::hook {
Result<csh> openCapstone() override;

std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) override;
std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) override;
};
Expand Down
4 changes: 2 additions & 2 deletions src/target/MacosM1Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Result<csh> MacosM1Target::openCapstone() {
}

std::unique_ptr<HandlerGenerator> MacosM1Target::getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) {
return std::make_unique<ArmV8HandlerGenerator>(address, trampoline, handler, content, wrapped, metadata);
return std::make_unique<ArmV8HandlerGenerator>(address, trampoline, handler, content, metadata);
}

std::unique_ptr<WrapperGenerator> MacosM1Target::getWrapperGenerator(void* address, WrapperMetadata const& metadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/MacosM1Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tulip::hook {
Result<csh> openCapstone() override;

std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) override;
std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) override;
};
Expand Down
4 changes: 2 additions & 2 deletions src/target/PosixArmV7Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Result<csh> PosixArmV7Target::openCapstone() {
}

std::unique_ptr<HandlerGenerator> PosixArmV7Target::getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) {
return std::make_unique<ArmV7HandlerGenerator>(address, trampoline, handler, content, wrapped, metadata);
return std::make_unique<ArmV7HandlerGenerator>(address, trampoline, handler, content, metadata);
}

std::unique_ptr<WrapperGenerator> PosixArmV7Target::getWrapperGenerator(void* address, WrapperMetadata const& metadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/PosixArmV7Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tulip::hook {
Result<csh> openCapstone() override;

std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) override;
std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) override;

Expand Down
4 changes: 2 additions & 2 deletions src/target/PosixArmV8Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Result<csh> PosixArmV8Target::openCapstone() {
}

std::unique_ptr<HandlerGenerator> PosixArmV8Target::getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) {
return std::make_unique<ArmV8HandlerGenerator>(address, trampoline, handler, content, wrapped, metadata);
return std::make_unique<ArmV8HandlerGenerator>(address, trampoline, handler, content, metadata);
}

std::unique_ptr<WrapperGenerator> PosixArmV8Target::getWrapperGenerator(void* address, WrapperMetadata const& metadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/PosixArmV8Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tulip::hook {
Result<csh> openCapstone() override;

std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) override;
std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) override;
};
Expand Down
2 changes: 1 addition & 1 deletion src/target/Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace tulip::hook {
virtual uint32_t getWritableProtection() = 0;

virtual std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) = 0;
virtual std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) = 0;
// sorry :( virtual BaseAssembler* getAssembler(int64_t baseAddress);
Expand Down
4 changes: 2 additions & 2 deletions src/target/Windows32Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ Result<csh> Windows32Target::openCapstone() {
}

std::unique_ptr<HandlerGenerator> Windows32Target::getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) {
return std::make_unique<X86HandlerGenerator>(address, trampoline, handler, content, wrapped, metadata);
return std::make_unique<X86HandlerGenerator>(address, trampoline, handler, content, metadata);
}

std::unique_ptr<WrapperGenerator> Windows32Target::getWrapperGenerator(void* address, WrapperMetadata const& metadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/Windows32Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace tulip::hook {
uint32_t getWritableProtection() override;

std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) override;
std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) override;
};
Expand Down
4 changes: 2 additions & 2 deletions src/target/Windows64Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Result<csh> Windows64Target::openCapstone() {
}

std::unique_ptr<HandlerGenerator> Windows64Target::getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) {
return std::make_unique<X64HandlerGenerator>(address, trampoline, handler, content, wrapped, metadata);
return std::make_unique<X64HandlerGenerator>(address, trampoline, handler, content, metadata);
}

std::unique_ptr<WrapperGenerator> Windows64Target::getWrapperGenerator(void* address, WrapperMetadata const& metadata) {
Expand Down
2 changes: 1 addition & 1 deletion src/target/Windows64Target.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace tulip::hook {
Result<csh> openCapstone() override;

std::unique_ptr<HandlerGenerator> getHandlerGenerator(
void* address, void* trampoline, void* handler, void* content, void* wrapped, HandlerMetadata const& metadata
void* address, void* trampoline, void* handler, void* content, HandlerMetadata const& metadata
) override;
std::unique_ptr<WrapperGenerator> getWrapperGenerator(void* address, WrapperMetadata const& metadata) override;
};
Expand Down

0 comments on commit ab4f8a7

Please sign in to comment.