28 typedef struct _THREAD_STACK_CONTEXT
41 BOOLEAN ConnectedToPhSvc;
80 switch (Control->Type)
91 context->ProcessId = Control->u.Initializing.ProcessId;
92 context->ThreadId = Control->u.Initializing.ThreadId;
93 context->ThreadHandle = Control->u.Initializing.ThreadHandle;
99 NtClose(processHandle);
126 ULONG64 displacement;
131 if (context->Support)
138 predictedEip = context->PredictedEip;
139 predictedEbp = context->PredictedEbp;
140 predictedEsp = context->PredictedEsp;
145 Control->u.ResolveSymbol.StackFrame->PcAddress,
146 Control->u.ResolveSymbol.StackFrame->FrameAddress,
147 Control->u.ResolveSymbol.StackFrame->StackAddress,
148 &context->PredictedEip,
149 &context->PredictedEbp,
150 &context->PredictedEsp
154 if (Control->u.ResolveSymbol.StackFrame->PcAddress == predictedEip)
156 Control->u.ResolveSymbol.StackFrame->FrameAddress = predictedEbp;
157 Control->u.ResolveSymbol.StackFrame->StackAddress = predictedEsp;
163 (ULONG64)Control->u.ResolveSymbol.StackFrame->PcAddress,
168 else if (context->IsWow64 && context->ConnectedToPhSvc)
174 predictedEip = context->PredictedEip;
175 predictedEbp = context->PredictedEbp;
176 predictedEsp = context->PredictedEsp;
181 Control->u.ResolveSymbol.StackFrame->PcAddress,
182 Control->u.ResolveSymbol.StackFrame->FrameAddress,
183 Control->u.ResolveSymbol.StackFrame->StackAddress,
184 &context->PredictedEip,
185 &context->PredictedEbp,
186 &context->PredictedEsp
190 if (Control->u.ResolveSymbol.StackFrame->PcAddress == predictedEip)
192 Control->u.ResolveSymbol.StackFrame->FrameAddress = predictedEbp;
193 Control->u.ResolveSymbol.StackFrame->StackAddress = predictedEsp;
198 (ULONG64)Control->u.ResolveSymbol.StackFrame->PcAddress,
206 if (displacement != 0)
209 if (Control->u.ResolveSymbol.Symbol)
230 if (context->IsWow64)
242 if (context->Support)
245 context->Support = NULL;
249 if (context->ConnectedToPhSvc)
252 context->ConnectedToPhSvc =
FALSE;
262 _In_ HANDLE ThreadId,
263 _In_ PVOID PcAddress,
264 _In_ PVOID FrameAddress,
265 _In_ PVOID StackAddress,
266 _Out_ PVOID *PredictedEip,
267 _Out_ PVOID *PredictedEbp,
268 _Out_ PVOID *PredictedEsp
272 *PredictedEip = NULL;
273 *PredictedEbp = NULL;
274 *PredictedEsp = NULL;
278 *PredictedEip = NULL;
279 *PredictedEbp = NULL;
280 *PredictedEsp = NULL;
283 Support->DataProcess,
284 HandleToUlong(ThreadId),
293 BOOLEAN firstTime =
TRUE;
297 memset(&context, 0,
sizeof(CONTEXT));
298 context.ContextFlags = CONTEXT_CONTROL;
299 context.Eip = PtrToUlong(PcAddress);
300 context.Ebp = PtrToUlong(FrameAddress);
301 context.Esp = PtrToUlong(StackAddress);
309 *PredictedEip = UlongToPtr(context.Eip);
310 *PredictedEbp = UlongToPtr(context.Ebp);
311 *PredictedEsp = UlongToPtr(context.Esp);