diff --git a/CMakeLists.txt b/CMakeLists.txt index 62981f4..40e7fdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.18) # find_program(... REQUIRED) -project(w32ms C) +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(W32MS_LTO "Enable LTO" OFF) # build-only; shipped default is -O2, no LTO +option(VMIE_LTO "Enable LTO" OFF) # build-only; shipped default is -O2, no LTO # ---- host: VMI core as a static library --------------------------------- -add_library(w32ms STATIC +add_library(vmie STATIC src/gpa.c src/gva.c src/host.c @@ -17,30 +17,30 @@ add_library(w32ms STATIC src/text.c src/scan.c src/sigscan.c) -target_include_directories(w32ms +target_include_directories(vmie 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) +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(w32ms_cli src/cli.c) -target_link_libraries(w32ms_cli PRIVATE w32ms) -target_compile_options(w32ms_cli PRIVATE -Wall -Wextra) +add_executable(vmie_cli src/cli.c) +target_link_libraries(vmie_cli PRIVATE vmie) +target_compile_options(vmie_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) +set(VMIE_STARTUP ${CMAKE_CURRENT_BINARY_DIR}/vmie-startup.exe) add_custom_command( - OUTPUT ${W32MS_GUEST} + OUTPUT ${VMIE_STARTUP} COMMAND ${MINGW_CC} -O2 -Wall -Wextra -static -s -I${CMAKE_CURRENT_SOURCE_DIR}/src - -o ${W32MS_GUEST} ${CMAKE_CURRENT_SOURCE_DIR}/src/guest.c + -o ${VMIE_STARTUP} ${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)" + COMMENT "Cross-compiling vmie-startup.exe (mingw-w64, x86-64)" VERBATIM) -add_custom_target(w32ms_guest ALL DEPENDS ${W32MS_GUEST}) +add_custom_target(vmie-startup ALL DEPENDS ${VMIE_STARTUP}) diff --git a/include/include.h b/include/include.h index 68f58e5..2e49510 100644 --- a/include/include.h +++ b/include/include.h @@ -16,8 +16,8 @@ * pointer past the call that received it, unless explicitly stated. */ -#ifndef W32MS_INCLUDE_H -#define W32MS_INCLUDE_H +#ifndef VMIE_INCLUDE_H +#define VMIE_INCLUDE_H #include #include @@ -169,4 +169,4 @@ int proc_modules(gva_ctx* ctx, const process* pr, pmodule* dst, size_t nmax); int gva_regions(gva_ctx* ctx, uintptr_t cr3, uint64_t lo, uint64_t hi, uint32_t prot_any, vregion* out, int nmax); -#endif /* W32MS_INCLUDE_H */ \ No newline at end of file +#endif /* VMIE_INCLUDE_H */ \ No newline at end of file diff --git a/include/scan.h b/include/scan.h index f690f37..0d99167 100644 --- a/include/scan.h +++ b/include/scan.h @@ -6,8 +6,8 @@ * pointer chains; the gva_sig_* bridges build mem_view_t windows out of guest * memory and feed them to the signature matcher. */ -#ifndef W32MS_SCAN_H -#define W32MS_SCAN_H +#ifndef VMIE_SCAN_H +#define VMIE_SCAN_H #include #include #include "include.h" /* gva_ctx, process (vregion - internal) */ @@ -60,4 +60,4 @@ int gva_pe_section(gva_ctx* ctx, uintptr_t cr3, uint64_t module_base, const char* name, uint8_t* buf, size_t bufcap, mem_view_t* out); int gva_sig_phys (gva_ctx* ctx, const sig_pattern_t* p, uint64_t* out, int max); -#endif /* W32MS_SCAN_H */ +#endif /* VMIE_SCAN_H */ diff --git a/include/sigscan.h b/include/sigscan.h index 654c00e..a27df7d 100644 --- a/include/sigscan.h +++ b/include/sigscan.h @@ -10,8 +10,8 @@ * guest memory, build views from the gva layer (see scan.h: gva_sig_scan, * gva_pe_section, gva_sig_phys) and feed them here. */ -#ifndef W32MS_SIGSCAN_H -#define W32MS_SIGSCAN_H +#ifndef VMIE_SIGSCAN_H +#define VMIE_SIGSCAN_H #include #include #include @@ -102,4 +102,4 @@ bool pe_find_section(mem_view_t v, uint64_t module_base, const char* name, bool pe_section(mem_view_t v, uint64_t module_base, const char* name, mem_view_t* out); -#endif /* W32MS_SIGSCAN_H */ \ No newline at end of file +#endif /* VMIE_SIGSCAN_H */ \ No newline at end of file diff --git a/src/cli.c b/src/cli.c index c708a7a..e103e4e 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1,4 +1,4 @@ -/* cli.c - thin demonstrator over the public w32ms API. +/* cli.c - thin demonstrator over the public vmi-engine API. * * Opens a guest RAM backing file, brings up the VMI context, lists processes, * and for the first user process dumps its loaded modules and mapped regions. @@ -88,7 +88,7 @@ static void dump_regions(gva_ctx* ctx, const process* pr) { int main(int argc, char** argv) { if (argc < 3) { fprintf(stderr, "usage: %s [nmax]\n", - argc > 0 ? argv[0] : "w32ms_cli"); + argc > 0 ? argv[0] : "vmie_cli"); return 2; } diff --git a/src/include/contract.h b/src/include/contract.h index 8db9a58..36cb0d9 100644 --- a/src/include/contract.h +++ b/src/include/contract.h @@ -10,8 +10,8 @@ #define CONTRACT_ACK 0xACED5EEDACED5EEDull #endif -#ifndef W32MS_CONTRACT_H -#define W32MS_CONTRACT_H +#ifndef VMIE_CONTRACT_H +#define VMIE_CONTRACT_H #include diff --git a/src/include/memory.h b/src/include/memory.h index e4e1677..73ced58 100644 --- a/src/include/memory.h +++ b/src/include/memory.h @@ -1,5 +1,5 @@ -#ifndef W32MS_MEMORY_H -#define W32MS_MEMORY_H +#ifndef VMIE_MEMORY_H +#define VMIE_MEMORY_H #include #include struct gva_ctx; /* forward: completed below; lets profile.h name it */ @@ -98,4 +98,4 @@ typedef int (*gva_sweep_cb)(void* user, const uint8_t* data, size_t len, int gva_sweep(gva_ctx* ctx, uintptr_t cr3, uint64_t lo, uint64_t hi, uint32_t prot_any, size_t overlap, gva_sweep_cb cb, void* user); -#endif /* W32MS_MEMORY_H */ \ No newline at end of file +#endif /* VMIE_MEMORY_H */ \ No newline at end of file diff --git a/src/include/profile.h b/src/include/profile.h index 462e465..3607c99 100644 --- a/src/include/profile.h +++ b/src/include/profile.h @@ -1,5 +1,5 @@ -#ifndef W32MS_PROFILE_H -#define W32MS_PROFILE_H +#ifndef VMIE_PROFILE_H +#define VMIE_PROFILE_H #include