Skip to content

NullReferenceException in Agile_NET obfuscator detection when a method matching the delegate-creator signature has no body (P/Invoke) #42

Description

@Stonica

`Agile_NET.ProxyCallFixer.FindDelegateCreator()` (`de4dot.code/deobfuscators/Agile_NET/ProxyCallFixer.cs:47`) accesses `method.Body.Instructions` for any static method matching `void(int32)`, without checking `method.HasBody`. A `static extern void(int32)` P/Invoke method with that signature causes a `NullReferenceException` during obfuscator detection (before any actual deobfuscation), aborting processing of the whole file — even though the file legitimately is Dotfuscator-protected (confirmed via the `DotfuscatorAttribute`).

Repro: any assembly containing a P/Invoke `static extern void Foo(int)` alongside Agile_NET/Dotfuscator protection.

Fix: guard with `method.HasBody`:
```csharp
if (method.IsStatic && method.HasBody && !method.IsStaticConstructor && DotNetUtils.IsMethod(method, "System.Void", "(System.Int32)")) {
```

Happy to submit this as a PR if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions