How to debug a Windows Search property handler

1k views Asked by At

I'm maintainning a Windows Search property handler project, it is loaded by SearchFilterHost.exe. I don’t know when SearchFilterHost.exe will be launched, don’t know the command line arguments usage, and I find SearchFilterHost.exe will exit one or two minutes after started, so it’s difficult to use the debugger to attach the process then debug the DLL it loaded.

How to debug a Windows Search property handler?

1

There are 1 answers

0
Rick Berge On BEST ANSWER

Debugging Protocol Handlers in MSDN talks about how to do this. It involves adding registry entries to make SearchIndexer and SearchFilterHost a little more friendly to debug. You probably will need to take ownership of the registry branch(es) to be able to change the values. Just doing the first set may be enough for you to be able to directly attach to SearchFilterHost.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
   Windows Search
      Gathering Manager
         DebugFilters = 1
         DisableBackOff = 1           may also be helpful

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
   Image File Execution Options
      SearchIndexer.exe
         Debugger = <path to debugger> <debugger options> 

Example using the ntsd debugger  
Debugger = C:\debuggers\ntsd.exe -odGx -c: "sxe ld mydll.dll;g"
Option  Description
-o  Tells ntsd.exe to debug child prcoesses.
-d  Pipes ntsd.exe through the kernel debugger to ensure the debugger is lauched on the right desktop (system context).
-g  Tells ntsd.exe to exit immediately when the child terminates.
-x  Disables first-chance break on access violation exceptions. The second occurrence of an access violation will break into the debugger.
-c  Sets the order of commands passed ntsd.exe.

Once you have things set up, restart the WSearch service, tweak your searched file, and things should happen.

Also, here's an old thread of others' experiences. Among other things, it talks about using the MSDN tool IFiltTst in your project's debug settings.

In your Project properties window, open ‘configuration properties’, ‘debugging’; and enter the following settings:

Debugger to launch:  Local Windows Debugger
Command: C:\<your path here>\IFiltTst.Exe
Command arguments: /i  "D:\<your project test folder>\<good file>.<extention to filter>" /v 3 /t 5 /l /d
Working directory: /i  "D:\<your project test folder>
Attach: No

Leave all other settings as default.

Both methods require your DLL to be registered so it will be found by Search.