crashlink 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 N3rdL0rd
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.
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.1
2
+ Name: crashlink
3
+ Version: 0.0.1
4
+ Summary: Just another HashLink decompiler/disassembler.
5
+ Author-email: N3rdL0rd <n3rdl0rd@proton.me>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 N3rdL0rd
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Programming Language :: Python :: 3
29
+ Classifier: License :: OSI Approved :: MIT License
30
+ Classifier: Operating System :: OS Independent
31
+ Classifier: Topic :: Software Development :: Disassemblers
32
+ Requires-Python: >=3.10
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Provides-Extra: dev
36
+ Requires-Dist: pdoc3; extra == "dev"
37
+ Requires-Dist: black; extra == "dev"
38
+ Requires-Dist: build; extra == "dev"
39
+ Requires-Dist: twine; extra == "dev"
40
+ Requires-Dist: isort; extra == "dev"
41
+ Requires-Dist: mypy; extra == "dev"
42
+ Requires-Dist: radon; extra == "dev"
43
+ Requires-Dist: no_implicit_optional; extra == "dev"
44
+ Requires-Dist: pytest; extra == "dev"
45
+ Requires-Dist: tqdm; extra == "dev"
46
+ Requires-Dist: snakeviz; extra == "dev"
47
+ Requires-Dist: typeguard; extra == "dev"
48
+ Requires-Dist: types-tqdm; extra == "dev"
49
+ Provides-Extra: tqdm
50
+ Requires-Dist: tqdm; extra == "tqdm"
51
+
52
+ # crashlink
53
+
54
+ ![workflow](https://github.com/N3rdL0rd/crashlink/actions/workflows/python-package.yml/badge.svg)
55
+
56
+ Pure Python HashLink bytecode parser/disassembler/decompiler/modding tool
57
+
58
+ > [!WARNING]
59
+ > This project is under active development. Breaking changes may be made to APIs with zero notice.
60
+
61
+ ## Features
62
+
63
+ - Pure Python with zero dependencies, integrates nicely in a lot of places (IDAPython compatible!)
64
+ - Allows values to be externally modified and reserialised through a scriptable interface
65
+ - A very nice little CLI with [hlbc](https://github.com/Gui-Yom/hlbc)-compatible mode.
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ pip install crashlink
71
+ ```
72
+
73
+ Optionally, install `tqdm` for progress bars when parsing large files:
74
+
75
+ ```bash
76
+ pip install crashlink[tqdm]
77
+ ```
78
+
79
+ You also need to have Graphviz installed to generate control flow graphs. On most *nix systems, on Windows (with Chocolatey or Scoop), and on MacOS (with Homebrew), you can install it with your package manager under `graphviz`.
80
+
81
+ - Windows: `choco install graphviz`
82
+ - MacOS: `brew install graphviz`
83
+ - Debian: `sudo apt install graphviz`
84
+ - Arch: `sudo pacman -S graphviz`
85
+ - Fedora: `sudo dnf install graphviz`
86
+
87
+ ## Usage
88
+
89
+ Either:
90
+
91
+ ```py
92
+ from crashlink import *
93
+ code = Bytecode.from_path("path/to/file.hl")
94
+ for func in code.functions:
95
+ if func.findex.value == 22 or func.findex.value == 240: # typical entry points that the compiler generates
96
+ print(disasm.func(code, func))
97
+ # > f@22 static $Clazz.main () -> Void (from Clazz.hx)
98
+ # > Reg types:
99
+ # > 0. Void
100
+ # >
101
+ # > Ops:
102
+ # > 0. Ret {'ret': 0} return
103
+ ```
104
+
105
+ Or:
106
+
107
+ ```txt
108
+ $ crashlink path/to/file.hl # or python -m crashlink
109
+ crashlink> funcs
110
+ f@22 static Clazz.main () -> Void (from Clazz.hx)
111
+ f@23 Clazz.method (Clazz) -> I32 (from Clazz.hx)
112
+ crashlink> fn 22
113
+ f@22 static Clazz.main () -> Void (from Clazz.hx)
114
+ Reg types:
115
+ 0. Void
116
+
117
+ Ops:
118
+ 0. Ret {'ret': 0} return
119
+ ```
120
+
121
+ ## Development
122
+
123
+ > [!NOTE]
124
+ > This project is configured for the [just](https://just.systems/) command runner. If you don't have it installed, you can still run the commands in the `justfile` manually, but I don't recommend it.
125
+
126
+ For development purposes, you can clone the repo, install development dependencies, and run the tests:
127
+
128
+ ```bash
129
+ git clone https://github.com/N3rdL0rd/crashlink
130
+ cd crashlink
131
+ # optionally, create and activate a venv here.
132
+ just install # or pip install -e .[dev]
133
+ just test # or pytest
134
+ ```
135
+
136
+ Before committing, please run `just dev` to format the code, run tests, and generate documentation in `docs/`. If you're adding new features to the core serialisation/deserialisation code (`core.py`), please also add a test case in `tests/haxe/` for the new language feature you're adding. If you're adding a feature to the decompiler or disassembler, please add a normal test case (in Python) in `tests/` that tests the new feature.
137
+
138
+ Pull requests are always welcome! For major changes, please open an issue first to discuss what you would like to change.
139
+
140
+ You can use the following pre-defined commands with `just`:
141
+
142
+ - `just dev`: Run tests, format code, and generate documentation.
143
+ - `just build`: Build the package.
144
+ - `just install`: Install development dependencies and the package in editable mode.
145
+ - `just build-tests`: Build test samples.
146
+ - `just test`: Run tests.
147
+ - `just format`: Format code.
148
+ - `just docs`: Generate documentation.
149
+ - `just check`: Run static analysis/typechecking.
150
+ - `just clean`: Clean up build artifacts.
151
+ - `just profile`: Run the test suite with cProfile and then open the results in a browser.
152
+ - `just serve-docs`: Serve the documentation locally.
153
+
154
+ ## Architecture
155
+
156
+ ![Architecture](docs/static/flow.svg)
157
+
158
+ > [!NOTE]
159
+ > IR and the IR optimization layers have not yet been fully implemented.
160
+
161
+ ## Credits
162
+
163
+ - Thank you to [Gui-Yom](https://github.com/Gui-Yom) for writing hlbc and for maintaining documentation on the HashLink bytecode format, as well as for providing tests and helping me during development.
164
+ - Thank you to [Haxe Foundation](https://haxe.org/) for creating the HashLink VM and the Haxe programming language.
165
+ - And a big thank you to you, dear user, for being at least partially interested in this project.
166
+
167
+ :heart: N3rdL0rd
@@ -0,0 +1,116 @@
1
+ # crashlink
2
+
3
+ ![workflow](https://github.com/N3rdL0rd/crashlink/actions/workflows/python-package.yml/badge.svg)
4
+
5
+ Pure Python HashLink bytecode parser/disassembler/decompiler/modding tool
6
+
7
+ > [!WARNING]
8
+ > This project is under active development. Breaking changes may be made to APIs with zero notice.
9
+
10
+ ## Features
11
+
12
+ - Pure Python with zero dependencies, integrates nicely in a lot of places (IDAPython compatible!)
13
+ - Allows values to be externally modified and reserialised through a scriptable interface
14
+ - A very nice little CLI with [hlbc](https://github.com/Gui-Yom/hlbc)-compatible mode.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install crashlink
20
+ ```
21
+
22
+ Optionally, install `tqdm` for progress bars when parsing large files:
23
+
24
+ ```bash
25
+ pip install crashlink[tqdm]
26
+ ```
27
+
28
+ You also need to have Graphviz installed to generate control flow graphs. On most *nix systems, on Windows (with Chocolatey or Scoop), and on MacOS (with Homebrew), you can install it with your package manager under `graphviz`.
29
+
30
+ - Windows: `choco install graphviz`
31
+ - MacOS: `brew install graphviz`
32
+ - Debian: `sudo apt install graphviz`
33
+ - Arch: `sudo pacman -S graphviz`
34
+ - Fedora: `sudo dnf install graphviz`
35
+
36
+ ## Usage
37
+
38
+ Either:
39
+
40
+ ```py
41
+ from crashlink import *
42
+ code = Bytecode.from_path("path/to/file.hl")
43
+ for func in code.functions:
44
+ if func.findex.value == 22 or func.findex.value == 240: # typical entry points that the compiler generates
45
+ print(disasm.func(code, func))
46
+ # > f@22 static $Clazz.main () -> Void (from Clazz.hx)
47
+ # > Reg types:
48
+ # > 0. Void
49
+ # >
50
+ # > Ops:
51
+ # > 0. Ret {'ret': 0} return
52
+ ```
53
+
54
+ Or:
55
+
56
+ ```txt
57
+ $ crashlink path/to/file.hl # or python -m crashlink
58
+ crashlink> funcs
59
+ f@22 static Clazz.main () -> Void (from Clazz.hx)
60
+ f@23 Clazz.method (Clazz) -> I32 (from Clazz.hx)
61
+ crashlink> fn 22
62
+ f@22 static Clazz.main () -> Void (from Clazz.hx)
63
+ Reg types:
64
+ 0. Void
65
+
66
+ Ops:
67
+ 0. Ret {'ret': 0} return
68
+ ```
69
+
70
+ ## Development
71
+
72
+ > [!NOTE]
73
+ > This project is configured for the [just](https://just.systems/) command runner. If you don't have it installed, you can still run the commands in the `justfile` manually, but I don't recommend it.
74
+
75
+ For development purposes, you can clone the repo, install development dependencies, and run the tests:
76
+
77
+ ```bash
78
+ git clone https://github.com/N3rdL0rd/crashlink
79
+ cd crashlink
80
+ # optionally, create and activate a venv here.
81
+ just install # or pip install -e .[dev]
82
+ just test # or pytest
83
+ ```
84
+
85
+ Before committing, please run `just dev` to format the code, run tests, and generate documentation in `docs/`. If you're adding new features to the core serialisation/deserialisation code (`core.py`), please also add a test case in `tests/haxe/` for the new language feature you're adding. If you're adding a feature to the decompiler or disassembler, please add a normal test case (in Python) in `tests/` that tests the new feature.
86
+
87
+ Pull requests are always welcome! For major changes, please open an issue first to discuss what you would like to change.
88
+
89
+ You can use the following pre-defined commands with `just`:
90
+
91
+ - `just dev`: Run tests, format code, and generate documentation.
92
+ - `just build`: Build the package.
93
+ - `just install`: Install development dependencies and the package in editable mode.
94
+ - `just build-tests`: Build test samples.
95
+ - `just test`: Run tests.
96
+ - `just format`: Format code.
97
+ - `just docs`: Generate documentation.
98
+ - `just check`: Run static analysis/typechecking.
99
+ - `just clean`: Clean up build artifacts.
100
+ - `just profile`: Run the test suite with cProfile and then open the results in a browser.
101
+ - `just serve-docs`: Serve the documentation locally.
102
+
103
+ ## Architecture
104
+
105
+ ![Architecture](docs/static/flow.svg)
106
+
107
+ > [!NOTE]
108
+ > IR and the IR optimization layers have not yet been fully implemented.
109
+
110
+ ## Credits
111
+
112
+ - Thank you to [Gui-Yom](https://github.com/Gui-Yom) for writing hlbc and for maintaining documentation on the HashLink bytecode format, as well as for providing tests and helping me during development.
113
+ - Thank you to [Haxe Foundation](https://haxe.org/) for creating the HashLink VM and the Haxe programming language.
114
+ - And a big thank you to you, dear user, for being at least partially interested in this project.
115
+
116
+ :heart: N3rdL0rd
@@ -0,0 +1,111 @@
1
+ """
2
+ Pure Python HashLink bytecode parser/disassembler/decompiler/modding tool
3
+
4
+ ## Features
5
+
6
+ - Pure Python with zero dependencies, integrates nicely in a lot of places (IDAPython compatible!)
7
+ - Allows values to be externally modified and reserialised through a scriptable interface
8
+ - A very nice little CLI with [hlbc](https://github.com/Gui-Yom/hlbc)-compatible mode.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pip install crashlink
14
+ ```
15
+
16
+ Optionally, install `tqdm` for progress bars when parsing large files:
17
+
18
+ ```bash
19
+ pip install crashlink[tqdm]
20
+ ```
21
+
22
+ You also need to have Graphviz installed to generate control flow graphs. On most *nix systems, on Windows (with Chocolatey or Scoop), and on MacOS (with Homebrew), you can install it with your package manager under `graphviz`.
23
+
24
+ - Windows: `choco install graphviz`
25
+ - MacOS: `brew install graphviz`
26
+ - Debian: `sudo apt install graphviz`
27
+ - Arch: `sudo pacman -S graphviz`
28
+ - Fedora: `sudo dnf install graphviz`
29
+
30
+ ## Usage
31
+
32
+ Either:
33
+
34
+ ```py
35
+ from crashlink import *
36
+ code = Bytecode.from_path("path/to/file.hl")
37
+ for func in code.functions:
38
+ if func.findex.value == 22 or func.findex.value == 240: # typical entry points that the compiler generates
39
+ print(disasm.func(code, func))
40
+ # > f@22 static $Clazz.main () -> Void (from Clazz.hx)
41
+ # > Reg types:
42
+ # > 0. Void
43
+ # >
44
+ # > Ops:
45
+ # > 0. Ret {'ret': 0} return
46
+ ```
47
+
48
+ Or:
49
+
50
+ ```bash
51
+ $ crashlink path/to/file.hl # or python -m crashlink
52
+ crashlink> funcs
53
+ f@22 static Clazz.main () -> Void (from Clazz.hx)
54
+ f@23 Clazz.method (Clazz) -> I32 (from Clazz.hx)
55
+ crashlink> fn 22
56
+ f@22 static Clazz.main () -> Void (from Clazz.hx)
57
+ Reg types:
58
+ 0. Void
59
+
60
+ Ops:
61
+ 0. Ret {'ret': 0} return
62
+ ```
63
+
64
+ ## Development
65
+
66
+ > Note:
67
+ > This project is configured for the [just](https://just.systems/) command runner. If you don't have it installed, you can still run the commands in the `justfile` manually, but I don't recommend it.
68
+
69
+ For development purposes, you can clone the repo, install development dependencies, and run the tests:
70
+
71
+ ```bash
72
+ git clone https://github.com/N3rdL0rd/crashlink
73
+ cd crashlink
74
+ # optionally, create and activate a venv here.
75
+ just install # or pip install -e .[dev]
76
+ just test # or pytest
77
+ ```
78
+
79
+ Before committing, please run `just dev` to format the code, run tests, and generate documentation in `docs/`. If you're adding new features to the core serialisation/deserialisation code (`crashlink.core`), please also add a test case in `tests/haxe/` for the new language feature you're adding. If you're adding a feature to the decompiler or disassembler, please add a normal test case (in Python) in `tests/` that tests the new feature.
80
+
81
+ Pull requests are always welcome! For major changes, please open an issue first to discuss what you would like to change.
82
+
83
+ You can use the following pre-defined commands with `just`:
84
+
85
+ - `just dev`: Run tests, format code, and generate documentation.
86
+ - `just build`: Build the package.
87
+ - `just install`: Install development dependencies and the package in editable mode.
88
+ - `just build-tests`: Build test samples.
89
+ - `just test`: Run tests.
90
+ - `just format`: Format code.
91
+ - `just docs`: Generate documentation.
92
+ - `just check`: Run static analysis/typechecking.
93
+ - `just clean`: Clean up build artifacts.
94
+ - `just profile`: Run the test suite with cProfile and then open the results in a browser.
95
+ - `just serve-docs`: Serve the documentation locally.
96
+
97
+ ## Credits
98
+
99
+ - Thank you to [Gui-Yom](https://github.com/Gui-Yom) for writing hlbc and for maintaining documentation on the HashLink bytecode format, as well as for providing tests and helping me during development.
100
+ - Thank you to [Haxe Foundation](https://haxe.org/) for creating the HashLink VM and the Haxe programming language.
101
+ - And a big thank you to you, dear user, for being at least partially interested in this project.
102
+
103
+ ❤ N3rdL0rd
104
+
105
+ """
106
+
107
+ from . import decomp, disasm
108
+ from .core import *
109
+ from .errors import *
110
+ from .globals import *
111
+ from .opcodes import *