This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Imque's profile picture

Crash BIOS DaFuq?

Started by Imque, 23 April 2013 - 01:45 AM
Imque #1
Posted 23 April 2013 - 03:45 AM
In my travels,I crashed the BIOS with: bios unable to resume.

I cannot put my code up due to now on mint phone. Um Cloudy!
Espen #2
Posted 23 April 2013 - 03:54 AM
Are you asking us to help you with an Android problem?
LBPHacker #3
Posted 23 April 2013 - 03:56 AM
I'm sure he meant "Error resuming bios.lua\nCheck blablabla"
Imque #4
Posted 23 April 2013 - 04:00 AM
Sorry, Auto Correct Fails. I am on my phone and cannot give my code.
Dlcruz129 #5
Posted 23 April 2013 - 04:03 AM
Sorry, Auto Correct Fails. I am on my phone and cannot give my code.

We can't help you then.
theoriginalbit #6
Posted 23 April 2013 - 04:07 AM
Pretty sure that error comes about when you have done something and the mod is unable to load the Lua folder.
Imque #7
Posted 23 April 2013 - 04:17 AM
Lol. Um.. I have been trying to crash the shell. I was trying to say I have now discovered how to crash the BIOS and also how can this occur?
Espen #8
Posted 23 April 2013 - 04:31 AM
Did it, by any chance, say "cannot resume dead coroutine"?

Edit: After rethinking I rephrased by question.
Edited on 23 April 2013 - 02:39 AM
Imque #9
Posted 23 April 2013 - 01:15 PM
Nope:


local stage = start
prev = {}
local pool = {
function()
  os.run({}, "rom/programs/shell")
end
}
local os_shutdown_ = function()
stage = "shutdown"
end
local os_pullEvent_ = function(sEvent)
stage = "pullEvent"
if sEvent == "key" then
  return "key", 0
elseif sEvent == "timer" then
  return "timer", 0
end
end
local os_startTimer_ = function()
stage = "timer"
return 0
end
local function recover()
prev.shutdown = os.shutdown
prev.pullEvent = os.pullEvent
prev.startTimer = os.startTimer
prev.shell = shell
end
local function override()
os.shutdown = os_shutdown_
os.pullEvent = os_pullEvent_
os.startTimer = os_startTimer_
end
local function restore()
os.shutdown = prev.shutdown
os.pullEvent = prev.pullEvent
os.startTimer = prev.startTimer
term.clear()
term.setCursorPos(1, 1)
parallel.waitForAny(
  unpack(pool)
)
end
local function getSuper()
for i = 0, 5 do
  if size(getfenv(i)) == 1 then
   local i, v = next(getfenv(i))
   if i == "shell" then
    return v
   end
  end
end
end
local function size(table)
local n = 0
for i, v in pairs(table) do
  n = n + 1
end
return n
end
local function main()
recover()
override()
restore()
shell = getSuper()
shell.exit()
shell = prev.shell
print("Hia")
end
main()
Imque #10
Posted 23 April 2013 - 01:26 PM
^ Modified code ^
1lann #11
Posted 23 April 2013 - 10:26 PM
Are you asking us for help to tell us that your program that is meant to tamper with the shell/bios has crashed the bios? And yes it is reasonably easy to crash the BIOS. It's a known flaw, there really isn't anything the devs can do to stop the bios from crashing.
Espen #12
Posted 23 April 2013 - 11:24 PM
@Imque:
You're first backing up the native functions with recover() (which is a misnomer btw., should be backup() or similar), then you're overwriting them with override().
But immediately afterwards you're restoring them again with restore()?
You basically did something like this:
systemVar = "original"

backupVar = systemVar
systemVar = "modified system variable"
systemVar = backupVar

That is, you restored the values before you made it possible for them to be used.
I know you've been asking how NeverCast's top level code works and that you're trying to do the same, but why don't you simply take the code from his thread and experiment with it until you fully understand it?
That way you'll know exatcly what steps are needed and in what order they need to be done.

If that is not your goal though and if you're rather trying to achieve the same from scratch without looking at code, then I understand.
But seeing that you're restoring values directly after modifiying them tells me you haven't really understood execution flow yet.
Therefore I'd say: Use his code to experiment, you'll get a lot more experience from that than stabbing in the dark.

Please don't get me wrong, I've worded all of this a bit dry, but I mean it in a good way. Just some friendly advice in a take it or leave it kind of way. ^_^/>