コード例 #1
0
gsyms = pdb.streams[pdb.streams[3].gsym_file]
omap = Omap(pdb.streams[12].data)
omap_rev = Omap(pdb.streams[11].data)

print gsyms.globals

for tbl, addr in zip(names, addrs):
    for sym in gsyms.globals:
        try:
            virt_base = sects[sym.segment - 1].VirtualAddress
        except IndexError:
            continue
        off = sym.offset

        if tbl.ServiceTable in sym.name:
            value = omap.remap(off + virt_base)
            addr.ServiceTable = value
            # print tbl.ServiceTable,hex(omap.remap(off+virt_base))
        elif tbl.ServiceLimit in sym.name:
            value = omap.remap(off + virt_base)
            addr.ServiceLimit = value
            # print tbl.ServiceLimit,hex(value)
        elif tbl.ArgumentTable in sym.name:
            value = omap.remap(off + virt_base)
            addr.ArgumentTable = value
            # print tbl.ArgumentTable,hex(value)

print addrs

for addr, val in zip(addrs, values):
    if not addr.ServiceTable:
コード例 #2
0
ファイル: print_gvars.py プロジェクト: a-palchikov/attic
parser = OptionParser()
parser.add_option("-n", "--no-omap",
                  action="store_false", dest="omap", default=True,
                  help="don't try to make use of OMAP information")
(opts, args) = parser.parse_args()

if len(args) != 3:
    parser.error("Need filename, base address, and first section offset")

pdb = pdbparse.parse(args[0])
imgbase = int(args[1], 0)
secbase = int(args[2], 0)
sects = Sections.parse(pdb.streams[secbase].data)
gsyms = pdb.streams[pdb.streams[3].gsym_file]

if opts.omap:
    omap = Omap(pdb.streams[secbase+2].data)
else:
    class Dummy: pass
    omap = Dummy()
    omap.remap = lambda x: x

for sym in gsyms.globals:
    try:
        off = sym.offset
        virt_base = sects[sym.segment-1].VirtualAddress
        nm = cstring(sects[sym.segment-1].Name)
        print "%s,%#x,%d,%s" % (sym.name,imgbase+omap.remap(off+virt_base),sym.symtype,nm)
    except IndexError,e:
        print >> sys.stderr, "Skipping %s, segment %d does not exist" % (sym.name,sym.segment-1)
コード例 #3
0
ファイル: lookup.py プロジェクト: a-palchikov/attic
    omap_rev = Omap(pdb.streams[BASE+1].data)

    last_sect = max(sects, key=attrgetter('VirtualAddress'))
    limit = base + last_sect.VirtualAddress + last_sect.Misc.VirtualSize

    addrs[base,limit] = {}
    addrs[base,limit]['name'] = pdbbase
    addrs[base,limit]['addrs'] = []
    for sym in gsyms.globals:
        off = sym.offset
        try:
            virt_base = sects[sym.segment-1].VirtualAddress
        except IndexError:
            continue

        mapped = omap.remap(off+virt_base) + base
        addrs[base,limit]['addrs'].append((mapped,sym.name))

    addrs[base,limit]['addrs'].sort(key=itemgetter(0))

def lookup(loc):
    for base,limit in addrs:
        if loc in xrange(base,limit):
            mod = addrs[base,limit]['name']
            symbols = addrs[base,limit]['addrs']
            locs  = [a[0] for a in symbols]
            names = [a[1] for a in symbols]
            idx = bisect_right(locs, loc) - 1
            diff = loc - locs[idx]
            if diff:
                return "%s!%s+%#x" % (mod,names[idx],diff)