mirror of
https://dev.lirent.ru/Vatrog/vm-introspection-engine.git
synced 2026-06-18 02:06:36 +03:00
79e82ffc6a
Wave 1 of the code-analysis layer, built on the x86-64 decoder: - vmie_win32_callgraph walks each .pdata function with the decoder and emits an edge for every direct call/jmp whose target lands in the module - the intra-module call graph. Indirect edges are left to the IAT and jump tables. - gva_jumptable recovers a switch's case targets from an indirect jump's table: consecutive pointer entries that land in an executable region. - cfg_blocks splits one function view into basic blocks (a generic handler: leaders from intra-function branch targets, cut after jmp/jcc/ret). - gva_imm_xref finds the instructions whose immediate operand equals a constant - the dual of code-xref for magic values, error codes, syscall numbers. The decoder now also reports imm_off/imm_len so a caller can read or match the immediate operand. The generic primitives live in the new codeanalysis.h (jump tables, basic blocks) and scan.h (constant xref); the .pdata-bound call graph stays on the win32 surface and reuses the existing function/section/decode primitives - no second PE or instruction parser.
63 lines
2.7 KiB
CMake
63 lines
2.7 KiB
CMake
cmake_minimum_required(VERSION 3.18) # find_program(... REQUIRED)
|
|
project(vmi-engine C)
|
|
|
|
set(CMAKE_C_STANDARD 17) # generation B uses no C23 feature
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
set(CMAKE_C_EXTENSIONS ON) # deliberate: strnlen (POSIX) + void* arithmetic (GNU)
|
|
|
|
option(VMIE_LTO "Enable LTO" OFF) # build-only; shipped default is -O2, no LTO
|
|
|
|
# ---- host: VMI core as a static library ---------------------------------
|
|
add_library(vmie STATIC
|
|
src/core/gpa.c
|
|
src/engine/gva.c
|
|
src/engine/sigphys.c
|
|
src/engine/win32/host.c
|
|
src/engine/win32/pe.c
|
|
src/engine/win32/proc.c
|
|
src/engine/win32/profile.c
|
|
src/engine/win32/text.c
|
|
src/handlers/scan.c
|
|
src/handlers/sigscan.c
|
|
src/handlers/sigset.c
|
|
src/handlers/codescan.c
|
|
src/handlers/codeanalysis.c
|
|
src/handlers/siggen.c
|
|
src/handlers/x86dec.c
|
|
src/handlers/pmap.c
|
|
src/handlers/snapdiff.c)
|
|
target_include_directories(vmie
|
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include # public API: include/*.h
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/core/include # private: core.h
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/engine/include # private: engine-arch.h, pe.h
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/engine/win32) # private: engine-win32.h, contract.h
|
|
target_compile_options(vmie PRIVATE -O2 -Wall -Wextra)
|
|
if(VMIE_LTO)
|
|
target_compile_options(vmie PRIVATE -flto)
|
|
target_link_options(vmie PRIVATE -flto)
|
|
endif()
|
|
|
|
# ---- host: CLI demonstrator over the library ----------------------------
|
|
add_executable(vmie_cli src/cli.c)
|
|
target_link_libraries(vmie_cli PRIVATE vmie) # public include/ comes via vmie (PUBLIC)
|
|
target_compile_options(vmie_cli PRIVATE -Wall -Wextra)
|
|
|
|
# ---- host: dump-scan demonstrator (OS-agnostic, no win32) ----------------
|
|
add_executable(vmie_scan src/scan_cli.c)
|
|
target_link_libraries(vmie_scan PRIVATE vmie)
|
|
target_compile_options(vmie_scan PRIVATE -Wall -Wextra)
|
|
|
|
# ---- guest: cross-compile to Windows x86-64 via mingw-w64 ---------------
|
|
find_program(MINGW_CC NAMES x86_64-w64-mingw32-gcc REQUIRED)
|
|
set(VMIE_STARTUP ${CMAKE_CURRENT_BINARY_DIR}/vmie-startup.exe)
|
|
add_custom_command(
|
|
OUTPUT ${VMIE_STARTUP}
|
|
COMMAND ${MINGW_CC} -O2 -Wall -Wextra -static -s
|
|
-I${CMAKE_CURRENT_SOURCE_DIR}/src/engine/win32
|
|
-o ${VMIE_STARTUP} ${CMAKE_CURRENT_SOURCE_DIR}/src/engine/win32/guest.c
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/engine/win32/guest.c
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/engine/win32/contract.h
|
|
COMMENT "Cross-compiling vmie-startup.exe (mingw-w64, x86-64)"
|
|
VERBATIM)
|
|
add_custom_target(vmie-startup ALL DEPENDS ${VMIE_STARTUP})
|