Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ trim_trailing_whitespace = true

[*.y*ml]
indent_size = 2
indent_style = space

[*.json]
indent_size = 2
13 changes: 11 additions & 2 deletions .github/workflows/cpp-apitracing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
image: gdatacyberdefense/clang-format:16

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Perform C++ format check
run: find plugins/apitracing/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
Expand All @@ -50,11 +50,20 @@ jobs:
compiler: [ clang, gcc ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build and test apitracing
run: |
cmake --preset ${{ matrix.compiler }}-debug
cmake --build --preset ${{ matrix.compiler }}-build-debug
ctest --preset ${{ matrix.compiler }}-test
working-directory: plugins/apitracing
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
13 changes: 11 additions & 2 deletions .github/workflows/cpp-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
image: gdatacyberdefense/clang-format:16

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Perform C++ format check
run: find vmicore/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
Expand All @@ -46,11 +46,20 @@ jobs:
compiler: [clang, gcc]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build and test vmicore
run: |
cmake --preset ${{ matrix.compiler }}-debug
cmake --build --preset ${{ matrix.compiler }}-build-debug
ctest --preset ${{ matrix.compiler }}-test
working-directory: vmicore
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
13 changes: 11 additions & 2 deletions .github/workflows/cpp-inmemory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
image: gdatacyberdefense/clang-format:16

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Perform C++ format check
run: find plugins/inmemoryscanner/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
Expand All @@ -50,11 +50,20 @@ jobs:
compiler: [ clang, gcc ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build and test inmemoryscanner
run: |
cmake --preset ${{ matrix.compiler }}-debug
cmake --build --preset ${{ matrix.compiler }}-build-debug
ctest --preset ${{ matrix.compiler }}-test
working-directory: plugins/inmemoryscanner
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
13 changes: 11 additions & 2 deletions .github/workflows/cpp-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
image: gdatacyberdefense/clang-format:16

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Perform C++ format check
run: find plugins/template/ -iname *.h -o -iname *.cpp | xargs clang-format --style=file --dry-run --Werror
Expand All @@ -50,11 +50,20 @@ jobs:
compiler: [ clang, gcc ]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');

- name: Build and test template
run: |
cmake --preset ${{ matrix.compiler }}-debug
cmake --build --preset ${{ matrix.compiler }}-build-debug
ctest --preset ${{ matrix.compiler }}-test
working-directory: plugins/template
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
140 changes: 86 additions & 54 deletions plugins/apitracing/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,88 @@
{
"version": 3,
"configurePresets": [
{
"name": "clang-debug",
"displayName": "Debug Clang",
"description": "Use Clang toolchain",
"generator": "Ninja",
"binaryDir": "build-clang-debug/",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld"
}
},
{
"name": "gcc-debug",
"displayName": "Debug G++",
"description": "Use gcc toolchain",
"generator": "Ninja",
"binaryDir": "build-gcc-debug/",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
}
],
"buildPresets": [
{
"name": "clang-build-debug",
"displayName": "Build Clang Debug",
"configurePreset": "clang-debug"
},
{
"name": "gcc-build-debug",
"displayName": "Build G++ Debug",
"configurePreset": "gcc-debug"
}
],
"testPresets": [
{
"name": "clang-test",
"displayName": "Test Clang",
"configurePreset": "clang-debug"
},
{
"name": "gcc-test",
"displayName": "Test G++",
"configurePreset": "gcc-debug"
}
]
"version": 3,
"configurePresets": [
{
"name": "clang-debug",
"displayName": "Clang Debug",
"description": "Use Clang toolchain",
"binaryDir": "build-clang-debug/",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS": "-stdlib=libc++",
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/vcpkg/triplets/",
"VCPKG_TARGET_TRIPLET": "x64-linux-clang"
}
},
{
"name": "clang-release",
"displayName": "Clang Release",
"inherits": "clang-debug",
"binaryDir": "build-clang-release/",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "gcc-debug",
"displayName": "G++ Debug",
"description": "Use gcc toolchain",
"binaryDir": "build-gcc-debug/",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "gcc-release",
"displayName": "G++ Release",
"inherits": "gcc-debug",
"binaryDir": "build-gcc-release/",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
}
],
"buildPresets": [
{
"name": "clang-build-debug",
"displayName": "Build Clang Debug",
"configurePreset": "clang-debug"
},
{
"name": "clang-build-release",
"displayName": "Build Clang Release",
"configurePreset": "clang-release"
},
{
"name": "gcc-build-debug",
"displayName": "Build G++ Debug",
"configurePreset": "gcc-debug"
},
{
"name": "gcc-build-release",
"displayName": "Build G++ Release",
"configurePreset": "gcc-release"
}
],
"testPresets": [
{
"name": "clang-test",
"displayName": "Test Clang",
"configurePreset": "clang-debug"
},
{
"name": "gcc-test",
"displayName": "Test G++",
"configurePreset": "gcc-debug"
}
]
}
14 changes: 14 additions & 0 deletions plugins/apitracing/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,17 @@ typedef struct _OBJECT_ATTRIBUTES {
The parameter *ObjectName* is a pointer to a unicode and forms an exception since it is extracted directly.
Both *PVOID* at the end are structs, that are currently not covered by our definitions.
You can find a list under the struct section in the [function definitions file](configuration/functiondefinitions/functionDefinitions.yaml).

## How to Build

- Install Build Requirements
- g++ or clang
- cmake
- vcpkg
- Clone this repository
- Inside the source directory, run:

```console
[user@localhost source_dir]$ cmake --preset <gcc/clang>-debug
[user@localhost source_dir]$ cmake --build --preset <gcc/clang>-build-debug
```
40 changes: 9 additions & 31 deletions plugins/apitracing/src/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,26 @@ target_compile_features(apitracing-obj PUBLIC cxx_std_20)
set_target_properties(apitracing-obj PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
target_include_directories(apitracing-obj INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)

include(FindPkgConfig)
pkg_check_modules(TCLAP REQUIRED tclap>=1.2)
# Setup TClap

include(FetchContent)
find_path(TCLAP_INCLUDE_DIRS "tclap/Arg.h")
target_include_directories(apitracing-obj PUBLIC ${TCLAP_INCLUDE_DIRS})

# Setup fmt library as it is not available yet in gnu stdlib

FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 8.1.1
)
FetchContent_MakeAvailable(fmt)
target_link_libraries(apitracing-obj PUBLIC fmt-header-only)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(apitracing-obj PUBLIC fmt::fmt)

# Setup yaml-cpp

FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG yaml-cpp-0.7.0
)
option(YAML_BUILD_SHARED_LIBS "" OFF)
option(YAML_CPP_BUILD_TOOLS "" OFF)
FetchContent_MakeAvailable(yaml-cpp)
set_property(TARGET yaml-cpp PROPERTY POSITION_INDEPENDENT_CODE TRUE)
find_package(yaml-cpp CONFIG REQUIRED)
target_link_libraries(apitracing-obj PUBLIC yaml-cpp::yaml-cpp)
target_compile_definitions(apitracing-obj PUBLIC YAML_CPP_SUPPORT)
target_link_libraries(apitracing-obj PUBLIC yaml-cpp)

# Setup json-cpp

FetchContent_Declare(
jsoncpp
GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp.git
GIT_TAG 1.9.5
)
option(JSONCPP_WITH_TESTS "" OFF)
option(JSONCPP_WITH_POST_BUILD_UNITTEST "" OFF)
option(JSONCPP_WITH_EXAMPLE "" OFF)
FetchContent_MakeAvailable(jsoncpp)
set_property(TARGET jsoncpp_static PROPERTY POSITION_INDEPENDENT_CODE TRUE)
target_link_libraries(apitracing-obj PUBLIC jsoncpp_static)
find_package(jsoncpp CONFIG REQUIRED)
target_link_libraries(apitracing-obj PUBLIC JsonCpp::JsonCpp)

# Add public vmicore headers

Expand Down
14 changes: 4 additions & 10 deletions plugins/apitracing/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@ add_executable(apitracing-test
FunctionHook_UnitTest.cpp
TracedProcess_UnitTest.cpp
Tracer_UnitTest.cpp)
target_link_libraries(apitracing-test apitracing-obj pthread)
target_link_libraries(apitracing-test PRIVATE apitracing-obj)

# Setup bundled google test framework

FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
option(INSTALL_GTEST "" OFF)
FetchContent_MakeAvailable(googletest)
target_link_libraries(apitracing-test gtest gmock gmock_main)
find_package(GTest CONFIG REQUIRED)
target_link_libraries(apitracing-test PRIVATE GTest::gtest GTest::gmock GTest::gmock_main)

# Add VmiCore public test headers

add_subdirectory("${VMICORE_DIRECTORY_ROOT}/test/include" "${CMAKE_CURRENT_BINARY_DIR}/vmicore-public-test-headers")
target_link_libraries(apitracing-test vmicore-public-test-headers)
target_link_libraries(apitracing-test PRIVATE vmicore-public-test-headers)

# Copy config files to bin directory

Expand Down
1 change: 1 addition & 0 deletions plugins/apitracing/vcpkg
14 changes: 14 additions & 0 deletions plugins/apitracing/vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "14542c8ad9b6bcb9da755884ab823605c3300b68",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}
Loading
Loading