> I had set breakpoints, which were never hit.
It may mean that the DLL loaded differs from your current code.
The following may help (along with a simple loop like
bool sleepAgain = true;
while(sleepAgain) { // put a breakpoint here and set sleepAgain = false
after it has been hit
Sleep(500);
}
so that you can attach to a process.)
This puppy brings the VS up automatically (note that WaitForInputIdle should
be enough but it is not; that's why an ugly Sleep(1500) follows):
//
// attaches the user-mode debugger VsJITDebugger, if it is not attached yet,
// and breaks, if attached (was attached before or attached just now)
// and doBreak is true.
//
void GiveMeAChance(bool doBreak = true) {
#ifdef _DEBUG
DWORD le_saved = GetLastError();
wchar_t cmdLine[100];
__try {
BOOL alreadyAttached = IsDebuggerPresent();
if(FALSE == alreadyAttached) { //
"%SystemRoot%\system32\VsJITDebugger.exe"
swprintf_s(cmdLine, L"VsJITDebugger.exe -p %lu",
GetCurrentProcessId());
STARTUPINFOW si = {0};
si.cb = sizeof(si);
PROCESS_INFORMATION pi = {0};
BOOL brc = CreateProcessW(0, cmdLine, 0, 0, 0, 0, 0,
0, &si, &pi);
_ASSERT(brc);
DWORD dwrc = WaitForInputIdle(pi.hProcess,
INFINITE);
Sleep(1500); // yield to give the
debugger some more time
}
if(FALSE != IsDebuggerPresent()) { // if we did not
attach, don't do DebugBreak, b/c
if(doBreak) {
DebugBreak(); // it crashes the
app if there is no debugger attached
}
}
} __finally {
}
SetLastError(le_saved);
#endif // _DEBUG
}
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-323380-
xxxxx@lists.osr.com] On Behalf Of priya sehgal
Sent: Tuesday, May 06, 2008 6:46 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to debug a COM DLL Server if it is being called
from a windows service
Hello,
I am developing a VSS Hardware Provider for Windows on
Windows 2003 Server machine. This provider is a COM
Server DLL. I am facing some problems in it and wish
to debug it. How can I debug this?
Please note that the functions of my DLL are called by
Windows VSS Service.
So, I do not have any of my own applications directly
calling this DLL, although the VSS requester is mine.
I tried attaching the vsssvc.exe to my dll code, after
making a debug build and registering it. But of no
use. I had set breakpoints, which were never hit.
Please help me on this.
Thanks and Regards,
Priya
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now.
Ihre Datenschutzeinstellungen
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
OSR Seminars – OSR
To unsubscribe, visit the List Server section of OSR Online at
ListServer/Forum