From 781916180b4ba69a08c57b7c6637cc26fedb815c Mon Sep 17 00:00:00 2001 From: m417z Date: Fri, 13 Nov 2020 12:43:28 +0200 Subject: [PATCH] Small changes to hde --- src/hde/hde32.c | 12 +++++------- src/hde/hde64.c | 8 ++------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/hde/hde32.c b/src/hde/hde32.c index 08fa25bd..eb6af9b8 100644 --- a/src/hde/hde32.c +++ b/src/hde/hde32.c @@ -7,6 +7,7 @@ #if defined(_M_IX86) || defined(__i386__) +#include #include "hde32.h" #include "table32.h" @@ -15,12 +16,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs) uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0; uint8_t *ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0; - // Avoid using memset to reduce the footprint. -#ifndef _MSC_VER - memset((LPBYTE)hs, 0, sizeof(hde32s)); -#else - __stosb((LPBYTE)hs, 0, sizeof(hde32s)); -#endif + memset(hs, 0, sizeof(hde32s)); for (x = 16; x; x--) switch (c = *p++) { @@ -183,7 +179,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs) } for (; ht != table_end; ht += 2) if (*ht++ == opcode) { - if (*ht++ & pref && !((*ht << m_reg) & 0x80)) + if ((*ht++ & pref) && !((*ht << m_reg) & 0x80)) goto error_operand; else break; @@ -234,6 +230,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs) disp_size = 2; if (!(pref & PRE_67)) disp_size <<= 1; + break; } if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) { @@ -259,6 +256,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs) case 4: hs->flags |= F_DISP32; hs->disp.disp32 = *(uint32_t *)p; + break; } p += disp_size; } else if (pref & PRE_LOCK) diff --git a/src/hde/hde64.c b/src/hde/hde64.c index c23e2fc6..55a702e7 100644 --- a/src/hde/hde64.c +++ b/src/hde/hde64.c @@ -7,6 +7,7 @@ #if defined(_M_X64) || defined(__x86_64__) +#include #include "hde64.h" #include "table64.h" @@ -16,12 +17,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs) uint8_t *ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0; uint8_t op64 = 0; - // Avoid using memset to reduce the footprint. -#ifndef _MSC_VER - memset((LPBYTE)hs, 0, sizeof(hde64s)); -#else - __stosb((LPBYTE)hs, 0, sizeof(hde64s)); -#endif + memset(hs, 0, sizeof(hde64s)); for (x = 16; x; x--) switch (c = *p++) {