ida idc script: convert memory string to address format
Sometimes it is necessary to copy the content in memory as a jump address, but the debugger has its own address format,
Therefore, the following steps of ida idc are to convert the string in the memory format to the address format:
#include <idc.idc>
// 内存字符串转为地址格式 (小端格式)
static MemStrToAddr(info)
{
Message("memstrInput:%s\n", info);
auto strResult = "";
auto stringarr = object();
auto nSpaceCount = 0;
auto pos=strstr(info," ");
while (pos!=-1)
{
strResult = substr(info,0, pos) + strResult;
auto last=pos;
info=substr(info,last+1,-1);
pos=strstr(info," ");
auto tempstr = info;
nSpaceCount++;
}
if(strlen(info>0))
{
strResult = info + strResult;
}
Message("OutputResult:%s\n", strResult);
Message("OutputResult:0x%s\n", strResult);
}
static main()
{
auto memstr = "38 88 ec f4 92 00 00";
MemStrToAddr(memstr);
memstr = "a2831942318 blog.csdn.net/ https://";
MemStrToAddr(memstr);
memstr = "Ninja App https://blog.csdn.net/a2831942318";
MemStrToAddr(memstr);
}
Before conversion: memstrInput:38 88 ec f4 92 00 00
After conversion:
OutputResult:000092f4ec8838
OutputResult:0x000092f4ec8838