Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mainGPU = component.proxy(component.list("gpu")())
- mainGPU.bind(component.list("screen")(), true)
- eepData = component.invoke(component.list("eeprom")(), "getData") or ""
- prefLoad = string.sub(eepData, 1, 36)
- prefType = string.sub(eepData, 37, 37)
- eepData = nil
- readOnly = false
- function readManaged(drive)
- mainDrive = drive
- drive = nil
- if mainDrive.isReadOnly() then
- readOnly = true
- return
- end
- local success, file = pcall(mainDrive.open, ".boot", "r")
- if not success then
- return
- end
- success = nil
- readOnly = nil
- local path = mainDrive.read(file, 2048)
- mainDrive.close(file)
- if not path then
- return
- end
- local success, file = pcall(mainDrive.open, path, "r")
- local exec = load(function() return mainDrive.read(file, 2048) end, "=managedBoot@/".. path)
- mainDrive.close(file)
- file, path = nil, nil
- if not exec then
- return
- end
- exec()
- computer.shutdown()
- end
- function readUnmanaged(drive)
- mainDrive = drive
- drive = nil
- if string.sub(mainDrive.readSector(1), 1, 7) ~= "TYKBOOT" then return end
- readOnly = nil
- local start = 1
- local atByte = 8
- while true do
- local temp = mainDrive.readByte(atByte)
- if temp == -128 then
- start = start / mainDrive.readByte(atByte-1)
- if start == 1 then
- start = 0
- end
- start = start + mainDrive.readByte(atByte-1)
- break
- end
- start = start * temp
- atByte = atByte + 1
- end
- atByte = 0
- local code = ""
- while true do
- local temp = mainDrive.readByte(start + atByte)
- if temp == 28 then
- break
- end
- atByte = atByte + 1
- code = code .. string.char(temp)
- end
- load(code, "=unmanagedBoot@"..start.."-"..(start+atByte))()
- computer.shutdown()
- end
- if prefType == "m" then
- local success, drive = pcall(component.proxy, prefLoad)
- prefLoad, prefType = nil, nil
- if success then
- readManaged(drive)
- end
- elseif prefType == "u" then
- local success, drive = pcall(component.proxy, prefLoad)
- prefLoad, prefType = nil, nil
- if success then
- readUnmanaged(drive)
- end
- end
- prefLoad, prefType = nil, nil
- list = component.list("filesystem")
- while true do
- local success, drive = pcall(component.proxy, list())
- if not success then
- break
- end
- readManaged(drive)
- end
- list = component.list("drive")
- while true do
- local success, drive = pcall(component.proxy, list())
- if not success then
- break
- end
- readUnmanaged(drive)
- end
- if readOnly then
- error("All mediums are readonly!", 0)
- end
- error("No Bootable Medium Found!", 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement