unidecompiler-plugin-dotnet-cli 0.1.0__tar.gz → 0.1.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.
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/PKG-INFO +7 -2
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/pyproject.toml +9 -2
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli/lifter.py +30 -6
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli/plugin.py +2 -0
- unidecompiler_plugin_dotnet_cli-0.1.1/src/unidecompiler_plugin_dotnet_cli/simulation.py +53 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli.egg-info/PKG-INFO +7 -2
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli.egg-info/SOURCES.txt +1 -0
- unidecompiler_plugin_dotnet_cli-0.1.1/src/unidecompiler_plugin_dotnet_cli.egg-info/requires.txt +2 -0
- unidecompiler_plugin_dotnet_cli-0.1.0/src/unidecompiler_plugin_dotnet_cli.egg-info/requires.txt +0 -2
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/README.md +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/setup.cfg +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli/__init__.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli/assembly.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli/support.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli.egg-info/dependency_links.txt +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli.egg-info/entry_points.txt +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/src/unidecompiler_plugin_dotnet_cli.egg-info/top_level.txt +0 -0
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unidecompiler-plugin-dotnet-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: .NET CLI assembly frontend plugin for unidecompiler
|
|
5
|
+
Author-email: Wker <1670133844@qq.com>
|
|
6
|
+
License-Expression: AGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/Wker666/unidecompiler
|
|
8
|
+
Project-URL: Repository, https://github.com/Wker666/unidecompiler
|
|
9
|
+
Project-URL: Issues, https://github.com/Wker666/unidecompiler/issues
|
|
5
10
|
Requires-Python: >=3.11
|
|
6
11
|
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: unidecompiler<0.2.0,>=0.1.
|
|
12
|
+
Requires-Dist: unidecompiler<0.2.0,>=0.1.1
|
|
8
13
|
Requires-Dist: dnfile<1,>=0.15
|
|
9
14
|
|
|
10
15
|
# unidecompiler-plugin-dotnet-cli
|
{unidecompiler_plugin_dotnet_cli-0.1.0 → unidecompiler_plugin_dotnet_cli-0.1.1}/pyproject.toml
RENAMED
|
@@ -4,11 +4,18 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "unidecompiler-plugin-dotnet-cli"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = ".NET CLI assembly frontend plugin for unidecompiler"
|
|
9
9
|
readme = "README.md"
|
|
10
|
+
license = "AGPL-3.0-or-later"
|
|
11
|
+
authors = [{ name = "Wker", email = "1670133844@qq.com" }]
|
|
10
12
|
requires-python = ">=3.11"
|
|
11
|
-
dependencies = ["unidecompiler>=0.1.
|
|
13
|
+
dependencies = ["unidecompiler>=0.1.1,<0.2.0", "dnfile>=0.15,<1"]
|
|
14
|
+
|
|
15
|
+
[project.urls]
|
|
16
|
+
Homepage = "https://github.com/Wker666/unidecompiler"
|
|
17
|
+
Repository = "https://github.com/Wker666/unidecompiler"
|
|
18
|
+
Issues = "https://github.com/Wker666/unidecompiler/issues"
|
|
12
19
|
|
|
13
20
|
[project.entry-points."unidecompiler.frontends"]
|
|
14
21
|
dotnet-cli = "unidecompiler_plugin_dotnet_cli.plugin:DotNetFrontendPlugin"
|
|
@@ -199,16 +199,40 @@ def _dotnet_unknown_opcode_effect(
|
|
|
199
199
|
return (UnknownOpcode(source=source, opcode=instruction.opcode, raw=_dotnet_raw_instruction_line(instruction)),)
|
|
200
200
|
|
|
201
201
|
|
|
202
|
-
def
|
|
202
|
+
def _dotnet_numeric_facts(opcode: str) -> tuple[str, int | None]:
|
|
203
|
+
if opcode.endswith(".un") or opcode == "shr.un":
|
|
204
|
+
return "unsigned", 32
|
|
205
|
+
return "default", None
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _dotnet_binary(opcode: str, op: str):
|
|
203
209
|
def factory(_method: DotNetMethodListing, _instruction: DotNetInstruction, source: SourceRef) -> tuple:
|
|
204
|
-
|
|
210
|
+
numeric_domain, bit_width = _dotnet_numeric_facts(opcode)
|
|
211
|
+
return (
|
|
212
|
+
Binary(
|
|
213
|
+
source=source,
|
|
214
|
+
op=op,
|
|
215
|
+
semantics="static",
|
|
216
|
+
numeric_domain=numeric_domain,
|
|
217
|
+
bit_width=bit_width,
|
|
218
|
+
),
|
|
219
|
+
)
|
|
205
220
|
|
|
206
221
|
return factory
|
|
207
222
|
|
|
208
223
|
|
|
209
|
-
def _dotnet_compare(op: str):
|
|
224
|
+
def _dotnet_compare(opcode: str, op: str):
|
|
210
225
|
def factory(_method: DotNetMethodListing, _instruction: DotNetInstruction, source: SourceRef) -> tuple:
|
|
211
|
-
|
|
226
|
+
numeric_domain, bit_width = _dotnet_numeric_facts(opcode)
|
|
227
|
+
return (
|
|
228
|
+
Binary(
|
|
229
|
+
source=source,
|
|
230
|
+
op=op,
|
|
231
|
+
semantics="static",
|
|
232
|
+
numeric_domain=numeric_domain,
|
|
233
|
+
bit_width=bit_width,
|
|
234
|
+
),
|
|
235
|
+
)
|
|
212
236
|
|
|
213
237
|
return factory
|
|
214
238
|
|
|
@@ -304,8 +328,8 @@ DOTNET_EFFECT_TABLE = VMEffectTable(
|
|
|
304
328
|
opcode_attr="opcode",
|
|
305
329
|
ignored=frozenset(IGNORED_OPS),
|
|
306
330
|
exact={
|
|
307
|
-
**{opcode: _dotnet_binary(op) for opcode, op in BINARY_OPS.items()},
|
|
308
|
-
**{opcode: _dotnet_compare(op) for opcode, op in COMPARE_OPS.items()},
|
|
331
|
+
**{opcode: _dotnet_binary(opcode, op) for opcode, op in BINARY_OPS.items()},
|
|
332
|
+
**{opcode: _dotnet_compare(opcode, op) for opcode, op in COMPARE_OPS.items()},
|
|
309
333
|
"ldnull": lambda _method, _instruction, source: (Push(source=source, value=Const(value=None, source=source)),),
|
|
310
334
|
"dup": lambda _method, instruction, source: (DuplicateTop(source=source, materialized_name=f"local_stack_{instruction.offset}"),),
|
|
311
335
|
"pop": lambda _method, _instruction, source: (Pop(source=source, count=1, emit_calls=True),),
|
|
@@ -8,6 +8,7 @@ from unidecompiler_plugin_dotnet_cli.assembly import (
|
|
|
8
8
|
looks_like_dotnet,
|
|
9
9
|
)
|
|
10
10
|
from unidecompiler_plugin_dotnet_cli.lifter import lift_dotnet_assembly
|
|
11
|
+
from unidecompiler_plugin_dotnet_cli.simulation import DotNetSimulationAdapter
|
|
11
12
|
from unidecompiler_plugin_dotnet_cli.support import DOTNET_CLI_VERSION_SUPPORT
|
|
12
13
|
|
|
13
14
|
|
|
@@ -16,6 +17,7 @@ class DotNetFrontendPlugin:
|
|
|
16
17
|
display_name = ".NET CLI assembly"
|
|
17
18
|
supported_inputs = (".dll", ".exe")
|
|
18
19
|
version_support = DOTNET_CLI_VERSION_SUPPORT
|
|
20
|
+
simulation_adapter = DotNetSimulationAdapter
|
|
19
21
|
|
|
20
22
|
def __init__(self, decoder: DotNetAssemblyDecoder | None = None) -> None:
|
|
21
23
|
self.decoder = decoder or DnfileAssemblyDecoder()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"""Optional .NET method lookup for the decoupled generic IR simulator."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class DotNetSimulationAdapter:
|
|
7
|
+
frontend_id = "dotnet-cli"
|
|
8
|
+
|
|
9
|
+
def resolve_function(self, query, decoded_module, lifted_module):
|
|
10
|
+
from unidecompiler_simulator import NotHandled, ResolvedFunction
|
|
11
|
+
|
|
12
|
+
if not isinstance(query, str):
|
|
13
|
+
return NotHandled
|
|
14
|
+
method_name = query.rsplit(".", 1)[-1]
|
|
15
|
+
context = self._function_context(lifted_module.functions)
|
|
16
|
+
matches = context.get(method_name, ())
|
|
17
|
+
if len(matches) != 1:
|
|
18
|
+
return NotHandled
|
|
19
|
+
return ResolvedFunction(matches[0], context=context, identifier=query)
|
|
20
|
+
|
|
21
|
+
def resolve_global(self, name, context):
|
|
22
|
+
from unidecompiler_simulator import NotHandled, ResolvedFunction
|
|
23
|
+
|
|
24
|
+
if not isinstance(context, dict):
|
|
25
|
+
return NotHandled
|
|
26
|
+
matches = context.get(name.rsplit(".", 1)[-1], ())
|
|
27
|
+
if len(matches) != 1:
|
|
28
|
+
return NotHandled
|
|
29
|
+
return ResolvedFunction(matches[0], context=context, identifier=name)
|
|
30
|
+
|
|
31
|
+
def list_simulation_targets(self, decoded_module, lifted_module):
|
|
32
|
+
from unidecompiler_simulator import SimulationTargetCandidate
|
|
33
|
+
|
|
34
|
+
context = self._function_context(lifted_module.functions)
|
|
35
|
+
return tuple(
|
|
36
|
+
SimulationTargetCandidate(name, name)
|
|
37
|
+
for name, matches in context.items()
|
|
38
|
+
if len(matches) == 1
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
def get_attr(self, obj, attr, context):
|
|
42
|
+
from unidecompiler_simulator import NotHandled
|
|
43
|
+
|
|
44
|
+
if attr == "length" and isinstance(obj, (list, tuple, str, bytes)):
|
|
45
|
+
return len(obj)
|
|
46
|
+
return NotHandled
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def _function_context(functions):
|
|
50
|
+
context = {}
|
|
51
|
+
for function in functions:
|
|
52
|
+
context.setdefault(function.name, []).append(function)
|
|
53
|
+
return {name: tuple(matches) for name, matches in context.items()}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unidecompiler-plugin-dotnet-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: .NET CLI assembly frontend plugin for unidecompiler
|
|
5
|
+
Author-email: Wker <1670133844@qq.com>
|
|
6
|
+
License-Expression: AGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/Wker666/unidecompiler
|
|
8
|
+
Project-URL: Repository, https://github.com/Wker666/unidecompiler
|
|
9
|
+
Project-URL: Issues, https://github.com/Wker666/unidecompiler/issues
|
|
5
10
|
Requires-Python: >=3.11
|
|
6
11
|
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: unidecompiler<0.2.0,>=0.1.
|
|
12
|
+
Requires-Dist: unidecompiler<0.2.0,>=0.1.1
|
|
8
13
|
Requires-Dist: dnfile<1,>=0.15
|
|
9
14
|
|
|
10
15
|
# unidecompiler-plugin-dotnet-cli
|
|
@@ -4,6 +4,7 @@ src/unidecompiler_plugin_dotnet_cli/__init__.py
|
|
|
4
4
|
src/unidecompiler_plugin_dotnet_cli/assembly.py
|
|
5
5
|
src/unidecompiler_plugin_dotnet_cli/lifter.py
|
|
6
6
|
src/unidecompiler_plugin_dotnet_cli/plugin.py
|
|
7
|
+
src/unidecompiler_plugin_dotnet_cli/simulation.py
|
|
7
8
|
src/unidecompiler_plugin_dotnet_cli/support.py
|
|
8
9
|
src/unidecompiler_plugin_dotnet_cli.egg-info/PKG-INFO
|
|
9
10
|
src/unidecompiler_plugin_dotnet_cli.egg-info/SOURCES.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|