Skip to content

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SourceMatcher

Status: unfinished prototype. Not all of what's described below is fully wired up, and the README doesn't try to cover every code path. I'm not actively working on this project right now.

A C# / .NET 8 static analyzer that re-identifies obfuscated Dofus 3 classes, fields, and methods across game updates.

Each Dofus 3 release rotates the obfuscation, so symbols like Class_a1b2 in one version become Class_x9y4 in the next. SourceMatcher takes the decompiled C# from two versions plus a small JSON manifest of the symbols you already understand in the old version, and emits a Defines.h header mapping your friendly names to the new obfuscated names.

How it works

  1. Parse both versions of every listed file with Roslyn (Microsoft.CodeAnalysis.CSharp), extracting per-class structural fingerprints (see Models.cs).
  2. Match classes by computing a weighted similarity score between the known v1 class and every v2 class, then keeping the highest-scoring v2 candidate. Implemented in ComputeSimilarityScore at Program.cs:427.
  3. Match fields positionally inside the matched class, normalizing non-builtin types to object so that re-obfuscated type names don't break the comparison (Program.cs:99).
  4. Match functions by exact (return type, parameter types, modifiers); if nothing matches, retry with non-builtin types collapsed to object (Program.cs:178).
  5. Emit a Defines.h line per renamed class: #define <yourName> "<v2ObfuscatedName>".

Similarity score

A class fingerprint is a structural summary that survives renaming:

Feature Weight Notes
Const fields (type + literal value) 0.40 Intersection over max. Literals are the strongest signal — they don't get obfuscated.
Base class count match 0.40 Binary 0/1.
[DependsOnService] field count 0.40 Game-specific DI attribute; the count is stable across versions.
Method count proximity 0.40 `1 -
Nested type count 0.40 `1 -
Field count proximity 0.10
Field-type set overlap 0.10
Method-signature set overlap 0.05 Return type + parameter type list.
Compiler-generated method count 0.05

Scores aren't normalized to [0, 1] — they're a ranking signal, and the highest wins. The matcher also warns when the gap between the top two candidates is under 0.10, since that's where false positives tend to hide.

Usage

SourceMatcher <v1-types-dir> <v2-types-dir> <classes.json> <output-dir>
  • v1-types-dir — directory containing the decompiled .cs files from the old version you've already reverse-engineered.
  • v2-types-dir — directory containing the same file names from the new version (still obfuscated).
  • classes.json — manifest of what to map (see schema below).
  • output-dir — written to: Defines.h.

classes.json schema

{
  "version": "3.x.y",
  "files": [
    {
      "name": "SomeFile.cs",
      "classes": {
        "OldObfuscatedClassName": {
          "rename": "MyFriendlyClassName",
          "fields": [
            { "name": "oldFieldName", "rename": "myFriendlyFieldName" }
          ],
          "functions": [
            { "name": "oldMethodName", "rename": "MyFriendlyMethod", "candidates": [] }
          ]
        }
      }
    }
  ]
}

File names must match between v1-types-dir and v2-types-dir. The shape is defined in Models.cs:13-43.

Example output

#define MyFriendlyClassName       "Class_x9y4"

Build

dotnet build SourceMatcher_2/SourceMatcher.csproj
dotnet run --project SourceMatcher_2 -- <v1> <v2> classes.json out/

Requires the .NET 8 SDK.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages