Debugging DLLRegisterServer

I have a COM DLL built with a script. Visual Studio project is not available. When I register the dll using regsvr32 " c:\windows\system32\dllname.dll

" the message is not displayed.

I added DebugBreak () to the DllRegisterServer function as well as DllMain to wait for the debug dialog to be displayed. However, nothing happened.

The entries expected from the DLL are NOT added to the registry.

Any suggestions on what might be missing to get the DLL to register correctly and why the message isn't showing.

How to debug this.


source to share

2 answers


breaks under the debugger and gives out a process that is not being debugged.

You need to configure Visual Studio in the Debug C ++ project settings so that it will run C: \ Windows \ system32 \ regsvr32.exe from your DLL, i.e. "$(TargetPath)"

or the full path explicitly. Start debugging and your breakpoints will be removed.

Please note that on a 64-bit OS, to debug a 32-bit DLL, you need C: \ Windows \ syswow64 \ regsvr32.exe.

UPD. The fact that the Visual Studio project is not available is not really a hindrance. A fake project to start a debug session with the proper command line will work fine.

Alternatively, if you can still update the source code, you can add MessageBox

to DllRegisterServer

esp. instead DebugBreak

, start COM registration, a message box appears, then add the Visual Studio debugger (no need for a VS project), set breakpoints, and then close the message box to continue execution and reach the points of interest.



I found RegSvrEx very helpful in these situations. This gives a much better diagnostic result, and since you have the source, you can attach a debugger.



All Articles