Quantcast
Channel: Obfuscar, The Open Source Obfuscation Tool for .NET Assemblies
Viewing all 249 articles
Browse latest View live

Commented Unassigned: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. [25]

$
0
0
Getting exception right out of the gate. I just attempted to use SmartAssembly from RedGate and it was choking on compiler generated code from the use of _async_ and _await_ keywords. I'm guessing this tool has the same issue?

```
Loading project...Processing assembly: MyAssembly.Owin, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null
Loading assemblies...Extra framework folders: Trying to resolve dependency: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5
c561934e089
Trying to resolve dependency: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Done.
Renaming: fields...parameters...properties...events...methods...types...
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Obfuscar.TypeKey.Matches(TypeReference type)
at Obfuscar.Obfuscator.RenameType(AssemblyInfo info, TypeDefinition type, TypeKey oldTypeKey, TypeKey newTypeKey, TypeKey unrenamedTypeKe
y)
at Obfuscar.Obfuscator.RenameTypes()
at Obfuscar.Obfuscator.RunRules()
at Obfuscar.Program.Main(String[] args)
```

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value=".\input" />
<Var name="OutPath" value=".\Obfuscator_Output" />

<Module file="$(InPath)\MyAssembly.Owin.dll" />
</Obfuscator>
```

```
[CompilerGenerated]
private struct <ApplyResponseGrantAsync>d__46 : IAsyncStateMachine
{
public int <>1__state;
public AynonymousIdentityHandler <>4__this;
public AsyncTaskMethodBuilder <>t__builder;
private object <>t__stack;
private TaskAwaiter <>u__$awaiter4b;
public CookieOptions <cookieOptions>5__47;
public IdentityCreatedContext <createdContext>5__4a;
public bool <removeAnonymousCookie>5__49;
public AuthenticationResponseRevoke <revoke>5__48;

private void MoveNext();
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine param0);
}
```
Comments: It has little to do with async-await, as my test on other assemblies are OK. If possible, you can send me the assembly via support@lextm.com. There should be something else.

Commented Unassigned: Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. [25]

$
0
0
Getting exception right out of the gate. I just attempted to use SmartAssembly from RedGate and it was choking on compiler generated code from the use of _async_ and _await_ keywords. I'm guessing this tool has the same issue?

```
Loading project...Processing assembly: MyAssembly.Owin, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null
Loading assemblies...Extra framework folders: Trying to resolve dependency: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5
c561934e089
Trying to resolve dependency: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Done.
Renaming: fields...parameters...properties...events...methods...types...
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Obfuscar.TypeKey.Matches(TypeReference type)
at Obfuscar.Obfuscator.RenameType(AssemblyInfo info, TypeDefinition type, TypeKey oldTypeKey, TypeKey newTypeKey, TypeKey unrenamedTypeKe
y)
at Obfuscar.Obfuscator.RenameTypes()
at Obfuscar.Obfuscator.RunRules()
at Obfuscar.Program.Main(String[] args)
```

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value=".\input" />
<Var name="OutPath" value=".\Obfuscator_Output" />

<Module file="$(InPath)\MyAssembly.Owin.dll" />
</Obfuscator>
```

```
[CompilerGenerated]
private struct <ApplyResponseGrantAsync>d__46 : IAsyncStateMachine
{
public int <>1__state;
public AynonymousIdentityHandler <>4__this;
public AsyncTaskMethodBuilder <>t__builder;
private object <>t__stack;
private TaskAwaiter <>u__$awaiter4b;
public CookieOptions <cookieOptions>5__47;
public IdentityCreatedContext <createdContext>5__4a;
public bool <removeAnonymousCookie>5__49;
public AuthenticationResponseRevoke <revoke>5__48;

private void MoveNext();
[DebuggerHidden]
private void SetStateMachine(IAsyncStateMachine param0);
}
```
Comments: It has little to do with async-await, as my test on other assemblies are OK. If possible, you can send me the assembly via support@lextm.com. There should be something else. Or alternatively, you can download Obfuscar source code and debug further to see which line in `Obfuscar.TypeKey.Matches` method causes the exception.

Commented Unassigned: Inconsistent virtual method obfuscation state detected [19]

$
0
0
This is the error:

Renaming: fields...parameters...properties...events...methods...
An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review the
following methods,
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.IPlaneObject::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.LineSegment::get_
BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YOrientedRectangl
e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YRectangle::get_B
oundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.BusRepresentations/c::g
et_BoundingBox[0]->Skipped:special name
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.LabelCandidate::get_BoundingBo
x[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]or/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]uw/g::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]ki/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.DynamicObstacl
eDecomposition/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Circular.CircularLayouter/b::g
et_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]dg/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.RemoveOverlapsLayoutSt
age/b::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.ShuffleLayouter/a::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.EdgeRouter/e::
get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]kz/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Labeling.MISLabelingAlgorithm/
c::get_BoundingBox[0]->WillRename:A


In the obfuscar.xml file i'm using this variables:

<Var name="InPath" value="..\Dlls" />
<Var name="OutPath" value="..\Dlls" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="ReuseNames" value="false" />

Can you help me with this issue?
Comments: I am trying to use Obfuscar with the yWorks dlls and am getting this exact same error. I don't believe it is a duplicate of item 16.

Commented Unassigned: Inconsistent virtual method obfuscation state detected [19]

$
0
0
This is the error:

Renaming: fields...parameters...properties...events...methods...
An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review the
following methods,
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.IPlaneObject::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.LineSegment::get_
BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YOrientedRectangl
e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YRectangle::get_B
oundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.BusRepresentations/c::g
et_BoundingBox[0]->Skipped:special name
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.LabelCandidate::get_BoundingBo
x[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]or/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]uw/g::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]ki/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.DynamicObstacl
eDecomposition/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Circular.CircularLayouter/b::g
et_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]dg/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.RemoveOverlapsLayoutSt
age/b::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.ShuffleLayouter/a::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.EdgeRouter/e::
get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]kz/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Labeling.MISLabelingAlgorithm/
c::get_BoundingBox[0]->WillRename:A


In the obfuscar.xml file i'm using this variables:

<Var name="InPath" value="..\Dlls" />
<Var name="OutPath" value="..\Dlls" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="ReuseNames" value="false" />

Can you help me with this issue?
Comments: Looking at yWorks.yFilesNET.Algorithms assembly in ILSpy shows that within BusRepresentations.d (where the special name skip shows up) this property shows up as: ``` public virtual YRectangle get_BoundingBox() { return this.c; } ``` Other implementations of the IPlaneObject interface look like normal properties. Like this one from LabelCandidate: ``` public virtual YRectangle BoundingBox { get { YRectangle yRectangle = LabelCandidate.a(this.a); if (yRectangle != null) { return yRectangle; } return this.a.BoundingBox; } } ``` I've tried adding this ForceMethod element to my config, but it doesn't resolve the issue: ``` <ForceMethod type="yWorks.yFiles.Layout.Router.BusRepresentations/d" name="get_BoundingBox" /> ``` I don't think the yWorks license allows me to send you their partially obfuscated dll.

Created Unassigned: System.InvalidProgramException occurs in a special situation that use the ternary operator. [26]

$
0
0
#Conditions

Problems in the following combinations.

* The ternary operation that returns a String (condition ? string1 : string2)
* The variadic function like String.Format (string, params string[])
* The assignment to a property (string Property { get; set; })

#Environment

* Windows 7 Professional(64bit)
* Microsoft Visual C# 2010 Express
* Obfuscar 2.0 rc7

#Example Source
##Program.cs
```
namespace Example
{
public class Model
{
public string Property { get; set; }
}

public class Program
{
public static void Main(string[] args)
{
InvalidFunction(true);
}

public static void InvalidFunction(bool flag)
{
Model model = new Model();
model.Property = flag ? MultiParameterFunction("example") : "test";
}

public static string MultiParameterFunction(string value, params string[] args)
{
return value;
}
}
}
```
##Obfuscar.xml
```
<?xml version='1.0'?>

<Obfuscator>
<Var name="InPath" value=".\" />
<Var name="OutPath" value=".\Out" />

<Module file="$(InPath)\Example.exe" />
</Obfuscator>
```

#Execution Result
```
>Example.exe

Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at A.a.A(Boolean )
at A.a.A(String[] )
```

#Workaround

I stopped using the ternary operator.
I was using the if statement instead.

Updated Wiki: Home

$
0
0
The project logo comes from Legendora Icon by Teekatas Suwannakrua.

Maintained and supported by LeXtudio.

Project Description
Obfuscar is an open source .NET obfuscator released under MIT license. It provides basic obfuscation features that help secure secrets in a .NET assembly.

Obfuscation Example

News

  • April 4, 2015 Process started to import original Google Code issues to GitHub.
  • Feb 2, 2014 Discussion board is going to be shut down. Please post questions to StackOverflow using obfuscar tag.

Get Started

Documentation section contains most information you need, and also a detailed history of this project all through the years.

The source repository for this project is at GitHub.

This tool has been heavily in Lex Li's personal project (#SNMP Pro).

Issues

If you have a patch to contribute, a feature to request, or a bug to report, please post to the Issue Tracker.

Support Services

Please contact LeXtudio for support services.

Donation

If you find this project useful and want to donate to my efforts on this project, please use the following link,

Donate

Updated Wiki: Home

$
0
0
The project logo comes from Legendora Icon by Teekatas Suwannakrua.

Maintained and supported by LeXtudio.

Project Description
Obfuscar is an open source .NET obfuscator released under MIT license. It provides basic obfuscation features that help secure secrets in a .NET assembly.

Obfuscation Example

News

  • March 1, 2014 Obfuscar 2.0 is officially released. It is also available as a NuGet package
  • Feb 2, 2014 Discussion board is going to be shut down. Please post questions to StackOverflow using obfuscar tag.

Get Started

Documentation section contains most information you need, and also a detailed history of this project all through the years.

The source repository for this project is at GitHub.

This tool has been heavily in Lex Li's personal project (#SNMP Pro).

Issues

If you have a patch to contribute, a feature to request, or a bug to report, please post to the Issue Tracker.

Support Services

Please contact LeXtudio for support services.

Donation

If you find this project useful and want to donate to my efforts on this project, please use the following link,

Donate

Updated Wiki: Home

$
0
0
The project logo comes from Legendora Icon by Teekatas Suwannakrua.

Maintained and supported by LeXtudio.

Project Description
Obfuscar is an open source .NET obfuscator released under MIT license. It provides basic obfuscation features that help secure secrets in a .NET assembly.

Obfuscation Example

News

  • April 14, 2015 Obfuscar 2.0.1 is officially released as a NuGet package
  • March 1, 2014 Obfuscar 2.0 is officially released. It is also available as a NuGet package
  • Feb 2, 2014 Discussion board is going to be shut down. Please post questions to StackOverflow using obfuscar tag.

Get Started

Documentation section contains most information you need, and also a detailed history of this project all through the years.

The source repository for this project is at GitHub.

This tool has been heavily in Lex Li's personal project (#SNMP Pro).

Issues

If you have a patch to contribute, a feature to request, or a bug to report, please post to the Issue Tracker.

Support Services

Please contact LeXtudio for support services.

Donation

If you find this project useful and want to donate to my efforts on this project, please use the following link,

Donate

Updated Wiki: Home

$
0
0
The project logo comes from Legendora Icon by Teekatas Suwannakrua.

Maintained and supported by LeXtudio.

Project Description
Obfuscar is an open source .NET obfuscator released under MIT license. It provides basic obfuscation features that help secure secrets in a .NET assembly.

Obfuscation Example

News

  • April 17, 2015 Obfuscar 2.0.2 Beta 1 is available at NuGet.org
  • April 14, 2015 Obfuscar 2.0.1 is officially released as a NuGet package
  • March 1, 2014 Obfuscar 2.0 is officially released. It is also available as a NuGet package
  • Feb 2, 2014 Discussion board is going to be shut down. Please post questions to StackOverflow using obfuscar tag.

Get Started

Documentation section contains most information you need, and also a detailed history of this project all through the years.

The source repository for this project is at GitHub.

This tool has been heavily in Lex Li's personal project (#SNMP Pro).

Issues

If you have a patch to contribute, a feature to request, or a bug to report, please post to the Issue Tracker.

Support Services

Please contact LeXtudio for support services.

Donation

If you find this project useful and want to donate to my efforts on this project, please use the following link,

Donate

Updated Release: 2.0.1 (Apr 14, 2015)

Updated Release: 2.0.1 (Apr 14, 2015)

Created Release: 2.0.2 (Beta 1) (Apr 17, 2015)

$
0
0
This release is available at NuGet.org,

https://www.nuget.org/packages/Obfuscar/2.0.2-beta1
  • Fixed GitHub issue 47. Generic support is enhanced so that F# assemblies can be obfuscated properly.

Released: 2.0.2 (Beta 1) (Apr 17, 2015)

$
0
0
This release is available at NuGet.org,

https://www.nuget.org/packages/Obfuscar/2.0.2-beta1
  • Fixed GitHub issue 47. Generic support is enhanced so that F# assemblies can be obfuscated properly.

Updated Release: 2.0.2 (Beta 1) (Apr 17, 2015)

$
0
0
This release is available at NuGet.org,

https://www.nuget.org/packages/Obfuscar/2.0.2-beta1
  • Fixed GitHub issue 47. Generic support is enhanced so that F# assemblies can be obfuscated properly.

Released: 2.0.1 (Apr 14, 2015)


Updated Release: 2.0.1 (Apr 14, 2015)

Commented Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A
Comments: @jirka7a, your fix is not at the correct location. This bug was caused by name choosing algorithm, which mistakenly decides `IA.get_PropA` and `IB.get_PropB` should both be named to `A`. The then obfuscated assembly has a logic change that makes `ClassB.get_PropB` an overriding method of `ClassA.get_PropA`, which is of course wrong and leads to the incorrect output. Properties can be renamed and even dropped as they are not in fact used in most of the cases. Method references usually go directly to the getter or setter methods. A more suitable fix (instead of making `uniqueMemberNameIndex` global) is to let `IA` and `ClassA` be put into consideration when renaming `IB.get_PropB` and `ClassB.get_PropB`. Then Obfuscar can easily tell `A` is not suitable, and switch to `a` (the next unique name). Thus, only a few lines are needed to be inserted to `Obfuscator.GetNameGroups` method. The fix is coming in Obfuscar 2.0.2 release.

Closed Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A

Commented Unassigned: System.InvalidProgramException occurs in a special situation that use the ternary operator. [26]

$
0
0
#Conditions

Problems in the following combinations.

* The ternary operation that returns a String (condition ? string1 : string2)
* The variadic function like String.Format (string, params string[])
* The assignment to a property (string Property { get; set; })

#Environment

* Windows 7 Professional(64bit)
* Microsoft Visual C# 2010 Express
* Obfuscar 2.0 rc7

#Example Source
##Program.cs
```
namespace Example
{
public class Model
{
public string Property { get; set; }
}

public class Program
{
public static void Main(string[] args)
{
InvalidFunction(true);
}

public static void InvalidFunction(bool flag)
{
Model model = new Model();
model.Property = flag ? MultiParameterFunction("example") : "test";
}

public static string MultiParameterFunction(string value, params string[] args)
{
return value;
}
}
}
```
##Obfuscar.xml
```
<?xml version='1.0'?>

<Obfuscator>
<Var name="InPath" value=".\" />
<Var name="OutPath" value=".\Out" />

<Module file="$(InPath)\Example.exe" />
</Obfuscator>
```

#Execution Result
```
>Example.exe

Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at A.a.A(Boolean )
at A.a.A(String[] )
```

#Workaround

I stopped using the ternary operator.
I was using the if statement instead.

Comments: Thanks for reporting this. I can see it is a bug affecting 2.0 and 2.0.1. You can try out 2.0.2 Beta 1 as this issue seems to be fixed in recent changes.

Closed Unassigned: System.InvalidProgramException occurs in a special situation that use the ternary operator. [26]

$
0
0
#Conditions

Problems in the following combinations.

* The ternary operation that returns a String (condition ? string1 : string2)
* The variadic function like String.Format (string, params string[])
* The assignment to a property (string Property { get; set; })

#Environment

* Windows 7 Professional(64bit)
* Microsoft Visual C# 2010 Express
* Obfuscar 2.0 rc7

#Example Source
##Program.cs
```
namespace Example
{
public class Model
{
public string Property { get; set; }
}

public class Program
{
public static void Main(string[] args)
{
InvalidFunction(true);
}

public static void InvalidFunction(bool flag)
{
Model model = new Model();
model.Property = flag ? MultiParameterFunction("example") : "test";
}

public static string MultiParameterFunction(string value, params string[] args)
{
return value;
}
}
}
```
##Obfuscar.xml
```
<?xml version='1.0'?>

<Obfuscator>
<Var name="InPath" value=".\" />
<Var name="OutPath" value=".\Out" />

<Module file="$(InPath)\Example.exe" />
</Obfuscator>
```

#Execution Result
```
>Example.exe

Unhandled Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at A.a.A(Boolean )
at A.a.A(String[] )
```

#Workaround

I stopped using the ternary operator.
I was using the if statement instead.

Viewing all 249 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>