unidecompiler-plugin-dotnet-cli 0.1.2__tar.gz → 0.1.4__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.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/PKG-INFO +2 -2
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/pyproject.toml +2 -2
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli/lifter.py +54 -38
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli/simulation.py +6 -1
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli.egg-info/PKG-INFO +2 -2
- unidecompiler_plugin_dotnet_cli-0.1.4/src/unidecompiler_plugin_dotnet_cli.egg-info/requires.txt +2 -0
- unidecompiler_plugin_dotnet_cli-0.1.2/src/unidecompiler_plugin_dotnet_cli.egg-info/requires.txt +0 -2
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/README.md +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/setup.cfg +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli/__init__.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli/assembly.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli/plugin.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli/support.py +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli.egg-info/SOURCES.txt +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli.egg-info/dependency_links.txt +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli.egg-info/entry_points.txt +0 -0
- {unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/src/unidecompiler_plugin_dotnet_cli.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unidecompiler-plugin-dotnet-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: .NET CLI assembly frontend plugin for unidecompiler
|
|
5
5
|
Author-email: Wker <1670133844@qq.com>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -9,7 +9,7 @@ Project-URL: Repository, https://github.com/Wker666/unidecompiler
|
|
|
9
9
|
Project-URL: Issues, https://github.com/Wker666/unidecompiler/issues
|
|
10
10
|
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist: unidecompiler<0.2.0,>=0.1.
|
|
12
|
+
Requires-Dist: unidecompiler<0.2.0,>=0.1.10
|
|
13
13
|
Requires-Dist: dnfile<1,>=0.15
|
|
14
14
|
|
|
15
15
|
# unidecompiler-plugin-dotnet-cli
|
{unidecompiler_plugin_dotnet_cli-0.1.2 → unidecompiler_plugin_dotnet_cli-0.1.4}/pyproject.toml
RENAMED
|
@@ -4,13 +4,13 @@ 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.4"
|
|
8
8
|
description = ".NET CLI assembly frontend plugin for unidecompiler"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "AGPL-3.0-or-later"
|
|
11
11
|
authors = [{ name = "Wker", email = "1670133844@qq.com" }]
|
|
12
12
|
requires-python = ">=3.11"
|
|
13
|
-
dependencies = ["unidecompiler>=0.1.
|
|
13
|
+
dependencies = ["unidecompiler>=0.1.10,<0.2.0", "dnfile>=0.15,<1"]
|
|
14
14
|
|
|
15
15
|
[project.urls]
|
|
16
16
|
Homepage = "https://github.com/Wker666/unidecompiler"
|
|
@@ -6,6 +6,7 @@ from unidecompiler.core.effects import (
|
|
|
6
6
|
BuildCall,
|
|
7
7
|
CallTopAs,
|
|
8
8
|
DuplicateTop,
|
|
9
|
+
Emit,
|
|
9
10
|
InvokeMember,
|
|
10
11
|
LoadIndirect,
|
|
11
12
|
LoadAttr,
|
|
@@ -15,6 +16,7 @@ from unidecompiler.core.effects import (
|
|
|
15
16
|
Pop,
|
|
16
17
|
Push,
|
|
17
18
|
RaiseTop,
|
|
19
|
+
ReraiseTop,
|
|
18
20
|
ReturnTop,
|
|
19
21
|
StoreAttr,
|
|
20
22
|
StoreIndirect,
|
|
@@ -23,7 +25,7 @@ from unidecompiler.core.effects import (
|
|
|
23
25
|
StoreStaticMember,
|
|
24
26
|
UnknownOpcode,
|
|
25
27
|
)
|
|
26
|
-
from unidecompiler.core.ir import BinaryOp, Const, Expr, Global, IndirectRef, SourceRef, Var
|
|
28
|
+
from unidecompiler.core.ir import BinaryOp, Const, Expr, Global, IndirectRef, SourceRef, Unsupported, Var
|
|
27
29
|
from unidecompiler.core.vm_bytecode import VMBytecodeStep
|
|
28
30
|
from unidecompiler.core.vm_effect_table import VMEffectRule, VMEffectTable
|
|
29
31
|
from unidecompiler.core.vm_function import VMFunctionSpec, lift_steps, lift_vm_step_function, recover_vm_function
|
|
@@ -66,7 +68,7 @@ BINARY_OPS = {
|
|
|
66
68
|
"xor": "^",
|
|
67
69
|
"shl": "<<",
|
|
68
70
|
"shr": ">>",
|
|
69
|
-
"shr.un": "
|
|
71
|
+
"shr.un": ">>>",
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
COMPARE_OPS = {
|
|
@@ -152,38 +154,7 @@ IGNORED_OPS = {
|
|
|
152
154
|
"volatile.",
|
|
153
155
|
"unaligned.",
|
|
154
156
|
"prefix",
|
|
155
|
-
"castclass",
|
|
156
|
-
"box",
|
|
157
|
-
"unbox",
|
|
158
|
-
"unbox.any",
|
|
159
|
-
"conv.i",
|
|
160
|
-
"conv.i1",
|
|
161
|
-
"conv.i2",
|
|
162
|
-
"conv.i4",
|
|
163
|
-
"conv.i8",
|
|
164
|
-
"conv.u",
|
|
165
|
-
"conv.u1",
|
|
166
|
-
"conv.u2",
|
|
167
|
-
"conv.u4",
|
|
168
|
-
"conv.u8",
|
|
169
|
-
"conv.r4",
|
|
170
|
-
"conv.r8",
|
|
171
|
-
"conv.r.un",
|
|
172
|
-
"conv.ovf.i",
|
|
173
|
-
"conv.ovf.i.un",
|
|
174
|
-
"conv.ovf.i1.un",
|
|
175
|
-
"conv.ovf.i2.un",
|
|
176
|
-
"conv.ovf.i4.un",
|
|
177
|
-
"conv.ovf.i8.un",
|
|
178
|
-
"conv.ovf.u",
|
|
179
|
-
"conv.ovf.u.un",
|
|
180
|
-
"conv.ovf.u1.un",
|
|
181
|
-
"conv.ovf.u2.un",
|
|
182
|
-
"conv.ovf.u4.un",
|
|
183
|
-
"conv.ovf.u8.un",
|
|
184
157
|
"endfinally",
|
|
185
|
-
"endfilter",
|
|
186
|
-
"rethrow",
|
|
187
158
|
*CONTROL_OPS,
|
|
188
159
|
}
|
|
189
160
|
|
|
@@ -250,6 +221,13 @@ def _dotnet_load_local_effect(method: DotNetMethodListing, instruction: DotNetIn
|
|
|
250
221
|
if index is None:
|
|
251
222
|
return None
|
|
252
223
|
name = _local_name(method, index)
|
|
224
|
+
if instruction.opcode.startswith("ldloca"):
|
|
225
|
+
return (
|
|
226
|
+
Push(
|
|
227
|
+
source=source,
|
|
228
|
+
value=IndirectRef(source=source, target=Var(name=name, source=source)),
|
|
229
|
+
),
|
|
230
|
+
)
|
|
253
231
|
return (LoadLocal(source=source, name=name, fallback=Var(name=name, source=source)),)
|
|
254
232
|
|
|
255
233
|
|
|
@@ -325,6 +303,36 @@ def _dotnet_call(_method: DotNetMethodListing, instruction: DotNetInstruction, s
|
|
|
325
303
|
)
|
|
326
304
|
|
|
327
305
|
|
|
306
|
+
def _dotnet_operation_call(arg_count: int, *, returns: int = 0):
|
|
307
|
+
def factory(
|
|
308
|
+
_method: DotNetMethodListing,
|
|
309
|
+
instruction: DotNetInstruction,
|
|
310
|
+
source: SourceRef,
|
|
311
|
+
) -> tuple:
|
|
312
|
+
suffix = f"<{instruction.operands}>" if instruction.operands else ""
|
|
313
|
+
return (
|
|
314
|
+
BuildCall(
|
|
315
|
+
source=source,
|
|
316
|
+
callee=Global(name=f"{instruction.opcode}{suffix}", source=source),
|
|
317
|
+
arg_count=arg_count,
|
|
318
|
+
returns=returns,
|
|
319
|
+
),
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
return factory
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def _dotnet_unary_operation(_method, instruction, source: SourceRef) -> tuple:
|
|
326
|
+
# Keep the CLI operation name neutral and readable. Operand metadata is
|
|
327
|
+
# already retained on the decoded instruction; embedding the Python tuple
|
|
328
|
+
# representation in the callee name prevents generic intrinsic handling.
|
|
329
|
+
return (CallTopAs(source=source, callee_name=instruction.opcode),)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def _dotnet_unsupported_operation(_method, instruction, source: SourceRef) -> tuple:
|
|
333
|
+
return (Emit(source=source, statement=Unsupported(source=source, message="unsupported CLI control operation", detail=instruction.opcode, raw=(_dotnet_raw_instruction_line(instruction),))),)
|
|
334
|
+
|
|
335
|
+
|
|
328
336
|
DOTNET_EFFECT_TABLE = VMEffectTable(
|
|
329
337
|
opcode_attr="opcode",
|
|
330
338
|
ignored=frozenset(IGNORED_OPS),
|
|
@@ -332,6 +340,12 @@ DOTNET_EFFECT_TABLE = VMEffectTable(
|
|
|
332
340
|
**{opcode: _dotnet_binary(opcode, op) for opcode, op in BINARY_OPS.items()},
|
|
333
341
|
**{opcode: _dotnet_compare(opcode, op) for opcode, op in COMPARE_OPS.items()},
|
|
334
342
|
"ldnull": lambda _method, _instruction, source: (Push(source=source, value=Const(value=None, source=source)),),
|
|
343
|
+
**{opcode: _dotnet_unary_operation for opcode in {
|
|
344
|
+
"castclass", "box", "unbox", "unbox.any", "conv.i", "conv.i1", "conv.i2", "conv.i4", "conv.i8",
|
|
345
|
+
"conv.u", "conv.u1", "conv.u2", "conv.u4", "conv.u8", "conv.r4", "conv.r8", "conv.r.un",
|
|
346
|
+
"conv.ovf.i", "conv.ovf.i.un", "conv.ovf.i1.un", "conv.ovf.i2.un", "conv.ovf.i4.un", "conv.ovf.i8.un",
|
|
347
|
+
"conv.ovf.u", "conv.ovf.u.un", "conv.ovf.u1.un", "conv.ovf.u2.un", "conv.ovf.u4.un", "conv.ovf.u8.un",
|
|
348
|
+
}},
|
|
335
349
|
"dup": lambda _method, instruction, source: (DuplicateTop(source=source, materialized_name=f"local_stack_{instruction.offset}"),),
|
|
336
350
|
"pop": lambda _method, _instruction, source: (Pop(source=source, count=1, emit_calls=True),),
|
|
337
351
|
"neg": lambda _method, _instruction, source: (CallTopAs(source=source, callee_name="neg"),),
|
|
@@ -342,12 +356,12 @@ DOTNET_EFFECT_TABLE = VMEffectTable(
|
|
|
342
356
|
"jmp": _dotnet_call,
|
|
343
357
|
"ldftn": lambda _method, instruction, source: (Push(source=source, value=Global(name=_member_token_name(instruction.operands), source=source)),),
|
|
344
358
|
"ldvirtftn": lambda _method, instruction, source: (Push(source=source, value=Global(name=_member_token_name(instruction.operands), source=source)),),
|
|
345
|
-
"initobj":
|
|
359
|
+
"initobj": _dotnet_operation_call(1),
|
|
346
360
|
"arglist": lambda _method, _instruction, source: (Push(source=source, value=Global(name="arglist", source=source)),),
|
|
347
361
|
"ckfinite": lambda _method, _instruction, source: (CallTopAs(source=source, callee_name="check_finite"),),
|
|
348
|
-
"cpblk":
|
|
349
|
-
"cpobj":
|
|
350
|
-
"initblk":
|
|
362
|
+
"cpblk": _dotnet_operation_call(3),
|
|
363
|
+
"cpobj": _dotnet_operation_call(2),
|
|
364
|
+
"initblk": _dotnet_operation_call(3),
|
|
351
365
|
"localloc": lambda _method, _instruction, source: (BuildCall(source=source, callee=Global(name="localloc", source=source), arg_count=1),),
|
|
352
366
|
"mkrefany": lambda _method, instruction, source: (BuildCall(source=source, callee=Global(name=f"mkrefany<{instruction.operands or 'type'}>", source=source), arg_count=1),),
|
|
353
367
|
"refanytype": lambda _method, _instruction, source: (CallTopAs(source=source, callee_name="refanytype"),),
|
|
@@ -356,7 +370,7 @@ DOTNET_EFFECT_TABLE = VMEffectTable(
|
|
|
356
370
|
"ldstr": lambda _method, instruction, source: (Push(source=source, value=Const(value=instruction.operands, source=source)),),
|
|
357
371
|
"ldtoken": lambda _method, instruction, source: (Push(source=source, value=Global(name=instruction.operands, source=source)),),
|
|
358
372
|
"isinst": lambda _method, instruction, source: (BuildCall(source=source, callee=Global(name="instanceof", source=source), arg_count=1, returns=1),),
|
|
359
|
-
"ldobj":
|
|
373
|
+
"ldobj": _dotnet_operation_call(1, returns=1),
|
|
360
374
|
"ldfld": lambda _method, instruction, source: (LoadAttr(source=source, attr=_member_name(instruction)),),
|
|
361
375
|
"ldflda": lambda _method, instruction, source: (LoadAttr(source=source, attr=_member_name(instruction)),),
|
|
362
376
|
"stfld": lambda _method, instruction, source: (StoreAttr(source=source, attr=_member_name(instruction)),),
|
|
@@ -372,6 +386,8 @@ DOTNET_EFFECT_TABLE = VMEffectTable(
|
|
|
372
386
|
"ldlen": lambda _method, _instruction, source: (LoadAttr(source=source, attr="length"),),
|
|
373
387
|
"newarr": lambda _method, instruction, source: (BuildArrayCall(source=source, kind=instruction.operands or "array"),),
|
|
374
388
|
"throw": lambda _method, _instruction, source: (RaiseTop(source=source),),
|
|
389
|
+
"rethrow": lambda _method, _instruction, source: (ReraiseTop(source=source),),
|
|
390
|
+
"endfilter": _dotnet_unsupported_operation,
|
|
375
391
|
"ret": lambda _method, _instruction, source: (ReturnTop(source=source, empty_is_void=True),),
|
|
376
392
|
},
|
|
377
393
|
rules=(
|
|
@@ -19,7 +19,12 @@ class DotNetSimulationAdapter:
|
|
|
19
19
|
return ResolvedFunction(matches[0], context=context, identifier=query)
|
|
20
20
|
|
|
21
21
|
def resolve_global(self, name, context):
|
|
22
|
-
from unidecompiler_simulator import NotHandled, ResolvedFunction
|
|
22
|
+
from unidecompiler_simulator import IntrinsicCall, NotHandled, ResolvedFunction
|
|
23
|
+
|
|
24
|
+
# Conversion and unary operation names emitted by the generic lifter
|
|
25
|
+
# are pure value intrinsics, not methods in the lifted module.
|
|
26
|
+
if name.startswith(("conv.", "castclass", "box", "unbox", "neg", "bitnot", "check_finite", "refanytype")):
|
|
27
|
+
return IntrinsicCall(name)
|
|
23
28
|
|
|
24
29
|
if not isinstance(context, dict):
|
|
25
30
|
return NotHandled
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unidecompiler-plugin-dotnet-cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: .NET CLI assembly frontend plugin for unidecompiler
|
|
5
5
|
Author-email: Wker <1670133844@qq.com>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -9,7 +9,7 @@ Project-URL: Repository, https://github.com/Wker666/unidecompiler
|
|
|
9
9
|
Project-URL: Issues, https://github.com/Wker666/unidecompiler/issues
|
|
10
10
|
Requires-Python: >=3.11
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist: unidecompiler<0.2.0,>=0.1.
|
|
12
|
+
Requires-Dist: unidecompiler<0.2.0,>=0.1.10
|
|
13
13
|
Requires-Dist: dnfile<1,>=0.15
|
|
14
14
|
|
|
15
15
|
# unidecompiler-plugin-dotnet-cli
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|