Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging DLLRegisterServer

I have a COM DLL built using a script. There is no Visual studio project available. When I register the dll using the command regsvr32 "c:\windows\system32\dllname.dll" no message is displayed.

I added a DebugBreak() in the function DllRegisterServer and also in DllMain to expect a debug dialog to be displayed. However nothing happened.

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

Any suggestions on what could be missing for the DLL to register correctly and why no message is displayed.

How do I debug this.

like image 712
Karthick Avatar asked May 15 '26 23:05

Karthick


1 Answers

DebugBreak breaks under debugger and crashes process which is not being debugged.

What you need is to set up Visual Studio, under C++ Project settings, Debugging, so that it starts C:\Windows\system32\regsvr32.exe with your DLL, i.e. "$(TargetPath)" or full path explicitly. Start debugging and your breakpoints will be hit.

Note that in 64-bit OS to debug 32-bit DLL you will need C:\Windows\syswow64\regsvr32.exe.

UPD. The fact that no Visual Studio project is available is not really an obstacle. A fake project to just launch debugging session with proper command line is going to work out fine.

Other than that if you are still able to update the source code, you can add a MessageBox into DllRegisterServer, esp. instead of DebugBreak, start COM registration, have the message box popped up, then attach Visual Studio debugger (without need to have VS project), set breakpoints and then close the message box to let the execution continue and reach the points of interest.

like image 110
Roman R. Avatar answered May 19 '26 02:05

Roman R.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!