-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
116 lines (95 loc) · 2.75 KB
/
CMakeLists.txt
File metadata and controls
116 lines (95 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
cmake_minimum_required(VERSION 3.16)
project(patchwork
VERSION 1.0.0
DESCRIPTION "Windows PatchGuard (KPP) analysis and research toolkit"
LANGUAGES C
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Platform check
if(NOT WIN32)
message(WARNING "Patchwork is designed for Windows. Cross-compilation may require adjustments.")
endif()
# Compiler flags
if(MSVC)
add_compile_options(/W4 /WX- /D_CRT_SECURE_NO_WARNINGS /DUNICODE /D_UNICODE)
add_compile_options(/Zi /Od)
else()
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS UNICODE _UNICODE)
endif()
# Common include directories
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/analysis
${CMAKE_SOURCE_DIR}/src/monitor
${CMAKE_SOURCE_DIR}/src/driver
)
# Source groups
set(CORE_SOURCES
src/core/kpp_context.c
src/core/kpp_timer.c
src/core/kpp_checks.c
)
set(CORE_HEADERS
src/core/kpp_context.h
src/core/kpp_timer.h
src/core/kpp_checks.h
)
set(ANALYSIS_SOURCES
src/analysis/pg_decrypt.c
src/analysis/exception_chain.c
src/analysis/dpc_analysis.c
)
set(ANALYSIS_HEADERS
src/analysis/pg_decrypt.h
src/analysis/exception_chain.h
src/analysis/dpc_analysis.h
)
set(MONITOR_SOURCES
src/monitor/kpp_monitor.c
src/monitor/integrity_check.c
)
set(MONITOR_HEADERS
src/monitor/kpp_monitor.h
src/monitor/integrity_check.h
)
set(COMMON_HEADERS
src/common/ntdef.h
)
# Static library with all analysis components
add_library(patchwork_lib STATIC
${CORE_SOURCES}
${ANALYSIS_SOURCES}
${MONITOR_SOURCES}
)
target_include_directories(patchwork_lib PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/src/common
)
# Usermode CLI tool
add_executable(patchwork_cli
src/usermode/cli.c
)
target_link_libraries(patchwork_cli PRIVATE patchwork_lib)
if(WIN32)
target_link_libraries(patchwork_cli PRIVATE advapi32 ntdll)
endif()
# Tests
enable_testing()
add_executable(test_pg_decrypt tests/test_pg_decrypt.c)
target_link_libraries(test_pg_decrypt PRIVATE patchwork_lib)
add_test(NAME PgDecryptTest COMMAND test_pg_decrypt)
add_executable(test_timer_enum tests/test_timer_enum.c)
target_link_libraries(test_timer_enum PRIVATE patchwork_lib)
add_test(NAME TimerEnumTest COMMAND test_timer_enum)
# Install rules
install(TARGETS patchwork_cli DESTINATION bin)
install(TARGETS patchwork_lib DESTINATION lib)
install(FILES ${COMMON_HEADERS} ${CORE_HEADERS} ${ANALYSIS_HEADERS} ${MONITOR_HEADERS}
DESTINATION include/patchwork
)
message(STATUS "Patchwork v${PROJECT_VERSION} - KPP Analysis Toolkit")
message(STATUS "Note: The kernel driver must be built separately with WDK.")