Skip to content

Commit adaac6f

Browse files
Merge remote-tracking branch 'upstream' into dev
2 parents 9a6e727 + bd1a157 commit adaac6f

File tree

1,072 files changed

+250338
-86973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,072 files changed

+250338
-86973
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ assignees: ''
99

1010
**Version and Platform (required):**
1111
- Binary Ninja Version: [e.g. 4.0.4000-dev] (if version is stable, please also test the latest development build via the "Update Channel" option)
12+
- Edition: Non-Commercial / Commercial / Ultimate
1213
- OS: [e.g. Ubuntu Linux]
1314
- OS Version: [e.g. 22.04]
1415
- CPU Architecture: [e.g. x64 or M1]
@@ -32,7 +33,7 @@ If applicable, please add screenshots/video recording here to help explain your
3233
**Binary:**
3334
If applicable, please provide us with the binary to help us work with the issue faster. Here are a few options:
3435

35-
1. Upload it privately using the [Binary Ninja Portal file uploader](https://portal.binary.ninja/upload) and add the provided reference phrase here
36+
1. Upload it privately using the [Binary Ninja Portal file uploader](https://portal.binary.ninja/upload) and add the provided reference phrase here.
3637
2. Directly attach it to this issue in a ZIP archive
3738
3. Share a publicly accessible link to it (For malware samples, we do not have access to VirusTotal; [Malshare](https://malshare.com/) is an option)
3839
4. Email it to binaryninja at vector35.com, or join our [Slack](https://slack.binary.ninja/) and share it with us in private

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ python/generator.tlog
3434
.cache/
3535
target/
3636
view/sharedcache/api/python/_sharedcachecore.py
37+
view/kernelcache/api/python/_kernelcachecore.py
38+
plugins/warp/api/python/_warpcore.py
3739

3840
# Unit Tests
3941
suite/unit.py
@@ -91,3 +93,6 @@ rust/examples/dwarf/*/target/
9193
# Debugger docs
9294
docs/img/debugger
9395
docs/guide/debugger
96+
97+
# AI
98+
.claude

CMakeLists.txt

Lines changed: 42 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
22

33
project(binaryninjaapi CXX C)
44
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
55

66
option(BN_API_BUILD_EXAMPLES "Builds example plugins" OFF)
7+
option(BN_ALLOW_STUBS "Allow generating and linking against stubs if a Binary Ninja installation was not found" OFF)
78

89
option(BN_REF_COUNT_DEBUG "Add extra debugging checks for RefCountObject leaks" OFF)
910
mark_as_advanced(BN_REF_COUNT_DEBUG)
@@ -33,46 +34,39 @@ add_library(binaryninjaapi STATIC ${BN_API_SOURCES})
3334
target_include_directories(binaryninjaapi
3435
PUBLIC ${PROJECT_SOURCE_DIR})
3536

37+
# Store path to user plugin dir
38+
if(WIN32)
39+
set(BN_USER_PLUGINS_DIR "$ENV{APPDATA}\\Binary Ninja\\plugins")
40+
elseif(APPLE)
41+
set(BN_USER_PLUGINS_DIR "$ENV{HOME}/Library/Application Support/Binary Ninja/plugins")
42+
else()
43+
set(BN_USER_PLUGINS_DIR "$ENV{HOME}/.binaryninja/plugins")
44+
endif()
45+
message(STATUS "Binary Ninja User Plugins Dir: ${BN_USER_PLUGINS_DIR}")
46+
3647
find_package(BinaryNinjaCore)
3748
if(BinaryNinjaCore_FOUND)
3849
target_link_libraries(binaryninjaapi PUBLIC ${BinaryNinjaCore_LIBRARIES})
3950
target_link_directories(binaryninjaapi PUBLIC ${BinaryNinjaCore_LIBRARY_DIRS})
4051
target_compile_definitions(binaryninjaapi PUBLIC ${BinaryNinjaCore_DEFINITIONS})
52+
elseif(BN_ALLOW_STUBS)
53+
add_subdirectory(stubs EXCLUDE_FROM_ALL)
54+
55+
# Be sure to only link against the stubs archive file
56+
add_dependencies(binaryninjaapi binaryninjacore_stubs)
57+
target_link_libraries(binaryninjaapi PUBLIC binaryninjacore_stubs)
4158
else()
42-
if(APPLE)
43-
target_link_options(binaryninjaapi PUBLIC -undefined dynamic_lookup)
44-
elseif(MSVC)
45-
# Generate stubs.cpp with implementations of all the BNAPI functions
46-
execute_process(COMMAND python ${PROJECT_SOURCE_DIR}/cmake/generate_stubs.py ${PROJECT_SOURCE_DIR}/binaryninjacore.h ${PROJECT_BINARY_DIR}/stubs)
47-
48-
# Compile those stubs into a stub library we can use to fool the linker
49-
add_library(binaryninjacore SHARED ${PROJECT_BINARY_DIR}/stubs/stubs.cpp)
50-
set_target_properties(binaryninjacore
51-
PROPERTIES OUTPUT_NAME binaryninjacore
52-
SOVERSION 1
53-
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/stubs
54-
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/stubs
55-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/stubs
56-
)
57-
target_include_directories(binaryninjacore PUBLIC ${PROJECT_SOURCE_DIR})
58-
59-
# Be sure to only link against the stubs archive file
60-
add_dependencies(binaryninjaapi binaryninjacore)
61-
if(${CMAKE_GENERATOR} MATCHES "^Visual Studio")
62-
# Visual Studio's generator adds the config to the file path
63-
target_link_libraries(binaryninjaapi PUBLIC "$<TARGET_PROPERTY:binaryninjacore,ARCHIVE_OUTPUT_DIRECTORY>/$<CONFIG>/$<TARGET_PROPERTY:binaryninjacore,OUTPUT_NAME>.lib")
64-
else()
65-
target_link_libraries(binaryninjaapi PUBLIC "$<TARGET_PROPERTY:binaryninjacore,ARCHIVE_OUTPUT_DIRECTORY>/$<TARGET_PROPERTY:binaryninjacore,OUTPUT_NAME>.lib")
66-
endif()
67-
else()
68-
target_link_options(binaryninjaapi PUBLIC "LINKER:--allow-shlib-undefined")
69-
endif()
59+
message(FATAL_ERROR "No Binary Ninja installation was found and stub generation is disabled")
7060
endif()
7161

7262
if(BN_REF_COUNT_DEBUG)
7363
target_compile_definitions(binaryninjaapi PUBLIC BN_REF_COUNT_DEBUG)
7464
endif()
7565

66+
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
67+
target_compile_definitions(binaryninjaapi PRIVATE BN_ENABLE_LOG_TRACE)
68+
endif()
69+
7670
add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL)
7771
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
7872
target_link_libraries(binaryninjaapi PUBLIC fmt::fmt)
@@ -83,7 +77,7 @@ if(APPLE)
8377
endif()
8478

8579
set_target_properties(binaryninjaapi PROPERTIES
86-
CXX_STANDARD 17
80+
CXX_STANDARD 20
8781
CXX_VISIBILITY_PRESET hidden
8882
CXX_STANDARD_REQUIRED ON
8983
VISIBILITY_INLINES_HIDDEN ON
@@ -99,7 +93,7 @@ if(NOT HEADLESS)
9993
if(BinaryNinjaUI_FOUND)
10094
# Precompiled ui library
10195
add_library(binaryninjaui INTERFACE)
102-
target_link_libraries(binaryninjaui INTERFACE ${BinaryNinjaUI_LIBRARIES})
96+
target_link_libraries(binaryninjaui INTERFACE binaryninjaapi ${BinaryNinjaUI_LIBRARIES})
10397
target_link_directories(binaryninjaui INTERFACE ${BinaryNinjaUI_LIBRARY_DIRS})
10498
target_compile_definitions(binaryninjaui INTERFACE ${BinaryNinjaUI_DEFINITIONS})
10599

@@ -118,25 +112,24 @@ if(NOT HEADLESS)
118112
endif()
119113

120114
function(bn_install_plugin target)
115+
if(WIN32)
116+
set(BN_USER_PLUGINS_DIR "$ENV{APPDATA}\\Binary Ninja\\plugins")
117+
elseif(APPLE)
118+
set(BN_USER_PLUGINS_DIR "$ENV{HOME}/Library/Application Support/Binary Ninja/plugins")
119+
else()
120+
set(BN_USER_PLUGINS_DIR "$ENV{HOME}/.binaryninja/plugins")
121+
endif()
122+
121123
if(NOT BN_INTERNAL_BUILD)
122-
# Get API source directory so we can find BinaryNinjaCore
123-
get_target_property(BN_API_SOURCE_DIR binaryninjaapi SOURCE_DIR)
124-
message(STATUS "${BN_API_SOURCE_DIR}")
125-
list(APPEND CMAKE_MODULE_PATH "${BN_API_SOURCE_DIR}/cmake")
126-
127-
# BinaryNinjaCore has the user plugins dir define that we want
128-
find_package(BinaryNinjaCore)
129-
if(BinaryNinjaCore_FOUND)
130-
if(WIN32)
131-
install(TARGETS ${target} RUNTIME
132-
DESTINATION ${BinaryNinjaCore_USER_PLUGINS_DIR})
133-
134-
install(FILES $<TARGET_PDB_FILE:${target}>
135-
DESTINATION ${BinaryNinjaCore_USER_PLUGINS_DIR} OPTIONAL)
136-
else()
137-
install(TARGETS ${target} LIBRARY
138-
DESTINATION ${BinaryNinjaCore_USER_PLUGINS_DIR})
139-
endif()
124+
if(WIN32)
125+
install(TARGETS ${target} RUNTIME
126+
DESTINATION ${BN_USER_PLUGINS_DIR})
127+
128+
install(FILES $<TARGET_PDB_FILE:${target}>
129+
DESTINATION ${BN_USER_PLUGINS_DIR} OPTIONAL)
130+
else()
131+
install(TARGETS ${target} LIBRARY
132+
DESTINATION ${BN_USER_PLUGINS_DIR})
140133
endif()
141134
endif()
142135
endfunction()

0 commit comments

Comments
 (0)