var
GWorld_Ptr_Offset = 0xB32D8A8
var
GName_Offset = 0xB171CC0
var
GUObjectArray_Offset = 0xB1B5F98
var
playerName =
"FirstPersonCharacter_C"
;
var
moduleBase;
var
GWorld;
var
GName;
var
GUObjectArray;
var
offset_UObject_InternalIndex = 0xC;
var
offset_UObject_ClassPrivate = 0x10;
var
offset_UObject_FNameIndex = 0x18;
var
offset_UObject_OuterPrivate = 0x20;
var
UObject = {
getClass:
function
(obj) {
var
classPrivate = ptr(obj).add(offset_UObject_ClassPrivate).readPointer();
return
classPrivate;
},
getNameId:
function
(obj) {
try
{
var
nameId = ptr(obj).add(offset_UObject_FNameIndex).readU32();
return
nameId;
}
catch
(e) {
info(
'error'
)
return
0;
}
},
getName:
function
(obj) {
if
(
this
.isValid(obj)){
return
getFNameFromID(
this
.getNameId(obj));
}
else
{
return
"None"
;
}
},
getClassName:
function
(obj) {
if
(
this
.isValid(obj)) {
var
classPrivate =
this
.getClass(obj);
return
this
.getName(classPrivate);
}
else
{
return
"None"
;
}
},
isValid:
function
(obj) {
var
isValid = (ptr(obj) > 0 &&
this
.getNameId(obj) > 0 &&
this
.getClass(obj) > 0);
return
isValid;
}
}
function
getFNameFromID(index) {
var
FNameStride = 0x2
var
offset_GName_FNamePool = 0x30;
var
offset_FNamePool_Blocks = 0x10;
var
offset_FNameEntry_Info = 0;
var
FNameEntry_LenBit = 6;
var
offset_FNameEntry_String = 0x2;
var
Block = index >> 16;
var
Offset = index & 65535;
var
FNamePool = GName.add(offset_GName_FNamePool);
var
NamePoolChunk = FNamePool.add(offset_FNamePool_Blocks + Block * 8).readPointer();
var
FNameEntry = NamePoolChunk.add(FNameStride * Offset);
try
{
if
(offset_FNameEntry_Info !== 0) {
var
FNameEntryHeader = FNameEntry.add(offset_FNameEntry_Info).readU16();
}
else
{
var
FNameEntryHeader = FNameEntry.readU16();
}
}
catch
(e) {
return
""
;
}
var
str_addr = FNameEntry.add(offset_FNameEntry_String);
var
str_length = FNameEntryHeader >> FNameEntry_LenBit;
var
wide = FNameEntryHeader & 1;
if
(wide)
return
"widestr"
;
if
(str_length > 0 && str_length < 250) {
var
str = str_addr.readUtf8String(str_length);
return
str;
}
else
{
return
"None"
;
}
}
function
set(moduleName) {
moduleBase = Module.findBaseAddress(moduleName);
GName = moduleBase.add(GName_Offset);
GUObjectArray = moduleBase.add(GUObjectArray_Offset);
}
class Vector {
constructor(x, y, z) {
this
.x = x;
this
.y = y;
this
.z = z;
}
toString() {
return
`(${
this
.x}, ${
this
.y}, ${
this
.z})`;
}
}
function
getPlayerAddr(){
var
player_addr;
var
actorsAddr = getActorsAddr();
for
(
var
key
in
actorsAddr){
if
(key==playerName){
player_addr = actorsAddr[key];
}
}
return
player_addr;
}
function
setVector(addr,x,y,z){
let vecAddr = addr;
info(
'vecAddr'
,vecAddr);
let vec =
new
Vector(x,y,z);
let address = vecAddr;
let floatArray =
new
Float32Array([vec.x, vec.y, vec.z]);
Memory.writeByteArray(address, floatArray.buffer);
console.log(
"Vector values written to address:"
, address.toString());
}
function
dumpActorInstances(){
GWorld = moduleBase.add(GWorld_Ptr_Offset).readPointer();
var
Level_Offset = 0x30
var
Actors_Offset = 0x98
var
Level = GWorld.add(Level_Offset).readPointer()
var
Actors = Level.add(Actors_Offset).readPointer()
var
Actors_Num = Level.add(Actors_Offset).add(8).readU32()
var
actorsInstances = {};
for
(
var
index = 0; index < Actors_Num; index++){
var
actor_addr = Actors.add(index * 8).readPointer()
var
actorName = UObject.getName(actor_addr)
actorsInstances[index] = actorName;
info(`actors[${index}]:${actor_addr}`,actorName);
getActorLocation(actor_addr);
try
{
setActorVisibility(actor_addr)
}
catch
(e){
}
}
}
function
getActorsAddr(){
GWorld = moduleBase.add(GWorld_Ptr_Offset).readPointer();
var
Level_Offset = 0x30
var
Actors_Offset = 0x98
var
Level = GWorld.add(Level_Offset).readPointer()
var
Actors = Level.add(Actors_Offset).readPointer()
var
Actors_Num = Level.add(Actors_Offset).add(8).readU32()
var
actorsAddr = {};
for
(
var
index = 0; index < Actors_Num; index++){
var
actor_addr = Actors.add(index * 8).readPointer()
var
actorName = UObject.getName(actor_addr)
actorsAddr[actorName] = actor_addr;
}
return
actorsAddr;
}
function
setPlayerLocation(x,y,z){
setActorLocation(getPlayerAddr(),x,y,z);
}
function
dumpVector(addr){
const values = Memory.readByteArray(addr, 3 * 4);
const vec =
new
Vector(
new
Float32Array(values, 0, 1)[0],
new
Float32Array(values, 4, 1)[0],
new
Float32Array(values, 8, 1)[0]
);
info(
'location'
,vec);
}
function
getActorLocation(actor_addr){
GWorld = moduleBase.add(GWorld_Ptr_Offset).readPointer();
actor_addr = ptr(actor_addr)
var
buf = Memory.alloc(0x100);
var
f_addr = moduleBase.add(0x965ddf8);
var
getLocationFunc =
new
NativeFunction(f_addr,
'void'
, [
'pointer'
,
'pointer'
,
'pointer'
]);
try
{
getLocationFunc(actor_addr,buf,buf);
dumpVector(buf);
}
catch
(e){
}
}
function
setActorLocation(actor_addr,x,y,z){
GWorld = moduleBase.add(GWorld_Ptr_Offset).readPointer();
actor_addr = ptr(actor_addr)
var
buf = Memory.alloc(0x100);
var
f_addr = moduleBase.add(0x8C3181C);
var
setLocationFunc =
new
NativeFunction(f_addr,
'bool'
, [
'pointer'
,
'bool'
,
'pointer'
,
'bool'
,
'float'
,
'float'
,
'float'
]);
setLocationFunc(actor_addr,0,ptr(0),0,x,y,z);
}
function
getActorVisibility(actor_addr){
info(ptr(actor_addr).add(0x130).readPointer().add(0x14d).readU8()&4 != 0);
}
function
dump(addr,len){
var
buf = ptr(addr).readByteArray(len);
info(buf);
}
function
setPlayerHP(hp = 1000000){
getPlayerAddr().add(0x510).writeFloat(hp);
}
function
setActorHidden(actor_addr,NewHidden=0,bPropagateToChildren=2){
var
f_addr = moduleBase.add(0x8E61C70);
let setActorHiddenFunc =
new
NativeFunction(f_addr,
'void'
, [
'pointer'
,
'char'
,
'char'
]);
setActorHiddenFunc(ptr(actor_addr).add(0x130).readPointer(),NewHidden,bPropagateToChildren);
}
function
setActorVisibility(actor_addr,NewHidden=1,bPropagateToChildren=2){
var
f_addr = moduleBase.add(0x8E619BC);
let setActorHiddenFunc =
new
NativeFunction(f_addr,
'void'
, [
'pointer'
,
'char'
,
'char'
]);
setActorHiddenFunc(ptr(actor_addr).add(0x130).readPointer(),NewHidden,bPropagateToChildren);
}
function
setActorCollisionEnabled(actor_addr,bNewActorEnableCollision=1){
var
f_addr = moduleBase.add(0x8C21320);
let setActorCollisionEnabledFunc =
new
NativeFunction(f_addr,
'void'
, [
'pointer'
,
'char'
]);
setActorCollisionEnabledFunc(ptr(actor_addr),bNewActorEnableCollision);
}
function
getStaticMeshActorCollisionEnabled(actor_addr){
actor_addr = ptr(actor_addr)
var
f_addr = actor_addr.add(0x220).readPointer().readPointer().add(0x510).readPointer();
var
getActorCollisionEnabled =
new
NativeFunction(f_addr,
'char'
, [
'pointer'
]);
let ret = getActorCollisionEnabled(actor_addr.add(0x220).readPointer());
info(ret);
}
function
setStaticMeshActorCollisionEnabled(actor_addr,NewType=3){
actor_addr = ptr(actor_addr)
var
f_addr = actor_addr.add(0x220).readPointer().readPointer().add(0x660).readPointer();
var
getActorCollisionEnabled =
new
NativeFunction(f_addr,
'char'
, [
'pointer'
,
'char'
]);
let ret = getActorCollisionEnabled(actor_addr.add(0x220).readPointer(),NewType);
info(ret);
}
function
cheat(){
setPlayerLocation(-1000, 100, 270)
setPlayerHP(10000000)
var
actorsAddr = getActorsAddr();
for
(
var
key
in
actorsAddr){
if
(key.includes(
"Wall"
)){
setActorCollisionEnabled(actorsAddr[key],0)
}
}
}
set(
'libUE4.so'
)
function
info(x,y){
if
(y !== undefined && y !=
null
){
console.log(x+
' => '
+y);
}
else
{
console.log(x);
}
}