Skip to content

Commit 6e4809c

Browse files
committed
0.0.3
1 parent 02d2a18 commit 6e4809c

11 files changed

Lines changed: 448 additions & 56 deletions

File tree

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: Build & Publish wheels
2+
on:
3+
workflow_dispatch
4+
5+
6+
jobs:
7+
build_wheels_win:
8+
name: Build wheels on Windows
9+
runs-on: windows-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
submodules: recursive
15+
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: 9.X
20+
21+
- name: Publish
22+
run: |
23+
dotnet publish -c Release -r win-x86
24+
dotnet publish -c Release -r win-x64
25+
dotnet publish -c Release -r win-arm64
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.x'
31+
32+
- name: Build Wheels
33+
run: |
34+
cd ./bindings/python
35+
python -m pip install setuptools
36+
python setup.py bdist_wheel -p win32
37+
python setup.py bdist_wheel -p win_amd64
38+
python setup.py bdist_wheel -p win_arm64
39+
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: Windows
43+
path: ./bindings/python/dist/*.whl
44+
retention-days: 1
45+
46+
build_wheels_mac:
47+
name: Build wheels on MacOS
48+
runs-on: macos-latest
49+
50+
steps:
51+
- uses: actions/checkout@v4
52+
with:
53+
submodules: recursive
54+
55+
- name: Setup .NET
56+
uses: actions/setup-dotnet@v4
57+
with:
58+
dotnet-version: 9.X
59+
60+
- name: Publish
61+
run: |
62+
dotnet publish -c Release -r osx-x64
63+
dotnet publish -c Release -r osx-arm64
64+
65+
- name: Set up Python
66+
uses: actions/setup-python@v5
67+
with:
68+
python-version: '3.x'
69+
70+
- name: Build Wheels
71+
run: |
72+
cd ./bindings/python
73+
python -m pip install setuptools
74+
python setup.py bdist_wheel -p macosx_10_0_x86_64
75+
python setup.py bdist_wheel -p macosx_10_0_arm64
76+
77+
- uses: actions/upload-artifact@v4
78+
with:
79+
name: MacOS
80+
path: ./bindings/python/dist/*.whl
81+
retention-days: 1
82+
83+
build_wheels_linux:
84+
name: Build wheels on Ubuntu
85+
runs-on: ubuntu-22.04 # oldest ubuntu for compatiblity
86+
87+
steps:
88+
- uses: actions/checkout@v4
89+
with:
90+
submodules: recursive
91+
92+
- name: Setup .NET
93+
uses: actions/setup-dotnet@v4
94+
with:
95+
dotnet-version: 9.X
96+
97+
- name: Publish
98+
run: |
99+
dotnet publish -c Release -r linux-x64
100+
dotnet publish -c Release -r linux-musl-x64
101+
102+
- name: Set up Python
103+
uses: actions/setup-python@v5
104+
with:
105+
python-version: '3.x'
106+
107+
- name: Build Wheels
108+
run: |
109+
cd ./bindings/python
110+
python -m pip install setuptools
111+
python setup.py bdist_wheel -p manylinux2014_x86_64
112+
python setup.py bdist_wheel -p musllinux_2_0_x86_64
113+
114+
- uses: actions/upload-artifact@v4
115+
with:
116+
name: Linux
117+
path: ./bindings/python/dist/*.whl
118+
retention-days: 1
119+
120+
build_wheels_linux_arm:
121+
name: Build wheels on Ubuntu-Arm
122+
runs-on: ubuntu-22.04-arm # oldest ubuntu for compatiblity
123+
124+
steps:
125+
- uses: actions/checkout@v4
126+
with:
127+
submodules: recursive
128+
129+
- name: Setup .NET
130+
uses: actions/setup-dotnet@v4
131+
with:
132+
dotnet-version: 9.X
133+
134+
- name: Publish Arm64
135+
run: |
136+
dotnet publish -c Release -r linux-arm64
137+
dotnet publish -c Release -r linux-musl-arm64
138+
139+
- name: Publish Arm
140+
run: |
141+
sudo dpkg --add-architecture armhf
142+
sudo apt update
143+
sudo apt install -y gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libc6-dev:armhf
144+
dotnet publish -c Release -r linux-arm
145+
146+
- name: Set up Python
147+
uses: actions/setup-python@v5
148+
with:
149+
python-version: '3.x'
150+
151+
- name: Build Wheels
152+
run: |
153+
cd ./bindings/python
154+
python -m pip install setuptools
155+
python setup.py bdist_wheel -p manylinux2014_aarch64
156+
python setup.py bdist_wheel -p manylinux2014_armv7l
157+
python setup.py bdist_wheel -p musllinux_2_0_aarch64
158+
159+
- uses: actions/upload-artifact@v4
160+
with:
161+
name: Linux-Arm
162+
path: ./bindings/python/dist/*.whl
163+
retention-days: 1
164+
165+
upload_pypi:
166+
name: Publish to PyPI
167+
needs: [build_wheels_win, build_wheels_mac, build_wheels_linux, build_wheels_linux_arm]
168+
runs-on: ubuntu-latest
169+
170+
permissions:
171+
id-token: write
172+
steps:
173+
- uses: actions/download-artifact@v4
174+
with:
175+
path: dist
176+
merge-multiple: true
177+
178+
- name: Publish package distributions to PyPI
179+
uses: pypa/gh-action-pypi-publish@release/v1
180+
with:
181+
skip-existing: true

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
on:
3+
push:
4+
branches: [ "master" ]
5+
pull_request:
6+
branches: [ "master" ]
7+
8+
jobs:
9+
build_wheels:
10+
name: Build wheels on ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-13]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: recursive
21+
22+
- name: Setup .NET
23+
uses: actions/setup-dotnet@v4
24+
with:
25+
dotnet-version: 9.X
26+
27+
- name: Restore dependencies
28+
run: dotnet restore
29+
30+
- name: Publish
31+
run: dotnet publish -c Release
32+
33+
- name: Test
34+
run: dotnet test --no-build --verbosity normal
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using AssetStudio;
2-
using System.Drawing;
3-
using System.IO;
4-
using System.Runtime.InteropServices;
1+
using System.Runtime.InteropServices;
52

63
namespace TypeTreeGeneratorAPI
74
{
@@ -18,7 +15,7 @@ unsafe public static IntPtr TypeTreeGenerator_create(IntPtr unityVersionPtr)
1815
try
1916
{
2017
var typeTreeGenerator = new TypeTreeGenerator(unityVersion);
21-
return (IntPtr)GCHandle.Alloc(typeTreeGenerator);
18+
return GCHandle.ToIntPtr(GCHandle.Alloc(typeTreeGenerator));
2219
}
2320
catch
2421
{
@@ -27,7 +24,7 @@ unsafe public static IntPtr TypeTreeGenerator_create(IntPtr unityVersionPtr)
2724
}
2825

2926
[UnmanagedCallersOnly(EntryPoint = "TypeTreeGenerator_loadDLL")]
30-
unsafe public static int TypeTreeGenerator_loadDLL(IntPtr typeTreeGeneratorPtr, IntPtr dllPtr, int dllLength)
27+
unsafe public static int TypeTreeGenerator_loadDLL(IntPtr typeTreeGeneratorPtr, byte* dllPtr, int dllLength)
3128
{
3229
if (typeTreeGeneratorPtr == IntPtr.Zero)
3330
{
@@ -36,7 +33,7 @@ unsafe public static int TypeTreeGenerator_loadDLL(IntPtr typeTreeGeneratorPtr,
3633
try
3734
{
3835
var typeTreeGenerator = (TypeTreeGenerator)GCHandle.FromIntPtr(typeTreeGeneratorPtr).Target!;
39-
using (var stream = new UnmanagedMemoryStream((byte*)dllPtr, dllLength, dllLength, FileAccess.ReadWrite))
36+
using (var stream = new UnmanagedMemoryStream(dllPtr, dllLength, dllLength, FileAccess.ReadWrite))
4037
{
4138
if (stream == null)
4239
{
@@ -54,7 +51,7 @@ unsafe public static int TypeTreeGenerator_loadDLL(IntPtr typeTreeGeneratorPtr,
5451

5552

5653
[UnmanagedCallersOnly(EntryPoint = "TypeTreeGenerator_loadIL2CPP")]
57-
unsafe public static int TypeTreeGenerator_loadIL2CPP(IntPtr typeTreeGeneratorPtr, IntPtr assemblyDataPtr, int assemblyDataLength, IntPtr metadataDataPtr, int metadataDataLength)
54+
unsafe public static int TypeTreeGenerator_loadIL2CPP(IntPtr typeTreeGeneratorPtr, byte* assemblyDataPtr, int assemblyDataLength, byte* metadataDataPtr, int metadataDataLength)
5855
{
5956
if (typeTreeGeneratorPtr == IntPtr.Zero)
6057
{
@@ -68,11 +65,11 @@ unsafe public static int TypeTreeGenerator_loadIL2CPP(IntPtr typeTreeGeneratorPt
6865

6966
fixed (byte* managedPtr = assemblyData)
7067
{
71-
Buffer.MemoryCopy((void*)assemblyDataPtr, managedPtr, assemblyDataLength, assemblyDataLength);
68+
Buffer.MemoryCopy(assemblyDataPtr, managedPtr, assemblyDataLength, assemblyDataLength);
7269
}
7370
fixed (byte* managedPtr = metadataData)
7471
{
75-
Buffer.MemoryCopy((void*)metadataDataPtr, managedPtr, metadataDataLength, metadataDataLength);
72+
Buffer.MemoryCopy(metadataDataPtr, managedPtr, metadataDataLength, metadataDataLength);
7673
}
7774

7875
typeTreeGenerator.LoadIL2CPP(assemblyData, metadataData);
@@ -93,8 +90,9 @@ public static int TypeTreeGenerator_delete(IntPtr typeTreeGeneratorPtr)
9390
}
9491
try
9592
{
96-
var typeTreeGenerator = (TypeTreeGenerator)GCHandle.FromIntPtr(typeTreeGeneratorPtr).Target!;
97-
GCHandle.FromIntPtr(typeTreeGeneratorPtr).Free();
93+
var gch = GCHandle.FromIntPtr(typeTreeGeneratorPtr);
94+
//var typeTreeGenerator = (TypeTreeGenerator)gch.Target!;
95+
gch.Free();
9896
return 0;
9997
}
10098
catch

TypeTreeGeneratorCLI/Program.cs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
using System.Text.Json;
4-
using TypeTreeGeneratorAPI;
1+
using TypeTreeGeneratorAPI;
52

6-
Console.WriteLine("Hello, World!");
7-
var c = new TypeTreeGenerator("2020.3.41f1");
3+
if (args.Length < 2)
4+
{
5+
Console.WriteLine("Usage: TypeTreeGeneratorCLI <unity_version> <dll directory>");
6+
Console.WriteLine("Usage: TypeTreeGeneratorCLI <unity_version> <il2cpp assembly> <il2cpp metadata>");
7+
return;
8+
}
9+
10+
var generator = new TypeTreeGenerator(args[0]);
11+
12+
if (args.Length == 2)
13+
{
14+
var dll_dir = args[1];
15+
foreach (var dll_fp in Directory.GetFiles(dll_dir, "*.dll"))
16+
{
17+
var dll = File.ReadAllBytes(dll_fp);
18+
generator.LoadDLL(dll);
19+
}
20+
}
21+
else if (args.Length == 3)
22+
{
23+
var assembly_fp = args[1];
24+
var metadata_fp = args[2];
25+
var assembly = File.ReadAllBytes(assembly_fp);
26+
var metadata = File.ReadAllBytes(metadata_fp);
27+
generator.LoadIL2CPP(assembly, metadata);
28+
}
829

9-
var asm_fp = "D:\\Program Files\\SwordofConvallaria\\SoCLauncher\\SwordOfConvallaria\\GameAssembly.dll";
10-
var metadata_fp = "D:\\Program Files\\SwordofConvallaria\\SoCLauncher\\SwordOfConvallaria\\SoC_Data\\il2cpp_data\\Metadata\\global-metadata.dat";
11-
var asm_fs = new FileStream(asm_fp, FileMode.Open, FileAccess.Read);
12-
var metadata_fs = new FileStream(metadata_fp, FileMode.Open, FileAccess.Read);
13-
var asm = new byte[asm_fs.Length];
14-
var metadata = new byte[metadata_fs.Length];
15-
asm_fs.ReadExactly(asm);
16-
metadata_fs.ReadExactly(metadata);
17-
asm_fs.Close();
18-
metadata_fs.Close();
19-
c.LoadIL2CPP(asm, metadata);
20-
foreach (var def in c.GetMonoBehaviourDefinitions())
30+
foreach (var def in generator.GetMonoBehaviourDefinitions())
2131
{
22-
var nodes = c.GenerateTreeNodes(def.Module.Name, def.FullName);
32+
var nodes = generator.GenerateTreeNodes(def.Module.Name, def.FullName)!;
2333
if (nodes.Count == 0)
2434
continue;
2535
Console.WriteLine($"{def.Module.Name} - {def.FullName}");

bindings/python/.gitignore

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
.vscode/
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
.dump
46
.idea/
57
*.py[cod]
68
*$py.class
79

8-
# precompiled C extensions
9-
UnityPy/*.so
10-
UnityPy/*.pyd
10+
# precompiled native extensions
11+
TypeTreeGeneratorAPI/*.pyd
12+
TypeTreeGeneratorAPI/*.dll
13+
TypeTreeGeneratorAPI/*.so
14+
TypeTreeGeneratorAPI/*.dylib
1115

1216
# Distribution / packaging
1317
.Python

bindings/python/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025-2025 K0lb3
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

bindings/python/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Python Bindings for TypeTreeGenerator API
2+
3+
Simple bindings to use TypeTreeGenerator API in python.

0 commit comments

Comments
 (0)