Welcome to MSDN Blogs Sign in | Join | Help

Look at the operating system version and SP details from the dump in WinDbg..

This is a very common question, we encounter almost all the times.

Just imagine a situation, we have got a memory dump from somewhere and want to see what operating system which is run there and what SP is installed.. For this, there is a very simple command.

0:001>vertarget

Windows Server 2003 Version 3790 (Service Pack 2) MP (4 procs) Free x86 compatible
Product: Server, suite: TerminalServer SingleUserTS
kernel32.dll version: 5.2.3790.4062 (srv03_sp2_gdr.070417-0203)
Debug session time: Tue Oct 30 05:54:21.000 2007 (GMT+5)
System Uptime: 3 days 8:21:53.750
Process Uptime: 0 days 4:28:05.000
  Kernel time: 0 days 0:00:34.000
  User time: 0 days 0:09:37.000

Stay tuned.. Wave

Posted by Jigar Mehta | 0 Comments
Filed under: ,

How to change value of register when doing live debugging with Windbg?

Windbg has not only registers reading functionality but it can also modify registers when doing live debugging..

Its really useful sometimes to modify the register values and take different path to check for particular code branch..

You can modify the register value like this..

0:000>r @eax=0x80040005

Above command will modify value of register eax and set it to 0x80040005.

Stay tuned.. Wave

Posted by Jigar Mehta | 0 Comments
Filed under: ,

Collection of SysInternal Tools

The team has just released a new subdomain that has neat and clean list of all SysInternal Tools, ready for you!!

Take a look,
http://live.sysinternals.com

Stay tuned.. Wave

Posted by Jigar Mehta | 4 Comments

Visual Studio 2008 SP1 Beta is available!!

I've been using Visual Studio 2008 from few months.. Its really a great improvement over productivity.. I love new features and speedy IDE. Service Pack 1 for Visual Studio 2008 contains not only bug fixes but also lots of new features! Along with .NET Framework 3.5 SP1 beta, VS2008 SP1 beta has been released few days ago. I just installed it on all my machines!

If you want to download it, refer to following links,

After you install it, following may be few useful links,

Happy coding!

Stay tuned.. Wave

Posted by Jigar Mehta | 0 Comments

What is better way of keeping an eye on last win32 error while debugging?

I have found it necessary many times to keep an eye on last win32 error, while using Win32 APIs in code! (Calling GetLastError() after each API usage is not feasible solution!).. In Visual Studio they have provided a very good small feature. You can write @err,hr in the watch window,

05-08-2008 (225206)

Similarly, you can use another pseudo register @eax for keeping an eye on the function return value! (If you are looking at some Win32 API's return value, you can also do @eax,hr to find out the text message behind the integer..)

Sometimes these small debugging tips increase significant debugging speed..

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under:

How can I check the details about Process Token while debugging in Visual Studio?

Visual Studio 2005 onwards, watch window has got a pseudo register for investigating the details about process token. So, all you have to do is, just start debugging and write "$user" in watch window,

05-08-2008 (223012)

Its interesting to look at expanded view of privileges and groups sometimes!

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under:

CoCreateInstance returns 0x80080005 for Visual Studio 2008 based ATL service??

I just worked with a customer who was facing interesting issue. He was getting 0x80080005 at client when he calls CoCreateInstance. The COM component is implemented within an ATL Service which is running on the same machine (we are not hitting wire/network). Now, typical meaning of this error is,

CO_E_SERVER_EXEC_FAILURE                                      winerror.h
Server execution failed

Generally this means Server (out of process server, either stand alone EXE or service) did not respond to RPCSS within definite time about COM server's successful start. Many things could have happened (may be Server got some exception/error, or server got crashed!)

But in this case, even if I start the service before making call from client, I get same response from client. Something else was wrong! And after lots of checks here and there, we found out that it is a BUG!

The bug shows up when,

  • You create a brand new ATL Service project using Wizard with Visual Studio 2008.

The root cause is, newly generated CoClass's rgs file (that holds the component registration information) doesn't contain entry for AppID. So, even if you register the COM component (using <exename.exe> /service), you dont get AppID key generated for CoClass. And COM runtime returns this error at client.

To fix it,

  • Look at your rgs file (for each ATL simple objects you added to COM service project),
  • Replace snippet looking similar to following,

                ForceRemove {9ACB97C6-4492-40E8-A1BD-51DFE8962E92} = s 'CMyObject Class'

                {

                      ProgID = s 'ATLComService.CMyObject.1'

                      VersionIndependentProgID = s 'ATLComService.CMyObject'

                      ForceRemove 'Programmable'

                      LocalServer32 = s '%MODULE%'

                      'TypeLib' = s '{E423A7DE-58C7-4535-A864-395DCEDE941F}'

                }

    with 

                ForceRemove {9ACB97C6-4492-40E8-A1BD-51DFE8962E92} = s 'CMyObject Class'

                {

                      ProgID = s 'ATLComService.CMyObject.1'

                      VersionIndependentProgID = s 'ATLComService.CMyObject'

                      ForceRemove 'Programmable'

                      LocalServer32 = s '%MODULE%'

                      val AppID = s '%APPID%'

                      'TypeLib' = s '{E423A7DE-58C7-4535-A864-395DCEDE941F}'

                }

There is also another way to permanently fix this issue (Product Team is planning to fix this issue in Visual Studio 2008 SP1), you can also,

  • Go to C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\CodeWiz\ATL\Simple\Templates\1033\object.rgs
  • Add following line right before statement for "typelib"

    [!if APPID_EXIST]

                                        val AppID = s '[!output APPID_REGISTRY_FORMAT]'

    [!endif]

That should fix the issue.

Stay tuned.. Wave

Posted by Jigar Mehta | 0 Comments
Filed under:

VC++ Debug C++ Runtime Files..

How many times have you tried to run the debug build of your project on a test machine where you don't have Visual Studio installed, and faced issues? Issues like,

For binaries built in debug configuration with Visual Studio 2005..

Activation context generation failed for "<your file>". Dependent Assembly Microsoft.VC80.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762" could not be found.

For binaries build in debug configuration with Visual Studio 2003..

This application has failed to start because MSVCR71D.dll was not found. Re-installing the application may fix this problem.

Actually the solution to problem is very simple.

For binaries built in debug configuration with Visual Studio 2005, download following files, extract them get files from following location and put them in your application directory (along with the manifest file).

Update:**I cant re-distribute the debug run-time files over here, So, I have removed the download links, but you can get the required files from following location (on the machine where you have Visual Studio 2005 installed)**

C:\Program Files\Microsoft Visual Studio 8\VC\redist\Debug_NonRedist\x86

For binaries build in debug configuration with Visual Studio 2003, you can copy following files and place them in application path.

    • C:\windows\system32\msvcr71d.dll
    • C:\windows\system32\msvci70.dll
    • C:\windows\system32\msvcp71d.dll

Following documentation may also help..

Redistributing Visual C++ Files
http://msdn.microsoft.com/en-us/library/ms235299.aspx

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under:

COM Interop Sample : Using C# DLL from C++ application

I have found many people who are beginning to learn COM Interop, looking for a sample application that explains how to use C# DLL from C++ application.

Here is one sample that I developed (SLN file is in VS2008 format!)

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under:

How to register .NET Assembly for COM Interop ?

Do you want to use your .NET DLL (assembly) from VB6 or C++ application (native code) ? Yes, you can do that using COM Interop. As per COM rules, you need to get your assembly registered on system (in Registry, yes, thats how COM works!).

To get an assembly registered on system, you can use regasm utility that comes with .net framework.

If you have .NET Framework 2.0 installed, regasm would be in following path (assuming you have 32-bit OS)
C:\windows\microsoft.net\Framework\v2.0.50727\regasm.exe

If you have 64-bit OS as well as .NET framework installed, you should find 32bit version of regasm in,
C:\windows\microsoft.net\Framework\v2.0.50727\regasm.exe

and 64 bit version of regasm should be in,
C:\windows\microsoft.net\Framework64\v2.0.50727\regasm.exe

More on regasm and its command line options is described here.

If you are developing project in Visual Studio, there is option to register your assembly with COM Interop in Project Properties (Right click on project and choose properties), Go to Build tab, There is an option for "Register for COM Interop". (Basically what it does is, it calls regasm after DLL is built!)

image

 

There are two options while registering the assembly for COM Interop,

  • Put your assembly in GAC.
    • If you put your assembly in GAC, you don't have to use /codebase command line switch with regasm, because application will be able to find the assembly using default probing mechanisms.
  • Assembly is not in GAC.
    • Its advisable to use /codebase command line switch when you dont have your assembly in GAC because that will add absolute path for your assembly in registry so that COM client (your native application which uses .NET assembly) can find it.
    • Following is what will be written in case if you choose to use /codebase option while registering. (notice the CodeBase key).

image

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under: , ,

Live Mesh Technology Preview Available!

I am very excited to tell that Microsoft announced Live Mesh Technology preview today. Its awesome piece of system, and will surely increase your productivity if you have multiple machines/devices at multiple location! I just love it!!!

More details here..

Stay tuned!!

Posted by Jigar Mehta | 2 Comments
Filed under:

Parallel Computing Initiative..

As a part of Parallel computing initiative at Microsoft, we just released Parallel Extensions to .NET Framework 3.5 Community Technology Preview (CTP) which can be downloaded from here.

Also, at MSDN, there is new section dedicated to ideas, technology, samples and information for developers who are interested in leveraging parallel computing, which can be accessed here.

I could also find this white paper very informative..

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments

Visual Studio 2005 debugging trick..

Just now, I found a trick in Visual Studio 2005 to debug pointers in better way. You can ',n' in watch window where 'n' is number of elements to display. I think following snapshot is self explanatory..

SHOT0063

Stay tuned.. Wave

Posted by Jigar Mehta | 3 Comments
Filed under:

My component is not listed in DCOMCNFG..

I hear this problem occasionally. Customers have COM/DCOM component on the system registered properly, they want to enable DCOM on their component (to access the component over the network!). They need to modify the permissions for their component, for which they open DCOMCNFG.exe, but they can not find their component in the list of DCOM components installed.

If this is happening, mostly its the issue with AppID!

As I told in one of my previous post, DCOMCNFG is supposed to create AppID if its not already there! But, if it has happened that DCOMCNFG is not doing its task, first, please drop me a line, I want to debug that further and second, follow the alternate way to generate AppIDs properly.

Open OleView.exe (if you dont have it, download it from here). Expand "All Objects" by double clicking on it (it might take some time as its enumerating entire HKLM\CLSID and related keys,

image

Select your object from the expanded list. If your COM/DCOM component is registered properly, you should be able to find your component in the list! As you select the component, you will see right side pane with various options.

image

Select "Launch Permissions" tab, you should get something similar to below.

image

Select the radio button, "Use these launch permissions:". Clicking this setting is supposed to create the required AppID key. So, after you select this option, you can select the default launch option again (that would not remove the newly generated AppID!) and close the OLE Viewer.

Hope that helps..

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under:

Interesting windbg command-line parameters..

Here is a list of few interesting command-line parameters and their mapping to interactive commands in windbg..

image

PS: Taken from "Advanced Windows Debugging" (the best debugging book, I have ever come across!!).. Go grab your copy!

Stay tuned.. Wave

Posted by Jigar Mehta | 1 Comments
Filed under: ,
More Posts Next page »
 
Page view tracker