mirror of
https://dev.lirent.ru/Vatrog/vm-introspection-engine.git
synced 2026-07-09 00:46:36 +03:00
Add readable operand decode and register def-use analysis
insndec.h: insn_decode() decodes one instruction into a readable form - concrete registers as canonical roots (al/ah/ax/eax/rax -> one root), memory base/index/scale/disp, immediate values, operand sizes, per-operand read/write, and implicit operands/effects (rsp on push/pop, rdx:rax on mul/div, FLAGS). It is ABI-agnostic: a call reports only its architectural effects. codetrace.h: func_usedef(fn, abi, ...) computes per-instruction register use/def over a function view (reusing cfg_blocks), splitting writes into full-kill / partial / conditional so a reaching-definitions pass can be built on top. With TRACE_ABI_WIN64 it marks the Win64 caller-saved set (rax,rcx,rdx,r8-r11,xmm0-5,flags) clobbered at each call site; the clobber table is confined to codetrace.c and the generic layer stays OS-agnostic (TRACE_ABI_NONE keeps the conservative behaviour). Both ride the existing optional disassembler seam (a second insn_decode_full is added to semsig_backend.h; sem_insn and semsig_hash are untouched), gated behind VMIE_HAVE_DISASM; OFF builds a stub. Adds the vmie_win32_func_usedef wrapper. No new build option - the feature shares VMIE_DISASM with semsig.
This commit is contained in:
+6
-1
@@ -49,12 +49,17 @@ add_library(vmie_obj OBJECT
|
||||
# backend TU that talks to the disassembler. semsig.c is never built in OFF (it
|
||||
# calls the backend decode, absent there) - so there is no dead/unresolved call.
|
||||
if(VMIE_DISASM STREQUAL "OFF")
|
||||
target_sources(vmie_obj PRIVATE src/handlers/semsig_stub.c)
|
||||
target_sources(vmie_obj PRIVATE src/handlers/semsig_stub.c
|
||||
src/handlers/insndec_stub.c)
|
||||
elseif(VMIE_DISASM STREQUAL "zydis")
|
||||
target_sources(vmie_obj PRIVATE src/handlers/semsig.c
|
||||
src/handlers/insndec.c
|
||||
src/handlers/codetrace.c
|
||||
src/handlers/semsig_backend_zydis.c)
|
||||
elseif(VMIE_DISASM STREQUAL "capstone")
|
||||
target_sources(vmie_obj PRIVATE src/handlers/semsig.c
|
||||
src/handlers/insndec.c
|
||||
src/handlers/codetrace.c
|
||||
src/handlers/semsig_backend_capstone.c)
|
||||
else()
|
||||
message(FATAL_ERROR "VMIE_DISASM must be OFF, zydis, or capstone (got '${VMIE_DISASM}')")
|
||||
|
||||
Reference in New Issue
Block a user