Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #if defined(_WIN32)
00015
00016 #if _MSC_VER < 1500
00017
00018
00019 namespace Win {
00020 #else
00021
00022 #define Win
00023 #endif
00024
00025
00026 #ifndef NOMSG
00027 # define NOMSG
00028 # ifndef NOGDI
00029 # define NOGDI
00030 # endif
00031 #endif
00032 #include "windows.h"
00033 #include "process.h"
00034
00035 #if _MSC_VER < 1500
00036 };
00037 #endif
00038
00039 #else
00040 #include <unistd.h>
00041 #endif
00042
00043
00044 #include "GaudiKernel/Debugger.h"
00045
00047 long System::breakExecution() {
00048 #ifdef _WIN32
00049 _asm int 3
00050 return 1;
00051 #else
00052
00053 return 0;
00054 #endif
00055 }
00056
00058 long System::breakExecution(long pid) {
00059 #ifdef _WIN32
00060 long result = 0;
00061 if ( pid == Win::_getpid() ) {
00062 _asm int 3
00063 return 1;
00064 }
00065 else {
00066 Win::LPTHREAD_START_ROUTINE fun;
00067 Win::HANDLE th, ph;
00068 Win::HINSTANCE mh;
00069 Win::DWORD id;
00070 mh = Win::LoadLibrary( "Kernel32" );
00071 if ( 0 != mh ) {
00072 fun = (Win::LPTHREAD_START_ROUTINE)Win::GetProcAddress(mh, "DebugBreak");
00073 if ( 0 != fun ) {
00074 ph = Win::OpenProcess (PROCESS_ALL_ACCESS, TRUE, pid);
00075 if ( 0 != ph ) {
00076 th = Win::CreateRemoteThread(ph,NULL,0,fun,0,0,&id);
00077 if ( 0 != th ) {
00078 Win::CloseHandle(th);
00079 result = 1;
00080 }
00081 Win::CloseHandle(ph);
00082 }
00083 }
00084 Win::FreeLibrary(mh);
00085 }
00086 }
00087 if ( result != 1 ) result = Win::GetLastError();
00088 return result;
00089 #else
00090
00091 return pid;
00092 #endif
00093 }