unidecompiler-plugin-dotnet-cli 0.1.1__tar.gz → 0.1.2__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.
Files changed (17) hide show
  1. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/PKG-INFO +2 -2
  2. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/pyproject.toml +2 -2
  3. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli/assembly.py +16 -4
  4. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli/lifter.py +2 -0
  5. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli.egg-info/PKG-INFO +2 -2
  6. unidecompiler_plugin_dotnet_cli-0.1.2/src/unidecompiler_plugin_dotnet_cli.egg-info/requires.txt +2 -0
  7. unidecompiler_plugin_dotnet_cli-0.1.1/src/unidecompiler_plugin_dotnet_cli.egg-info/requires.txt +0 -2
  8. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/README.md +0 -0
  9. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/setup.cfg +0 -0
  10. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli/__init__.py +0 -0
  11. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli/plugin.py +0 -0
  12. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli/simulation.py +0 -0
  13. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli/support.py +0 -0
  14. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli.egg-info/SOURCES.txt +0 -0
  15. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli.egg-info/dependency_links.txt +0 -0
  16. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/src/unidecompiler_plugin_dotnet_cli.egg-info/entry_points.txt +0 -0
  17. {unidecompiler_plugin_dotnet_cli-0.1.1 → unidecompiler_plugin_dotnet_cli-0.1.2}/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.1
3
+ Version: 0.1.2
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.1
12
+ Requires-Dist: unidecompiler<0.2.0,>=0.1.2
13
13
  Requires-Dist: dnfile<1,>=0.15
14
14
 
15
15
  # unidecompiler-plugin-dotnet-cli
@@ -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.1"
7
+ version = "0.1.2"
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.1,<0.2.0", "dnfile>=0.15,<1"]
13
+ dependencies = ["unidecompiler>=0.1.2,<0.2.0", "dnfile>=0.15,<1"]
14
14
 
15
15
  [project.urls]
16
16
  Homepage = "https://github.com/Wker666/unidecompiler"
@@ -26,6 +26,8 @@ class DotNetInstruction:
26
26
  arg_count: int | None = None
27
27
  returns_void: bool | None = None
28
28
  is_static: bool | None = None
29
+ artifact_offset: int | None = None
30
+ size: int | None = None
29
31
 
30
32
 
31
33
  @dataclass(frozen=True)
@@ -132,7 +134,7 @@ def _method_listing(pe, row_index: int, row) -> DotNetMethodListing:
132
134
  param_count=_signature_param_count(row.Signature),
133
135
  max_stack=None if body is None else body.max_stack,
134
136
  code_size=0 if body is None else len(body.code),
135
- instructions=() if body is None else _decode_il(pe, body.code),
137
+ instructions=() if body is None else _decode_il(pe, body.code, body.artifact_offset),
136
138
  )
137
139
 
138
140
 
@@ -140,6 +142,7 @@ def _method_listing(pe, row_index: int, row) -> DotNetMethodListing:
140
142
  class _MethodBody:
141
143
  max_stack: int
142
144
  code: bytes
145
+ artifact_offset: int | None
143
146
 
144
147
 
145
148
  def _read_method_body(pe, rva: int) -> _MethodBody | None:
@@ -150,7 +153,7 @@ def _read_method_body(pe, rva: int) -> _MethodBody | None:
150
153
  kind = first & 0x3
151
154
  if kind == 0x2:
152
155
  code_size = first >> 2
153
- return _MethodBody(max_stack=8, code=pe.get_data(rva + 1, code_size))
156
+ return _MethodBody(max_stack=8, code=pe.get_data(rva + 1, code_size), artifact_offset=_artifact_offset(pe, rva + 1))
154
157
  if kind == 0x3:
155
158
  header = pe.get_data(rva, 12)
156
159
  if len(header) < 12:
@@ -159,7 +162,7 @@ def _read_method_body(pe, rva: int) -> _MethodBody | None:
159
162
  header_size = (_flags_size >> 12) * 4
160
163
  if header_size < 12:
161
164
  return None
162
- return _MethodBody(max_stack=max_stack, code=pe.get_data(rva + header_size, code_size))
165
+ return _MethodBody(max_stack=max_stack, code=pe.get_data(rva + header_size, code_size), artifact_offset=_artifact_offset(pe, rva + header_size))
163
166
  return None
164
167
 
165
168
 
@@ -428,7 +431,14 @@ _TWO_BYTE_OPCODES = {
428
431
  }
429
432
 
430
433
 
431
- def _decode_il(pe, code: bytes) -> tuple[DotNetInstruction, ...]:
434
+ def _artifact_offset(pe, rva: int) -> int | None:
435
+ try:
436
+ return int(pe.get_offset_from_rva(rva))
437
+ except Exception:
438
+ return None
439
+
440
+
441
+ def _decode_il(pe, code: bytes, artifact_offset: int | None = None) -> tuple[DotNetInstruction, ...]:
432
442
  instructions: list[DotNetInstruction] = []
433
443
  offset = 0
434
444
  while offset < len(code):
@@ -454,6 +464,8 @@ def _decode_il(pe, code: bytes) -> tuple[DotNetInstruction, ...]:
454
464
  arg_count=operand.arg_count,
455
465
  returns_void=operand.returns_void,
456
466
  is_static=operand.is_static,
467
+ artifact_offset=None if artifact_offset is None else artifact_offset + start,
468
+ size=offset - start,
457
469
  )
458
470
  )
459
471
  return tuple(instructions)
@@ -30,6 +30,7 @@ from unidecompiler.core.vm_function import VMFunctionSpec, lift_steps, lift_vm_s
30
30
  from unidecompiler.core.vm_hints import VMHint
31
31
  from unidecompiler.core.vm_module import assemble_vm_module
32
32
  from unidecompiler.core.vm_operands import VMDecodedInstruction, VMOperand
33
+ from unidecompiler.provenance import ByteRange
33
34
  from unidecompiler.core.vm_region import (
34
35
  VMLinearState,
35
36
  VMRegionOpcodeClasses,
@@ -551,6 +552,7 @@ def _dotnet_decoded_instruction(instruction: DotNetInstruction, source: SourceRe
551
552
  source=source,
552
553
  operands=operands,
553
554
  raw=_dotnet_raw_instruction_line(instruction),
555
+ artifact_range=(None if instruction.artifact_offset is None or instruction.size is None else ByteRange(instruction.artifact_offset, instruction.size)),
554
556
  )
555
557
 
556
558
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unidecompiler-plugin-dotnet-cli
3
- Version: 0.1.1
3
+ Version: 0.1.2
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.1
12
+ Requires-Dist: unidecompiler<0.2.0,>=0.1.2
13
13
  Requires-Dist: dnfile<1,>=0.15
14
14
 
15
15
  # unidecompiler-plugin-dotnet-cli
@@ -0,0 +1,2 @@
1
+ unidecompiler<0.2.0,>=0.1.2
2
+ dnfile<1,>=0.15
@@ -1,2 +0,0 @@
1
- unidecompiler<0.2.0,>=0.1.1
2
- dnfile<1,>=0.15