Files
vatrog-vm-introspection-engine/CMakeLists.txt
T
lirent 4015e839eb Zero-copy hot path, correctness hardening
gva_ptr: leaf-bounded zero-copy guest reads. gva_sweep redesigned to drive
on it — large-page leaves are lent to the callback while 4K runs stay
buffered, and the run loop is guarded against wrap at the top of the address
space. gva_gpa fetches PTEs zero-copy; optional W32MS_LTO build option folds
the per-fetch call boundary (shipped -O2 default unchanged).

Correctness: subtract-form bounds check (no add overflow), memcpy decode in
place of type-punned wide loads, zero-init PDB name before compare,
PCI-hole-crossing range rejection, single-sourced VA_CANON and USER bounds.
hot/cold attributes audited across the translation and scan path.
2026-06-15 01:05:00 +03:00

47 lines
1.9 KiB
CMake

cmake_minimum_required(VERSION 3.18) # find_program(... REQUIRED)
project(w32ms 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(W32MS_LTO "Enable LTO" OFF) # build-only; shipped default is -O2, no LTO
# ---- host: VMI core as a static library ---------------------------------
add_library(w32ms STATIC
src/gpa.c
src/gva.c
src/host.c
src/proc.c
src/profile.c
src/text.c
src/scan.c
src/sigscan.c)
target_include_directories(w32ms
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include # public API: include/*.h
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) # private: src/include/*.h via "include/..."
target_compile_options(w32ms PRIVATE -O2 -Wall -Wextra)
if(W32MS_LTO)
target_compile_options(w32ms PRIVATE -flto)
target_link_options(w32ms PRIVATE -flto)
endif()
# ---- host: CLI demonstrator over the library ----------------------------
add_executable(w32ms_cli src/cli.c)
target_link_libraries(w32ms_cli PRIVATE w32ms)
target_compile_options(w32ms_cli 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(W32MS_GUEST ${CMAKE_CURRENT_BINARY_DIR}/w32ms_guest.exe)
add_custom_command(
OUTPUT ${W32MS_GUEST}
COMMAND ${MINGW_CC} -O2 -Wall -Wextra -static -s
-I${CMAKE_CURRENT_SOURCE_DIR}/src
-o ${W32MS_GUEST} ${CMAKE_CURRENT_SOURCE_DIR}/src/guest.c
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/guest.c
${CMAKE_CURRENT_SOURCE_DIR}/src/include/contract.h
COMMENT "Cross-compiling w32ms_guest.exe (mingw-w64, x86-64)"
VERBATIM)
add_custom_target(w32ms_guest ALL DEPENDS ${W32MS_GUEST})