Exemplo n.º 1
0
        //============================================================================
        // enumSymbolsCallback
        //============================================================================
        bool enumSymbolsCallback(ref DbgHelp.SYMBOL_INFO pSymInfo, uint SymbolSize, IntPtr UserContext)
        {
            int index = mSymbolNames.IndexOf(pSymInfo.Name);

            if (index == -1)
            {
                index = mSymbolNames.Count;
                mSymbolNames.Add(pSymInfo.Name);
            }


            SymDesc sd = new SymDesc();

            sd.mAddress   = (uint)(pSymInfo.Address >> 32);
            sd.mSize      = SymbolSize;
            sd.mNameIndex = (uint)index;// pSymInfo.Name;// +4;

            //insert based upon address
            for (int i = 0; i < mSymbolDat.Count; i++)
            {
                if (mSymbolDat[i].mAddress < sd.mAddress)
                {
                    mSymbolDat.Insert(i, sd);
                    break;
                }
            }


            //gXDBFileBuilder.addSymbol((DWORD)(pSymInfo->Address >> 32U), SymbolSize, pSymInfo->Name + 4);

            return(true);
        }
Exemplo n.º 2
0
        //============================================================================
        // enumSymbolsCallback
        //============================================================================
        bool enumSymbolsCallback(ref DbgHelp.SYMBOL_INFO pSymInfo, uint SymbolSize, IntPtr UserContext)
        {
            SymDesc sd = new SymDesc();

            sd.mAddress    = (uint)(pSymInfo.Address >> 32);
            sd.mSize       = SymbolSize;
            sd.mNameOffset = pSymInfo.Name;// +4;

            //gXDBFileBuilder.addSymbol((DWORD)(pSymInfo->Address >> 32U), SymbolSize, pSymInfo->Name + 4);

            return(true);
        }
Exemplo n.º 3
0
        public bool lookupImmediate(UInt32 address, ref LookupInfo info)
        {
            info.mAddress     = address;
            info.mLine        = -1;
            info.mFilename    = "?";
            info.mSymbol      = "?";
            info.mFoundLine   = false;
            info.mFoundSymbol = false;


            ///////////////////////////////////////////////////
            //lookup filename
            byte[] fName = new byte[1000];

            uint displacement = 0;

            DbgHelp._IMAGEHLP_LINE64 lineinfo = new DbgHelp._IMAGEHLP_LINE64();
            lineinfo.SizeOfStruct = (uint)DbgHelp._IMAGEHLP_LINE64.getSize();


            unsafe
            {
                fixed(byte *pCst = fName)
                {
                    //IntPtr ptr = new IntPtr()
                    lineinfo.FileName = new IntPtr(pCst);
                    info.mFoundLine   = DbgHelp.SymGetLineFromAddr64(hProcess, (UInt64)address, ref displacement, ref lineinfo);
                }
            }

            if (!info.mFoundLine)
            {
                Int32 errCode = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
                return(false);
            }
            else
            {
                info.mLine = (int)lineinfo.LineNumber;

                info.mFilename = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(lineinfo.FileName);
            }



            ///////////////////////////////////////////////////
            //lookup symbol
            ulong pdwDisplacment = 0;

            DbgHelp.SYMBOL_INFO symbInfo = new DbgHelp.SYMBOL_INFO();
            symbInfo.SizeOfStruct = (uint)DbgHelp.SYMBOL_INFO.getSize();
            symbInfo.MaxNameLen   = (int)DbgHelp.SYMBOL_INFO.getmaxCharSize();

            info.mFoundSymbol = DbgHelp.SymFromAddr(hProcess, address, ref pdwDisplacment, ref symbInfo);
            if (!info.mFoundSymbol)
            {
                Int32 errCode = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
                return(false);
            }
            else
            {
                info.mSymbol      = symbInfo.Name;
                info.mFoundSymbol = true;
            }



            return(true);
        }