diff --git a/search.cpp b/search.cpp index 1e985f0..76ce76e 100644 --- a/search.cpp +++ b/search.cpp @@ -477,6 +477,7 @@ std::unordered_map 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(), @@ -485,6 +486,7 @@ std::unordered_map 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(), @@ -514,6 +516,7 @@ std::unordered_map 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(), @@ -522,6 +525,7 @@ std::unordered_map 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(), }, @@ -540,19 +544,29 @@ std::unordered_map 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 g_cached_addresses; +std::unordered_map &get_addresses() { + return g_cached_addresses; +} + void preload_addresses() { Memory mem = Memory::get(); const char *exe = mem.exe(); diff --git a/search.h b/search.h index 5cade76..1f8e35c 100644 --- a/search.h +++ b/search.h @@ -5,6 +5,7 @@ #include // for optional, nullopt #include // for string #include // for operator""sv, string_view, string_view_literals +#include using namespace std::string_view_literals; @@ -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 &get_addresses(); diff --git a/ui.cpp b/ui.cpp index 4275d04..7c788ae 100644 --- a/ui.cpp +++ b/ui.cpp @@ -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}; @@ -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(); @@ -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 { @@ -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"); @@ -764,3 +767,24 @@ void UI::LoadINI(std::string file) { windowScale = toml::find_or(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) + ); + } */ +} diff --git a/ui.h b/ui.h index 979b799..9e414ed 100644 --- a/ui.h +++ b/ui.h @@ -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;