-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
119 lines (88 loc) · 3.58 KB
/
CMakeLists.txt
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
117
118
119
cmake_minimum_required(VERSION 3.15)
#enable_language(CSharp)
enable_language(CXX)
enable_language(C)
#set(CMAKE_CSharp_FLAGS "/define:TRACE /langversion:7.3")
#set(staticLinkToMyDll TRUE)
set(staticLinkToMyDll FALSE)
set(linkPeConv FALSE)
project(test_dll_load)
add_definitions(-DUNICODE -D_UNICODE)
set(CMAKE_CXX_STANDARD 20)
#set(CMAKE_CXX_STANDARD 17)
#---------------------------------------------------------------------
add_executable(test_dll_load
minhook/src/buffer.c
minhook/src/hook.c
minhook/src/trampoline.c
minhook/src/hde/hde64.c
minhook/src/hde/hde32.c
minhook/src/buffer.h
minhook/src/hde/hde32.h
minhook/src/hde/hde64.h
minhook/include/MinHook.h
minhook/src/hde/pstdint.h
minhook/src/hde/table32.h
minhook/src/hde/table64.h
minhook/src/trampoline.h
minhook/LICENSE.txt
test_dll.cpp
ntddk.h
)
set(outDir ${CMAKE_CURRENT_SOURCE_DIR}/bin)
set_target_properties( test_dll_load
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${outDir}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${outDir}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${outDir}"
)
add_dependencies(test_dll_load inject_exe)
#add_custom_command( TARGET test_dll_load POST_BUILD COMMAND dotnet run --project ${CMAKE_CURRENT_SOURCE_DIR}/inject_exe/inject_exe.csproj )
#---------------------------------------------------------------------
#add_executable(inject_exe inject_exe.cpp)
#set_target_properties( inject_exe
# PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY_DEBUG "${outDir}"
# RUNTIME_OUTPUT_DIRECTORY_RELEASE "${outDir}"
#)
#---------------------------------------------------------------------
add_library(dllstub SHARED dllstub.cpp)
set_target_properties( dllstub
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${outDir}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${outDir}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${outDir}"
)
#---------------------------------------------------------------------
add_library(mydll SHARED dll.cpp)
set_target_properties( mydll
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${outDir}/ext"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${outDir}/ext"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${outDir}/ext"
)
#---------------------------------------------------------------------
add_library(mydll2 SHARED dll.cpp)
set_target_properties( mydll2
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${outDir}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${outDir}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${outDir}"
)
include_external_msproject(inject_exe ${CMAKE_CURRENT_SOURCE_DIR}/inject_exe/inject_exe.csproj PLATFORM AnyCPU)
#set_target_properties(mydll PROPERTIES VS_GLOBAL_CLRSupport "true")
#target_compile_options(mydll PRIVATE /clr:netcore)
#set_property(TARGET mydll PROPERTY DOTNET_TARGET_FRAMEWORK "netcoreapp3.1")
if(${linkPeConv})
target_include_directories(test_dll_load PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libpeconv/include)
target_link_libraries(test_dll_load ${CMAKE_CURRENT_SOURCE_DIR}/libpeconv/libpeconv.lib)
add_compile_definitions(test_dll_load PECONV)
endif()
target_link_libraries(test_dll_load KtmW32.lib)
if(${staticLinkToMyDll})
target_link_libraries(test_dll_load ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/mydll.lib)
add_dependencies(test_dll_load mydll)
add_compile_definitions(test_dll_load STATIC_LINK_TO_DLL)
endif()
#target_link_libraries(test_dll_load delayimp.lib)
set_target_properties(test_dll_load PROPERTIES LINK_FLAGS "/DELAYLOAD:mydll.dll")