Skip to content

Commit c70c6f1

Browse files
committed
Modernize the plugin template a bit
- Update GitHub Actions with latest best practices - Update cmkr to the latest version - Update x64dbg-sdk to the latest snapshot - Simplify cmake.toml - Add documentation - Add some actual example code
1 parent 26b50b3 commit c70c6f1

File tree

13 files changed

+305
-632
lines changed

13 files changed

+305
-632
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cmkr
2+
/**/CMakeLists.txt linguist-generated
3+
/cmake/*.cmake linguist-vendored

.github/workflows/build.yml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
name: Visual Studio
2-
1+
name: Build
32
on: [push, pull_request]
43

54
jobs:
65
build:
76
# Skip building pull requests from the same repository
87
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
9-
runs-on: windows-2019
8+
runs-on: windows-2022
9+
permissions:
10+
contents: write # Allow job to create a release
1011
steps:
1112
- name: Checkout
12-
uses: actions/checkout@v2
13-
13+
uses: actions/checkout@v3
14+
1415
- name: Add msbuild to PATH
15-
uses: microsoft/setup-msbuild@v1.0.2
16-
16+
uses: microsoft/setup-msbuild@1ff57057b5cfdc39105cd07a01d78e9b0ea0c14c # v1.3.1
17+
1718
- name: Build (x64)
1819
run: |
1920
mkdir package\x64\plugins
@@ -27,24 +28,25 @@ jobs:
2728
cmake -B build32 -A Win32
2829
cmake --build build32 --config Release
2930
copy build32\Release\*.dp32 package\x32\plugins\
30-
31-
- uses: actions/upload-artifact@v2
31+
32+
- uses: actions/upload-artifact@v3
3233
with:
3334
name: ${{ github.event.repository.name }}-${{ github.sha }}
3435
path: package/
35-
36+
3637
- name: Compress artifacts
37-
uses: papeloto/action-zip@v1
38+
uses: vimtor/action-zip@26a249fb00d43ca98dad77a4b3838025fc226aa1 # v1.1
3839
if: ${{ startsWith(github.ref, 'refs/tags/') }}
3940
with:
4041
files: package/
4142
dest: ${{ github.event.repository.name }}-${{ github.ref_name }}.zip
4243

4344
- name: Release
44-
uses: softprops/action-gh-release@v1
45+
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15
4546
if: ${{ startsWith(github.ref, 'refs/tags/') }}
4647
with:
4748
prerelease: ${{ !startsWith(github.ref, 'refs/tags/v') || contains(github.ref, '-pre') }}
4849
files: ${{ github.event.repository.name }}-${{ github.ref_name }}.zip
50+
generate_release_notes: true
4951
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CMakeLists.txt

Lines changed: 23 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PluginTemplate
22

3-
Template CMake project for x64dbg plugins. This uses [cmkr](https://build-cpp.github.io/cmkr/), `cmake.toml` contains the project configuration.
3+
Template CMake project for x64dbg plugins. This uses [cmkr](https://cmkr.build), `cmake.toml` contains the project configuration.
44

55
## Using the template
66

@@ -9,6 +9,17 @@ You can click the green *Use this template* button. See the article [*Creating a
99

1010
Alternatively you can download a ZIP of this repository and set up the template locally.
1111

12+
## Getting started
13+
14+
- Pretty much all of the available functionality can be found in [`bridgemain.h`](https://github.com/x64dbg/x64dbg/blob/97ff1ec98a5bbf543e6d80ebbbd2401edf6c8cca/src/bridge/bridgemain.h).
15+
- You can find some (commented) example code in [`src/plugin.cpp`](./src/plugin.cpp).
16+
- Example plugins: https://plugins.x64dbg.com.
17+
- References:
18+
- https://help.x64dbg.com/en/latest/developers/plugins/index.html
19+
- https://x64dbg.com/blog/2016/10/04/architecture-of-x64dbg.html
20+
- https://x64dbg.com/blog/2016/10/20/threading-model.html
21+
- https://x64dbg.com/blog/2016/07/30/x64dbg-plugin-sdk.html
22+
1223
## Building
1324

1425
From a Visual Studio command prompt:
@@ -31,3 +42,10 @@ Alternatively you can open this folder in Visual Studio/CLion/Qt Creator.
3142

3243
![building animation](https://github.com/x64dbg/PluginTemplate/blob/3951eb4b320b7a26164616ab5141414e8cd5b0a1/building.gif?raw=true)
3344

45+
## Creating releases
46+
47+
This template has GitHub Actions set up in [`.github/workflows/build.yml`](./.github/workflows/build.yml). If you push a tag prefixed with `v` (for instance `v1.0`) it will automatically publish a GitHub release with the plugin binaries compiled for both architectures.
48+
49+
## Automatic reloading
50+
51+
You can set up the [PluginDevHelper](https://github.com/x64dbg/PluginDevHelper) utility to automatically unload and reload the plugin from x64dbg when compiling. See the README there for more detailled instructions.

cmake.toml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,24 @@ version = "3.15"
33
cmkr-include = "cmake/cmkr.cmake"
44

55
[project]
6-
cmake-before = """
7-
# Set up a more familiar Visual Studio configuration
8-
# Override these options with -DCMAKE_OPTION=Value
9-
#
10-
# See: https://cmake.org/cmake/help/latest/command/set.html#set-cache-entry
11-
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "")
12-
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG:FULL /INCREMENTAL:NO" CACHE STRING "")
13-
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG:FULL /INCREMENTAL:NO" CACHE STRING "")
14-
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
15-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "")
16-
"""
176
name = "PluginTemplate"
18-
include-after = [
19-
"cmake/CPM.cmake",
20-
"cmake/x64dbg.cmake",
7+
include-before = [
8+
"cmake/msvc-static-runtime.cmake",
9+
"cmake/msvc-configurations.cmake",
2110
]
2211

23-
[target.PluginTemplate]
12+
[fetch-content.x64dbg]
13+
url = "https://sourceforge.net/projects/x64dbg/files/snapshots/snapshot_2023-06-10_18-05.zip"
14+
sha1 = "04468bd61fb36d6b10d17f342f03ef12f5b2ce62"
15+
include-after = ["cmake/x64dbg.cmake"]
16+
17+
[template.plugin]
2418
type = "shared"
19+
add-function = "x64dbg_plugin"
20+
21+
[target.PluginTemplate]
22+
type = "plugin"
2523
sources = [
2624
"src/*.cpp",
2725
"src/*.h",
28-
]
29-
cmake-after = """
30-
x64dbg_plugin(${CMKR_TARGET})
31-
"""
26+
]

0 commit comments

Comments
 (0)