Minor refactorings

This commit is contained in:
flobernd 2017-09-23 19:53:48 +02:00
parent 04ae18bef2
commit 38975c8d3d
2 changed files with 53 additions and 50 deletions

View File

@ -59,7 +59,7 @@ enum ZydisStatusCode
/**
* @brief The operation completed successfully.
*/
ZYDIS_STATUS_SUCCESS = 0x00000000,
ZYDIS_STATUS_SUCCESS = 0x00000000,
/**
* @brief An invalid parameter was passed to a function.
*/
@ -139,7 +139,7 @@ enum ZydisStatusCode
/**
* @brief The base value for user-defined status codes.
*/
ZYDIS_STATUS_USER = 0x10000000
ZYDIS_STATUS_USER = 0x10000000
// Max value entry intentionally omitted since users might
// define custom error codes for formatter hooks.

View File

@ -441,47 +441,48 @@ void printInstruction(ZydisDecodedInstruction* instruction)
const char* str;
} attributeMap[] =
{
{ZYDIS_ATTRIB_HAS_MODRM, "HAS_MODRM" },
{ZYDIS_ATTRIB_HAS_SIB, "HAS_SIB" },
{ZYDIS_ATTRIB_HAS_REX, "HAS_REX" },
{ZYDIS_ATTRIB_HAS_XOP, "HAS_XOP" },
{ZYDIS_ATTRIB_HAS_VEX, "HAS_VEX" },
{ZYDIS_ATTRIB_HAS_EVEX, "HAS_EVEX" },
{ZYDIS_ATTRIB_HAS_MVEX, "HAS_MVEX" },
{ZYDIS_ATTRIB_IS_RELATIVE, "IS_RELATIVE" },
{ZYDIS_ATTRIB_IS_PRIVILEGED, "IS_PRIVILEGED" },
{ZYDIS_ATTRIB_ACCEPTS_LOCK, "ACCEPTS_LOCK" },
{ZYDIS_ATTRIB_ACCEPTS_REP, "ACCEPTS_REP" },
{ZYDIS_ATTRIB_ACCEPTS_REPE, "ACCEPTS_REPE" },
{ZYDIS_ATTRIB_ACCEPTS_REPZ, "ACCEPTS_REPZ" },
{ZYDIS_ATTRIB_ACCEPTS_REPNE, "ACCEPTS_REPNE" },
{ZYDIS_ATTRIB_ACCEPTS_REPNZ, "ACCEPTS_REPNZ" },
{ZYDIS_ATTRIB_ACCEPTS_BOUND, "ACCEPTS_BOUND" },
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TS_SEGMENT, "ACCEPTS_SEGMENT" },
{ ZYDIS_ATTRIB_HAS_LOCK, "HAS_LOCK" },
{ ZYDIS_ATTRIB_HAS_REP, "HAS_REP" },
{ ZYDIS_ATTRIB_HAS_REPE, "HAS_REPE" },
{ ZYDIS_ATTRIB_HAS_REPZ, "HAS_REPZ" },
{ ZYDIS_ATTRIB_HAS_REPNE, "HAS_REPNE" },
{ ZYDIS_ATTRIB_HAS_REPNZ, "HAS_REPNZ" },
{ ZYDIS_ATTRIB_HAS_BOUND, "HAS_BOUND" },
{ ZYDIS_ATTRIB_HAS_XACQUIRE, "HAS_XACQUIRE" },
{ ZYDIS_ATTRIB_HAS_XRELEASE, "HAS_XRELEASE" },
{ ZYDIS_ATTRIB_HAS_BRANCH_NOT_TAKEN, "HAS_BRANCH_NOT_TAKEN" },
{ ZYDIS_ATTRIB_HAS_BRANCH_TAKEN, "HAS_BRANCH_TAKEN" },
{ ZYDIS_ATTRIB_HAS_SEGMENT, "HAS_SEGMENT" },
{ ZYDIS_ATTRIB_HAS_SEGMENT_CS, "HAS_SEGMENT_CS" },
{ ZYDIS_ATTRIB_HAS_SEGMENT_SS, "HAS_SEGMENT_SS" },
{ ZYDIS_ATTRIB_HAS_SEGMENT_DS, "HAS_SEGMENT_DS" },
{ ZYDIS_ATTRIB_HAS_SEGMENT_ES, "HAS_SEGMENT_ES" },
{ ZYDIS_ATTRIB_HAS_SEGMENT_FS, "HAS_SEGMENT_FS" },
{ ZYDIS_ATTRIB_HAS_SEGMENT_GS, "HAS_SEGMENT_GS" },
{ ZYDIS_ATTRIB_HAS_OPERANDSIZE, "HAS_OPERANDSIZE" },
{ ZYDIS_ATTRIB_HAS_ADDRESSSIZE, "HAS_ADDRESSSIZE" }
};
fputs("== [ BASIC ] =====================================================", stdout);
@ -499,17 +500,19 @@ void printInstruction(ZydisDecodedInstruction* instruction)
printf(" ISA-SET: %s\n", ZydisISASetGetString(instruction->meta.isaSet));
printf(" ISA-EXT: %s\n", ZydisISAExtGetString(instruction->meta.isaExt));
printf(" EXCEPTIONS: %s\n", exceptionClassStrings[instruction->meta.exceptionClass]);
fputs (" ATTRIBUTES: ", stdout);
for (size_t i = 0; i < ZYDIS_ARRAY_SIZE(attributeMap); ++i)
if (instruction->attributes)
{
if (instruction->attributes & attributeMap[i].attrMask)
fputs (" ATTRIBUTES: ", stdout);
for (size_t i = 0; i < ZYDIS_ARRAY_SIZE(attributeMap); ++i)
{
printf("%s ", attributeMap[i].str);
if (instruction->attributes & attributeMap[i].attrMask)
{
printf("%s ", attributeMap[i].str);
}
}
fputs("\n", stdout);
}
fputs("\n", stdout);
if (instruction->operandCount > 0)
{