Skip to content

Commit 0f22d9c

Browse files
authored
init (#1)
init
1 parent b6d4e82 commit 0f22d9c

File tree

4,265 files changed

+180362
-54
lines changed

Some content is hidden

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

4,265 files changed

+180362
-54
lines changed

.github/workflows/ci.yaml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
env:
12+
VERSION_MAJOR: 0
13+
VERSION_MINOR: 1
14+
15+
jobs:
16+
version:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
version: ${{ steps.version.outputs.version }}
20+
build: ${{ steps.version.outputs.build }}
21+
revision: ${{ steps.version.outputs.revision }}
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- name: generate version
29+
id: version
30+
shell: bash
31+
run: |
32+
BUILD_NUMBER=0
33+
REVISION=${{ github.run_number }}
34+
VERSION="${{ env.VERSION_MAJOR }}.${{ env.VERSION_MINOR }}.${BUILD_NUMBER}.${REVISION}"
35+
36+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
37+
echo "build=${BUILD_NUMBER}" >> $GITHUB_OUTPUT
38+
echo "revision=${REVISION}" >> $GITHUB_OUTPUT
39+
40+
echo "Generated version: ${VERSION}"
41+
echo " - Build: ${BUILD_NUMBER}"
42+
echo " - Revision (Run Number): ${REVISION}"
43+
44+
build:
45+
needs: version
46+
strategy:
47+
matrix:
48+
include:
49+
- os: windows-latest
50+
platform: windows
51+
- os: ubuntu-latest
52+
platform: linux
53+
54+
runs-on: ${{ matrix.os }}
55+
56+
steps:
57+
- name: checkout
58+
uses: actions/checkout@v5
59+
with:
60+
fetch-depth: 0
61+
62+
- name: setup .NET
63+
uses: actions/setup-dotnet@v5
64+
with:
65+
dotnet-version: 8.0.x
66+
67+
- name: build (Linux)
68+
if: runner.os == 'Linux'
69+
run: |
70+
echo "[+] build linux"
71+
dotnet publish -r linux-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
72+
73+
- name: build (Windows)
74+
if: runner.os == 'Windows'
75+
run: |
76+
echo "[+] build windows"
77+
dotnet publish -r win-x64 --self-contained=true -c Release -p:PublishDir=build /p:Version=${{ needs.version.outputs.version }} /p:FileVersion=${{ needs.version.outputs.version }} /p:AssemblyVersion=${{ needs.version.outputs.version }} /p:ProductVersion=${{ needs.version.outputs.version }}
78+
79+
- name: collect artifacts
80+
shell: bash
81+
run: |
82+
mkdir -p artifacts
83+
cp build/* artifacts/
84+
ls -lh artifacts
85+
86+
- name: upload artifacts
87+
uses: actions/upload-artifact@v3
88+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
89+
with:
90+
name: ${{ matrix.platform }}-v${{ needs.version.outputs.version }}
91+
path: artifacts/*.*
92+
93+
release:
94+
needs: [ version , build ]
95+
runs-on: ubuntu-latest
96+
if: github.ref == 'refs/heads/master' && github.ref == 'refs/heads/master' && github.event_name == 'push'
97+
steps:
98+
- name: checkout
99+
uses: actions/checkout@v3
100+
with:
101+
fetch-depth: 0
102+
103+
- name: download artifacts
104+
uses: actions/download-artifact@v3
105+
with:
106+
path: artifacts
107+
108+
- name: create release
109+
uses: softprops/action-gh-release@v1
110+
with:
111+
tag_name: v${{ needs.version.outputs.version }}
112+
name: release v${{ needs.version.outputs.version }}
113+
generate_releases: true
114+
draft: false
115+
prerelease: true
116+
files: artifacts/*.*
117+
118+
- name: publish to NuGet
119+
if: secrets.NUGET_TOKEN != ''
120+
env:
121+
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
122+
run: |
123+
echo "[+] Publishing NuGet packages with version ${{ needs.version.outputs.version }}"
124+
shopt -s globstar nullglob
125+
126+
for pkg in artifacts/**/*.nupkg; do
127+
if [[ "$pkg" == *.snupkg ]]; then
128+
continue
129+
fi
130+
echo "-> dotnet nuget push $pkg"
131+
dotnet nuget push "$pkg" \
132+
--api-key "$NUGET_AUTH_TOKEN" \
133+
--source "https://api.nuget.org/v3/index.json" \
134+
--skip-duplicate
135+
done

.gitignore

Lines changed: 7 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,7 @@
1-
## A streamlined .gitignore for modern .NET projects
2-
## including temporary files, build results, and
3-
## files generated by popular .NET tools. If you are
4-
## developing with Visual Studio, the VS .gitignore
5-
## https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
6-
## has more thorough IDE-specific entries.
7-
##
8-
## Get latest from https://github.com/github/gitignore/blob/main/Dotnet.gitignore
9-
10-
# Build results
11-
[Dd]ebug/
12-
[Dd]ebugPublic/
13-
[Rr]elease/
14-
[Rr]eleases/
15-
x64/
16-
x86/
17-
[Ww][Ii][Nn]32/
18-
[Aa][Rr][Mm]/
19-
[Aa][Rr][Mm]64/
20-
bld/
21-
[Bb]in/
22-
[Oo]bj/
23-
[Ll]og/
24-
[Ll]ogs/
25-
26-
# .NET Core
27-
project.lock.json
28-
project.fragment.lock.json
29-
artifacts/
30-
31-
# ASP.NET Scaffolding
32-
ScaffoldingReadMe.txt
33-
34-
# NuGet Packages
35-
*.nupkg
36-
# NuGet Symbol Packages
37-
*.snupkg
38-
39-
# Others
40-
~$*
41-
*~
42-
CodeCoverage/
43-
44-
# MSBuild Binary and Structured Log
45-
*.binlog
46-
47-
# MSTest test Results
48-
[Tt]est[Rr]esult*/
49-
[Bb]uild[Ll]og.*
50-
51-
# NUnit
52-
*.VisualState.xml
53-
TestResult.xml
54-
nunit-*.xml
1+
# dir
2+
.idea/
3+
obj/
4+
bin/
5+
dist/
6+
build/
7+
Folder.DotSettings.user/

.globalconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
is_global = true
2+
dotnet_diagnostic.CA1510.severity = none
3+
dotnet_diagnostic.CA1822.severity = none

BinaryNinja.csproj

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<RootNamespace>BinaryNinja</RootNamespace>
4+
<AssemblyName>BinaryNinja</AssemblyName>
5+
6+
<TargetFramework>net8.0</TargetFramework>
7+
<LangVersion>latestmajor</LangVersion>
8+
<ImplicitUsings>disable</ImplicitUsings>
9+
<Nullable>enable</Nullable>
10+
<OutputType>library</OutputType>
11+
12+
<NativeLib>Shared</NativeLib>
13+
<PublishAot>true</PublishAot>
14+
<IsAotCompatible>true</IsAotCompatible>
15+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
16+
17+
<!-- version -->
18+
<Version>0.1.0.0</Version>
19+
<AssemblyVersion>0.1.0.0</AssemblyVersion>
20+
<FileVersion>0.1.0.0</FileVersion>
21+
<ProductVersion>0.1.0.0</ProductVersion>
22+
<Company>tinysec.net</Company>
23+
<Product>SharpBinja</Product>
24+
<Copyright>tinysec©2006-2025</Copyright>
25+
<Description>BinaryNinja dotnet bindings</Description>
26+
</PropertyGroup>
27+
28+
<!-- for Windows -->
29+
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'win-x64'">
30+
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
31+
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
32+
</PropertyGroup>
33+
</Project>

Constant.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace BinaryNinja
2+
{
3+
public static partial class Core
4+
{
5+
public const byte MaxConfidence = 255;
6+
7+
// BN_CURRENT_CORE_ABI_VERSION 147
8+
public const uint CurrentCoreABIVersion = 147;
9+
}
10+
}

Delegate/BNProgressFunction.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Runtime.InteropServices;
4+
using Microsoft.Win32.SafeHandles;
5+
6+
namespace BinaryNinja
7+
{
8+
public delegate bool ProgressDelegate(
9+
10+
// uint64_t param2
11+
ulong param2 ,
12+
13+
// uint64_t param3
14+
ulong param3
15+
);
16+
17+
internal static partial class NativeDelegates
18+
{
19+
/// <summary>
20+
///
21+
/// typedef bool (*BNProgressFunction)(void* param1, uint64_t param2, uint64_t param3)
22+
/// </summary>
23+
[UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.Cdecl)]
24+
internal delegate bool BNProgressFunction(
25+
26+
// void* param1
27+
IntPtr param1 ,
28+
29+
// uint64_t param2
30+
ulong param2 ,
31+
32+
// uint64_t param3
33+
ulong param3
34+
);
35+
}
36+
37+
internal static partial class UnsafeUtils
38+
{
39+
internal static NativeDelegates.BNProgressFunction WrapProgressDelegate(
40+
ProgressDelegate callback)
41+
{
42+
return bool (param1 , param2 , param3) =>
43+
{
44+
return callback(param2 , param3);
45+
};
46+
}
47+
}
48+
}

Delegate/MatchConstantDelegate.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace BinaryNinja
4+
{
5+
public delegate bool MatchConstantDelegate
6+
(
7+
ulong address ,
8+
LinearDisassemblyLine line
9+
);
10+
11+
internal static partial class NativeDelegates
12+
{
13+
// bool (*matchCallback)(void* matchCtxt, uint64_t addr, BNLinearDisassemblyLine* line)
14+
public delegate bool MatchConstantDelegate(
15+
IntPtr matchCtxt,
16+
ulong address,
17+
IntPtr line
18+
);
19+
}
20+
21+
internal static partial class UnsafeUtils
22+
{
23+
internal static NativeDelegates.MatchConstantDelegate WrapMatchConstantDelegate(
24+
MatchConstantDelegate callback)
25+
{
26+
return bool (matchCtxt , address , line) =>
27+
{
28+
return callback (
29+
address ,
30+
LinearDisassemblyLine.MustFromNativePointer(line)
31+
);
32+
};
33+
}
34+
}
35+
}

Delegate/MatchDataDelegate.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace BinaryNinja
4+
{
5+
public delegate bool MatchDataDelegate
6+
(
7+
ulong address ,
8+
byte[] data
9+
);
10+
11+
internal static partial class NativeDelegates
12+
{
13+
// bool (*matchCallback)(void* matchCtxt, uint64_t addr, BNDataBuffer* match)
14+
public delegate bool MatchDataDelegate(
15+
IntPtr matchCtxt,
16+
ulong address,
17+
IntPtr match
18+
);
19+
}
20+
21+
internal static partial class UnsafeUtils
22+
{
23+
internal static NativeDelegates.MatchDataDelegate WrapMatchDataDelegate(
24+
MatchDataDelegate callback)
25+
{
26+
return bool (matchCtxt , address , buffer) =>
27+
{
28+
return callback(
29+
address ,
30+
DataBuffer.MustBorrowHandle(buffer).Contents
31+
);
32+
};
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)