work again with heapless processes, and show wether you're currently viewing heap or code on screen (apart from the address)
This commit is contained in:
parent
65af93c8ce
commit
37a9fa1bf4
@ -225,7 +225,10 @@ static void ProcessListMenu_MemoryViewer(const ProcessInfo *info)
|
|||||||
Result codeRes = svcMapProcessMemoryEx(processHandle, codeDestAddress, codeStartAddress, codeTotalSize);
|
Result codeRes = svcMapProcessMemoryEx(processHandle, codeDestAddress, codeStartAddress, codeTotalSize);
|
||||||
Result heapRes = svcMapProcessMemoryEx(processHandle, heapDestAddress, heapStartAddress, heapTotalSize);
|
Result heapRes = svcMapProcessMemoryEx(processHandle, heapDestAddress, heapStartAddress, heapTotalSize);
|
||||||
|
|
||||||
if(R_SUCCEEDED(codeRes | heapRes))
|
bool codeAvailable = R_SUCCEEDED(codeRes);
|
||||||
|
bool heapAvailable = R_SUCCEEDED(heapRes);
|
||||||
|
|
||||||
|
if(codeAvailable || heapAvailable)
|
||||||
{
|
{
|
||||||
#define ROWS_PER_SCREEN 0x10
|
#define ROWS_PER_SCREEN 0x10
|
||||||
#define BYTES_PER_ROW 0x10
|
#define BYTES_PER_ROW 0x10
|
||||||
@ -297,18 +300,23 @@ static void ProcessListMenu_MemoryViewer(const ProcessInfo *info)
|
|||||||
// Viewing
|
// Viewing
|
||||||
void viewHeap(void)
|
void viewHeap(void)
|
||||||
{
|
{
|
||||||
|
if(!heapAvailable) return;
|
||||||
menus[MENU_MODE_NORMAL].selected = 0;
|
menus[MENU_MODE_NORMAL].selected = 0;
|
||||||
menus[MENU_MODE_NORMAL].buf = (u8*)heapDestAddress;
|
menus[MENU_MODE_NORMAL].buf = (u8*)heapDestAddress;
|
||||||
menus[MENU_MODE_NORMAL].max = heapTotalSize;
|
menus[MENU_MODE_NORMAL].max = heapTotalSize;
|
||||||
}
|
}
|
||||||
void viewCode(void)
|
void viewCode(void)
|
||||||
{
|
{
|
||||||
|
if(!codeAvailable) return;
|
||||||
menus[MENU_MODE_NORMAL].selected = 0;
|
menus[MENU_MODE_NORMAL].selected = 0;
|
||||||
menus[MENU_MODE_NORMAL].buf = (u8*)codeDestAddress;
|
menus[MENU_MODE_NORMAL].buf = (u8*)codeDestAddress;
|
||||||
menus[MENU_MODE_NORMAL].max = codeTotalSize;
|
menus[MENU_MODE_NORMAL].max = codeTotalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewHeap();
|
if(heapAvailable)
|
||||||
|
viewHeap();
|
||||||
|
else
|
||||||
|
viewCode();
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
|
|
||||||
// Jumping
|
// Jumping
|
||||||
@ -359,27 +367,47 @@ static void ProcessListMenu_MemoryViewer(const ProcessInfo *info)
|
|||||||
{
|
{
|
||||||
Draw_Lock();
|
Draw_Lock();
|
||||||
Draw_DrawString(10, 10, COLOR_TITLE, "Memory viewer");
|
Draw_DrawString(10, 10, COLOR_TITLE, "Memory viewer");
|
||||||
Draw_DrawString(10, 30, COLOR_WHITE, "D-PAD to move, X to jump, Y to search, A to edit.");
|
|
||||||
|
// Instructions
|
||||||
|
const u32 instructionsY = 30;
|
||||||
|
u32 viewerY = instructionsY + SPACING_Y + 6;
|
||||||
|
Draw_DrawString(10, instructionsY, COLOR_WHITE, "D-PAD to move, X to jump, Y to search, A to edit.");
|
||||||
|
|
||||||
|
switch(menuMode)
|
||||||
|
{
|
||||||
|
case MENU_MODE_NORMAL:
|
||||||
|
Draw_DrawString(10 + SPACING_X * 9, instructionsY, COLOR_GREEN, "move");
|
||||||
|
break;
|
||||||
|
case MENU_MODE_GOTO:
|
||||||
|
Draw_DrawString(10 + SPACING_X * 20, instructionsY, COLOR_GREEN, "jump");
|
||||||
|
break;
|
||||||
|
case MENU_MODE_SEARCH:
|
||||||
|
Draw_DrawString(10 + SPACING_X * 31, instructionsY, COLOR_GREEN, "search");
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
if(editing)
|
if(editing)
|
||||||
Draw_DrawString(10 + SPACING_X* 44, 30, COLOR_RED, "edit");
|
Draw_DrawString(10 + SPACING_X * 44, instructionsY, COLOR_RED, "edit");
|
||||||
|
// ------------------------------------------
|
||||||
|
|
||||||
char * modeStr[] = {
|
// Location
|
||||||
"move",
|
if(codeAvailable && heapAvailable)
|
||||||
"jump",
|
{
|
||||||
"search",
|
const u32 infoY = instructionsY + SPACING_Y;
|
||||||
};
|
viewerY += SPACING_Y;
|
||||||
u32 modeStrPos[] = {
|
Draw_DrawString(10, infoY, COLOR_WHITE, "Press L or R to switch between heap and code.");
|
||||||
9,
|
if((u32)menus[MENU_MODE_NORMAL].buf == heapDestAddress)
|
||||||
20,
|
Draw_DrawString(10 + SPACING_X * 31, infoY, COLOR_GREEN, "heap");
|
||||||
31,
|
if((u32)menus[MENU_MODE_NORMAL].buf == codeDestAddress)
|
||||||
};
|
Draw_DrawString(10 + SPACING_X * 40, infoY, COLOR_GREEN, "code");
|
||||||
Draw_DrawString(10 + SPACING_X*modeStrPos[menuMode], 30, COLOR_GREEN, modeStr[menuMode]);
|
}
|
||||||
|
// ------------------------------------------
|
||||||
|
|
||||||
for(u32 row = menus[menuMode].starti; row < (menus[menuMode].starti + ROWS_PER_SCREEN); row++)
|
for(u32 row = menus[menuMode].starti; row < (menus[menuMode].starti + ROWS_PER_SCREEN); row++)
|
||||||
{
|
{
|
||||||
u32 offset = row - menus[menuMode].starti;
|
u32 offset = row - menus[menuMode].starti;
|
||||||
u32 y = 50 + offset*SPACING_Y;
|
u32 y = viewerY + offset*SPACING_Y;
|
||||||
|
|
||||||
u32 address = row*BYTES_PER_ROW;
|
u32 address = row*BYTES_PER_ROW;
|
||||||
Draw_DrawFormattedString(10, y, COLOR_TITLE, "%.8lx | ", address + ((menuMode == MENU_MODE_NORMAL) ? (u32)menus[MENU_MODE_NORMAL].buf : 0));
|
Draw_DrawFormattedString(10, y, COLOR_TITLE, "%.8lx | ", address + ((menuMode == MENU_MODE_NORMAL) ? (u32)menus[MENU_MODE_NORMAL].buf : 0));
|
||||||
@ -527,9 +555,9 @@ static void ProcessListMenu_MemoryViewer(const ProcessInfo *info)
|
|||||||
clearMenu();
|
clearMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(R_SUCCEEDED(codeRes))
|
if(codeAvailable)
|
||||||
svcUnmapProcessMemoryEx(processHandle, codeDestAddress, codeTotalSize);
|
svcUnmapProcessMemoryEx(processHandle, codeDestAddress, codeTotalSize);
|
||||||
if(R_SUCCEEDED(heapRes))
|
if(heapAvailable)
|
||||||
svcUnmapProcessMemoryEx(processHandle, heapDestAddress, heapTotalSize);
|
svcUnmapProcessMemoryEx(processHandle, heapDestAddress, heapTotalSize);
|
||||||
|
|
||||||
svcCloseHandle(processHandle);
|
svcCloseHandle(processHandle);
|
||||||
|
Reference in New Issue
Block a user