Skip to content

Commit

Permalink
Fixed VSIB encoding in 16-bit mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mappzor committed Nov 6, 2024
1 parent dde61f7 commit 47b92fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -2177,9 +2177,13 @@ static ZyanBool ZydisIsMemoryOperandCompatible(ZydisEncoderInstructionMatch *mat
return ZYAN_FALSE;
}
}
else
else if (candidate_easz == 16)
{
if (candidate_easz == 16 && !disp_only)
if (is_vsib)
{
candidate_easz = 32;
}
else if (!disp_only)
{
if (disp_size > 16)
{
Expand Down
6 changes: 6 additions & 0 deletions tests/re_enc_test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -938,5 +938,11 @@
"stack_width": "ZYDIS_STACK_WIDTH_64",
"payload": "F3660FA7C86239F6",
"description": "rep xcrypt_ecb <- TODO: Remove 0x66 byte after fixing OSIZE handling for XCRYPT"
},
{
"machine_mode": "ZYDIS_MACHINE_MODE_LONG_COMPAT_16",
"stack_width": "ZYDIS_STACK_WIDTH_16",
"payload": "6762C27D2DA00C150000000000000000",
"description": "vpscatterdd dword ptr ds:[ymm2*1] {k5}, ymm1"
}
]
4 changes: 4 additions & 0 deletions tools/ZydisFuzzShared.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ void ZydisPrintInstruction(const ZydisDecodedInstruction* instruction,
ZYAN_UNREACHABLE;
}
printf("-%u ", instruction->stack_width);
if (instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_MVEX)
{
printf("-knc ");
}

for (ZyanU8 i = 0; i < instruction->length; ++i)
{
Expand Down

0 comments on commit 47b92fd

Please sign in to comment.