Do you know how to read another process stack in delphi ??
2 Answers
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.

- 41,404
- 5
- 117
- 189
-
2And use dbghelp api's to get names from the symbols could be the next step. – Remko Sep 21 '10 at 15:44
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

- 8,920
- 1
- 24
- 24