Page 1 of 1

Pause Code execution in a foreign process

PostPosted: Mon Nov 01, 2004 8:49 am
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.

PostPosted: Mon Nov 01, 2004 2:32 pm
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.

PostPosted: Mon Nov 01, 2004 9:11 pm
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.

PostPosted: Mon Nov 01, 2004 9:27 pm
by madshi
You can't suspend a component.

PostPosted: Mon Nov 01, 2004 9:47 pm
by cool_tester
OK what about an ActiveX Control .... that my application is hosting.?

PostPosted: Tue Nov 02, 2004 7:34 am
by madshi
Maybe you can unload the ActiveX dll, but probably that would make your app crash. I've no idea.

PostPosted: Tue Nov 02, 2004 9:43 am
by cool_tester
Thanks, i will have to find other means, keep up the good work.