|
|
How to trace VC Add-ins objects
If you want to develope a VC Add-in, you maybe want to trace the VC Add-ins objects.
The VC Add-ins is Application, Document, Documents, Project, Projects...
These object has a COM interface, example: the Application has IApplication interface.
| Object |
Interface |
Object |
Interface |
| Application |
IApplication |
Breakpoint |
IBreakpoint |
| Breakpoints |
IBreakpoints |
BuildProject |
IBuildProject |
| Configuration |
IConfiguration |
Configurations |
IConfigurations |
| Debugger |
IDebugger |
Document |
IGenericDocument |
| Project |
IGenericProject |
Projects |
IProjects |
| TextDocument |
ITextDocument |
TextEditor |
ITextEditor |
| TextSelection |
ITextSelection |
TextWindow |
ITextWindow |
| Window |
IGenericWindow |
Windows |
IWindows |
You can get these objects's head file at "C:\Program Files\Microsoft Visual Studio\VC98\Include\ObjModel"
Step1: Generate A VC Add-in project
Start your VC, create a project with "DevStudio Add-in Wizard" project.
Step2: Modify your source code like our sample source.
- Find IApplication interface form .h file.
- Fill the FUNCTION_NAME struct like these code.
static FUNCTION_NAME __Application[] =
{"QueryInterface(REFIID riid, LPVOID FAR * ppvObj)"
,"AddRef()"
,"Release()"
,"GetTypeInfoCount(UINT *pctinfo)"
,"GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)"
,"GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)"
,"Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,"
"VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)"
,"get_Height(long* Height)"
,"put_Height(long Height)"
... ...
,"get_Errors(long* nErrors)"
,"get_Warnings(long* nWarnings)"
,"AddProject(BSTR szName, BSTR szPath, BSTR szType, VARIANT_BOOL bAddDefaultFolders)"
};
- After you get the IApplication Object in your source, create the map now.
STDMETHODIMP CDSAddIn::OnConnection(IApplication* pApp, VARIANT_BOOL bFirstTime,
long dwCookie, VARIANT_BOOL* OnConnection)
{
// Create IApplication Interface map file.
DebugMap_AddArrayToMapFile((DWORD*)*(DWORD*)pApplication, "IApplication", __Application,
sizeof(__Application)/sizeof(__Application[0]));
... ...
}
- Fill all source code which you want to trace.
- Build the source as a dll.
Step3: Register the dll as VC add-in.
Select Tool - Customize menu, and click Add-Ins and Macro Files
Tab, then click Browse... button. Select the dll module which you built at Step2.
And checked the check box with the add-in. Now, you will find a new ToolBar in VC's IDE.
Step4: Run VC to create the map file.
- Load a project from VC's IDE to create IProject interface map file.
- Click a documet to trigger DocumentOpen event to create IDocument interface map file.
- Set a breakpoint to Trigger BreakpointHit event to create IBreakpoint interface map file.
To create IBreakpoint interface map file, you need debug a project and let the program to execute through the Breakpoint.
- Click the ToolBar's icon and to create other interface map file.
- Close VC.
You will find some txt files had be created at C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin
Step5: Use these map file to trace VC add-in objects.
- Copy these txt files to Auto Debug Plug-in directory.
- Launch Auto Debug Professional.
- Select Tool - Option... and let the Load Extends MapFile item to chek on.
- Select File - New Process... to launch VC.
You will find the VC add-in map file had be added in Function Filter.

Requirements
Auto Debug for Windows: Unsupported.
Auto Debug Professional: Requires version 3.2 or later.
Auto Debug Enterprise: Requires version 3.2 or later.
Auto Debug Agent: Requires version 2.1 or later.
|