WinDbg service debuggin

Folks, I need some insight into the following process of debugging a service , using DebugBreak() …

Using the following link – https://docs.microsoft.com/en-us/windows/win32/api/debugapi/nf-debugapi-debugbreak

Registry entry I added –
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\colortokens-lgm.mtoken]
“Debugger”=“C:\Program Files\Debugging Tools for Windows (x64)\windbg.exe"”

In foo( …)

I’ve the call to DebugBreak();

Now when I demand start the service, after sometime it hits that line of code, and locked the VMware work station. Without the DebugBreak() statement, I’ve exeception coming from some other parts, needless to say, excetption handling is not ideal here…

Question is the VM gets locked, any clue ?

Also I suppose the Windbg would be launched automatically !!

TIA,
Pro

It looks like you have a backslash after the exe name. That’s certainly wrong. And does that really say “colortokens-lgm.mtoken”? That’s nonsense. Where did you find that?

Thanks much Tim

https://docs.microsoft.com/en-us/windows/win32/services/debugging-a-service
is what I found online ( after a long while got back to Windows environment ).

For the second part it should be the name of exe (i,e, foo.exe ) I think.

Another one is https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/a329t4ed(v=vs.100)?redirectedfrom=MSDN
The image file execution.

Which one is better ?

Pro

OK, the first option also no longer available from Vista onward.

Going to try the Image File execution, to see …
Pro

Right, the key name should be

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\YourExeName.exe

What you had was not sensible.

That was the service name, not the exe. Now I tried with the exact exe name…
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\ct-lgm.exe]
“debugger”=“WinDbg.exe”

System env. variable is update to point to the full path of Windbg.

With that , after rebooting, I can not start the service (either by the service name - which what I do for demand start, or trying to start the exe – which is not really sc understand ).

sc start colortokens-lgm.mtoken
[SC] StartService FAILED 2:

The system cannot find the file specified.

Administrator@WIN-QLARN9P79KK MINGW64 /c/Program Files/ColorTokens/LGM/LogFiles
$ sc start ct-lgm.exe
[SC] StartService: OpenService FAILED 1060:

The specified service does not exist as an installed service.

Thanks,
Pro

Unless you know “windbg.exe” is on your default boot-time PATH, you’d best include the complete path to the exe.

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%systemroot%\System32\WindowsPowerShell\v1.0;%systemroot%\System32\WindowsPowerShell\v1.0;C:\Program Files\Microsoft Windows Performance Toolkit;C:\Program Files\Git\cmd;“C:\Program Files\Debugging Tools for Windows (x64)\windbg.exe”

I will put the full path, anyway…

Need to see how the flags are being set when the service is created ( Joy of debugging old cruft :smile: )
prokash

Was that supposed to be your PATH? A PATH does not include individual executables. It includes the directories that CONTAIN the executables. Remove “\windbg.exe” from the end of that.

Thanks, making so many mistakes ( lost lot of context )