locked
Access Violation on reading symbols from PDB file using Debug Interface Access (DIA) RRS feed

  • Question

  • Dear all,

    I'm trying to dump the contents of a PDB file using the DIA API. I've first tried using Borland Delphi and, when that failed, using C#. In both cases the problem is the same: I get an access violation when I call IDiaEnumSymbolsByAddr.Enum. I've tried with the two different 32-bit versions on my system:

    C:\Program Files (x86)\Common Files\microsoft shared\VC\msdia80.dll (version 8.0.50727.4053)
    C:\Program Files (x86)\Common Files\microsoft shared\VC\msdia100.dll (version 10.0.30319.1)

    I also have 64-bit msdia90.dll and msdia100.dll on my system, but they don't show up in the Visual Studio COM references dialog even if I register them.

    The PDB file I'm trying to open is the WinXP kernel symbol file.

    I've found one report of access violations from the DIA (http://support.microsoft.com/kb/917780), but it refers to another version and only applies if the program contains Fortran code (which I would not expect for the WinXP kernel).

    The full source code I'm using is added below this post.

    Any ideas? Thanks in advance.

    With kind regards,
    Erik



    using System;
    using Dia2Lib;

    namespace DumpPdb
    {
        class Program
        {
            static void Main(string[] args)
            {
                IDiaDataSource source;
                IDiaSession session;
                IDiaEnumSymbolsByAddr enumByAddr;
                IDiaSymbol symbol;
                uint fetched;
                  
                source = new DiaSource();
                source.loadDataFromPdb("C:\\cygwin\\home\\erik\\winxpcd\\symbols\\exe\\ntoskrnl.pdb");
                source.openSession(out session);
                session.loadAddress = 0x804d0000;
                session.getSymbolsByAddr(out enumByAddr);

                for (; ; )
                {
                    enumByAddr.Next(1, out symbol, out fetched);
                    if (fetched < 1) break;

                    Console.WriteLine(String.Format("0x{0}\t{1}", symbol.virtualAddress, symbol.name));
                }

            }
        }
    }



    Tuesday, March 22, 2011 8:28 PM