1
0
Fork 0

DBG: add bswap format function

This commit is contained in:
Duncan Ogilvie 2019-09-01 16:39:32 +02:00
parent 8e2fb7f0b7
commit 12cf712ec2
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
1 changed files with 20 additions and 0 deletions

View File

@ -206,6 +206,26 @@ void FormatFunctions::Init()
return FORMAT_ERROR;
return formatcpy_s(dest, destCount, mod);
});
Register("bswap", [](char* dest, size_t destCount, int argc, char* argv[], duint addr, void* userdata)
{
duint size = sizeof(duint);
if(argc > 1 && !valfromstring(argv[1], &size))
{
strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Invalid argument...")));
return FORMAT_ERROR_MESSAGE;
}
if(size > sizeof(duint) || size == 0)
{
strcpy_s(dest, destCount, GuiTranslateText(QT_TRANSLATE_NOOP("DBG", "Invalid size...")));
return FORMAT_ERROR_MESSAGE;
}
auto data = (unsigned char*)&addr;
String result;
for(duint i = 0; i < size; i++)
result += StringUtils::sprintf("%02X", data[i]);
return formatcpy_s(dest, destCount, result.c_str());
});
}
bool FormatFunctions::Register(const String & type, const CBFORMATFUNCTION & cbFunction, void* userdata)