Looking at some analysis's online though would describe samples I would be tracking as VisualBasic as C# and vice versa. This was confusing with samples I was tracking as being copied from another variant as I expected them be the same source language.
I started looking at how VisualBasic and C# are compiled and if you could determine the source language of a .NET assembly. The following examples are simple 'Hello World' applications written in C# and VisualBasic.
With the exception of the string content we can see that the IL instruction set is identical in both the C# and VisualBasic assemblies.
- Dup - (Duplicate the value on the top of the stack.)
- Call SetProjectError
The setProjectError method is described as:
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.The Visual Basic compiler uses this helper method to capture exceptions in the Err object.
Looking for information on the setProjectError method I came across a post on the microsoft.public.dotnet.languages.vb list where Niklas from the complier team replied "The extra two calls are there to support the 'On Error' language feature which was retained to make it easier to upgrade from VB6 to VB.NET..."
This gives an indicator when looking at IL if it was generated using the VisualBasic compiler (vbc.exe). Within the catch clause the compiler will emit setProjectError and depending on the logic ClearProjectError. We don't see the second call in the example as the exception is thrown.
To test this I decompiled the VisualBasic compiled application and exported the IL as C#. Looking at the generated C# code there is the call to SetProjectError and a reference to Microsoft.VisualBasic.CompilerServices. If the source code was generated from IL compiled using the C# compiler, we would see 'throw exception;' with no reference to the SetProjectData method.
This class provides attributes that are applied to the standard module construct when it is emitted to Intermediate Language (IL). It is not intended to be called directly from your code.
VB.NET modules identical to a class with only shared members. When looking at emitted IL the module is compiled as a sealed class and that there is an additional reference to StandardModuleAttribute.
There are a number of other additional attributes which are generally specific to VisualBasic assemblies that can also be used as indicators such as the use of the My Feature and a number of other classes referenced within the CompilerServices Namespace.
Although these are specific to VisualBasic, C# applications could still reference functionality within VisualBasic namespaces. Obfuscation may also cloud the inclusion of these and isn't something I've looked into, but as they are references to the framework they should still be evident in samples.
References
- https://en.wikipedia.org/wiki/List_of_CIL_instructions
- https://msdn.microsoft.com/en-us/library/Microsoft.VisualBasic.CompilerServices(v=vs.110).aspx
- https://msdn.microsoft.com/en-us/library/s4kbxexc.aspx
- http://discuss.joelonsoftware.com/default.asp?dotnet.12.353213.14
This comment has been removed by a blog administrator.
ReplyDeleteThanks for posting keep updating it.
ReplyDeleteNode JS Training in Chennai
Node JS Advanced Training
French Classes in Chennai
pearson vue test center in chennai
Informatica Training in Chennai
best english coaching centre in chennai
best spoken english institute in chennai
Data Analytics Courses in Chennai
spanish language in chennai
content writing training in chennai
Node JS Training in OMR
Node JS Training in Porur
Thanks for sharing good info
ReplyDeletejava interview questions and answers
Betrivers: The Best Sportsbook for Betting on the Move 카지노 카지노 rb88 rb88 planet win 365 planet win 365 473Bet365 Review: A Reliable Sportsbook - LCB.com
ReplyDeleteLucky 15 Casino Hotel - Mapyro
ReplyDeleteFind the location for Lucky 15 순천 출장샵 Casino Hotel in Montville, along 제천 출장샵 with reviews, photos and a 안산 출장마사지 map. 상주 출장샵 Rating: 4.4 · 2,071 reviews · Price range: $ (Based on Average Nightly Rates for a Standard Room from our Partners)What are some of the property amenities 안양 출장마사지 at Lucky 15 Casino Hotel?What food & drink options are available at Lucky 15 Casino Hotel?