Wednesday, June 9, 2010

Finally World Cup 2010 Is Here

World Cup- Soccer 2010 is finally here, with our favorite teams lining up for the mega sporting spectacle. While for the Internet savvy's there's more to cherish with, as the IT giants Google, Yahoo and Microsoft are gearing up to woo you with their eye catchy gadgets and services to keep yourself updated with the events and news directly from South Africa.


WorldCup Highlights
In case if you missed out those heart throbbing shots? Then here is an opportunity for those tied up with tight schedules. FIFA has put up the match highlights video online here.








Google's World Cup Offerings

Google with its innovative offerings has loads of serves for Soccer enthusiasts. With the very first one from the search engine forefront itself. If you were to key-in world cup to Google search box, you will be presented with the match details straight away.




A Panoramic Walk-through of World Cup Stadiums
While Google Street View is there with more aerial and visual treats, with street and panoramic views focused on to world cup soccer stadiums. Here you can take a walk through of those majestic Soccer stadiums in South Africa.




just in case if you are curious on how the street view is captured, here's a  how to video released by Google.


World Cup Stadiums 3D Video
You tube guys are out there with something different with a three dimensional view of the world cup soccer stadiums. Here you can immerse yourself in a three dimensional treat of those marvelous engineering.


World Cup Theme Songs
YouTube doesn't end there with just a view of the soccer stadiums, theres even more. The 2010 World Cup Theme song which really holds the spirit of the game, is a must watch.  

Here's The Official World Cup 2010 theme song by FIFA
  
 FIFA World Cup South Africa 2010 Official Theme Song.


Ariel Snaps of World Cup Stadiums
The PicasaWeb is there with some really good snaps, where you can find some Ariel view of the stadiums right from construction to completion.


Chrome Extensions
With the World Cup fever caught up with the browser extensions, Google Chrome is now made available with a new extension exclusively for FIFA World Cup 2010. This lists out news, fixtures, results, videos and more from the Soccer forefront. You can download the extension from here.




Yahoo World Cup 2010 Offerings
Yahoo had put up a dedicated site for reporting the latest happenings at World Cup Football 2010. The site has loads of details which every football manic expects and many more. You can visit the Yahoo Sports site here.


Microsoft World Cup 2010 Offerings
Microsoft has come up with new FIFA World Cup 2010 themes for Windows 7, upholding the spirit of Soccer. Here you can download the themes for World Cup 2010


Microsoft World Cup 2010 Score Card
Keep track of Who's Who at next level with Microsoft Excel Templates. Here you can download templates hosted by community members.


World Cup Live Video Feed
Here is a couple of sites coming up with live video feed from World Cup 2010.
http://watchworldcup.tv/ These chaps are providing live feed for a nominal fee. http://www.streamdirect.tv/ While these guys are said to offer the live feed for FREE of cost !!!. I think I should try out this once the World Cup rolls out into action.


WorldCup - Blogs 
Keep a tab on development at FIFA World Cup 2010 at the forefront and the things behind the scenes at http://www.worldcupblog.org/


Official World Cup Site
World Cup 2010 South Africa
FIFA World Cup Matches







World Cup 2010 match Schedule
You can download the match schedules from FIFA website.


If you want a single snapshot of the match schedules, Teams, Groups, Countries, Locations. Then here's an elegant 360 degree chart presenting with all of the above attributes, click here to visit.













World Cup 2010 
Broadcasters
If you interested to know which channel covering World Cup Football in your country, click here.


So get yourself ready for the mega event starting from June 11th to July 11th.


Thursday, June 3, 2010

Exploring Main() in C#

In a typical Win32 .NET application you could find that the entry point always point to the Main method, be it Console or Windows application. Out of curiosity I thought of digging into the internals, to see whether is it possible to map the entry point to a method name different from "Main". So to start off with, lets take the infamous HelloWorld sample for demo purpose.

Listing - 1

   1:  using System;
   2:   
   3:  namespace HelloWorldNamespace
   4:  {
   5:      public class Program
   6:      {
   7:          public static void Main()
   8:          {
   9:              Console.WriteLine("Hello World...");
  10:          }
  11:      }
  12:  }

Here in listing 1, you could see the Main method being the entry point as usual; before proceeding have you ever tried renaming the "Main()" to something of your choice?, If so, definitely the compiler would have stopped from compiling the application saying like "The Entrypoint Main() not found". So c'mon lets alter this code to get the entry point name mapped to something different. Before starting off, I strongly recommend using Notepad++ for working with the code listing discussed in the article, as we are going to deal with multi-file assemblies.


Listing - 2

   1:  using System;
   2:  using System.Reflection;
   3:   
   4:  namespace HelloWorldNamespace
   5:  {
   6:      public class Program
   7:      {
   8:          public static void MyEntryPoint()
   9:          {
  10:              MethodBase method = MethodBase.GetCurrentMethod();
  11:              Console.WriteLine(method.Name + ": Hello World...");
  12:          }
  13:      }
  14:  }


In listing 2, you could find the same code as in Listing 1 being retrofitted with some new additions like, the entry point had been re-named to MyEntryPoint, while a new type MethodBase is being implemented for printing out, the method name during application execution, this for ensuring that the MyEntryPoint method name is not being altered or overwritten by the compiler nor by the runtime behind the scenes. 


So lets compile the above code snippet from "Visual Studio command prompt", before this save the code in listing 2, to a file named "HelloWorld.cs". Key-in the commands in listing 3, to the "VS.NET Command Prompt" and make sure the location in console window is set to where the source code is located.


Listing - 3











csc /target:module HelloWorld.cs
al HelloWorld.netmodule /target:exe /Main:HelloWorldNamespace.Program.MyEntryPoint /out:Helloworld.exe  


(If you find working with the VS.NET command prompt cumbersome; like opening up the program from deep inside the start menu item and thereafter navigating to the source code location, I recommend reading this article.)
If you are familiar the commands and parameters in listing 3, you can straight away proceed to "Executing Application" section. In case if you find the commands in listing 3 unfamiliar? Let me give you a sneak preview. The commands CSC and AL are provided by .NET framework SDK, where "CSC" is the "CSharp Compiler", while the "AL" is the "Assembly Linker". Lets analyze the Listing 3, line by line. 


Listing - 4




csc /target:module HelloWorld.cs



In listing 4, you can find the first line from taken from listing 3. Here the csharp compiler(CSC) is passed with two parameters. The first parameter "/target:" instructs the compiler to generate a ".netmodule". While the second parameter "HelloWorld.cs" specifies the file name of source code as input. On execution the CSC generates  a file named "HelloWorld.netmodule" in the same directory as of "HelloWorld.cs".


Listing - 5
al HelloWorld.netmodule /target:exe /Main:HelloWorldNamespace.Program.MyEntryPoint /out:Helloworld.exe

In listing 5, you can find the second line from taken from listing 3. Here we are calling the "Assembly Linker" to generate an executable by referring the previously generated "HelloWorld.netmodule". From the the above listing you could find four parameters being passed to "AL.exe". The first parameter instructs to reference the HelloWorld.netmodule which was generated in the preceding step (Listing - 4). While the second parameter is a '/target:' flag which instructs to generate an console application. The Third parameter '/Main:' is where the entry point mapping happens, here we are specifying the method to be called in replacement of Main method. You can find fully qualified path to the method being passed in the following format {Namespace.TypeName.MethodName}. Finally in last parameter, the "/out:" flag where the name of the executable is mentioned as "HelloWorld.exe".



Executing Application
Voila, we are done with. Now you can execute the application and see the output. The output should be similar to listing 5, if you have used the same name for your entry-point.


Listing - 6




MyEntryPoint: Hello World...



Inside Story
So now we have an assembly with the entry point mapped to a different method name than that of the default Main(). Lets peek inside the HelloWorld.exe Assembly using "Red-Gate Reflector" and see, how this entry point re-mapping works.


Peeking inside the Code
Here is a screenshot from Reflector, of the HelloWorld.exe.




In the above screen shot from "Red-Gate Reflector", you can see two different modules namely HelloWorld.exe and HelloWorld.netmodule. You can find a method named "_EntryPoint():Void" the one highlighted in the screenshot, which does the job of pointing to the  entry-point of our choice. In the Disassembler window; you can see the C# code that does this mapping.


Main Program Variants
Its common to see the Main() method container type being used inside a Reference-Type most of the time. But did you know that, its possible to use "Struct"in place of "Class" container? Here in the below code listing you could find "struct" being used in place of "class", which is perfectly legal.




Listing - 7
   1:  using System;
   2:   
   3:  namespace HelloWorldNamespace
   4:  {
   5:      public struct Program
   6:      {
   7:          public static void Main()
   8:          {
   9:              Console.WriteLine("Hello World...");
  10:          }
  11:      }
  12:  }

So thats it. Truth to be told, If you were you ask me whats the benefit of this remapping Main() with a custom method name? I am clueless on this, if you happen to know any benefits on aspects relating to security or obfuscation, please let me know.