Skip to content

Commit

Permalink
remove debug prints
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Jun 2, 2024
1 parent 472f077 commit 76a8541
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 48 deletions.
17 changes: 0 additions & 17 deletions src/Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
#include "target/PlatformTarget.hpp"

#include <algorithm>
#include <sstream>
#include <stack>
#include <iostream>

using namespace tulip::hook;

Expand All @@ -23,19 +21,10 @@ Result<std::unique_ptr<Handler>> Handler::create(void* address, HandlerMetadata
if (!ret->m_content) {
return Err("Failed to allocate HandlerContent");
}
std::cout << std::hex << "m_content: " << (void*)ret->m_content << std::endl;

TULIP_HOOK_UNWRAP_INTO(ret->m_handler, Target::get().allocateArea(0x300));
std::cout << std::hex << "m_handler: " << (void*)ret->m_handler << std::endl;

TULIP_HOOK_UNWRAP_INTO(ret->m_trampoline, Target::get().allocateArea(0x100));

// auto wrapperMetadata = WrapperMetadata{
// .m_convention = metadata.m_convention,
// .m_abstract = metadata.m_abstract,
// };
std::cout << std::hex << "m_trampoline: " << (void*)ret->m_trampoline << std::endl;

return Ok(std::move(ret));
}

Expand All @@ -48,19 +37,15 @@ Result<> Handler::init() {
Target::get().getHandlerGenerator(m_address, m_trampoline, m_handler, m_content, m_metadata);

TULIP_HOOK_UNWRAP(generator->generateHandler());
std::cout << "generate handler" << std::endl;

TULIP_HOOK_UNWRAP_INTO(m_modifiedBytes, generator->generateIntervener());
std::cout << "generate intervener" << std::endl;

auto target = m_modifiedBytes.size();

auto address = reinterpret_cast<uint8_t*>(Target::get().getRealPtr(m_address));
m_originalBytes.insert(m_originalBytes.begin(), address, address + target);
std::cout << "add original bytes" << std::endl;

TULIP_HOOK_UNWRAP(generator->generateTrampoline(target));
std::cout << "generate trampoline" << std::endl;

this->addOriginal();

Expand All @@ -75,7 +60,6 @@ void Handler::addOriginal() {
}

HookHandle Handler::createHook(void* address, HookMetadata m_metadata) {
std::cout << "createHook: " << address << std::endl;
static size_t s_nextHookHandle = 0;
auto hook = HookHandle(++s_nextHookHandle);

Expand Down Expand Up @@ -118,7 +102,6 @@ void Handler::reorderFunctions() {
std::sort(vec.begin(), vec.end(), [this](auto const a, auto const b) {
return (m_hooks.at(m_handles[a])->m_metadata.m_priority < m_hooks.at(m_handles[b])->m_metadata.m_priority);
});
std::cout << "sorted" << std::endl;
}

Result<> Handler::interveneFunction() {
Expand Down
3 changes: 0 additions & 3 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
#include "Pool.hpp"
#include "Wrapper.hpp"
#include "target/PlatformTarget.hpp"
#include <iostream>

#include <TulipHook.hpp>

using namespace tulip::hook;

Result<HandlerHandle> tulip::hook::createHandler(void* address, HandlerMetadata const& metadata) noexcept {
std::cout << "createHandler: " << address << std::endl;
return Pool::get().createHandler(address, metadata);
}

Expand All @@ -19,7 +17,6 @@ Result<> tulip::hook::removeHandler(HandlerHandle const& handler) noexcept {
}

HookHandle tulip::hook::createHook(HandlerHandle const& handler, void* function, HookMetadata const& metadata) noexcept {
std::cout << "createHook: " << function << std::endl;
return Pool::get().getHandler(handler).createHook(function, metadata);
}

Expand Down
2 changes: 0 additions & 2 deletions src/assembler/ArmV7Assembler.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "ArmV7Assembler.hpp"

#include <iostream>

using namespace tulip::hook;

ArmV7Assembler::ArmV7Assembler(int64_t baseAddress) :
Expand Down
1 change: 0 additions & 1 deletion src/convention/Windows32Convention.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <AbstractFunction.hpp>
#include <Platform.hpp>
#include <algorithm>
#include <iostream>
#include <optional>
#include <platform/Windows32Convention.hpp>
#include <variant>
Expand Down
2 changes: 0 additions & 2 deletions src/generator/ArmV7Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <CallingConvention.hpp>
#include <InstructionRelocation/InstructionRelocation.h>
#include <sstream>
#include <iostream>

using namespace tulip::hook;

Expand Down
12 changes: 0 additions & 12 deletions src/generator/X64Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
#include "../target/PlatformTarget.hpp"

#include <CallingConvention.hpp>
#include <sstream>
#include <iostream>

using namespace tulip::hook;

namespace {
void* TULIP_HOOK_DEFAULT_CONV preHandler(HandlerContent* content) {
Handler::incrementIndex(content);
auto ret = Handler::getNextFunction(content);
std::cout << "next function " << ret << std::endl;

return ret;
}

Expand Down Expand Up @@ -384,25 +380,17 @@ Result<> X64HandlerGenerator::generateTrampoline(uint64_t target) {
auto difference = a.currentAddress() - reinterpret_cast<int64_t>(m_address) + 5 - code.m_originalOffset;

if (difference <= 0x7fffffffll && difference >= -0x80000000ll) {
std::cout << "short jmp offset " << code.m_originalOffset << std::endl;
a.jmp(reinterpret_cast<uint64_t>(m_address) + code.m_originalOffset);
}
else {
std::cout << "long jmp offset " << code.m_originalOffset << std::endl;
a.jmpip("handler");

a.label("handler");
a.write64(reinterpret_cast<uint64_t>(m_address) + code.m_originalOffset);
}
// a.int3();

a.updateLabels();

for (auto i = 0; i < a.m_buffer.size(); ++i) {
std::cout << std::hex << (int)a.m_buffer[i] << " ";
}
std::cout << std::endl;

auto codeSize = a.m_buffer.size();
auto areaSize = (codeSize + (0x20 - codeSize) % 0x20);

Expand Down
9 changes: 0 additions & 9 deletions src/generator/X86Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@

#include <CallingConvention.hpp>
#include <capstone/capstone.h>
#include <sstream>
#include <iostream>
#include <iomanip>

using namespace tulip::hook;

namespace {
void* TULIP_HOOK_DEFAULT_CONV preHandler(HandlerContent* content) {
Handler::incrementIndex(content);
auto ret = Handler::getNextFunction(content);
std::cout << "preHandler: " << ret << std::endl;

return ret;
}

Expand Down Expand Up @@ -193,10 +188,6 @@ Result<> X86HandlerGenerator::generateTrampoline(uint64_t target) {
auto codeSize = a.m_buffer.size();
auto areaSize = (codeSize + (0x20 - codeSize) % 0x20);

for (auto i = 0; i < a.m_buffer.size(); ++i) {
std::cout << std::hex << std::setw(2) << (int)a.m_buffer[i] << " ";
}
std::cout << std::endl;

TULIP_HOOK_UNWRAP(Target::get().writeMemory(m_trampoline, a.m_buffer.data(), a.m_buffer.size()));

Expand Down
1 change: 0 additions & 1 deletion src/target/DarwinTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ using namespace tulip::hook;
#include <mach/mach_port.h>
#include <mach/vm_map.h> /* vm_allocate() */
#include <mach/task.h>
#include <iostream>

Result<> DarwinTarget::allocatePage() {
kern_return_t status;
Expand Down
1 change: 0 additions & 1 deletion test/CallingConventions.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <gtest/gtest.h>

#include <array>
#include <iostream>
#include <tulip/TulipHook.hpp>

using namespace tulip::hook;
Expand Down

0 comments on commit 76a8541

Please sign in to comment.