Пример #1
0
        public static Symbol[] GetSymbols(string DllFile)
        {
            IntPtr CurProc = Process.GetCurrentProcess().Handle;

            DbgHelp.SymInitialize(CurProc, null, false);

            if (!File.Exists(DllFile))
            {
                throw new FileNotFoundException("File not found", DllFile);
            }
            List <Symbol> Symbols = new List <Symbol>();

            ulong DllBase = DbgHelp.SymLoadModuleEx(CurProc, IntPtr.Zero, DllFile, null, 0, 0, IntPtr.Zero, 0);

            DbgHelp.SymEnumerateSymbols64(CurProc, DllBase, (Name, Addr, Size, Ctx) => {
                Symbols.Add(new Symbol(Name, DllBase - Addr, Size));
                return(true);
            }, IntPtr.Zero);

            DbgHelp.SymCleanup(CurProc);
            return(Symbols.ToArray());
        }