Easiest way to know if your target app was closed?
Easiest way to know if your target app was closed?
Hi!
I succesfully injected a DLL into a targetapp. Now, if this app. is closed, I would like to know that this happended in my own app. What's the easiest way to do this? Would it be to hook TerminateProcess?
- Claes
I succesfully injected a DLL into a targetapp. Now, if this app. is closed, I would like to know that this happended in my own app. What's the easiest way to do this? Would it be to hook TerminateProcess?
- Claes
Madshi, I was trying to do it.... But even in another thread my program stays frozen. Look at this:
Here is the thread source:
Here I create the Thread
Do you know whats happening?
Here is the thread source:
Code: Select all
TAguardaProcThread = class( TThread )
protected
procedure Execute; override;
procedure AguardaProc; virtual;
public
constructor Create;
end;
(...)
constructor TAguardaProcThread.Create;
begin
inherited Create( True );
FreeOnTerminate := True;
Priority := tpNormal;
end;
procedure TAguardaProcThread.Execute;
begin
Synchronize( AguardaProc );
end;
procedure TAguardaProcThread.AguardaProc;
begin
WaitForSingleObject( Processo.Handle, INFINITE );
Processo.Ativo := False;
end;
Code: Select all
fAguardaProc := TAguardaProcThread.Create;
fAguardaProc.Resume;
I tried this. But I'm not sure where to put the call to WaitForSingleObject. Only once during Create - or in the Execute method? And how do I catch the signal?
Create the thread:
Thanks in advance...
- Claes
Code: Select all
unit ThreadUnit;
interface
uses
Windows, Classes;
type
TWait4ProcessThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
constructor Create(ProcId: THandle);
end;
implementation
{ TWait4ProcessThread }
constructor TWait4ProcessThread.Create(ProcId: THandle);
begin
inherited Create(True);
FreeOnTerminate := True;
Priority := tpTimeCritical;
WaitForSingleObject(ProcId, INFINITE);
Resume;
end;
procedure TWait4ProcessThread.Execute;
begin
if not Terminated then
begin
???
end;
end;
end.
Code: Select all
uses
...
ThreadUnit;
var
Wait4ProcessThread: TWait4ProcessThread;
...
Wait4ProcessThread := TWait4ProcessThread.Create(ProcessHandle);
- Claes