How to debug unusual component with WinDbg

Control Panel applet

As my current is an audio driver on both Windows and Mac OS X, an applet to configure the device without launch the sophisticated application is convenient for the end-user to manipulate device quickly.

 

On Windows, Control Panel is the ideal way to do it. Actually Control Panel applies for all components running in the background, or automatically (e.g. service, driver or just a Non-GUI application).

 

Control Panel applets are just standard DLLs with a particular set of entry points and a .cpl extension. Place such a file in the Windows System directory and the next time you start up control panel your applet will be there.

 

About how to program a Control Panel applet, WDK provides a sample "Audio Control Panel Application". And I even found that there's a framework on CodeProject (http://www.codeproject.com/KB/winsdk/cjbcontrolpanelapplet.aspx). Here I just want to share the way of how to debug it.

 

WinDbg is usually a good choose for such kind of case.

1. In its File menu, click Open Executable.

2. In the following dialog, first of all, locate current folder into [SystemRoot]/System32/, and then

    type RunDll32.exe in the File Name textbox.

3. In the Arguments blank, type the below line:

    Shell32.dll,Control_RunDLL CPL

 

    As CPL has to be installed in [SystemRoot]/System32/ folder, we don't need any path prefix for it

    here. Of course, we need CPL to be debug version and type proper symbol path in WinDbg

    configuration to make debug session available.

Co-Installer

Windows WDM driver framework support co-installer mechanism to allow driver vendor intercept and customize driver installation. Co-installer is a user-mode Win32 DLL. Typically, a co-installer performs installation tasks that require dynamic information that is not available when the INF for its device or device class is written.

 

Driver installation on Windows will be handled by the operating system vis Setup API. While developing a co-installer, we don't need to create a InstallShield package for it. The update driver action in Device Manage has the same effect. Consequently the debug approach of co-installer can be done like below:

 

1. Open Device Manager firstly.

2. Launch WinDbg, and in its File menu, click Attach to a Process...

3. In the following dialog, select mmc.exe, and start debug session.

 

As the co-installer won't be called until the actual driver installation process starts, here we need a trick to make co-installer attach to the debugger by itself. Put a DebugBreak() in the entry fucntion of co-installer can achieve that. After the co-installer has been called and hit this break statement, WinDbg can capture it.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值