예제 #1
0
    public override UInt32 GetGlobalRVA(String symbolName,
                                        SymType symType)
    {
        DiaSymbol sy = df.GlobalSymbol.FindSymbol(symbolName);

        if (sy == null && symType == SymType.GlobalFunction)
        {
            // Try looking for the symbol in public symbols,
            // as assembly routines do not have normal
            // global symbol table entries.  We don't know
            // how many parameters to use, so just guess
            // at a few sizes.
            for (int i = 0; i <= 16; i += 4)
            {
                // Non-fastcall.
                sy = GetValidPublicSymbolEntry("_" + symbolName + "@" + i);
                if (sy != null)
                {
                    break;
                }
                // Fastcall.
                sy = GetValidPublicSymbolEntry("@" + symbolName + "@" + i);
                if (sy != null)
                {
                    break;
                }
            }
        }

        return(GetSymbolRva(sy, symbolName, "Symbol"));
    }
예제 #2
0
    private UInt32 GetSymbolRva(DiaSymbol sy, String symbolName, String typeName)
    {
        if (sy == null)
        {
            // Ideally this would throw an exception and
            // cause the whole process to fail but
            // currently it's too complicated to get
            // all the ifdef'ing right for all the
            // mix of debug/checked/free multiplied by
            // x86/AMD64/IA64/etc.
            return(UInt32.MaxValue);
        }
        if (sy.Address > UInt32.MaxValue)
        {
            throw new InvalidOperationException(
                      typeName + " symbol " + symbolName + " overflows UInt32"
                      );
        }

        return((UInt32)sy.Address);
    }