DbgHelp fails in a Windows service RRS feed

  • Question

  • I am trying to download debugging symbols from a .NET Windows service. The service calls a helper dll that does the actual calls into dbghelp.dll. I've found that the call to SymGetTypeFromNameW fails but GetLastError returns 0.  If I run the exact same code but in a Windows form application it works exactly as it should.  This is not a versioning issue because I load dbghelp with LoadLibrary with the exact path of the version I want to use and have verified through the debugger that it has actually loaded the correct version. 

    Here is the snippet of code that fails with a service but works with a form app.


     sz = sizeof(SYMBOL_INFOW) + MAX_SYM_NAME + 1;
     siw = (PSYMBOL_INFOW)malloc(sz);
     ZeroMemory(siw, sz);
     siw->SizeOfStruct = sizeof(SYMBOL_INFOW);
     siw->MaxNameLen   = MAX_SYM_NAME + 1;
     bRet = SymGetTypeFromNameW(proc, mb, sn, siw);
     if (!bRet) {
      gle = GetLastError();
      return gle;

    I have not yet stepped through the call to see where it fails but I'm wondering if anyone else has had this issue and if so knows a way to solve it.  Thanks.

    Thursday, April 16, 2015 3:03 AM


All replies

  • And to make it harder to figure out, there appears to be no symbols available for dbghelp.dll which is semi ironic.  So trying to step through the code is tricky.  I can see that there are no symbols from the error in Wireshark when symsrv goes to request the pdb (/download/symbols/dbghelp.pdb/7287EB19E5BD4BEBB3E638A476FFECC61/dbghelp.pdb)

    So because the code works in the non-service app, the only thing I can think of is it has to be a session issue of some kind.  Maybe dbghelp doesn't like session0 for some reason.  I can't imagine it's a permissions problem given that services run higher than the application.  Is there something else I could be overlooking? I saw a comment on the MSDN page for SymInit and it mentions services have to pass a non-relative path to the UserDir param and I do.  But that's the only reference to services that I saw on the various MSDN pages relating to the dbghelp functions.

    Friday, April 17, 2015 5:14 AM
  • Hi DevOps26,

    Like this document:

    As my understanding, the DbgHelp would be related to the windows debugging, I help you move this case to the WinDbg forum for dedicated support. Thanks for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 17, 2015 6:36 AM
  • Does your code work, when accessing symbols locally with your code?

    To download Symbols from ms-symbol-server, when using dbghelp functions in a service, on my Vista32 box - dbghelp.dll version, looks like setting a system environment variable does help:


    when running as a service - though it seems undocumented. 
    Reason I assume is
    Do not know, if this also apply for 'contemporary' versions.

    No warranty
    With kind regards

    • Edited by MaybeCompletelyW Saturday, April 18, 2015 6:09 AM
    • Marked as answer by DevOps26 Saturday, April 18, 2015 11:38 PM
    Saturday, April 18, 2015 6:05 AM
  • Thank you.  Adding that flag did the trick.  I suppose it wasn't downloading the correct symbols before so the call to SymGetTypeFromNameW would obviously fail.  Now the correct symbols are downloaded and it works.  Thanks again.
    Saturday, April 18, 2015 11:39 PM
  • Glad your issue is resolved. Looks like those, who are not so unlucky to use dbghelp-version which I do -, may try setting registry key - family -

    HKEY_CURRENT_USER\Software\Microsoft\Symbol Server\NoInternetProxy DWORD 1

    "The default behavior of SymProxy is to use whatever ..."

    Modifying registry incorrectly may lead to very serious problems - standard warnings apply about.
    With kind regards 

    Sunday, April 19, 2015 10:32 AM