Tavi
Tavi

Reputation: 21

StackWalk of other process in delphi?

Do you know how to read another process stack in delphi ??

Upvotes: 2

Views: 982

Answers (2)

André
André

Reputation: 9112

You could take a look at the "TThreadSampler.MakeStackDump" procedure of the following unit of my sampling profiler: http://code.google.com/p/asmprofiler/source/browse/trunk/Sampling/mcThreadSampler.pas

This function can read from the same thread, or same process or different process (each with it's own optimized function).

Btw: my Sampling Profiler reads Delphi debug symbols (.map, .jdbg, etc) because there is still no good Delphi to Pdb debug symbol converter (so you can view the stack of a Delphi program in Windows debugger or Process Explorer, Visual Studio etc). You can also use my sampling profiler for view the current stack of any process! http://code.google.com/p/asmprofiler/wiki/AsmProfilerSamplingMode

Upvotes: 1

Barry Kelly
Barry Kelly

Reputation: 42152

Yes.

You can enumerate threads with Toolhelp functions; get the context with GetThreadContext(); and read the stack memory (i.e. using ESP from the context) with ReadProcessMemory(). The stack grows downwards in memory, so reading memory locations after ESP is going down the stack.

Upvotes: 8

Related Questions