314 lines
13 KiB
Plaintext
314 lines
13 KiB
Plaintext
[ENABLE]
|
|
{$lua}
|
|
if syntaxcheck then return end
|
|
local signatures={world="48 8B 05 ?? ?? ?? ?? 48 85 C0 75 ?? 80 3D ?? ?? ?? ?? 02 72 ?? 48 8D 15 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 33 C0 48 83 C4 20 5B C3",names="89 03 48 8B C3 89 7B 04 48 8B 5C 24 48 48 83 C4 30 5F C3 80 3D ?? ?? ?? ?? 00 74 09 48 8D 05 ?? ?? ?? ?? EB 13 48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? C6 05 ?? ?? ?? ?? 01 0F 28 44 24 20",objects="44 8B 49 04 45 85 C9 74 ?? 8B 01 85 C0 78 ?? 3B 05 ?? ?? ?? ?? 7D ?? 8B C8 0F B7 C0 48 C1 E9 10 48 8D 14 40 48 8B 05 ?? ?? ?? ?? 48 8B 0C C8 4C 8D 04 D1"}
|
|
local state={pid=getOpenedProcessID(),classCache={},nameCache={}}
|
|
local function ptr(p) return type(p)=='number' and p>0x10000 and p<0x7FFFFFFFFFFF end
|
|
local function q(p) return ptr(p) and readQword(p) or nil end
|
|
local function finite(x) return type(x)=='number' and x==x and math.abs(x)<1e12 end
|
|
local function vector(p)
|
|
if not ptr(p) then return end
|
|
local x,y,z=readDouble(p),readDouble(p+8),readDouble(p+16)
|
|
if finite(x) and finite(y) and finite(z) then return {x,y,z} end
|
|
end
|
|
local function array(p,limit)
|
|
local data,num,cap=q(p),readInteger(p+8),readInteger(p+12)
|
|
if not num or not cap or num>limit or cap<num or cap>1000000 then return end
|
|
if num>0 and not ptr(data) then return end
|
|
return data,num
|
|
end
|
|
local function exactString(p,n,wide)
|
|
local bytes=readBytes(p,n*(wide and 2 or 1),true)
|
|
if not bytes or #bytes~=n*(wide and 2 or 1) then return '' end
|
|
if not wide then return string.char(table.unpack(bytes)) end
|
|
local chars={};local i=1
|
|
while i<=#bytes do
|
|
local unit=bytes[i]+bytes[i+1]*256;i=i+2
|
|
if unit>=0xD800 and unit<=0xDBFF and i<#bytes then
|
|
local low=bytes[i]+bytes[i+1]*256
|
|
if low>=0xDC00 and low<=0xDFFF then unit=0x10000+(unit-0xD800)*1024+low-0xDC00;i=i+2
|
|
else unit=0xFFFD end
|
|
elseif unit>=0xD800 and unit<=0xDFFF then unit=0xFFFD end
|
|
if unit==0 then break end
|
|
chars[#chars+1]=utf8.char(unit)
|
|
end
|
|
return table.concat(chars)
|
|
end
|
|
local function fname(p)
|
|
local id=readInteger(p)
|
|
if not id then return '' end
|
|
local text=state.nameCache[id]
|
|
if not text then
|
|
local block=id>>16
|
|
if block>8191 then return '' end
|
|
local b=q(state.namePool+0x10+block*8)
|
|
if not ptr(b) then return '' end
|
|
local entry=b+(id&0xFFFF)*2
|
|
local h=readSmallInteger(entry)
|
|
if not h then return '' end
|
|
local n=h>>6
|
|
if n<1 or n>1023 then return '' end
|
|
text=exactString(entry+2,n,(h&1)~=0)
|
|
if not text then return '' end
|
|
state.nameCache[id]=text
|
|
end
|
|
local number=readInteger(p+4)
|
|
if number and number>0 then text=text..'_'..tostring(number-1) end
|
|
return text
|
|
end
|
|
local function fstring(p)
|
|
local data,n=array(p,1024)
|
|
if not data or n<2 then return '' end
|
|
return exactString(data,n-1,true)
|
|
end
|
|
local function meta(cl)
|
|
if not ptr(cl) then return end
|
|
local nameId=q(cl+0x18)
|
|
local super=q(cl+0x40)
|
|
if not nameId or super==nil then return end
|
|
local old=state.classCache[cl]
|
|
if old and old.nameId==nameId and old.super==super then return old end
|
|
local m={nameId=nameId,super=super,name=fname(cl+0x18)}
|
|
state.classCache[cl]=m
|
|
return m
|
|
end
|
|
local function properties(cl)
|
|
local m=meta(cl);if not m then return {} end
|
|
if m.fields then return m.fields end
|
|
local fields={};local f=q(cl+0x50);local seen={}
|
|
for i=1,512 do
|
|
if not ptr(f) or seen[f] then break end
|
|
seen[f]=true
|
|
local off,size=readInteger(f+0x44),readInteger(f+0x34)
|
|
if off and off<0x100000 and size and size<0x100000 then
|
|
fields[fname(f+0x20)]={offset=off,size=size,type=q(f+0x70),
|
|
byte=readBytes(f+0x71,1),mask=readBytes(f+0x72,1)}
|
|
end
|
|
f=q(f+0x10)
|
|
end
|
|
m.fields=fields;return fields
|
|
end
|
|
local function field(cl,name,required)
|
|
local seen={}
|
|
for i=1,32 do
|
|
if not ptr(cl) or seen[cl] then break end
|
|
seen[cl]=true
|
|
local p=properties(cl)[name];if p then return p end
|
|
local m=meta(cl);cl=m and m.super
|
|
end
|
|
if required then error('Missing reflected field: '..name) end
|
|
end
|
|
local function offset(cl,name) return field(cl,name,true).offset end
|
|
local function classOf(a) return q(a+0x10) end
|
|
local function nativeFunction(cl,name)
|
|
local visited={}
|
|
for i=1,32 do
|
|
if not ptr(cl) or visited[cl] then break end
|
|
visited[cl]=true
|
|
local f=q(cl+0x48);local seen={}
|
|
for j=1,1024 do
|
|
if not ptr(f) or seen[f] then break end
|
|
seen[f]=true
|
|
if fname(f+0x18)==name then return q(f+0x128) end
|
|
f=q(f+0x28)
|
|
end
|
|
local m=meta(cl);cl=m and m.super
|
|
end
|
|
end
|
|
local function flag(a,f)
|
|
if not f or not f.byte or not f.mask then return false end
|
|
local b=readBytes(a+f.offset+f.byte,1)
|
|
return b and (b&f.mask)~=0
|
|
end
|
|
local function uniqueScan(pattern)
|
|
local scan=createMemScan();local found=createFoundList(scan)
|
|
local ok,result=pcall(function()
|
|
local base=getAddress('PBZ.exe')
|
|
scan.firstScan(soExactValue,vtByteArray,rtRounded,pattern,'',base,base+getModuleSize('PBZ.exe')-1,
|
|
'+X',fsmNotAligned,'1',true,false,false,false)
|
|
scan.waitTillDone();found.initialize()
|
|
if found.Count~=1 then error('ESP signature expected 1 match; found '..found.Count) end
|
|
return getAddress(found.Address[0])
|
|
end)
|
|
found.destroy();scan.destroy()
|
|
if not ok then error(result) end
|
|
return result
|
|
end
|
|
local wr=uniqueScan(signatures.world)
|
|
state.worldSlot=wr+7+readInteger(wr+3,true)
|
|
local nr=uniqueScan(signatures.names)+0x1C
|
|
state.namePool=nr+7+readInteger(nr+3,true)
|
|
local function identity(a)
|
|
if not ptr(a) then return end
|
|
local cl=q(a+0x10);local n=q(a+0x18);local index=readInteger(a+0xC)
|
|
if not ptr(cl) or not n or not index then return end
|
|
return {address=a,class=cl,name=n,index=index}
|
|
end
|
|
local function valid(id)
|
|
return id and state.pid==getOpenedProcessID() and q(id.address+0x10)==id.class
|
|
and q(id.address+0x18)==id.name and readInteger(id.address+0xC)==id.index
|
|
end
|
|
local function context()
|
|
if state.pid~=getOpenedProcessID() then return end
|
|
local world=q(state.worldSlot);if not ptr(world) then return end
|
|
local gi=q(world+offset(classOf(world),'OwningGameInstance'));if not ptr(gi) then return end
|
|
local list,n=array(gi+offset(classOf(gi),'LocalPlayers'),8);if not list or not n or n<1 then return end
|
|
local lp=q(list);if not ptr(lp) then return end
|
|
local pc=q(lp+offset(classOf(lp),'PlayerController'));if not ptr(pc) then return end
|
|
local pawn=q(pc+offset(classOf(pc),'Pawn'));if not ptr(pawn) then return end
|
|
local dying=field(classOf(pawn),'bActorIsBeingDestroyed')
|
|
if dying and flag(pawn,dying) then return end
|
|
return {world=world,gi=gi,lp=lp,pc=pc,pawn=pawn,pawnID=identity(pawn)}
|
|
end
|
|
local initial=assert(context(),'Load the local player before enabling this entry')
|
|
local function functions(cl,name)
|
|
for d=1,32 do
|
|
if not ptr(cl) then break end
|
|
local fn=q(cl+0x48)
|
|
for i=1,2048 do
|
|
if not ptr(fn) then break end
|
|
if fname(fn+0x18)==name then return fn end
|
|
fn=q(fn+0x28)
|
|
end
|
|
cl=q(cl+0x40)
|
|
end
|
|
end
|
|
local function objectInventory(wanted)
|
|
local ref=uniqueScan(signatures.objects)
|
|
state.objectChunksSlot=ref+0x2B+readInteger(ref+0x27,true)
|
|
state.objectCountSlot=ref+0x15+readInteger(ref+0x11,true)
|
|
local chunks=q(state.objectChunksSlot)
|
|
local count=readInteger(state.objectCountSlot)
|
|
assert(ptr(chunks) and count and count>0 and count<2000000,'Unsupported object array')
|
|
local out={};local last=-1;local chunk
|
|
for i=0,count-1 do
|
|
local ci=i>>16;if ci~=last then chunk=q(chunks+ci*8);last=ci end
|
|
if ptr(chunk) then local slot=chunk+(i&0xFFFF)*24;local flags=readInteger(slot+4)
|
|
if flags and flags&0x10200000==0 then
|
|
local a=q(slot+8)
|
|
if ptr(a) and readInteger(a+0xC)==i then
|
|
local n=fname(a+0x18);local kind=wanted[n]
|
|
if kind and fname(classOf(a)+0x18)==kind then
|
|
assert(not out[n],'Ambiguous loaded object: '..n);out[n]=a
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
for n in pairs(wanted) do assert(out[n],'Required game object is not loaded: '..n) end
|
|
return out
|
|
end
|
|
local function setBit(a,f,value)
|
|
assert(f and f.size==1 and f.byte==0 and f.mask and f.mask>0,'Unsupported boolean property')
|
|
local b=assert(readBytes(a+f.offset,1),'Boolean field unreadable')
|
|
local nextValue=value and (b|f.mask) or (b&(~f.mask&0xFF))
|
|
if nextValue~=b then assert(writeBytes(a+f.offset,nextValue),'Boolean field write failed') end
|
|
end
|
|
local old=rawget(_G,'PBZ_NoClipFly')
|
|
if old and old.pid==state.pid then error('NoClip / Fly is already enabled') end
|
|
if old and old.timer then old.timer.destroy() end
|
|
local s={pid=state.pid,speed=3200,verticalSpeed=2000}
|
|
local function snapshot(obj,f)
|
|
local bytes=assert(readBytes(obj.address+f.offset,f.size,true),'Flight field unreadable')
|
|
return {object=obj,field=f,bytes=bytes}
|
|
end
|
|
local function restore(l)
|
|
if not l then return end
|
|
for _,v in ipairs(l.saved) do
|
|
if valid(v.object) then
|
|
if v.field.mask and v.field.size==1 and v.field.byte==0 and v.bit then
|
|
setBit(v.object.address,v.field,(v.bytes[1]&v.field.mask)~=0)
|
|
else assert(writeBytes(v.object.address+v.field.offset,table.unpack(v.bytes)),'Flight field restore failed') end
|
|
end
|
|
end
|
|
if valid(l.moveID) then
|
|
for i=0,2 do assert(writeDouble(l.move+l.velocity.offset+i*8,0),'Flight stop failed') end
|
|
end
|
|
end
|
|
local function bind(c)
|
|
local move=q(c.pawn+offset(classOf(c.pawn),'CharacterMovement'))
|
|
local cap=q(c.pawn+offset(classOf(c.pawn),'CapsuleComponent'))
|
|
assert(ptr(move) and ptr(cap) and q(move+0x20)==c.pawn and q(cap+0x20)==c.pawn,'Flight components changed')
|
|
local mcl,ccl=classOf(move),classOf(cap)
|
|
local mode=field(mcl,'MovementMode',true);local velocity=field(mcl,'Velocity',true)
|
|
local gravity=field(mcl,'GravityScale',true);local speed=field(mcl,'MaxFlySpeed',true)
|
|
local rotation=field(classOf(c.pc),'ControlRotation',true)
|
|
local body=field(ccl,'BodyInstance',true);local collision=field(body.type,'CollisionEnabled',true)
|
|
assert(mode.size==1 and velocity.size==24 and gravity.size==4 and speed.size==4 and rotation.size==24,'Unexpected UE5 flight layout')
|
|
assert(fname(body.type+0x18)=='BodyInstance' and collision.size==1 and collision.offset<body.size,'Unexpected BodyInstance layout')
|
|
local bodyField={offset=body.offset+collision.offset,size=1}
|
|
local l={pawnID=c.pawnID,move=move,moveID=identity(move),capID=identity(cap),pcID=identity(c.pc),
|
|
mode=mode,velocity=velocity,gravity=gravity,speed=speed,rotation=rotation,bodyCollision=bodyField,saved={}}
|
|
local function save(obj,f,bit) local v=snapshot(obj,f);v.bit=bit;l.saved[#l.saved+1]=v end
|
|
save(l.moveID,mode);save(l.moveID,gravity);save(l.moveID,speed);save(l.capID,bodyField)
|
|
l.actorCollision=field(classOf(c.pawn),'bActorEnableCollision',true);save(c.pawnID,l.actorCollision,true)
|
|
l.soft=field(mcl,'bEnableSoftCollision');if l.soft then save(l.moveID,l.soft,true) end
|
|
return l
|
|
end
|
|
local function axis(v)
|
|
if type(v)~='number' or math.abs(v)<=8000 then return 0 end
|
|
local x=math.min(math.abs(v)/32767,1);return v<0 and -x or x
|
|
end
|
|
local function input()
|
|
if getForegroundProcess()~=s.pid then return 0,0,0 end
|
|
local fb=(isKeyPressed(0x57) and 1 or 0)-(isKeyPressed(0x53) and 1 or 0)
|
|
local lr=(isKeyPressed(0x44) and 1 or 0)-(isKeyPressed(0x41) and 1 or 0)
|
|
local ud=(isKeyPressed(0x20) and 1 or 0)-(isKeyPressed(0x10) and 1 or 0)
|
|
local pad=getXBox360ControllerState and getXBox360ControllerState(0)
|
|
if pad then
|
|
local x,y=axis(pad.ThumbLeftX),axis(pad.ThumbLeftY)
|
|
if math.abs(x)>math.abs(lr) then lr=x end;if math.abs(y)>math.abs(fb) then fb=y end
|
|
if pad.GAMEPAD_LEFT_SHOULDER then ud=1 end
|
|
if pad.GAMEPAD_RIGHT_SHOULDER then ud=-1 end
|
|
end
|
|
local length=math.sqrt(fb*fb+lr*lr);if length>1 then fb=fb/length;lr=lr/length end
|
|
return fb,lr,ud
|
|
end
|
|
s.tick=function()
|
|
if s.pid~=getOpenedProcessID() then s.timer.Enabled=false;return end
|
|
local c=context()
|
|
if not c then if s.lease then restore(s.lease);s.lease=nil end;return end
|
|
local move=q(c.pawn+offset(classOf(c.pawn),'CharacterMovement'))
|
|
local cap=q(c.pawn+offset(classOf(c.pawn),'CapsuleComponent'))
|
|
local l=s.lease
|
|
if l and (not valid(l.pawnID) or not valid(l.moveID) or not valid(l.capID) or not valid(l.pcID)
|
|
or l.pawnID.address~=c.pawn or l.move~=move or l.capID.address~=cap or l.pcID.address~=c.pc) then
|
|
restore(l);s.lease=nil;l=nil
|
|
end
|
|
if not l then l=bind(c);s.lease=l end
|
|
local yaw=readDouble(c.pc+l.rotation.offset+8)
|
|
if not finite(yaw) then return end
|
|
local fb,lr,ud=input();local radians=math.rad(yaw)
|
|
local vx=(math.cos(radians)*fb-math.sin(radians)*lr)*s.speed
|
|
local vy=(math.sin(radians)*fb+math.cos(radians)*lr)*s.speed
|
|
local vz=ud*s.verticalSpeed
|
|
assert(writeBytes(l.move+l.mode.offset,5),'MovementMode write failed')
|
|
assert(writeFloat(l.move+l.gravity.offset,0),'GravityScale write failed')
|
|
assert(writeFloat(l.move+l.speed.offset,math.sqrt(s.speed*s.speed+s.verticalSpeed*s.verticalSpeed)+1),'MaxFlySpeed write failed')
|
|
assert(writeBytes(l.capID.address+l.bodyCollision.offset,0),'Capsule collision write failed')
|
|
setBit(c.pawn,l.actorCollision,false)
|
|
if l.soft then setBit(l.move,l.soft,false) end
|
|
assert(writeDouble(l.move+l.velocity.offset,vx));assert(writeDouble(l.move+l.velocity.offset+8,vy));assert(writeDouble(l.move+l.velocity.offset+16,vz))
|
|
s.lastError=nil
|
|
end
|
|
s.stop=function()
|
|
if s.timer then s.timer.Enabled=false end
|
|
restore(s.lease);s.lease=nil
|
|
if s.timer then s.timer.destroy();s.timer=nil end
|
|
if rawget(_G,'PBZ_NoClipFly')==s then _G.PBZ_NoClipFly=nil end
|
|
end
|
|
s.lease=bind(initial)
|
|
s.timer=createTimer(nil,false);s.timer.Interval=10
|
|
s.timer.OnTimer=function()
|
|
local ok,e=pcall(s.tick)
|
|
if not ok then s.lastError=tostring(e);s.timer.Enabled=false;pcall(restore,s.lease) end
|
|
end
|
|
_G.PBZ_NoClipFly=s;s.timer.Enabled=true
|
|
{$asm}
|
|
[DISABLE]
|
|
{$lua}
|
|
if syntaxcheck then return end
|
|
local s=rawget(_G,'PBZ_NoClipFly')
|
|
if s then return s.stop() end
|
|
{$asm}
|