-
Notifications
You must be signed in to change notification settings - Fork 23
/
CMakeLists.txt
512 lines (449 loc) · 13.7 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# This file is automatically generated from cmake.toml - DO NOT EDIT
# See https://github.com/build-cpp/cmkr for more information
cmake_minimum_required(VERSION 3.15)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build")
endif()
set(CMKR_ROOT_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMKR_ROOT_PROJECT ON)
# Bootstrap cmkr and automatically regenerate CMakeLists.txt
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
if(CMKR_INCLUDE_RESULT)
cmkr()
endif()
# Enable folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Create a configure-time dependency on cmake.toml to improve IDE support
configure_file(cmake.toml cmake.toml COPYONLY)
endif()
project(Dotx64Dbg
LANGUAGES
CSharp
CXX
)
include(CSharpUtilities)
# Only have Release and Debug, there are configuration errors with managed otherwise.
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release")
SET(CMAKE_VS_NUGET_PACKAGE_RESTORE ON)
# Workaround for CLR projects, there is a pending fix for this:
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7807 which corrects the exception option in use of CLR
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32)
endif()
# Subdirectory: thirdparty
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/thirdparty")
else()
set(CMAKE_FOLDER thirdparty)
endif()
add_subdirectory(thirdparty)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})
# Target: Dotx64DbgCommon
add_library(Dotx64DbgCommon INTERFACE)
add_library(dotx64dbg::common ALIAS Dotx64DbgCommon)
target_compile_features(Dotx64DbgCommon INTERFACE
cxx_std_17
)
target_compile_options(Dotx64DbgCommon INTERFACE
"/MP"
)
target_link_options(Dotx64DbgCommon INTERFACE
"/DEBUG"
)
# Target: Dotx64DbgBindings
set(Dotx64DbgBindings_SOURCES
"src/Bindings/Breakpoints.cpp"
"src/Bindings/Commands.cpp"
"src/Bindings/Debugger.cpp"
"src/Bindings/Expressions.cpp"
"src/Bindings/Instruction.cpp"
"src/Bindings/Instruction.Decoder.cpp"
"src/Bindings/Instruction.Encoder.cpp"
"src/Bindings/Instruction.Generator.cpp"
"src/Bindings/Logging.cpp"
"src/Bindings/Memory.cpp"
"src/Bindings/Module.cpp"
"src/Bindings/Platform.cpp"
"src/Bindings/Process.cpp"
"src/Bindings/Settings.cpp"
"src/Bindings/Symbols.cpp"
"src/Bindings/Thread.cpp"
"src/Bindings/UI.cpp"
"src/Bindings/AsmJitHelper.hpp"
"src/Bindings/Decoder.Converter.hpp"
"src/Bindings/Encoder.Converter.hpp"
"src/Bindings/Instruction.Decoder.hpp"
"src/Bindings/Instruction.EFlags.hpp"
"src/Bindings/Instruction.Encoder.hpp"
"src/Bindings/Instruction.Generator.hpp"
"src/Bindings/Instruction.Meta.hpp"
"src/Bindings/Instruction.Operand.hpp"
"src/Bindings/Instruction.Operands.hpp"
"src/Bindings/Instruction.hpp"
"src/Bindings/Marshal.hpp"
"src/Bindings/Mnemonic.hpp"
"src/Bindings/Register.hpp"
cmake.toml
)
add_library(Dotx64DbgBindings SHARED)
target_sources(Dotx64DbgBindings PRIVATE ${Dotx64DbgBindings_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgBindings_SOURCES})
add_library(dotx64dbg::bindings ALIAS Dotx64DbgBindings)
target_link_libraries(Dotx64DbgBindings PRIVATE
dotx64dbg::common
x64dbg::pluginsdk
asmjit::asmjit
Zydis
)
set_target_properties(Dotx64DbgBindings PROPERTIES
RUNTIME_OUTPUT_NAME
Dotx64DbgBindings
DOTNET_TARGET_FRAMEWORK
net6.0
DOTNET_TARGET_FRAMEWORK_VERSION
6.0
COMMON_LANGUAGE_RUNTIME
netcore
VS_GLOBAL_ResolveNuGetPackages
false
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
set_target_properties(Dotx64DbgBindings PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
set_target_properties(Dotx64DbgBindings PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
set(CMKR_TARGET Dotx64DbgBindings)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x32bridge.dll")
endif()
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:titanengine.dll")
# Target: Dotx64DbgManaged
set(Dotx64DbgManaged_SOURCES
"src/Dotx64Managed/API/Analysis/RegisterMask.cs"
"src/Dotx64Managed/API/Assembler.cs"
"src/Dotx64Managed/API/Assembler.Instructions.cs"
"src/Dotx64Managed/API/Breakpoints.cs"
"src/Dotx64Managed/API/Commands.cs"
"src/Dotx64Managed/API/Debugger.cs"
"src/Dotx64Managed/API/Expressions.cs"
"src/Dotx64Managed/API/Memory.cs"
"src/Dotx64Managed/API/Memory.Stream.cs"
"src/Dotx64Managed/API/Module.cs"
"src/Dotx64Managed/API/Module.Exports.cs"
"src/Dotx64Managed/API/Module.Imports.cs"
"src/Dotx64Managed/API/Module.Sections.cs"
"src/Dotx64Managed/API/Platform.cs"
"src/Dotx64Managed/API/Process.cs"
"src/Dotx64Managed/API/Thread.cs"
"src/Dotx64Managed/API/Thread.Register.cs"
"src/Dotx64Managed/API/UI/Disassembly.cs"
"src/Dotx64Managed/API/UI/Dump.cs"
"src/Dotx64Managed/API/UI/Log.cs"
"src/Dotx64Managed/API/UI/MemoryMap.cs"
"src/Dotx64Managed/API/UI/Menu.cs"
"src/Dotx64Managed/API/UI/Stack.cs"
"src/Dotx64Managed/API/UI/StatusBar.cs"
"src/Dotx64Managed/API/UI/Types.cs"
"src/Dotx64Managed/API/UI/UI.cs"
"src/Dotx64Managed/AssemblyLoader.cs"
"src/Dotx64Managed/Compiler.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.Array.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.Class.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.GenericDictionary.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.GenericList.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.Object.cs"
"src/Dotx64Managed/Hotload/Hotload.Adapter.Statics.cs"
"src/Dotx64Managed/Hotload/Hotload.Context.cs"
"src/Dotx64Managed/Hotload/Hotload.cs"
"src/Dotx64Managed/IPlugin.cs"
"src/Dotx64Managed/Logging.cs"
"src/Dotx64Managed/Manager.cs"
"src/Dotx64Managed/Manager.Events.cs"
"src/Dotx64Managed/Menus.cs"
"src/Dotx64Managed/Menus.Main.cs"
"src/Dotx64Managed/NodeList.cs"
"src/Dotx64Managed/Plugins.Builder.cs"
"src/Dotx64Managed/Plugins.cs"
"src/Dotx64Managed/Plugins.DependencyManager.cs"
"src/Dotx64Managed/Plugins.Hotload.cs"
"src/Dotx64Managed/Plugins.Watcher.cs"
"src/Dotx64Managed/ProjectGenerator.cs"
"src/Dotx64Managed/Resources.cs"
"src/Dotx64Managed/Scripting/Scripting.cs"
"src/Dotx64Managed/Scripting/Scripting.Register.cs"
"src/Dotx64Managed/ScriptLoader.cs"
"src/Dotx64Managed/Settings.cs"
"src/Dotx64Managed/Tests.cs"
"src/Dotx64Managed/Utils.cs"
cmake.toml
)
add_library(Dotx64DbgManaged SHARED)
target_sources(Dotx64DbgManaged PRIVATE ${Dotx64DbgManaged_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgManaged_SOURCES})
add_library(dotx64dbg::managed ALIAS Dotx64DbgManaged)
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
target_compile_definitions(Dotx64DbgManaged PRIVATE
_X86_
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
target_compile_definitions(Dotx64DbgManaged PRIVATE
_X64_
)
endif()
target_link_libraries(Dotx64DbgManaged PRIVATE
dotx64dbg::bindings
)
set_target_properties(Dotx64DbgManaged PROPERTIES
RUNTIME_OUTPUT_NAME
Dotx64DbgManaged
DOTNET_SDK
Microsoft.NET.Sdk
DOTNET_TARGET_FRAMEWORK
net6.0
VS_GLOBAL_ResolveNuGetPackages
true
VS_GLOBAL_ROOTNAMESPACE
Dotx64Dbg
VS_GLOBAL_AppendTargetFrameworkToOutputPath
false
VS_GLOBAL_AppendRuntimeIdentifierToOutputPath
false
VS_GLOBAL_ProduceReferenceAssembly
false
VS_GLOBAL_ProduceReferenceAssemblyInOutDir
false
VS_GLOBAL_CopyLocalLockFileAssemblies
true
VS_GLOBAL_SatelliteResourceLanguages
neutral
VS_PACKAGE_REFERENCES
"Microsoft.CodeAnalysis.Compilers_3.10.0;NuGet.Configuration_5.11.5;NuGet.Frameworks_5.11.5;NuGet.Protocol_5.11.5;NuGet.Versioning_5.11.5"
VS_DOTNET_REFERENCES_COPY_LOCAL
false
)
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
set_target_properties(Dotx64DbgManaged PROPERTIES
VS_GLOBAL_PlatformTarget
x86
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
set_target_properties(Dotx64DbgManaged PROPERTIES
VS_GLOBAL_PlatformTarget
x64
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
# Target: Dotx64DbgTests
set(Dotx64DbgTests_SOURCES
"src/Dotx64DbgTests/Testing.cs"
"src/Dotx64DbgTests/Runner.cs"
"src/Dotx64DbgTests/Tests/Tests.Assembler.cs"
"src/Dotx64DbgTests/Tests/Tests.Decoder.cs"
"src/Dotx64DbgTests/Tests/Tests.Generator.cs"
"src/Dotx64DbgTests/Tests/Tests.Operands.cs"
"src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs"
"src/Dotx64DbgTests/Tests/Tests.Registers.cs"
cmake.toml
)
add_executable(Dotx64DbgTests)
target_sources(Dotx64DbgTests PRIVATE ${Dotx64DbgTests_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgTests_SOURCES})
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
target_compile_definitions(Dotx64DbgTests PRIVATE
_X86_
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
target_compile_definitions(Dotx64DbgTests PRIVATE
_X64_
)
endif()
target_link_libraries(Dotx64DbgTests PRIVATE
dotx64dbg::managed
dotx64dbg::bindings
)
set_target_properties(Dotx64DbgTests PROPERTIES
RUNTIME_OUTPUT_NAME
Dotx64DbgTests
DOTNET_SDK
Microsoft.NET.Sdk
DOTNET_TARGET_FRAMEWORK
net6.0
VS_GLOBAL_ROOTNAMESPACE
Dotx64Dbg
VS_GLOBAL_AppendTargetFrameworkToOutputPath
false
VS_GLOBAL_AppendRuntimeIdentifierToOutputPath
false
VS_GLOBAL_ProduceReferenceAssembly
false
VS_GLOBAL_ProduceReferenceAssemblyInOutDir
false
VS_GLOBAL_CopyLocalLockFileAssemblies
true
VS_GLOBAL_SatelliteResourceLanguages
neutral
VS_DOTNET_REFERENCES_COPY_LOCAL
true
)
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
set_target_properties(Dotx64DbgTests PROPERTIES
VS_GLOBAL_PlatformTarget
x86
RUNTIME_OUTPUT_DIRECTORY_RELEASE
"${BUILD_OUTPUT_DIR}/tests"
RUNTIME_OUTPUT_DIRECTORY_DEBUG
"${BUILD_OUTPUT_DIR}/tests"
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
set_target_properties(Dotx64DbgTests PROPERTIES
VS_GLOBAL_PlatformTarget
x64
RUNTIME_OUTPUT_DIRECTORY_RELEASE
"${BUILD_OUTPUT_DIR}/tests"
RUNTIME_OUTPUT_DIRECTORY_DEBUG
"${BUILD_OUTPUT_DIR}/tests"
)
endif()
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgTests)
endif()
# Target: Dotx64Dbg
set(Dotx64Dbg_SOURCES
"src/Dotx64Dbg/Loader.cpp"
"src/Dotx64Dbg/Plugin.cpp"
cmake.toml
)
add_library(Dotx64Dbg SHARED)
target_sources(Dotx64Dbg PRIVATE ${Dotx64Dbg_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64Dbg_SOURCES})
add_library(dotx64dbg::dotx64dbg ALIAS Dotx64Dbg)
target_link_libraries(Dotx64Dbg PRIVATE
dotx64dbg::common
x64dbg::pluginsdk
dotx64dbg::managed
)
set_target_properties(Dotx64Dbg PROPERTIES
DOTNET_TARGET_FRAMEWORK
net6.0
DOTNET_TARGET_FRAMEWORK_VERSION
6.0
COMMON_LANGUAGE_RUNTIME
netcore
VS_GLOBAL_ResolveNuGetPackages
false
VS_GLOBAL_SatelliteResourceLanguages
neutral
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
set_target_properties(Dotx64Dbg PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
set_target_properties(Dotx64Dbg PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
# Target: Dotx64DbgLoader
set(Dotx64DbgLoader_SOURCES
"src/Dotx64DbgLoader/Loader.cpp"
cmake.toml
)
add_library(Dotx64DbgLoader SHARED)
target_sources(Dotx64DbgLoader PRIVATE ${Dotx64DbgLoader_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgLoader_SOURCES})
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
target_compile_definitions(Dotx64DbgLoader PRIVATE
_X86_
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
target_compile_definitions(Dotx64DbgLoader PRIVATE
_X64_
)
endif()
target_link_libraries(Dotx64DbgLoader PRIVATE
dotx64dbg::common
x64dbg::pluginsdk
)
set_target_properties(Dotx64DbgLoader PROPERTIES
VS_GLOBAL_ResolveNuGetPackages
false
RUNTIME_OUTPUT_NAME
Dotx64Dbg
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
set_target_properties(Dotx64DbgLoader PROPERTIES
SUFFIX
.dp64
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
set_target_properties(Dotx64DbgLoader PROPERTIES
SUFFIX
.dp32
RUNTIME_OUTPUT_DIRECTORY_RELEASE
${BUILD_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG
${BUILD_OUTPUT_DIR}
)
endif()
# Target: Dotx64DbgResources
set(Dotx64DbgResources_SOURCES
cmake.toml
)
add_custom_target(Dotx64DbgResources SOURCES)
target_sources(Dotx64DbgResources PRIVATE ${Dotx64DbgResources_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgResources_SOURCES})
set(CMKR_TARGET Dotx64DbgResources)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/src/Resources
${BUILD_OUTPUT_DIR}/Resources
)