The Interviews with Microsoft were like this J
I found this and tweaked it a little to show the MS Interview Process … .lol
Bye !
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;
TOKEN_PRIVILEGES tp;
LUID luid;
TOKEN_PRIVILEGES tpPrevious;
DWORD cbPrevious=sizeof(TOKEN_PRIVILEGES);
if(!OpenProcessToken(::GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken))
return FALSE;
if(!LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &luid ))
return FALSE;
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
tp.Privileges[0].Attributes = 0;
AdjustTokenPrivileges(hToken,FALSE,&tp,
sizeof(TOKEN_PRIVILEGES),&tpPrevious,&cPrevious);
if (GetLastError() != ERROR_SUCCESS)
return FALSE;
tpPrevious.PrivilegeCount = 1;
tpPrevious.Privileges[0].Luid = luid;
tpPrevious.Privileges[0].Attributes|=(SE_PRIVILEGE_ENABLED);
AdjustTokenPrivileges(hToken,FALSE, &tpPrevious,cbPrevious,
NULL,NULL);
if (GetLastError() != ERROR_SUCCESS)
return FALSE;
CloseHandle(hToken);
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
System.Diagnostics.Process.EnterDebugMode();
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 ?
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;
Console.WriteLine(x==y);
}
public static void Question4()
{
int x = 10;
int y = 10;
Console.WriteLine(x == y && (object)x!=(object)y);
}
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
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.
http://msdn.microsoft.com/vcsharp/homepageheadlines/hejlsberg/
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
[DllImport("msvcrt.dll")]
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