Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F# dlls obfuscation #47

Closed
GoogleCodeExporter opened this issue Apr 4, 2015 · 4 comments
Closed

F# dlls obfuscation #47

GoogleCodeExporter opened this issue Apr 4, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Hello,

I try to obfuscate F# dll and I meet some diffcults. It's thrown unhandled 
exception: 

System.InvalidOperationException: Type names do not match: "FSharpFunc `3" != 
"Microsoft.FSharp.Core.OptimizedClosures/FSharpFunc`3...

If I'm not mistaken Obfuscar.exe can obfuscate all types .NET assemblies. So 
the problem is may be in my code?

Could you get me some suggestions for this issue?

Original issue reported on code.google.com by aleksand...@gmail.com on 16 Oct 2012 at 10:29

@GoogleCodeExporter
Copy link
Author

Unless you can provide obfuscated assembly with mapping file and the original 
one, it is very hard to tell what is the cause of the exception.

You might try my fork at https://github.com/lextm/obfuscar which has already 
resolved many known issues.

Original comment by lextu...@gmail.com on 28 Apr 2013 at 7:57

@lextm
Copy link
Member

lextm commented Apr 15, 2015

Another way to reproduce similar issues is to obfuscate F# compiler with

<?xml version='1.0'?>
<Obfuscator>
 <Var name='InPath' value='.' />
 <Var name='OutPath' value='.' />
<Var name='KeyFile' value='$(InPath)\test.snk' />
 <Var name='HidePrivateApi' value='true' />
 <Module file='$(InPath)\fsc.exe' />
<Module file='$(InPath)\FSharp.Compiler.dll' />
<Module file='$(InPath)\FSharp.Compiler.Interactive.Settings.dll' />
<Module file='$(InPath)\FSharp.Compiler.Server.Shared.dll' />
<Module file='$(InPath)\fsi.exe' />
</Obfuscator>

which leads to a crash

Unhandled Exception: System.TypeInitializationException: The type initializer for 'A.a' threw an exception. ---> System.TypeInitializationException: The type initializer for 'C.K' threw an exception. ---> System.TypeInitializationException: The type initializer for 'C.k' threw an exception. ---> System.TypeLoadException: Method 'GenerateNext' in type 'bD' from assembly 'FSharp.Compiler, Version=4.3.0.0, Culture=neutral, PublicKeyToken=f536804aa0eb945b' does not have an implementation.
   at C.k..cctor()
   --- End of inner exception stack trace ---
   at C.K..cctor()
   --- End of inner exception stack trace ---
   at C.K.a()
   at A.a..cctor()
   --- End of inner exception stack trace ---
   at A.A.A(String[] )

Further analysis shows that an overriding method was not properly skipped.

@lextm
Copy link
Member

lextm commented Apr 15, 2015

One generic related issue has been identified and fixed.

lextm added a commit that referenced this issue Apr 16, 2015
Conflicts:
	Obfuscar/InheritMap.cs
@lextm
Copy link
Member

lextm commented Apr 16, 2015

A blog post to summarize the investigation, https://blog.lextudio.com/2015/04/obfuscar-f-mono-cecil-and-method-overriding/

@lextm lextm closed this as completed Apr 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants