-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Open
Labels
Description
I am trying to decompile a VB.Net dll. I do not know what compiler produced it. Some methods with exceptions decompile cleanly, but some try to catch object instead of Exception. I cannot provide the original dll, but I have included an example of IL that fails. (only function names and strings have been changed from the original)
Input code
Please provide the input that failed to decompile.
If providing IL code as input, please provide enough context to allow us to re-assemble the IL.
If uploading a complete assembly, please mention which method failed to decompile.
.method assembly hidebysig instance void
VBFunction(object 'value') cil managed
{
// Code size 114 (0x72)
.maxstack 5
.locals init (
[0] int32,
[1] int32,
[2] class TestClass
)
.try
{
IL_0000: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectError()
IL_0005: ldc.i4.2
IL_0006: stloc.0
IL_0007: ldarg.0
IL_0008: stloc.2
IL_0009: ldloca.s 2
IL_000b: ldarg.1
IL_000c: call void TestClass::Func(class TestClass&, object)
IL_0011: br.s IL_0026
IL_0013: ldstr "VBFunction"
IL_0014: ldc.i4.0
IL_0015: ldstr "Exception"
IL_0016: ldnull
IL_0017: ldc.i4.0
IL_0018: call int32 TestClass::ShowMessage(string, int32, string, object, int32)
IL_0019: pop
IL_0026: leave.s IL_0069
IL_0028: ldc.i4.m1
IL_0029: stloc.1
IL_002a: ldloc.0
IL_002b: switch (IL_003c, IL_003c, IL_0013)
IL_003c: leave.s IL_005e
} // end .try
filter
{
IL_003e: isinst [mscorlib]System.Exception
IL_0043: ldnull
IL_0044: cgt.un
IL_0046: ldloc.0
IL_0047: ldc.i4.0
IL_0048: cgt.un
IL_004a: and
IL_004b: ldloc.1
IL_004c: ldc.i4.0
IL_004d: ceq
IL_004f: and
IL_0050: endfilter
} // end filter
{
IL_0052: castclass [mscorlib]System.Exception
IL_0057: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(class [mscorlib]System.Exception)
IL_005c: leave.s IL_0028
} // end handler
IL_005e: ldc.i4 -214628237
IL_0063: call class [mscorlib]System.Exception [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::CreateProjectError(int32)
IL_0068: throw
IL_0069: ldloc.1
IL_006a: brfalse.s IL_0071
IL_006c: call void [Microsoft.VisualBasic]Microsoft.VisualBasic.CompilerServices.ProjectData::ClearProjectData()
IL_0071: ret
} // end of method TestClass::VBFunction
Erroneous output
catch (object obj) when (obj is Exception && num2 != 0 && num == 0)
{
ProjectData.SetProjectError((Exception)obj);
try0000_dispatch = 40;
continue;
}I would have expected
catch (Exception obj) when (num2 != 0 && num == 0)
{
ProjectData.SetProjectError(obj);
try0000_dispatch = 40;
continue;
}Details
ILSpyCmd 8.2 and 9.1
Reactions are currently unavailable