Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decompiled DLL - Clues to help tell whether it was C# or VB.NET?

When using something like DotPeek to decompile a DLL, how do I tell whether it was originally coded in VB.Net or C#?

I gather there's no easy way to tell, but that there may be tell-tale signs (ie. clues) in some of the decompiled code?

like image 447
codeulike Avatar asked Dec 07 '22 09:12

codeulike


2 Answers

You can look for a reference to the Microsoft.VisualBasic library. If that is present, it's very probable that the code was made using VB. The library is sometimes included in C# projects also, but that is not very common. If the reference is not there, it's certainly not VB.

(Well, it's possible to compile VB without the library using the command line compiler and special compiler switches, but that is extremely rare.)

You can also check how frequently the VisualBasic library is used. In a regular VB program it would be used often, but in a C# program it would typically only be used for some specific task that isn't available in other libraries, like a DateDiff call.

Any VB specific commands, like CInt or Mid will show up as calls to the VisualBasic library, and even the = operator when used on strings, will use the library. This code (where a and b are strings):

If a = b Then

will actually make a library call to do the comparison, and shows up like this when decompiled as C#:

if (Operators.CompareString(a, b, false) == 0) {
like image 100
Guffa Avatar answered Apr 20 '23 00:04

Guffa


One posible route might be to look for Named Indexers; It isn't allowed in C# i.e. you can only have the following in c#

object this [int index] {get;set;}

but in managed C++ and VB.Net (I believe, will delete this if I'm wrong) it appears you can have named indexers.

So at least you could narrow it down to whether or not it was C#

like image 43
Meirion Hughes Avatar answered Apr 19 '23 23:04

Meirion Hughes