Remote Debugging using VC++ Editor & MSGina Debugging

To perform remote debugging, the Remote Debug Monitor is implemented. The Remote Debug Monitor is a small program that sits on the target computer, which communicates with the debugger and controls the execution of the program being debugged.

To install the Remote Debug Monitor on the target computer, do the following:
1. Copy the following files to the target computer

a. msvcmon.exe
b. msvcrt.dll
c. tln0t.dll
d. dm.dll
e. msvcp60.dll
f. msdis110.dll
g.psapi.dll is required only for Windows NT.

2.If you are using Windows 95/98, move the msvcrt.dll file to the Windows System directory and restart the computer.
a. On a Win32 computer, use these files:
b. msvcmon.exe
c. tlw3com.dll
d. dmw3.dll
(The files can be located in the ...\Microsoft Visual Studio\Common\MSDev98\bin subdirectory)

3. Set up a shared directory that can be viewed by both the remote machine and the local machine. The project should reside on the local machine.

4. Load the project into the Visual C++ development environment.

5. Open the Project Setting dialog box (Alt+F7). Then set the following options:
a. Executable for Debug Session—Enter the name and path of the executable as the local machine references it.
b. Additional DLLs—Enter the name and path of any DLLs as the local machine sees them.
c. Remote Executable Path—Enter the name and path of the executable as the remote computer sees it.
d. File Name— Enter the name of the file.
e. Working Directory—Should be blank.

6. Start msvcmon.exe on the remote machine to start the debugger. Click the Connect button to start the connection. (To start the debugger on Win32s platform, click the Visual C++ Debug Monitor icon from the Win32s program group.)

7. On the host computer, choose Debugger Remote Connection from the Build menu. Choose Network (TCP/IP) and then Settings. Enter the remote machine name or the IP address (password is not needed).

8. You now can begin debugging.
If a sharable directory cannot be made, copy the executable and any needed DLLs to the remote computer. The executables and DLLs must remain exactly the same all the time throughout the debugging process. Whenever they change on one machine, they must be copied to the other. All the other steps remain the same.
(If you are making use of VC++ .NET,
Copy the following files to the target computer:
c. natdbgtlnet.dll
d. natdbgdm.dll
e.psapi.dll (Windows NT 4.0 only)

(For dump support (for more information, see Dumps), install this file as well:
dbghelp.dll (supports dumps) )

Example: Debugging MSGina using Remote Debugging Technique
One of the instances where “Remote Debugging” can be used is while debugging MSGINA …

Remote GINA Debugging Technique
Debugging a GINA is somewhat of a hit and miss affair. Primarily, sufficient levels of debug logs can serve as the greatest tool that can provide an insight into what's going on between winlogon and GINA. Apart from that psychic powers can be beneficial. But, nothing can replace the real thing and thus the debugger is greatly missed. This could be easily remedied with Visual Studio remote debug tools. No longer debugging over serial cable is neccessary.

Rough instructions:

Create a debugging directory on target machine and add it to the %PATH%
Copy MSVCMON.EXE (The remote debugging server) to the debugging directory (along with all the DLLs it needs which are in the same directory as MSVCMON).
Install the debug GINA on target machine.

Get srvany and set it up to start msvcmon as a service on the target machine. I had to use tcpip as transport protocol (-tcpip) and allow all user connections (-anyuser). One more thing, the service has to run under an interactive user's account as LocalSystem? doesn't have network access.

So now we have the GINA DLL (and its dependencies) and the MSVCMON starting as a service on the target sysetm.

Load up the GINA project in Visual Studio on the system where debugging is to be done.
Choose to open the processes on the target machine remotely via TCP/IP. If everything worked, one should see a list of processes on the target machine. We choose Winlogon and attach to it...

At this point we can set breakpoints in the GINA source and get GINA on the remote machine to go over relevant execution paths to hit those breakpoints in the debugger!