mirror of
https://github.com/bitdefender/bddisasm.git
synced 2024-11-14 03:19:24 +00:00
752bc626c4
Fixed VEX decoding in 32 bit mode - vex.vvvv bit 3 is simply ignored. Fixed several FMA instructions decoding (L/W flag should be ignored). Print the 64 bit immediate value in disassembly, instead of the raw immediate (note that the operand always contains the sign-extended, full immediate). XBEGIN always uses 32/64 bit RIP size (0x66 does not affect its size). Decode WBINVD even if it's preceded by 0x66/0xF2 prefixes. Several mnemonic fixes (FXSAVE64, FXRSTOR64, PUSHA/PUSHAD...). Properly decode VPERMIL2* instructions. Fixed SSE register decoding when it is encoded in immediate. Decode SCATTER instructions even though they use the VSIB index as source. Some disp8 fixes (t1s -> t1s8/t1s16). SYSCALL/SYSRET are decoded and executed in 32 bit compat modem, even though SDM states they are invalid. RDPID uses 32/64 bit reg size, never 16. Various other minor tweaks & fixes. Re-generated the test files, and added some more, new tests.
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
#
|
|
# Copyright (c) 2020 Bitdefender
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
import os
|
|
import sys
|
|
import glob
|
|
|
|
total_tests = 0
|
|
failed_tests = 0
|
|
|
|
def test_dir(dir):
|
|
global total_tests
|
|
global failed_tests
|
|
|
|
for f in glob.glob('%s\\*' % dir):
|
|
if -1 == f.find('.'):
|
|
if 0 < f.find('_16'):
|
|
mod = '-b16'
|
|
elif 0 < f.find('_32'):
|
|
mod = '-b32'
|
|
else:
|
|
mod = '-b64'
|
|
if 0 < f.find('_r0'):
|
|
mod += ' -k'
|
|
|
|
print(' * Running test case %s...' % f)
|
|
os.system('disasm -shemu %s -f %s >%s.temp' % (mod, f, f))
|
|
try:
|
|
res = open('%s.result' % f).read()
|
|
except:
|
|
print(' ! No result file provided for test %s!' % f)
|
|
|
|
try:
|
|
tmp = open('%s.temp' % f).read()
|
|
except:
|
|
print(' ! No result produced by test %s!' % f)
|
|
|
|
total_tests += 1
|
|
if res != tmp:
|
|
print(' **** FAILED! ****')
|
|
failed_tests += 1
|
|
else:
|
|
print(' * Passed.')
|
|
|
|
for f in glob.glob('%s\\*_decoded.bin' % dir):
|
|
os.remove(f)
|
|
for f in glob.glob('%s\\*.temp' % dir):
|
|
os.remove(f)
|
|
|
|
def regenerate(dir):
|
|
for f in glob.glob('%s\\*' % dir):
|
|
if -1 == f.find('.'):
|
|
if 0 < f.find('_16'):
|
|
mod = '-b16'
|
|
elif 0 < f.find('_32'):
|
|
mod = '-b32'
|
|
else:
|
|
mod = '-b64'
|
|
if 0 < f.find('_r0'):
|
|
mod += ' -k'
|
|
|
|
print(' * Regenerating test case %s...' % f)
|
|
os.system('disasm -exi -shemu %s -f %s >%s.result' % (mod, f, f))
|
|
|
|
for f in glob.glob('%s\\*_decoded.bin' % dir):
|
|
os.remove(f)
|
|
|
|
for dn in glob.glob("*"):
|
|
if not os.path.isdir(dn):
|
|
continue
|
|
print('Testing %s...' % dn)
|
|
test_dir(dn)
|
|
print("Ran %d tests, %d failed" % (total_tests, failed_tests)) |