Skip to content

Commit

Permalink
trying something
Browse files Browse the repository at this point in the history
  • Loading branch information
TobyAdd committed Nov 27, 2024
1 parent a38cc97 commit a0ad4cd
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 6 deletions.
47 changes: 43 additions & 4 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "config.hpp"
#include <matjson.hpp>
#include "hacks.hpp"
#include "memory.hpp"

std::chrono::steady_clock::time_point animationStartTime;
bool isAnimating = false;
Expand Down Expand Up @@ -153,8 +154,46 @@ void Gui::Render() {
ApplyGuiColors(!inverted);
}
}
else if (windowName == "Variables") {
// ImGui::Button("ff");
else if (windowName == "Framerate") {
bool tps_enabled = config.get<bool>("tps_enabled", false);
float tps_value = config.get<float>("tps_value", 240.f);

ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (35 + 5) * m_scale);
if (ImGui::DragFloat("##tps_value", &tps_value, 1, 1, FLT_MAX, "%0.f TPS"))
config.set<float>("tps_value", tps_value);

ImGui::SameLine();
if (ImGuiH::Checkbox("##tps_enabled", &tps_enabled, m_scale))
config.set<bool>("tps_enabled", tps_enabled);

bool speedhack_enabled = config.get<bool>("speedhack_enabled", false);
float speedhack_value = config.get<float>("speedhack_value", 1.f);

bool speedhackAudio_enabled = config.get<bool>("speedhackAudio_enabled", false);

ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (35 + 5) * m_scale);
if (ImGui::DragFloat("##speedhack_value", &speedhack_value, 0.01f, 0, FLT_MAX, "Speed: %.2fx"))
config.set<float>("speedhack_value", speedhack_value);

ImGui::SameLine();
if (ImGuiH::Checkbox("##speedhack_enabled", &speedhack_enabled, m_scale))
config.set<bool>("speedhack_enabled", speedhack_enabled);

if (ImGuiH::Checkbox("Speedhack Audio", &speedhackAudio_enabled, m_scale))
config.set<bool>("speedhackAudio_enabled", speedhackAudio_enabled);
}
else if (windowName == "Variables") {
static uintptr_t address = geode::base::get();
ImGui::Text("%s", fmt::format("{:x} ({:x})", address, address - geode::base::get()).c_str());

if (ImGui::Button("scan"))
address = memory::PatternScan(address+1, 0, "00 60 6A 48");

if (ImGui::Button("scan2"))
address = memory::PatternScan(address+1, 0, "80 67 6A 48");

if (ImGui::Button("reset"))
address = geode::base::get();
}
else {
for (auto& hck : win.hacks) {
Expand All @@ -173,7 +212,7 @@ void Gui::Render() {
config.set(hck.config, enabled);
if (!hck.game_var.empty())
GameManager::get()->setGameVariable(hck.game_var.c_str(), enabled);
hck.handlerFunc(enabled);
if (hck.handlerFunc) hck.handlerFunc(enabled);
}

if (ImGui::IsItemHovered() && !hck.desc.empty()) {
Expand All @@ -187,7 +226,7 @@ void Gui::Render() {
}

if (ImGui::BeginPopupModal(fmt::format("{} Settings", hck.name).c_str(), NULL, ImGuiWindowFlags_AlwaysAutoResize)) {
if (hck.handlerCustomWindow) hck.handlerCustomWindow();
hck.handlerCustomWindow();

if (ImGui::Button("Close", {400 * m_scale, NULL})) {
ImGui::CloseCurrentPopup();
Expand Down
20 changes: 18 additions & 2 deletions src/hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void Hacks::Init() {
{"Copy Hack", "Copy any online level without a password", "copy_hack"}, // +
{"Custom Object Bypass", "Removes the limit restricted to 1000 objects", "custom_object_bypass"},
{"Default Song Bypass", "Removes restrictions on secret official songs", "default_song_bypass"}, // +
// {"Scale Snap Bypass", "Removes the slider snapping when stretched from 0.97 to 1.03", "scale_snap_bypass"},
{"Editor Extension", "", "editor_extension"},
{"Verify Hack", "Publish a level without verification", "verify_hack"}, // +
{"Smooth Editor Trail", "Makes the wave smoother in the editor", "smooth_editor_trail"}, // +
{"Level Edit", "Edit any online level", "level_edit"}, // +
Expand Down Expand Up @@ -125,6 +125,22 @@ void Hacks::Init() {
if (patch3) (void) patch1->disable();
}
});

SetHandlerByConfig("editor_extension", [this](bool enabled) {
static auto result1 = geode::Mod::get()->patch((void*)(geode::base::get() + 0x607ca0), {0x00, 0x60, 0xEA, 0x4B});
static auto patch1 = result1.isErr() ? nullptr : result1.unwrap();

static auto result2 = geode::Mod::get()->patch((void*)(geode::base::get() + 0x607ca4), {0x00, 0x60, 0xEA, 0x4B});
static auto patch2 = result1.isErr() ? nullptr : result2.unwrap();

if (enabled) {
if (patch1) (void) patch1->enable();
if (patch2) (void) patch2->enable();
} else {
if (patch1) (void) patch1->disable();
if (patch2) (void) patch2->disable();
}
});
#endif

SetHandlerByConfig("hide_pause_menu", [this](bool enabled) {
Expand Down Expand Up @@ -182,7 +198,7 @@ void Hacks::Init() {

for (auto& hck : win.hacks) {
if (!hck.game_var.empty()) config.set<bool>(hck.config, GameManager::get()->getGameVariable(hck.game_var.c_str()));
if (hck.handlerFunc) hck.handlerFunc(true);
if (config.get<bool>(hck.config, false) && hck.handlerFunc) hck.handlerFunc(true);
}
}
}
46 changes: 46 additions & 0 deletions src/memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include "memory.hpp"

struct PatternByte {
bool isWildcard;
uint8_t value;
};

uintptr_t memory::PatternScan(uintptr_t base, uintptr_t scanSize, const std::string signature) {
std::vector<PatternByte> patternData;

for (size_t i = 0; i < signature.size(); ++i) {
if (signature[i] == ' ') {
continue;
}

if (signature[i] == '?') {
patternData.push_back({ true, 0 });
}
else {
std::string byteStr = signature.substr(i, 2);
patternData.push_back({ false, static_cast<uint8_t>(std::stoul(byteStr, nullptr, 16)) });
i++;
}
}

for (uintptr_t i = base; /*i < base + scanSize*/; ++i) {
bool found = true;

for (size_t j = 0; j < patternData.size(); ++j) {
if (patternData[j].isWildcard) {
continue;
}

if (patternData[j].value != *reinterpret_cast<uint8_t*>(i + j)) {
found = false;
break;
}
}

if (found) {
return i;
}
}

return 0;
}
9 changes: 9 additions & 0 deletions src/memory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include <fstream>
#include <streambuf>
#include <vector>
#include <sstream>

namespace memory {
uintptr_t PatternScan(uintptr_t base, uintptr_t scanSize, const std::string signature);
}

0 comments on commit a0ad4cd

Please sign in to comment.