Home > Net >  Need to call some code in an arbitrary Windows process (externally) at some time interval. Is there
Need to call some code in an arbitrary Windows process (externally) at some time interval. Is there

Time:09-19

I want to test my idea, wherein I execute some code in the context of another process at some interval. What API call or kernel functionality or l technique should I look into to execute code in another process at some interval?

Seems like I need to halt the process and modify the instruction pointer value before continuing it, if that’s remotely possible. Alternatively, I could hook into the kernel code which schedules time on the CPU for each process, and run the code each time the next time slot happens for a process. But PatchGuard probably prevents that. This time interval doesn’t need to be precise.

CodePudding user response:

The wording of the question tells me you're fairly new to programming. A remote process doesn't have AN instruction pointer, it typically has many - one per executing thread. That's why the normal approach would be to not mess with any of those instruction pointers. Instead, you create a new thread in the remote process CreateRemoteThreadEx.

Since this thread is under your control, it can just run an infinite loop alternating between Sleep and the function you want to call.

  • Related