• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SamboyCoding / Cpp2IL / 15050968287

15 May 2025 05:05PM UTC coverage: 34.039% (-0.4%) from 34.453%
15050968287

Pull #451

github

web-flow
Merge 54df93004 into d3bbbb38e
Pull Request #451: Support injecting anything

1774 of 6622 branches covered (26.79%)

Branch coverage included in aggregate %.

147 of 195 new or added lines in 27 files covered. (75.38%)

54 existing lines in 3 files now uncovered.

4155 of 10796 relevant lines covered (38.49%)

188285.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.33
/Cpp2IL.Core/OutputFormats/WasmMappingOutputFormat.cs
1
using System;
2
using System.IO;
3
using System.Linq;
4
using System.Text;
5
using Cpp2IL.Core.Api;
6
using Cpp2IL.Core.Logging;
7
using Cpp2IL.Core.Model.Contexts;
8
using Cpp2IL.Core.Utils;
9
using LibCpp2IL.Wasm;
10

11
namespace Cpp2IL.Core.OutputFormats;
12

13
public class WasmMappingOutputFormat : Cpp2IlOutputFormat
14
{
15
    public override string OutputFormatId => "wasmmappings";
1✔
16
    public override string OutputFormatName => "WebAssembly Method Mappings";
×
17

18
    public override void DoOutput(ApplicationAnalysisContext context, string outputRoot)
19
    {
20
        if (context.Binary is not WasmFile wasmFile)
×
21
            throw new("This output format only works with WebAssembly files");
×
22

23
        Logger.InfoNewline("Generating WebAssembly method mappings...This may take up to a minute...", "WasmMappingOutputFormat");
×
24
        var output = new StringBuilder();
×
25

26
        foreach (var assemblyAnalysisContext in context.Assemblies)
×
27
        {
NEW
28
            output.Append("// ").Append(assemblyAnalysisContext.Name).Append(".dll").AppendLine().AppendLine();
×
29

30
            foreach (var typeAnalysisContext in assemblyAnalysisContext.Types)
×
31
            foreach (var methodAnalysisContext in typeAnalysisContext.Methods)
×
32
            {
33
                if (methodAnalysisContext is InjectedMethodAnalysisContext || methodAnalysisContext.Definition == null)
×
34
                    continue;
35

36
                output.Append(methodAnalysisContext.Definition.ReturnType)
×
37
                    .Append(' ')
×
38
                    .Append(methodAnalysisContext.DeclaringType!.FullName)
×
39
                    .Append("::")
×
40
                    .Append(methodAnalysisContext.Definition.Name)
×
41
                    .Append('(')
×
42
                    .Append(string.Join(", ", methodAnalysisContext.Definition.Parameters!.Select(p => $"{p.Type} {p.ParameterName}")))
×
43
                    .Append(") -> ");
×
44

45
                try
46
                {
47
                    var wasmDef = WasmUtils.GetWasmDefinition(methodAnalysisContext);
×
48
                    var ghidraName = WasmUtils.GetGhidraFunctionName(wasmDef);
×
49

50
                    output.AppendLine(ghidraName);
×
51
                }
×
52
                catch (Exception)
×
53
                {
54
                    output.AppendLine("<not resolved>");
×
55
                }
×
56
            }
57

58
            output.AppendLine().AppendLine();
×
59
        }
60

61
        var outPath = Path.Combine(outputRoot, "wasm_mappings.txt");
×
62
        File.WriteAllText(outPath, output.ToString());
×
63

64
        Logger.InfoNewline("Wasm mappings written to: " + outPath, "WasmMappingOutputFormat");
×
65
    }
×
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc