Created
November 29, 2014 00:10
-
-
Save simcop2387/ab73b2a55af466ebe1a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while 1 do | |
print("", "badfile") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sandbox(fn) | |
-- read script and set the environment | |
f = loadfile(fn, "t") | |
debug.setupvalue(f, 1, {print = print}) | |
-- create a coroutine and have it yield every 50 instructions | |
local co = coroutine.create(f) | |
function mhook() | |
print("hooked") | |
print(debug.getinfo(co, 0)) | |
co.yield() | |
end | |
debug.sethook(co, mhook, "", 1) | |
-- demonstrate stepped execution, 5 'ticks' | |
for i = 1, 50 do | |
print("tick") | |
print(coroutine.status(co)) | |
coroutine.resume(co) | |
end | |
end | |
sandbox("badfile.lua") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment