Skip to content

Commit

Permalink
jump back complete
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvita committed Jan 14, 2021
1 parent 3866cb9 commit 4ce09a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
4 changes: 3 additions & 1 deletion include/guis/gui_cheats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class GuiCheats : public Gui
std::stringstream m_PCAttr_filename;
std::stringstream m_PCDumpM_filename;
std::stringstream m_PCDumpR_filename;

void PCdump();
enum MemoryType
{
Expand Down Expand Up @@ -354,6 +354,8 @@ class GuiCheats : public Gui
MemoryDump **displayDump, std::vector<MemoryInfo> memInfos);

void prep_pointersearch(Debugger *debugger, std::vector<MemoryInfo> memInfos);

u32 get_main_offset32(u32 address);

void refresh_fromto();

Expand Down
41 changes: 35 additions & 6 deletions source/guis/gui_cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,10 @@ void GuiCheats::drawSEARCH_pickjump()
Gui::drawTextAligned(font20, c1, 160 + linegape * (1 + i), cellColor, ss.str().c_str(), ALIGNED_CENTER);

ss.str("");
ss << std::uppercase << std::hex << std::setfill('0') << std::setw(10) << m_heapBaseAddr + m_fromto32[i + m_fromto32_offset].from;
if (m_fromto32[i + m_fromto32_offset].from == 0)
ss << "Main+" << std::uppercase << std::hex << std::setfill('0') << std::setw(8) << get_main_offset32(m_fromto32[i + m_fromto32_offset].to);
else
ss << std::uppercase << std::hex << std::setfill('0') << std::setw(10) << m_heapBaseAddr + m_fromto32[i + m_fromto32_offset].from;
Gui::drawTextAligned(font20, c3, 160 + linegape * (1 + i), cellColor, ss.str().c_str(), ALIGNED_CENTER);

ss.str("");
Expand Down Expand Up @@ -3065,10 +3068,7 @@ void GuiCheats::pickjump_input(u32 kdown, u32 kheld)
{
m_searchMenuLocation = SEARCH_editRAM2;
u64 m_pick = m_selectedJumpSource + m_fromto32_offset;
if (m_fromto32[m_pick].from == 0)
{
// Need to get main
}
// u64 address = (m_EditorBaseAddr - (m_EditorBaseAddr % 16) - 0x20 + (m_selectedEntry - 1 - (m_selectedEntry / 5)) * 4 + m_addressmod);
if (m_z == 0)
m_bookmark.pointer.offset[m_z] = (m_EditorBaseAddr - (m_EditorBaseAddr % 16) - 0x20 + (m_selectedEntry - 1 - (m_selectedEntry / 5)) * 4 + m_addressmod) - (m_fromto32[m_pick].to + m_heapBaseAddr) ;
Expand All @@ -3078,7 +3078,12 @@ void GuiCheats::pickjump_input(u32 kdown, u32 kheld)
// printf("m_jump_stack[m_z].from %lx - (m_fromto32[m_pick].to + m_heapBaseAddr) %lx \n",m_jump_stack[m_z].from, (m_fromto32[m_pick].to + m_heapBaseAddr));
}
m_z++;
m_jump_stack[m_z].from = m_fromto32[m_pick].from + m_heapBaseAddr;
if (m_fromto32[m_pick].from == 0)
{
m_jump_stack[m_z].from = get_main_offset32(m_fromto32[m_pick].to) + m_mainBaseAddr;
}
else
m_jump_stack[m_z].from = m_fromto32[m_pick].from + m_heapBaseAddr;
m_jump_stack[m_z].to = m_fromto32[m_pick].to + m_heapBaseAddr;
m_EditorBaseAddr = m_jump_stack[m_z].from;
m_selectedEntry = (m_EditorBaseAddr % 16) / 4 + 11;
Expand Down Expand Up @@ -8819,14 +8824,38 @@ void GuiCheats::prep_pointersearch(Debugger *debugger, std::vector<MemoryInfo> m
m_PC_Dump = PCDump;
PCDumpM->flushBuffer();
// delete PCDumpM;
PCDumpM = PCDumpM;
m_PC_DumpM = PCDumpM;
PCAttr->flushBuffer();
delete PCAttr;
dmntchtResumeCheatProcess();
Gui::g_currMessageBox->hide();
}


u32 GuiCheats::get_main_offset32(u32 address)
{
u32 offset = 0;
if (m_PC_DumpM == nullptr)
{
printf("m_PC_DumpM == nullptr \n");
return offset;
}
u64 bufferSize = m_PC_DumpM->size();
// printf("m_PC_DumpM->size() %lx\n",m_PC_DumpM->size());
u8 *buffer = new u8[bufferSize];
m_PC_DumpM->getData(0, buffer, bufferSize);
for (u64 i = 0; i < bufferSize; i += sizeof(fromto32_t))
{
if (address == *reinterpret_cast<u32 *>(&buffer[i] + 4))
{
offset = *reinterpret_cast<u32 *>(&buffer[i]);
printf("Main offset = %x for heap offset = %x\n", offset, address);
};
}
delete[] buffer;
return offset;
}

void GuiCheats::refresh_fromto()
{
return;
Expand Down

0 comments on commit 4ce09a4

Please sign in to comment.