kill.cxx (86e1cf34) kill.cxx (e9cec295)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 176 unchanged lines hidden (view full) ---

185 {
186 ZeroMemory( &aContext, sizeof(aContext) );
187 aContext.ContextFlags = CONTEXT_FULL;
188
189 fSuccess = GetThreadContext( hThread, &aContext );
190
191 if ( fSuccess )
192 {
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 176 unchanged lines hidden (view full) ---

185 {
186 ZeroMemory( &aContext, sizeof(aContext) );
187 aContext.ContextFlags = CONTEXT_FULL;
188
189 fSuccess = GetThreadContext( hThread, &aContext );
190
191 if ( fSuccess )
192 {
193#if defined(INTEL)
193 if ( sig )
194 {
195 DWORD dwStackBuffer[] =
196 {
197 aContext.Eip,
198 SignalToExceptionCode( sig ),
199 EXCEPTION_NONCONTINUABLE,
200 0,
201 0
202 };
203
204 aContext.Esp -= sizeof(dwStackBuffer);
205 WriteProcessMemory( hProcess, (LPVOID)aContext.Esp, dwStackBuffer, sizeof(dwStackBuffer), NULL );
206 aContext.Eip = (DWORD)GetProcAddressEx( hProcess, GetModuleHandleA("KERNEL32"), "RaiseException" );
207 }
208 else
209 {
194 if ( sig )
195 {
196 DWORD dwStackBuffer[] =
197 {
198 aContext.Eip,
199 SignalToExceptionCode( sig ),
200 EXCEPTION_NONCONTINUABLE,
201 0,
202 0
203 };
204
205 aContext.Esp -= sizeof(dwStackBuffer);
206 WriteProcessMemory( hProcess, (LPVOID)aContext.Esp, dwStackBuffer, sizeof(dwStackBuffer), NULL );
207 aContext.Eip = (DWORD)GetProcAddressEx( hProcess, GetModuleHandleA("KERNEL32"), "RaiseException" );
208 }
209 else
210 {
211 // FIXME: why? Does AMD64 need it too?
210 aContext.Ecx = aContext.Eax = aContext.Ebx = aContext.Edx = aContext.Esi = aContext.Edi = 0;
211 }
212 aContext.Ecx = aContext.Eax = aContext.Ebx = aContext.Edx = aContext.Esi = aContext.Edi = 0;
213 }
214#elif defined(X86_64)
215 if ( sig )
216 {
217 DWORD dwStackBuffer[] =
218 {
219 (DWORD)(aContext.Rip >> 32),
220 (DWORD)(aContext.Rip),
221 SignalToExceptionCode( sig ),
222 EXCEPTION_NONCONTINUABLE,
223 0,
224 0,
225 0
226 };
212
227
228 aContext.Rsp -= sizeof(dwStackBuffer);
229 WriteProcessMemory( hProcess, (LPVOID)aContext.Rsp, dwStackBuffer, sizeof(dwStackBuffer), NULL );
230 aContext.Rip = (DWORD64) GetProcAddressEx( hProcess, GetModuleHandleA("KERNEL32"), "RaiseException" );
231 }
232#endif
233
213 fSuccess = SetThreadContext( hThread, &aContext );
214 }
215
216 fSuccess = ResumeThread( hThread ) && fSuccess;
217
218 DWORD dwLastError = GetLastError();
219 CloseHandle( hThread );
220 SetLastError( dwLastError );

--- 219 unchanged lines hidden ---
234 fSuccess = SetThreadContext( hThread, &aContext );
235 }
236
237 fSuccess = ResumeThread( hThread ) && fSuccess;
238
239 DWORD dwLastError = GetLastError();
240 CloseHandle( hThread );
241 SetLastError( dwLastError );

--- 219 unchanged lines hidden ---