How to debug a winsock LSP dll in VC++?
Hi, all
I wrote a winsock LSP DLL (lsp.dll) and passed it to c:\\windows\\system32.
Who can tell me how to step to step debug it in VC++? I set breakpoints but it never broke.What shall I do?
Thank you.
Best Regards.
[243 byte] By [
yukuang] at [2007-11-20 0:16:35]

# 1 Re: How to debug a winsock LSP dll in VC++?
You never mentioned the VisualStudio version... but in general (with VC), you first debug build the LSP dll... Install the LSP and then start the DLL from the command-line...
C:\Windows\System32>devenv mylsp.dll
Set some break-points... and then hit F5 (go, I think), DevEnv will ask for a EXE file to host the DLL... pick one EXE that will activate your LSP... For instance, if you put a break-point on WSPStartup, any Winsock application will trig your BP as soon as new socket is created. Try IEXPLORE.EXE and a BP on your WSPStartup function.
Good luck.
j0nas at 2007-11-9 13:53:40 >

# 2 Re: How to debug a winsock LSP dll in VC++?
You never mentioned the VisualStudio version...
I'm so sorry . It's VC++ 6.0.
when I typed the command "C:\Windows\System32>devenv mylsp.dll", MS InterDev 6.0 started but not MS VC++ 6.0. I think it doesn't work.
Thank you.
# 3 Re: How to debug a winsock LSP dll in VC++?
Symbols installed on your computer must match the versions
of the system DLLs installed there. If they don't match
(e.g., you have symbol files for older versions of the same
DLLs), the debugger will refuse to load them.
download from microsoft.com , there might some packages.
eguru at 2007-11-9 13:55:40 >

# 4 Re: How to debug a winsock LSP dll in VC++?
when I typed the command "C:\Windows\System32>devenv mylsp.dll", MS InterDev 6.0 started but not MS VC++ 6.0. I think it doesn't work.
The IDE in VC6 is called msdev.exe, so try the same command line but with msdev.exe instead of devenv.exe. You may also need to copy some of the debug files, from the output directory of your LSP (don't remember which), to the system32 directory.
PS. You don't need the OS symbols, but it may help (if you want to step into MS code).
j0nas at 2007-11-9 13:56:35 >

# 5 Re: How to debug a winsock LSP dll in VC++?
It's very simple to debug, put debug version lsp dll in system32, load the lsp project in vc++ and use Internet explorer or any other program which use winsock API (and which is your target) and go debug it.
Remember you will need to restart the computer after each uninstallation, reinstalling lsp without reboot will lead to crash in services or important system programs.
# 6 Re: How to debug a winsock LSP dll in VC++?
Hi, all
Unfortunately it didn't work properly. What I did is like this:
1. "lsp.dll","install.exe" are in F:\, and my VC++ 6.0 project is f:\LSP. The lsp.dll is debug version.
2. Run the command "f:\> install -i lsp.dll " ,and it's OK.
3. Open VC++ 6.0 ,then open my project "f:\lsp\lsp.dsw".
4. Set a breakpoint in the function "WSPStartup".
5. Press F5, then the project prompt me "Please specify the executale file for the debug session", then I seleted the "Default Web Browser".
6. The project run in the Debug model.
7. In the IE address bar, I typed "www.dev-archive.com" and hoped the programe would break in my breakpoint,but it failed.
In the setup 2, I also tryed to run "f:\> install -i f:\lsp\debug\lsp.dll" , but it failed too. I also copied "lsp.dll","install.exe" to to c:\winnt\system32\ , and then run "c:\winnt\system32>install -i lsp.dll", but it still never stop at my breakpoint.
Please help me.
Thank you .
Best Regards
# 7 Re: How to debug a winsock LSP dll in VC++?
Insert DebugBreak() function call in your WSPStartup and DllMain (for process attach), and see if that will work.
j0nas at 2007-11-9 13:59:39 >

# 8 Re: How to debug a winsock LSP dll in VC++?
Insert DebugBreak() function call in your WSPStartup and DllMain (for process attach), and see if that will work.
Sometimes it works nice, but sometimes it doesn't work . I don't know the reason.
Please help me. :D
# 9 Re: How to debug a winsock LSP dll in VC++?
It's not sometimes...You must be doing something wrong, do you give a reboot after uninstalling lsp ?
Also keep lsp.dll in system32 always, so that all programs who use winsock can find it.