
Originally Posted by
bee_tee_gee
all functions with the "debug" prefix were removed? when were they removed, recently or a while ago?
A few functions were removed due to a memory read/write exploit Cdriza stole from swadicalrag and released everywhere.
Code:
local function UInt32ToDouble(num) // credits to cake
local negative = false
if num >= 0x80000000 then
negative = true
num = num - 0x80000000
end
local biasedExponent = bit.rshift(bit.band(num, 0x7FF00000), 20)
local mantissa = (bit.band(num, 0x000FFFFF) * 4294967296 + num) / 2 ^ 52
local f
if biasedExponent == 0x0000 then
f = mantissa == 0 and 0 or math.ldexp(mantissa, -1022)
elseif biasedExponent == 0x07FF then
f = mantissa == 0 and math.huge or (math.huge - math.huge)
else
f = math.ldexp(1 + mantissa, biasedExponent - 1023)
end
return negative and -f or f
end
local function __readMemory(address, len)
local blankName, upFunction = debug.getupvalue(ipairs, 1) // backup ipairsaux
debug.setupvalue(ipairs, 1, UInt32ToDouble(address - 8)) // set first upvalue to converted address
local addrFunction = ipairs({}) // lua_pushvalue(L,lua_upvalueindex(1));
debug.setupvalue(ipairs, 1, upFunction) // return upvalue to ipairsaux
local fenvAddrNameFN = debug.getfenv(addrFunction)
local memeAddress = tonumber(string.format("%p", fenvAddrNameFN), 16)
memeAddress = bit.tohex(memeAddress, 8)
local memeAddress2 = ""
for i in memeAddress:gmatch("..") do
memeAddress2 = string.char(tonumber(i, 16)) .. memeAddress2
end
return memeAddress2:sub(1, len or 4)
end
local function readMemory(address, len)
local returnStr = ""
for i = 1, len or 1, 4 do
returnStr = returnStr .. __readMemory(address - 1, math.min(len - (i - 1), 4))
end
return returnStr
end
kmem = {}
kmem.util = {}
kmem.read = {}
function kmem.util:address(obj)
return tonumber(string.format("%p", obj))
end
function kmem.util:hex(num)
return "0x" .. string.format("%x", tostring(num)):upper()
end
function kmem.read:uint8(addr)
return readMemory(addr, 1):byte()
end
function kmem.read:uint16(addr)
local returnStr = ""
returnStr = returnStr .. string.format("%02x", readMemory(addr + 1, 1):byte())
returnStr = returnStr .. string.format("%02x", readMemory(addr, 1):byte())
return tonumber(returnStr, 16)
end
function kmem.read:uint24(addr)
local returnStr = ""
returnStr = returnStr .. string.format("%02x", readMemory(addr + 2, 1):byte())
returnStr = returnStr .. string.format("%02x", readMemory(addr + 1, 1):byte())
returnStr = returnStr .. string.format("%02x", readMemory(addr, 1):byte())
return tonumber(returnStr, 16)
end
function kmem.read:uint32(addr)
local blankName, upFunction = debug.getupvalue(ipairs, 1)
debug.setupvalue(ipairs, 1, UInt32ToDouble(addr - 8))
local addrFunction = ipairs({})
debug.setupvalue(ipairs, 1, upFunction)
local fenvAddrNameFN = debug.getfenv(addrFunction)
local memeAddress = tonumber(string.format("%p", fenvAddrNameFN), 16)
return memeAddress
end