1
0
Fork 0

DBG: print symbolic name + fixed logic bug in valfromstring_noexpr

This commit is contained in:
mrexodia 2016-09-29 19:15:00 +02:00
parent d256c6a2d8
commit ce4bf4bf44
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 36 additions and 20 deletions

View File

@ -10,6 +10,7 @@
#include "capstone_wrapper.h" #include "capstone_wrapper.h"
#include "mnemonichelp.h" #include "mnemonichelp.h"
#include "value.h" #include "value.h"
#include "symbolinfo.h"
CMDRESULT cbBadCmd(int argc, char* argv[]) CMDRESULT cbBadCmd(int argc, char* argv[])
{ {
@ -26,28 +27,31 @@ CMDRESULT cbBadCmd(int argc, char* argv[])
else else
valsize = 1; valsize = 1;
char format_str[deflen] = ""; char format_str[deflen] = "";
auto symbolic = SymGetSymbolicName(value);
if(symbolic.length())
symbolic = " " + symbolic;
if(isvar) // and *cmd!='.' and *cmd!='x') //prevent stupid 0=0 stuff if(isvar) // and *cmd!='.' and *cmd!='x') //prevent stupid 0=0 stuff
{ {
if(value > 9 && !hexonly) if(value > 9 && !hexonly)
{ {
if(!valuesignedcalc()) //signed numbers if(!valuesignedcalc()) //signed numbers
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%s=%%.%dllX (%%llud)\n", valsize); // TODO: This and the following statements use "%llX" for a "int"-typed variable. Maybe we can use "%X" everywhere? sprintf_s(format_str, "%%s=%%.%dllX (%%llud)%%s\n", valsize); // TODO: This and the following statements use "%llX" for a "int"-typed variable. Maybe we can use "%X" everywhere?
#else //x86 #else //x86
sprintf_s(format_str, "%%s=%%.%dX (%%ud)\n", valsize); sprintf_s(format_str, "%%s=%%.%dX (%%ud)%%s\n", valsize);
#endif //_WIN64 #endif //_WIN64
else else
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%s=%%.%dllX (%%lld)\n", valsize); sprintf_s(format_str, "%%s=%%.%dllX (%%lld)%%s\n", valsize);
#else //x86 #else //x86
sprintf_s(format_str, "%%s=%%.%dX (%%d)\n", valsize); sprintf_s(format_str, "%%s=%%.%dX (%%d)%%s\n", valsize);
#endif //_WIN64 #endif //_WIN64
dprintf_untranslated(format_str, *argv, value, value); dprintf_untranslated(format_str, *argv, value, value, symbolic.c_str());
} }
else else
{ {
sprintf_s(format_str, "%%s=%%.%dX\n", valsize); sprintf_s(format_str, "%%s=%%.%dX%%s\n", valsize);
dprintf_untranslated(format_str, *argv, value); dprintf_untranslated(format_str, *argv, value, symbolic.c_str());
} }
} }
else else
@ -56,31 +60,31 @@ CMDRESULT cbBadCmd(int argc, char* argv[])
{ {
if(!valuesignedcalc()) //signed numbers if(!valuesignedcalc()) //signed numbers
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%s=%%.%dllX (%%llud)\n", valsize); sprintf_s(format_str, "%%s=%%.%dllX (%%llud)%%s\n", valsize);
#else //x86 #else //x86
sprintf_s(format_str, "%%s=%%.%dX (%%ud)\n", valsize); sprintf_s(format_str, "%%s=%%.%dX (%%ud)%%s\n", valsize);
#endif //_WIN64 #endif //_WIN64
else else
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%s=%%.%dllX (%%lld)\n", valsize); sprintf_s(format_str, "%%s=%%.%dllX (%%lld)%%s\n", valsize);
#else //x86 #else //x86
sprintf_s(format_str, "%%s=%%.%dX (%%d)\n", valsize); sprintf_s(format_str, "%%s=%%.%dX (%%d)%%s\n", valsize);
#endif //_WIN64 #endif //_WIN64
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%.%dllX (%%llud)\n", valsize); sprintf_s(format_str, "%%.%dllX (%%llud)%%s\n", valsize);
#else //x86 #else //x86
sprintf_s(format_str, "%%.%dX (%%ud)\n", valsize); sprintf_s(format_str, "%%.%dX (%%ud)%%s\n", valsize);
#endif //_WIN64 #endif //_WIN64
dprintf_untranslated(format_str, value, value); dprintf_untranslated(format_str, value, value, symbolic.c_str());
} }
else else
{ {
#ifdef _WIN64 #ifdef _WIN64
sprintf_s(format_str, "%%.%dllX\n", valsize); sprintf_s(format_str, "%%.%dllX%%s\n", valsize);
#else //x86 #else //x86
sprintf_s(format_str, "%%.%dX\n", valsize); sprintf_s(format_str, "%%.%dX%%s\n", valsize);
#endif //_WIN64 #endif //_WIN64
dprintf_untranslated(format_str, value); dprintf_untranslated(format_str, value, symbolic.c_str());
} }
} }
} }

View File

@ -1435,16 +1435,28 @@ bool valapifromstring(const char* name, duint* value, int* value_size, bool prin
return true; return true;
for(int i = 0; i < found; i++) for(int i = 0; i < found; i++)
if(i != kernel32) if(i != kernel32)
{
auto symbolic = SymGetSymbolicName(addrfound()[i]);
if(symbolic.length())
dprintf_untranslated("%p %s\n", addrfound()[i], symbolic.c_str());
else
dprintf_untranslated("%p\n", addrfound()[i]); dprintf_untranslated("%p\n", addrfound()[i]);
} }
}
else else
{ {
*value = *addrfound(); *value = *addrfound();
if(!printall || silent) if(!printall || silent)
return true; return true;
for(int i = 1; i < found; i++) for(int i = 1; i < found; i++)
{
auto symbolic = SymGetSymbolicName(addrfound()[i]);
if(symbolic.length())
dprintf_untranslated("%p %s\n", addrfound()[i], symbolic.c_str());
else
dprintf_untranslated("%p\n", addrfound()[i]); dprintf_untranslated("%p\n", addrfound()[i]);
} }
}
return true; return true;
} }
@ -1704,7 +1716,7 @@ bool valfromstring_noexpr(const char* string, duint* value, bool silent, bool ba
return false; return false;
if(isvar) if(isvar)
*isvar = false; *isvar = false;
else if(valapifromstring(string, value, value_size, true, silent, hexonly)) //then come APIs if(valapifromstring(string, value, value_size, true, silent, hexonly)) //then come APIs
return true; return true;
else if(LabelFromString(string, value)) //then come labels else if(LabelFromString(string, value)) //then come labels
return true; return true;