Allow copying 16 and 32 bit values from the memory view

This commit is contained in:
Kingcom 2013-11-07 19:49:46 +01:00
parent ebd3763c7e
commit c85a7623cc
3 changed files with 37 additions and 7 deletions

View file

@ -416,7 +416,15 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
//popup menu?
POINT pt;
GetCursorPos(&pt);
switch (TrackPopupMenuEx(GetSubMenu(g_hPopupMenus,0),TPM_RIGHTBUTTON|TPM_RETURNCMD,pt.x,pt.y,wnd,0))
bool enable16 = !asciiSelected && (curAddress % 2) == 0;
bool enable32 = !asciiSelected && (curAddress % 4) == 0;
HMENU menu = GetSubMenu(g_hPopupMenus,0);
EnableMenuItem(menu,ID_MEMVIEW_COPYVALUE_16,enable16 ? MF_ENABLED : MF_GRAYED);
EnableMenuItem(menu,ID_MEMVIEW_COPYVALUE_32,enable32 ? MF_ENABLED : MF_GRAYED);
switch (TrackPopupMenuEx(menu,TPM_RIGHTBUTTON|TPM_RETURNCMD,pt.x,pt.y,wnd,0))
{
case ID_MEMVIEW_DUMP:
@ -432,22 +440,40 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
break;
}
case ID_MEMVIEW_COPYVALUE:
case ID_MEMVIEW_COPYVALUE_8:
{
char temp[24];
// it's admittedly not really useful like this
if (asciiSelected)
{
unsigned char c = Memory::IsValidAddress(curAddress) ? Memory::ReadUnchecked_U8(curAddress) : '.';
unsigned char c = Memory::IsValidAddress(curAddress) ? Memory::Read_U8(curAddress) : '.';
if (c < 32|| c >= 128) c = '.';
sprintf(temp,"%c",c);
} else {
sprintf(temp,"%02X",Memory::IsValidAddress(curAddress) ? Memory::ReadUnchecked_U8(curAddress) : 0xFF);
sprintf(temp,"%02X",Memory::IsValidAddress(curAddress) ? Memory::Read_U8(curAddress) : 0xFF);
}
W32Util::CopyTextToClipboard(wnd,temp);
}
break;
case ID_MEMVIEW_COPYVALUE_16:
{
char temp[24];
sprintf(temp,"%04X",Memory::IsValidAddress(curAddress) ? Memory::Read_U16(curAddress) : 0xFFFF);
W32Util::CopyTextToClipboard(wnd,temp);
}
break;
case ID_MEMVIEW_COPYVALUE_32:
{
char temp[24];
sprintf(temp,"%08X",Memory::IsValidAddress(curAddress) ? Memory::Read_U32(curAddress) : 0xFFFFFFFF);
W32Util::CopyTextToClipboard(wnd,temp);
}
break;
case ID_MEMVIEW_COPYADDRESS:
{

View file

@ -503,7 +503,9 @@ BEGIN
MENUITEM "Go to in Disasm", ID_MEMVIEW_GOTOINDISASM
MENUITEM "Copy address", ID_MEMVIEW_COPYADDRESS
MENUITEM SEPARATOR
MENUITEM "Copy Value", ID_MEMVIEW_COPYVALUE
MENUITEM "Copy Value (8 bit)", ID_MEMVIEW_COPYVALUE_8
MENUITEM "Copy Value (16 bit)", ID_MEMVIEW_COPYVALUE_16
MENUITEM "Copy Value (32 bit)", ID_MEMVIEW_COPYVALUE_32
MENUITEM "Dump...", ID_MEMVIEW_DUMP
END
POPUP "disasm"

View file

@ -166,7 +166,7 @@
#define ID_DISASM_ADDHLE 40002
#define ID_FUNCLIST_KILLFUNCTION 40003
#define ID_DISASM_RUNTOHERE 40004
#define ID_MEMVIEW_COPYVALUE 40005
#define ID_MEMVIEW_COPYVALUE_8 40005
#define ID_DISASM_COPYINSTRUCTIONDISASM 40006
#define ID_DISASM_COPYINSTRUCTIONHEX 40007
#define ID_EMULATION_SPEEDLIMIT 40008
@ -297,6 +297,8 @@
#define ID_DISASM_ADDFUNCTION 40139
#define ID_DISASM_REMOVEFUNCTION 40140
#define ID_OPTIONS_LANGUAGE 40141
#define ID_MEMVIEW_COPYVALUE_16 40142
#define ID_MEMVIEW_COPYVALUE_32 40143
// Dummy option to let the buffered rendering hotkey cycle through all the options.
#define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500
@ -309,7 +311,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 254
#define _APS_NEXT_COMMAND_VALUE 40139
#define _APS_NEXT_COMMAND_VALUE 40144
#define _APS_NEXT_CONTROL_VALUE 1193
#define _APS_NEXT_SYMED_VALUE 101
#endif