1
0
Fork 0

DBG: various fixes with mnemonic help and brief + updated mnemdb

This commit is contained in:
mrexodia 2016-05-29 20:32:03 +02:00
parent 5b218f57ba
commit 17768853d9
4 changed files with 217 additions and 52 deletions

View File

@ -2819,43 +2819,83 @@
"mnem": "cmc"
},
{
"description": "conditional move - below/not above or equal/carry (cf=1)",
"description": "conditional move - above/not below nor equal (cf=0 and zf=0)",
"mnem": "cmova"
},
{
"description": "conditional move - above or equal/not below/not carry (cf=0)",
"mnem": "cmovae"
},
{
"description": "conditional move - below/not above nor equal/carry (cf=1)",
"mnem": "cmovb"
},
{
"description": "conditional move - below or equal/not above (cf=1 and zf=1)",
"description": "conditional move - below or equal/not above (cf=1 or zf=1)",
"mnem": "cmovbe"
},
{
"description": "conditional move - if equal (zf=1)",
"description": "conditional move - carry/below/not above or equal (cf=1)",
"mnem": "cmovc"
},
{
"description": "conditional move - equal/zero (zf=1)",
"mnem": "cmove"
},
{
"description": "conditional move - less/not greater (sf!=of)",
"description": "conditional move - greater/not less nor equal (zf=0 and sf=of)",
"mnem": "cmovg"
},
{
"description": "conditional move - greater or equal/not less (sf=of)",
"mnem": "cmovge"
},
{
"description": "conditional move - less/not greater nor equal (sf!=of)",
"mnem": "cmovl"
},
{
"description": "conditional move - less or equal/not greater ((zf=1) or (sf!=of))",
"description": "conditional move - less or equal/not greater (zf=1 or sf!=of)",
"mnem": "cmovle"
},
{
"description": "conditional move - not above/below or equal (cf=1 or zf=1)",
"mnem": "cmovna"
},
{
"description": "conditional move - not above nor equal/below/carry (cf=1)",
"mnem": "cmovnae"
},
{
"description": "conditional move - not below/above or equal/not carry (cf=0)",
"mnem": "cmovnb"
},
{
"description": "conditional move - not below or equal/above (cf=0 and zf=0)",
"description": "conditional move - not below nor equal/above (cf=0 and zf=0)",
"mnem": "cmovnbe"
},
{
"description": "conditional move - if not equal (zf=0)",
"description": "conditional move - not carry/above or equal/not below (cf=0)",
"mnem": "cmovnc"
},
{
"description": "conditional move - not equal/not zero (zf=0)",
"mnem": "cmovne"
},
{
"description": "conditional move - not greater/less or equal (zf=1 or sf!=of)",
"mnem": "cmovng"
},
{
"description": "conditional move - not greater nor equal/less (sf!=of)",
"mnem": "cmovnge"
},
{
"description": "conditional move - not less/greater or equal (sf=of)",
"mnem": "cmovnl"
},
{
"description": "conditional move - not less nor equal/greater ((zf=0) and (sf=of))",
"description": "conditional move - not less nor equal/greater (zf=0 and sf=of)",
"mnem": "cmovnle"
},
{
@ -2863,7 +2903,7 @@
"mnem": "cmovno"
},
{
"description": "conditional move - not parity/parity odd",
"description": "conditional move - not parity/parity odd (pf=0)",
"mnem": "cmovnp"
},
{
@ -2871,7 +2911,7 @@
"mnem": "cmovns"
},
{
"description": "conditional move - not zero/not equal (zf=1)",
"description": "conditional move - not zero/not equal (zf=0)",
"mnem": "cmovnz"
},
{
@ -2882,12 +2922,20 @@
"description": "conditional move - parity/parity even (pf=1)",
"mnem": "cmovp"
},
{
"description": "conditional move - parity even/parity (pf=1)",
"mnem": "cmovpe"
},
{
"description": "conditional move - parity odd/not parity (pf=0)",
"mnem": "cmovpo"
},
{
"description": "conditional move - sign (sf=1)",
"mnem": "cmovs"
},
{
"description": "conditional move - zero/equal (zf=0)",
"description": "conditional move - zero/equal (zf=1)",
"mnem": "cmovz"
},
{
@ -3234,6 +3282,10 @@
"description": "free floating-point register",
"mnem": "ffree"
},
{
"description": "free floating-point register and pop (undocumented)",
"mnem": "ffreep"
},
{
"description": "integer add",
"mnem": "fiadd"
@ -3446,6 +3498,10 @@
"description": "store floating point value and pop",
"mnem": "fstp"
},
{
"description": "store floating point value and pop (undocumented)",
"mnem": "fstpnce"
},
{
"description": "store x87 fpu status word",
"mnem": "fstsw"
@ -3582,6 +3638,14 @@
"description": "input from port to string",
"mnem": "insb"
},
{
"description": "input from port to string",
"mnem": "insd"
},
{
"description": "input from port to string",
"mnem": "insw"
},
{
"description": "call to interrupt procedure",
"mnem": "int1"
@ -3635,7 +3699,7 @@
"mnem": "jae"
},
{
"description": "jump short if below/not above or equal/carry (cf=1)",
"description": "jump short if below/not above nor equal/carry (cf=1)",
"mnem": "jb"
},
{
@ -3671,7 +3735,7 @@
"mnem": "jl"
},
{
"description": "jump short if less or equal/not greater ((zf=1) or (sf!=of))",
"description": "jump short if less or equal/not greater (zf=1 or sf!=of)",
"mnem": "jle"
},
{
@ -3691,7 +3755,7 @@
"mnem": "jna"
},
{
"description": "jump short if not above or equal/below (cf=1)",
"description": "jump short if not above nor equal/below (cf=1)",
"mnem": "jnae"
},
{
@ -3711,7 +3775,7 @@
"mnem": "jne"
},
{
"description": "jump short if not greater/less or equal ((zf=1) or (sf!=of))",
"description": "jump short if not greater/less or equal (zf=1 or sf!=of)",
"mnem": "jng"
},
{
@ -3723,7 +3787,7 @@
"mnem": "jnl"
},
{
"description": "jump short if not less nor equal/greater ((zf=0) and (sf=of))",
"description": "jump short if not less nor equal/greater (zf=0 and sf=of)",
"mnem": "jnle"
},
{
@ -3731,7 +3795,7 @@
"mnem": "jno"
},
{
"description": "jump short if not parity/parity odd",
"description": "jump short if not parity/parity odd (pf=0)",
"mnem": "jnp"
},
{
@ -3739,7 +3803,7 @@
"mnem": "jns"
},
{
"description": "jump short if not zero/not equal (zf=1)",
"description": "jump short if not zero/not equal (zf=0)",
"mnem": "jnz"
},
{
@ -3755,7 +3819,7 @@
"mnem": "jpe"
},
{
"description": "jump short if parity odd/not parity",
"description": "jump short if parity odd/not parity (pf=0)",
"mnem": "jpo"
},
{
@ -3767,7 +3831,7 @@
"mnem": "js"
},
{
"description": "jump short if zero/equal (zf=0)",
"description": "jump short if zero/equal (zf=1)",
"mnem": "jz"
},
{
@ -4066,6 +4130,10 @@
"description": "move packed single-fp low and duplicate",
"mnem": "movsldup"
},
{
"description": "ES:[rdi] = (qword)DS:[rsi] (rsi+=8, rdi+=8)",
"mnem": "movsq"
},
{
"description": "move scalar single-fp values",
"mnem": "movss"
@ -4155,15 +4223,15 @@
"mnem": "outs"
},
{
"description": "Output string byte to port",
"description": "output string byte to port",
"mnem": "outsb"
},
{
"description": "Output string doubleword to port",
"description": "output string doubleword to port",
"mnem": "outsd"
},
{
"description": "Output string word to port",
"description": "output string word to port",
"mnem": "outsw"
},
{
@ -4362,6 +4430,10 @@
"description": "insert a qword value from a register or memory into an XMM register",
"mnem": "pinsrq"
},
{
"description": "insert a word value from a register or memory into an XMM register",
"mnem": "pinsrw"
},
{
"description": "multiply and add packed signed and unsigned bytes",
"mnem": "pmaddubsw"
@ -4546,6 +4618,10 @@
"description": "prefetch data into caches",
"mnem": "prefetcht2"
},
{
"description": "prefetch data into caches",
"mnem": "prefetchw"
},
{
"description": "compute sum of absolute differences",
"mnem": "psadbw"
@ -4742,6 +4818,10 @@
"description": "read performance-monitoring counters",
"mnem": "rdpmc"
},
{
"description": "read random number",
"mnem": "rdrand"
},
{
"description": "read time-stamp counter",
"mnem": "rdtsc"
@ -4919,7 +4999,11 @@
"mnem": "scasb"
},
{
"description": "cmp rax, ES:[rdi+=2]",
"description": "cmp eax, ES:[edi+=4]",
"mnem": "scasd"
},
{
"description": "cmp rax, ES:[rdi+=8]",
"mnem": "scasq"
},
{
@ -4927,35 +5011,51 @@
"mnem": "scasw"
},
{
"description": "set byte on condition - below/not above or equal/carry (cf=1)",
"description": "set byte on condition - above/not below nor equal (cf=0 and zf=0)",
"mnem": "seta"
},
{
"description": "set byte on condition - above or equal/not below/not carry (cf=0)",
"mnem": "setae"
},
{
"description": "set byte on condition - below/not above nor equal/carry (cf=1)",
"mnem": "setb"
},
{
"description": "set byte on condition - below or equal/not above (cf=1 and zf=1)",
"description": "set byte on condition - below or equal/not above (cf=1 or zf=1)",
"mnem": "setbe"
},
{
"description": "set byte on condition - carry (cf=1)",
"description": "set byte on condition - carry/below/not above nor equal (cf=1)",
"mnem": "setc"
},
{
"description": "set byte if equal (zf=1)",
"description": "set byte on condition - equal/zero (zf=1)",
"mnem": "sete"
},
{
"description": "set byte on condition - less/not greater (sf!=of)",
"description": "set byte on condition - greater/not less nor equal (zf=0 and sf=of)",
"mnem": "setg"
},
{
"description": "set byte on condition - greater or equal/not less (sf=of)",
"mnem": "setge"
},
{
"description": "set byte on condition - less/not greater nor equal (sf!=of)",
"mnem": "setl"
},
{
"description": "set byte on condition - less or equal/not greater ((zf=1) or (sf!=of))",
"description": "set byte on condition - less or equal/not greater (zf=1 or sf!=of)",
"mnem": "setle"
},
{
"description": "set byte on condition - below or not above/equal (cf=1 and zf=1)",
"description": "set byte on condition - not above/below or equal (cf=1 or zf=1)",
"mnem": "setna"
},
{
"description": "set byte on condition - not above or equal/below/carry (cf=1)",
"description": "set byte on condition - not above nor equal/below/carry (cf=1)",
"mnem": "setnae"
},
{
@ -4963,23 +5063,23 @@
"mnem": "setnb"
},
{
"description": "set byte on condition - not below or equal/above (cf=0 and zf=0)",
"description": "set byte on condition - not below nor equal/above (cf=0 and zf=0)",
"mnem": "setnbe"
},
{
"description": "set byte on condition - carry (cf=1)",
"description": "set byte on condition - not carry/above or equal/not below (cf=0)",
"mnem": "setnc"
},
{
"description": "set byte on condition - not zero/not equal (zf=0)",
"description": "set byte on condition - not equal/not zero (zf=0)",
"mnem": "setne"
},
{
"description": "set byte on condition - not greater/less or equal ((zf=1) or (sf!=of))",
"description": "set byte on condition - not greater/less or equal (zf=1 or sf!=of)",
"mnem": "setng"
},
{
"description": "set byte on condition - not greater/less (sf!=of)",
"description": "set byte on condition - not greater nor equal/less (sf!=of)",
"mnem": "setnge"
},
{
@ -4987,7 +5087,7 @@
"mnem": "setnl"
},
{
"description": "set byte on condition - not less nor equal/greater ((zf=0) and (sf=of))",
"description": "set byte on condition - not less nor equal/greater (zf=0 and sf=of)",
"mnem": "setnle"
},
{
@ -4995,7 +5095,7 @@
"mnem": "setno"
},
{
"description": "set byte on condition - not parity/parity odd",
"description": "set byte on condition - not parity/parity odd (pf=0)",
"mnem": "setnp"
},
{
@ -5003,7 +5103,7 @@
"mnem": "setns"
},
{
"description": "set byte on condition - not zero/not equal (zf=1)",
"description": "set byte on condition - not zero/not equal (zf=0)",
"mnem": "setnz"
},
{
@ -5015,11 +5115,11 @@
"mnem": "setp"
},
{
"description": "set byte on condition - parity/parity even (pf=1)",
"description": "set byte on condition - parity even/parity (pf=1)",
"mnem": "setpe"
},
{
"description": "set byte on condition - parity odd/not parity",
"description": "set byte on condition - parity odd/not parity (pf=0)",
"mnem": "setpo"
},
{
@ -5027,7 +5127,7 @@
"mnem": "sets"
},
{
"description": "set byte on condition - zero/equal (zf=0)",
"description": "set byte on condition - zero/equal (zf=1)",
"mnem": "setz"
},
{
@ -5115,13 +5215,21 @@
"mnem": "stos"
},
{
"description": "store string",
"description": "store string byte",
"mnem": "stosb"
},
{
"description": "store string dword",
"mnem": "stosd"
},
{
"description": "store string quadword (added with x86_64)",
"mnem": "stosq"
},
{
"description": "store string word",
"mnem": "stosw"
},
{
"description": "store task register",
"mnem": "str"

View File

@ -89,9 +89,19 @@ String MnemonicHelp::getDescription(const char* mnem, int depth)
if(depth == 10)
return "Too many redirections...";
SHARED_ACQUIRE(LockMnemonicHelp);
auto found = MnemonicMap.find(getUniversalMnemonic(mnem));
auto mnemuni = getUniversalMnemonic(mnem);
auto found = MnemonicMap.find(mnemuni);
if(found == MnemonicMap.end())
return "";
{
if(mnemuni[0] == 'v') //v/vm
{
found = MnemonicMap.find(mnemuni.c_str() + 1);
if(found == MnemonicMap.end())
return "";
}
else
return "";
}
const auto & description = found->second;
if(StringUtils::StartsWith(description, "-R:")) //redirect
{
@ -106,8 +116,23 @@ String MnemonicHelp::getBriefDescription(const char* mnem)
if(mnem == nullptr)
return "Invalid mnemonic!";
SHARED_ACQUIRE(LockMnemonicHelp);
auto found = MnemonicBriefMap.find(StringUtils::ToLower(mnem));
auto mnemLower = StringUtils::ToLower(mnem);
if(mnemLower == "???")
return "invalid instruction";
auto found = MnemonicBriefMap.find(mnemLower);
if(found == MnemonicBriefMap.end())
{
if(mnemLower[0] == 'v') //v/vm
{
found = MnemonicBriefMap.find(mnemLower.c_str() + 1);
if(found != MnemonicBriefMap.end())
{
if(mnemLower.length() > 1 && mnemLower[1] == 'm') //vm
return "vm " + found->second;
return "vector " + found->second;
}
}
return "";
}
return found->second;
}

View File

@ -272,6 +272,38 @@ static void registercommands()
dbgcmdnew("EnablePrivilege", cbEnablePrivilege, true); //enable priv
dbgcmdnew("DisablePrivilege", cbDisablePrivilege, true); //disable priv
dbgcmdnew("handleclose", cbHandleClose, true); //close remote handle
dbgcmdnew("briefcheck", [](int argc, char* argv[])
{
if(argc < 2)
return STATUS_ERROR;
duint addr;
if(!valfromstring(argv[1], &addr, false))
return STATUS_ERROR;
duint size;
auto base = DbgMemFindBaseAddr(addr, &size);
if(!base)
return STATUS_ERROR;
Memory<unsigned char*> buffer(size + 16);
DbgMemRead(base, buffer(), size);
Capstone cp;
std::unordered_set<String> reported;
for(duint i = 0; i < size;)
{
if(!cp.Disassemble(base + i, buffer() + i, 16))
{
i++;
continue;
}
i += cp.Size();
auto mnem = StringUtils::ToLower(cp.MnemonicId());
auto brief = MnemonicHelp::getBriefDescription(mnem.c_str());
if(brief.length() || reported.count(mnem))
continue;
reported.insert(mnem);
dprintf(fhex ": %s\n", cp.Address(), mnem.c_str());
}
return STATUS_CONTINUE;
}, true);
}
static bool cbCommandProvider(char* cmd, int maxlen)

View File

@ -7,7 +7,7 @@
#include <shlobj.h>
#include <atlcomcli.h>
typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS)(HANDLE, PBOOL);
enum arch
{
@ -79,15 +79,15 @@ static bool BrowseFileOpen(HWND owner, const TCHAR* filter, const TCHAR* defext,
static BOOL isWoW64()
{
LPFN_ISWOW64PROCESS fnIsWow64Process;
BOOL isWoW64 = FALSE;
fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
if (NULL != fnIsWow64Process)
if(NULL != fnIsWow64Process)
{
if (!fnIsWow64Process(GetCurrentProcess(), &isWoW64))
if(!fnIsWow64Process(GetCurrentProcess(), &isWoW64))
{
return FALSE;
}
@ -314,7 +314,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
if(MessageBox(nullptr, TEXT("Do you want to create Desktop Shortcuts?"), TEXT("Question"), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
AddDesktopShortcut(sz32Path, TEXT("x32dbg"));
if (isWoW64())
if(isWoW64())
AddDesktopShortcut(sz64Path, TEXT("x64dbg"));
}
if(bDoneSomething)