Exemplo n.º 1
0
        public static IMAGEHLP_SYMBOL64 GetSymbolFromAddress(IntPtr hProcess, ulong Address)
        {
            //Initialize params for SymGetSymFromAddr64
            IMAGEHLP_SYMBOL64 Symbol = new IMAGEHLP_SYMBOL64();

            Symbol.SizeOfStruct  = (uint)Marshal.SizeOf(Symbol);
            Symbol.MaxNameLength = 33;

            IntPtr lpSymbol = Marshal.AllocHGlobal(Marshal.SizeOf(Symbol));

            Marshal.StructureToPtr(Symbol, lpSymbol, false);
            ulong Offset = 0;

            DbgHelp.SymGetSymFromAddr64(hProcess, Address, Offset, lpSymbol);

            Symbol = (IMAGEHLP_SYMBOL64)Marshal.PtrToStructure(lpSymbol, typeof(IMAGEHLP_SYMBOL64));
            Marshal.FreeHGlobal(lpSymbol);

            return(Symbol);
        }