Pause Code execution in a foreign process

delphi package - getting into other processes
Post Reply
cool_tester
Posts: 75
Joined: Sun Oct 31, 2004 5:45 am

Pause Code execution in a foreign process

Post by cool_tester »

Is it possible to inject some kind of API into a foreign process and Pause it's Code execution until i notify it to finish.
kind of like using Sleep() api in our own code to pause the execution but i want it done on a foreign process...
By the way i tried using that but it didn't work... instead my own application stoped processing while the foreign application was still doing it's business as usual.

Thanks.
madshi
Site Admin
Posts: 10527
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Sleep only impacts the current thread. So it won't help. You could use SuspendThread for all threads of the target process. But this can have strange effects. If you suspend a thread while it's doing something *very* important, you might freeze the whole OS. This can happen on Hyperthreading and SMP machines. Rarely, but possible.

If you don't care about that (though you should) you can use madKernel like this:

uses madKernel;

begin
Process('someProcess.exe').Suspend;

As easy as that.
cool_tester
Posts: 75
Joined: Sun Oct 31, 2004 5:45 am

Post by cool_tester »

Thanks for the reply.
Is it possible to actually suspend a component that is runing inside my application so instead of an Exe file i need to suspend a Component or activeX Control based on Handle for example.. is this possible with MadKernel..?

Thanks again for your fast replies.
madshi
Site Admin
Posts: 10527
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You can't suspend a component.
cool_tester
Posts: 75
Joined: Sun Oct 31, 2004 5:45 am

Post by cool_tester »

OK what about an ActiveX Control .... that my application is hosting.?
madshi
Site Admin
Posts: 10527
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Maybe you can unload the ActiveX dll, but probably that would make your app crash. I've no idea.
cool_tester
Posts: 75
Joined: Sun Oct 31, 2004 5:45 am

Post by cool_tester »

Thanks, i will have to find other means, keep up the good work.
Post Reply