Ver Mensaje Individual
  #7  
Antiguo 11-05-2020
Avatar de aguml
aguml aguml is offline
Miembro
 
Registrado: may 2013
Posts: 885
Reputación: 11
aguml Va por buen camino
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 Pathint modeAnsiString WNameDWORD PID)
{
        ...
        ... 
    
EventoVariablesArmadas = new TEvent(false);
    return 
retval;

Código PHP:
void TDebugger::LoopDebug(void)
{
        
HiloDepuracion = new(std::nothrowTHiloDebugger(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(),NULLNULLNULLFALSEDEBUG_PROCESS DEBUG_ONLY_THIS_PROCESSNULLNULL, &si, &pi);
                        break;
                case 
MODE_ATACH_BY_WINDOW_NAME:
                        if(!
AtachProcessByNameWindow(WindowName.c_str(),Error)){
                                return;
                        }else{
                                
//Aqui Obtengo informacion del proceso
                                
EnumerarModulospi.dwProcessId );
                                
SystemEntryPoint=0;
                        }
                        break;
                case 
MODE_ATACH_BY_PID:
                        if(!
AtachProcessById(pid,Error)){
                                return;
                        }else{
                                
//Aqui Obtengo informacion del proceso
                                
EnumerarModulospi.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.
Responder Con Cita