Skip to content

Commit

Permalink
hotfix for missing patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed May 27, 2024
1 parent 8dd2e7d commit f0cc2cd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 18 deletions.
20 changes: 17 additions & 3 deletions search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
// RE:
"warp"sv,
PatternCommandBuffer{}
.set_optional(true)
.find_inst("4c 8d 6e 28 8a 86 1d 6b 02 00"_gh)
.offset(12)
.at_exe(),
Expand All @@ -485,6 +486,7 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
// RE: It's a call to GetKeyboardState...
"keyboard"sv,
PatternCommandBuffer{}
.set_optional(true)
.find_after_inst(
"0f 11 .. .. .. .. .. 0f 11 .. .. .. .. .. .. 89 .."_gh)
.at_exe(),
Expand Down Expand Up @@ -514,6 +516,7 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
// RE: take damage, this one just subs hearts
"damage"sv,
PatternCommandBuffer{}
.set_optional(true)
.find_after_inst(
"c7 46 7c 00 00 00 00 c7 46 6c 00 00 00 00 8a 86 90 00 00 00"_gh)
.at_exe(),
Expand All @@ -522,6 +525,7 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
// RE: take damage, this skips the whole if (jne -> jmp)
"god"sv,
PatternCommandBuffer{}
.set_optional(true)
.find_after_inst("80 be 90 00 00 00 00 48 8b 7c 24 48"_gh)
.at_exe(),
},
Expand All @@ -540,19 +544,29 @@ std::unordered_map<std::string_view, AddressRule> g_address_rules{
},
{
// RE: L"Visibility", 7E -> EB
"darkness"sv, PatternCommandBuffer{}.from_exe_base(0x12ae73), // TODO
"darkness"sv,
PatternCommandBuffer{}.set_optional(true).from_exe_base(
0x12ae73), // TODO
},
{
// RE: L"Visibility", 7F 0E -> EB 0E
"gameboy"sv, PatternCommandBuffer{}.from_exe_base(0x12c11a), // TODO
"gameboy"sv,
PatternCommandBuffer{}.set_optional(true).from_exe_base(
0x12c11a), // TODO
},
{
// RE: L"Visibility", 7E 19 -> EB 19
"hud"sv, PatternCommandBuffer{}.from_exe_base(0x12c40d), // TODO
"hud"sv,
PatternCommandBuffer{}.set_optional(true).from_exe_base(
0x12c40d), // TODO
},
};
std::unordered_map<std::string_view, size_t> g_cached_addresses;

std::unordered_map<std::string_view, size_t> &get_addresses() {
return g_cached_addresses;
}

void preload_addresses() {
Memory mem = Memory::get();
const char *exe = mem.exe();
Expand Down
2 changes: 2 additions & 0 deletions search.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional> // for optional, nullopt
#include <string> // for string
#include <string_view> // for operator""sv, string_view, string_view_literals
#include <unordered_map>

using namespace std::string_view_literals;

Expand All @@ -28,3 +29,4 @@ void preload_addresses();
size_t get_address(std::string_view address_name);

void register_application_version(std::string s);
std::unordered_map<std::string_view, size_t> &get_addresses();
54 changes: 39 additions & 15 deletions ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void UI::DrawPlayer() {
ImGui::PopItemWidth();
}

// TODO: Option to hilight important overlapping other world rooms
void UI::DrawMap() {
ImGuiIO &io = ImGui::GetIO();
static const ImVec2 realmapsize{800, 528};
Expand Down Expand Up @@ -326,14 +327,16 @@ UI::UI() {
[this]() { this->DrawOptions(); });
NewWindow("Debug", ImGuiKey_None, 0, [this]() {
ImGuiIO &io = ImGui::GetIO();
ImGui::Text("Check: %p", get_address("check"));
ImGui::Text("State: %p", Max::get().state());
ImGui::Text("Map: %p", Max::get().minimap());
ImGui::Text("Slots: %p", get_address("slots"));
ImGui::Text("Slot: %p", Max::get().slot());
ImGui::Text("Layer: %p", get_address("layer_base"));
ImGui::Text("Layer: %p", get_address("layer_offset"));
ImGui::Text("Options: %p", Max::get().options());
ImGui::SeparatorText("Patterns");
for (auto &[name, addr] : get_addresses()) {
if (!addr)
ImGui::PushStyleColor(ImGuiCol_Text, 0xff0000ff);
ImGui::InputScalar(name.data(), ImGuiDataType_U64, &addr, NULL, NULL,
"%p", ImGuiInputTextFlags_ReadOnly);
if (!addr)
ImGui::PopStyleColor();
}

if (!this->inMenu) {
ImGui::ShowDemoWindow();
ImGui::ShowMetricsWindow();
Expand Down Expand Up @@ -479,13 +482,13 @@ void UI::Draw() {
}
}

if (doWarp) {
if (doWarp && get_address("warp")) {
write_mem_recoverable("warp", get_address("warp"), "\xEB"sv, true);
} else {
recover_mem("warp");
}

if (options["input_block"].value) {
if (options["input_block"].value && get_address("keyboard")) {
if (Block()) {
write_mem_recoverable("block", get_address("keyboard"), get_nop(6), true);
} else {
Expand All @@ -495,33 +498,33 @@ void UI::Draw() {
recover_mem("block");
}

if (options["cheat_damage"].value) {
if (options["cheat_damage"].value && get_address("damage")) {
write_mem_recoverable("damage", get_address("damage"), get_nop(6), true);
} else {
recover_mem("damage");
}

if (options["cheat_godmode"].value) {
if (options["cheat_godmode"].value && get_address("god")) {
write_mem_recoverable("god", get_address("god"), "E9 79 01 00 00 90"_gh,
true);
} else {
recover_mem("god");
}

if (options["cheat_darkness"].value) {
if (options["cheat_darkness"].value && get_address("darkness")) {
write_mem_recoverable("darkness", get_address("darkness"), "\xEB\x19",
true);
} else {
recover_mem("darkness");
}

if (options["cheat_gameboy"].value) {
if (options["cheat_gameboy"].value && get_address("gameboy")) {
write_mem_recoverable("gameboy", get_address("gameboy"), "\xEB\x0E", true);
} else {
recover_mem("gameboy");
}

if (options["cheat_hud"].value) {
if (options["cheat_hud"].value && get_address("hud")) {
write_mem_recoverable("hud", get_address("hud"), "\xEB\x19", true);
} else {
recover_mem("hud");
Expand Down Expand Up @@ -764,3 +767,24 @@ void UI::LoadINI(std::string file) {
windowScale = toml::find_or<int>(opts, "scale", 4);
SaveINI(file);
}

void UI::Shot() {
/*m_screenshot = m_deviceResources->GetRenderTarget();
m_deviceResources->Present();
if (m_screenshot)
{
DX::ThrowIfFailed(
SaveDDSTextureToFile(m_deviceResources->GetCommandQueue(),
m_screenshot.Get(), L"screenshot.dds", D3D12_RESOURCE_STATE_PRESENT,
D3D12_RESOURCE_STATE_PRESENT)
);
DX::ThrowIfFailed(
SaveWICTextureToFile(m_deviceResources->GetCommandQueue(),
m_screenshot.Get(), GUID_ContainerFormatJpeg, L"screenshot.jpg",
D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_PRESENT)
);
} */
}
1 change: 1 addition & 0 deletions ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class UI {
void SaveINI(std::string file);
void LoadINI(std::string file);
void ScaleWindow();
void Shot();

HWND hWnd;
ID3D12Device *pD3DDevice = NULL;
Expand Down

0 comments on commit f0cc2cd

Please sign in to comment.