summaryrefslogtreecommitdiff
path: root/inject/CMakeLists.txt
blob: a63933e49994e9e4df816f74ea0d05329a347cfb (plain)
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
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

include_directories (
    ${CMAKE_SOURCE_DIR}/thirdparty/devcon
    ${CMAKE_SOURCE_DIR}/thirdparty/mhook/mhook-lib
)

if (NOT MSVC)
    add_compiler_flags (-Wno-unused-function)
endif ()

add_library (injectee_iat MODULE
    injectee_iat.cpp
)

add_library (injectee_mhook MODULE
    injectee_mhook.cpp
)

set_target_properties (injectee_iat injectee_mhook PROPERTIES
    PREFIX ""
)
if (MSVC)
    set_target_properties (injectee_iat injectee_mhook PROPERTIES LINK_FLAGS "/ENTRY:DllMainStartup")
else ()
    if (CMAKE_SIZEOF_VOID_P EQUAL 4)
        set_target_properties (injectee_iat injectee_mhook PROPERTIES LINK_FLAGS "-Wl,--entry=_DllMainStartup@12")
    else ()
        set_target_properties (injectee_iat injectee_mhook PROPERTIES LINK_FLAGS "-Wl,--entry=DllMainStartup")
    endif ()
endif ()
target_link_libraries (injectee_mhook
    mhook
)

install (TARGETS injectee_iat injectee_mhook LIBRARY DESTINATION bin)
install_pdb (injectee_iat injectee_mhook DESTINATION bin)

add_executable (injector
    injector.cpp
)
set_target_properties (injector PROPERTIES
    OUTPUT_NAME inject
)
target_link_libraries (injector
    ${GETOPT_LIBRARIES}
    devcon
    psapi
)
install (TARGETS injector RUNTIME DESTINATION bin)
install_pdb (injector DESTINATION bin)