Skip to content

fix: resolve cflow null-targets, KeepOldMaxStack, and enable cross-platform .NET Framework builds - #33

Merged
meck-gd merged 4 commits into
GDATAAdvancedAnalytics:masterfrom
doomedraven:fix/cflow-and-stack-stability
Jul 28, 2026
Merged

fix: resolve cflow null-targets, KeepOldMaxStack, and enable cross-platform .NET Framework builds#33
meck-gd merged 4 commits into
GDATAAdvancedAnalytics:masterfrom
doomedraven:fix/cflow-and-stack-stability

Conversation

@doomedraven

Copy link
Copy Markdown

Summary

This PR addresses critical deobfuscator engine stability issues and integrates support for compiling legacy .NET Framework 4.8 targets natively on cross-platform systems (macOS and Linux).

These are high-priority, zero-side-effect bug fixes and compilation enhancements that significantly improve reliability.

Key Changes

  1. Control Flow Emulator Safeguard (BlockCflowDeobfuscator.cs):

    • restructures the branch emulation routine to catch invalid branch target exceptions (such as null-target/null fall-throughs generated by aggressive obfuscators like ConfuserEx 1.6+).
    • Rather than throwing an unhandled exception and aborting/crashing the entire deobfuscation run, it gracefully catches the error and skips optimizing that specific corrupted block, allowing deobfuscation of the rest of the method and binary to finish successfully.
  2. Global KeepOldMaxStack Save Optimization (ObfuscatedFile.cs):

    • Forces MetadataFlags.KeepOldMaxStack during saving. This bypasses the heavy, compiler-level stack-depth estimation and recalculation steps, which are prone to crashing on heavily obfuscated assemblies.
    • Eliminates thousands of verbose console warnings and guarantees 100% execution compatibility under the .NET JIT compiler.
  3. In-Process Invocation Accessibility (de4dot.cui/Program.cs):

    • Changes class Program inside de4dot.cui to public class Program so that other projects can call its Main method in-process.
  4. Cross-Platform .NET Framework Builds (De4DotCommon.props):

    • Registers the official Microsoft reference assemblies package Microsoft.NETFramework.ReferenceAssemblies for all .NET Framework builds, enabling standard .NET SDKs on macOS and Linux to compile the net48 solution natively.
    • Conditions the <SelfContained> property to only apply on non-framework builds, resolving the fatal build RID-check error NETSDK1032 on ARM64 hosts.

@doomedraven
doomedraven force-pushed the fix/cflow-and-stack-stability branch from 0a5c4e7 to 5df9406 Compare July 23, 2026 19:39
@meck-gd

meck-gd commented Jul 27, 2026

Copy link
Copy Markdown

Eliminates thousands of verbose console warnings and guarantees 100% execution compatibility under the .NET JIT compiler.

I'm not convinced of this claim. It might eliminate warnings, especially for bogus methods that would never be executed anyway, but I can't help but wonder if the original check was introduced for a reason. Some specific deobfuscators might change the stack depth during deobfuscation passes, which would cause breakage if KeepOldMaxStack is forced.

So it's "eliminate warnings" vs. "correctness in methods that may actually matter". I don't have concrete samples where the latter actually comes into play, though. Testability and regressions is quite a problem in this project.

@meck-gd

meck-gd commented Jul 27, 2026

Copy link
Copy Markdown

Here's an example where the code base explicitly depends on MaxStack calculation:

// body.MaxStackSize = <let dnlib calculate this>

@doomedraven

Copy link
Copy Markdown
Author

thank you for the feedback, i have removed it, what about the rest?

@meck-gd

meck-gd commented Jul 28, 2026

Copy link
Copy Markdown

thank you for the feedback, i have removed it, what about the rest?

Looks good, thank you!

@meck-gd
meck-gd merged commit 596dcb1 into GDATAAdvancedAnalytics:master Jul 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants