Microsoft Interview Process :)

The Interviews with Microsoft were like this J

I found this and tweaked it a little to show the MS Interview Process … .lol

Bye !


Setting SeDebugPrivilige in .NET

It is really amazing how the .NET Framework has made the development tasks easier. The Framework Class Library is undoubtedly an extremely rich set of API’s. I wanted to dump the entire address space of any process. So, I thought of doing a small Dump Tool in the free time which I get occasionally in the evenings or on weekends. I’ll post the complete code when it’s complete.

Anyway I wrote the following C++ code to get SeDebugPrivilige for a process. SeDebugPrivilige allows any process to access memory and other information of operating system processes which you do not have access to otherwise.

BOOL CTaskManagerDlg::SetPrivilege()


   HANDLE hToken;
   LUID luid;
   DWORD cbPrevious=sizeof(TOKEN_PRIVILEGES);

     return FALSE;

   if(!LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &luid ))
     return FALSE;
   tp.PrivilegeCount           = 1;
   tp.Privileges[0].Luid       = luid;
   tp.Privileges[0].Attributes = 0;

   if (GetLastError() != ERROR_SUCCESS)
     return FALSE;

   tpPrevious.PrivilegeCount       = 1;
   tpPrevious.Privileges[0].Luid   = luid;

   AdjustTokenPrivileges(hToken,FALSE, &tpPrevious,cbPrevious,
   if (GetLastError() != ERROR_SUCCESS)
     return FALSE;

   return TRUE;


This code has been taken mostly from the MSDN Article Article ID: Q131065

To do all this from C# you just need to call a simple function J


Yes ! Its that easy. The Base Class Library is quite rich but you only have to find the things. However, I still could not find the equivalent of Functions from the native ToolHelp32 library defined in the Kernel32.dll. So, I have to write a complete PInvoke wrapper for that. I will post the complete code on the weekend.

Can anyone tell me where to find .NET Equivalents of  ToolHelp32 Functions ?

Fun with Equality

Brad Abrams Posted a small Equality Quiz
Its just 10 min but it was fun. Here are my answers (Try yoursellf first)
public static void Question1()
int x = 10;
long y = 10;
Console.WriteLine(x==y && !x.Equals(y));
public static void Question2()
object x = 10;
object y = 10;
Console.WriteLine(x!=y && x.Equals(y));
public static void Question3()
object x = new object();
int y = 10;
public static void Question4()
int x = 10;
int y = 10;
Console.WriteLine(x == y && (object)x!=(object)y);

Microsoft Puzzle/Analytical Questions

Ok! I said I’ll be sharing some of the MS Interview experience. For the preparation of the interview we (with my other friends) searched various resources on the internet. I even purchased an e-book but it didn’t turn out to be helpful. Generally there are three types of questions in an MS Interview. Analytical/Puzzles, Algorithms/Coding and Personality. We collected various questions in these categories.
Following are some of the Logical/Analytical questions generally asked at MS. There are a lot of questions but the following are the most common and are mentioned by various people who have been through the interviews. Frankly, before the interview I thought that this was some good set of questions but they will not ask these questions which you find so easily on the internet, or probably these questions are too old, but they do ask these questions repeatedly and sometimes they even know that you have done this question before but just to observe your reaction.
Anyway, even I got atleast 5-6 questions from the following set. It’s a good exercise, I’ll see if I get some time to post the answers to these over the next weekend. Wait for Coding/Algorithm questions in future posts.

Logical/Puzzles Questions Usually Asked at Microsoft

  1. Why is a manhole cover round?
  2. If you had an infinite supply of water and a 5 quart and 3 quart pail, how would you measure exactly 4 quarts?
  3. You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?
  4. If you are on a boat and you throw out a suitcase, will the level of water increase or decrease?
  5. How many times a day a clock’s hands overlap?
  6. One train leaves Los Angeles at 15mph heading for New York. Another train leaves from New York at 20mph heading for Los Angeles on the same track. If a bird, flying at 25mph, leaves from Los Angeles at the same time as the train and flies back and forth between the two trains until they collide, how far will the bird have traveled?
  7. There are 3 ants at 3 corners of a triangle; they randomly start moving towards another corner. What is the probability that they don’t collide?
  8. If you look at a clock and the time is 3:15, what is the angle between the hour and the minute hands? (The answer to this is not zero!)
  9. How would you weigh a plane without using scales
  10. Why are beer cans tapered at the top and bottom?
  11. You have 8 balls. One of them is defective and weighs less than others. You have a balance to measure balls against each other. In 2 weighings how do you find the defective one?
  12. There are 3 baskets. one of them have apples, one has oranges only and the other has mixture of apples and oranges. The labels on their baskets always lie. (i.e. if the label says oranges, you are sure that it doesn’t have oranges only,it could be a mixture) The task is to pick one basket and pick only one fruit from it and then correctly label all the three baskets.
  13. Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife?
  14. If you have two buckets, one with red paint and the other with blue paint, and you take one cup from the blue bucket and poor it into the red bucket. Then you take one cup from the red bucket and poor it into the blue bucket. Which bucket has the highest ratio between red and blue? Prove it mathematically.
  15. You have a bucket of jelly beans. Some are red, some are blue, and some green. With your eyes closed, pick out 2 of a like color. How many do you have to grab to be sure you have 2 of the same?
  16. You are given a scale which you are to use to measure eight balls. Seven of these balls have the same weight: the eigth ball is heavier than the rest. What is the minimum number of weighs you could perform to find the heaviest of the eight balls?.
  17. Pairs of primes separated by a single number are called prime pairs. Examples are 17 and 19. Prove that the number between a prime pair is always divisible by 6 (assuming both numbers in the pair are greater than 6). Now prove that there are no ‘prime triples.’
  18. There is a room with a door (closed) and three light bulbs. Outside the room there are three switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door you can’t change them. Identify each switch with its bulb.
  19. There are 4 women who want to cross a bridge. They all begin on the same side. You have 17 minutes to get all of them across to the other side. It is night. There is one flashlight. A maximum of two people can cross at one time. Any party who crosses, either 1 or 2 people, must have the flashlight with them. The flashlight must be walked back and forth, it cannot be thrown, etc. Each woman walks at a different speed. A pair must walk together at the rate of the slower woman’s pace.
    Woman 1: 1 minute to cross
    Woman 2: 2 minutes to cross
    Woman 3: 5 minutes to cross
    Woman 4: 10 minutes to cross
    For example if Woman 1 and Woman 4 walk across first, 10 minutes have elapsed when they get to the other side of the bridge. If Woman 4 then returns with the flashlight, a total of 20 minutes have passed and you have failed the mission. What is the order required to get all women across in 17 minutes? Now, what’s the other way?

The C# Design Process

There is a good discussion available on MSDN with “Anders Hejlsberg”, the lead Architect of C# language. The discussion focuses on various new features in C# and their comparison with C++ and Java, like Generics in C#, Checked and Un-Checked exceptions and other topics. It’s a useful reading.

Exception in System.Drawing.dll

There is a small problem with System.Drawing.dll in VS.NET 2003. Sometimes you get an Arithmetic Exception and the program is terminated. If u get this "Arithmetic Exception" in System.Drawing.dll, then there must be some spy software or some virus installed on your system which has hooked the system and changed the FPU (FloatingPoint Unit value) for all the processes.

To Set the FPU value to dafault u can use _controlfp() function defined in "msvcrt.dll". This is a native function, to call this function in C# u will have to use .NET Runtime Interop Services. To do this add the following lines of code to your Form class

private static extern int _controlfp(int n, int mask);
private const int _MCW_EW = 0x8001F;
private const int _EM_INVALID = 0x10;

Now call this function at the start of your form constructor

_controlfp(_MCW_EW, _EM_INVALID);

The FPU value is now set to default and you will not get any Exception in system.Drawing.dll