Script Language Threading
- From: "Martin Rheley" <no@xxxxxxxx>
- Date: Thu, 8 Jun 2006 15:30:38 +0200
Hi,
Iam writing an assembler for some sort of Script language. Now I want to
create some sort of sandbox for the script, meaning that it runs for some
time, and if it doesn't terminate on its own, its supposed to be terminated
from outside.
My idea was to have a Thread do this:
-Receive some pointer to the program in memory
-Perform a Far Jump ( using push adr; ret; } to the adress
-When the Script finished, signal this with a SetEvent call
Now the observing Thread waits X ms for this Event to be signaled, if it
gets signaled, it should restart the thread with another script. If it
doesnt get signaled, restart as well.
Now simply restarting the thread would be kinda easy. Since I dont want to
take the performance hit of recreating the thread for each script, I thought
of some other way to reset the Thread.
The idea was that after the Signaling of the event, go into some while(1);
loop, and wait for the other observer Thread to suspend it. Then set the EIP
Register of the Worker Thread to the start again, write a new program to the
memory and resume the thread. The problem with this is that sometimes the
thread gets suspended while its still inside SetEvent. Writing a new EIP
does in that case destroy the stack etc. and cause an exception.
Now basically what I need is some method to synchronize the threads without
Win32 commands, or a better method to achieve what I want :-)
Btw: Iam fully aware this is not portable, secure or anything.
Thanks alot in advance
.
- Prev by Date: Re: Re:manually start driver service
- Next by Date: Re: Re:manually start driver service
- Previous by thread: Re: ReadDirectoryChangesW
- Next by thread: WIndows process table and process image.
- Index(es):
Relevant Pages
|