StackWalk of other process in delphi?

时光怂恿深爱的人放手 提交于 2019-12-09 07:06:50

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/3760744/stackwalk-of-other-process-in-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!