creo que TEvent es lo mejor pero no se como se usa. Tengo esto.
En el archivo TDebuger.h:
Código PHP:
TEvent *EventoVariablesArmadas;
En el TDebuger.cpp:
Código PHP:
bool TDebugger::InitDebug(AnsiString Path, int mode, AnsiString WName, DWORD PID)
{
...
...
EventoVariablesArmadas = new TEvent(false);
return retval;
}
Código PHP:
void TDebugger::LoopDebug(void)
{
HiloDepuracion = new(std::nothrow) THiloDebugger(false,Mode,PathFile,NameWindow,pid,this); // no me gusta no hay control de PathFile en este método.
EventoVariablesArmadas->WaitFor(INFINITE);
if(HiloDepuracion == NULL)
{
...
...
}
En el THiloDebuger.cpp:
Código PHP:
void __fastcall THiloDebugger::Execute()
{
DEBUG_EVENT DebugEv;
HANDLE CurrentExceptionThread;
DWORD dwContinueStatus;
int Error;
TDll *ItemDLL;
bool salir=false;
ListaBPs = new TList;
ListaDlls = new TList;
ListaThreads = new TList;
//Synchronize(OnInitLoopDebugThread); //Usaremos este evento para inizialización de variables en la clase usuario si se requiere.
si.cb = sizeof(STARTUPINFO);
GetStartupInfo(&si);
// El proceso se tiene que crear en la misma función donde está el hilo del depurador sino no vale
switch(Mode){
case MODE_NORMAL:
CreateProcess(PathFile.c_str(),NULL, NULL, NULL, FALSE, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &si, &pi);
break;
case MODE_ATACH_BY_WINDOW_NAME:
if(!AtachProcessByNameWindow(WindowName.c_str(),Error)){
return;
}else{
//Aqui Obtengo informacion del proceso
EnumerarModulos( pi.dwProcessId );
SystemEntryPoint=0;
}
break;
case MODE_ATACH_BY_PID:
if(!AtachProcessById(pid,Error)){
return;
}else{
//Aqui Obtengo informacion del proceso
EnumerarModulos( pi.dwProcessId );
SystemEntryPoint=0;
}
break;
default:
return;
}
InfoProcess.hProcess = pi.hProcess;
InfoProcess.ProcessID = pi.dwProcessId;
EventoVariablesArmadas->SetEvent();
...
...
if(EventoVariablesArmadas != NULL)
delete EventoVariablesArmadas;
}
No se porque al llamar al constructor del TEvento me da NULL pero si en vez de declararlo en TDebugger.h lo hag en TDebugger.cpp ahi si me asigna bien pero claro, no puedo acceder desde THiloDebugger.