Source code for vdb.recon.dopestack

'''
A quick set of tools for doing stack doping.
'''
import vtrace

[docs]def dopeThreadStack(trace, threadid): curthread = trace.getCurrentThread() try: trace.selectThread(threadid) sp = trace.getStackCounter() map = trace.getMemoryMap(sp) if map == None: raise Exception('Thread %d has invalid stack pointer 0x%.8x' % (threadid, sp)) mapva, mapsize, mperms, mfname = map dopesize = sp - mapva trace.writeMemory(mapva, 'V' * dopesize) except Exception, e: print 'dopeThreadStack Failed On %d' % threadid trace.selectThread(curthread)
[docs]def dopeAllThreadStacks(trace): ''' Apply stack doping to all thread stacks. ''' for threadid in trace.getThreads().keys(): dopeThreadStack(trace, threadid)
[docs]class ThreadDopeNotifier(vtrace.Notifier):
[docs] def notify(self, event, trace): dopeAllThreadStacks(trace)
dopenotif = ThreadDopeNotifier()
[docs]def enableEventDoping(trace): trace.registerNotifier(vtrace.NOTIFY_CONTINUE, dopenotif)
[docs]def disableEventDoping(trace): trace.deregisterNotifier(vtrace.NOTIFY_CONTINUE, dopenotif)