Skip to content

Commit

Permalink
Added many structs so compilations work better and now using more props
Browse files Browse the repository at this point in the history
- Borderlands3 (90 GB) compiles now
  • Loading branch information
Spuckwaffel committed Jul 18, 2024
1 parent de5ec88 commit f62d458
Show file tree
Hide file tree
Showing 11 changed files with 392 additions and 25 deletions.
34 changes: 21 additions & 13 deletions UEDumper/Engine/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,24 @@ void EngineCore::cookMemberArray(EngineStructs::Struct & eStruct)
eStruct.cookedMembers.clear();


auto checkRealMemberSize = [&](EngineStructs::Member* currentMember)
{
//set the real size
if (!currentMember->type.isPointer())
{
if (const auto classObject = getInfoOfObject(currentMember->type.name))
{
if (classObject->type == ObjectInfo::OI_Struct || classObject->type == ObjectInfo::OI_Class)
{
const auto cclass = static_cast<EngineStructs::Struct*>(classObject->target);
if(!cclass->noFixedSize)
currentMember->size = cclass->maxSize * (currentMember->arrayDim <= 0 ? 1 : currentMember->arrayDim);
}
}
}
};


auto genUnknownMember = [&](int from, int to, int special)
{
EngineStructs::Member unknown;
Expand Down Expand Up @@ -808,18 +826,7 @@ void EngineCore::cookMemberArray(EngineStructs::Struct & eStruct)
//0x7 [0x2]


//set the real size
if(!currentMember.type.isPointer())
{
if (const auto classObject = getInfoOfObject(currentMember.type.name))
{
if (classObject->type == ObjectInfo::OI_Struct || classObject->type == ObjectInfo::OI_Class)
{
const auto cclass = static_cast<EngineStructs::Struct*>(classObject->target);
currentMember.size = cclass->maxSize * (currentMember.arrayDim <= 0 ? 1 : currentMember.arrayDim);
}
}
}
checkRealMemberSize(&currentMember);


if (nextMember.offset - (currentMember.offset + currentMember.size) > 0)
Expand All @@ -835,7 +842,8 @@ void EngineCore::cookMemberArray(EngineStructs::Struct & eStruct)
}
//add the last member
eStruct.cookedMembers.push_back(std::pair(true, eStruct.definedMembers.size() - 1));
const auto& last = eStruct.getMemberForIndex(eStruct.cookedMembers.size() - 1);
auto last = eStruct.getMemberForIndex(eStruct.cookedMembers.size() - 1);
checkRealMemberSize(last);
if (last->offset + last->size < eStruct.maxSize)
genUnknownMember(last->offset + last->size, eStruct.maxSize, 7);
}
Expand Down
1 change: 1 addition & 0 deletions UEDumper/Engine/Core/EngineStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ namespace EngineStructs
std::vector<Struct*> superOfOthers{}; //all the structs that use this class as a super
bool inherited = false; //if the struct is inherited
int maxSize = 0; //the maximum size this struct is "allowed" to have, as size is not accurate due to padding and trailing
bool noFixedSize = false; // if this boolean is true, the current struct or class has no specific fixed size, meaning it can change (template classes)
int minAlignment = 0; //minimal alignment defined by ue
int size = 0; //propertiesSize, possibly wrong, use maxSize
int unknownCount = 0; //keep track of all missed vars, only used for the package viewer to edit unknowndata
Expand Down
2 changes: 1 addition & 1 deletion UEDumper/Engine/Core/ObjectsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class ObjectsManager
#ifdef _DEBUG
if (gamePtr < 0x100) {
// if your pointer is less than 0x100, it's likely invalid and there's a bug. Check your structs
DebugBreak();
//DebugBreak();
}
#endif
if(!gUObjectManager.linkedUObjectPtrs.contains(gamePtr))
Expand Down
114 changes: 114 additions & 0 deletions UEDumper/Engine/Generation/BasicType.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,120 @@ class TEnumAsByte

definedStructs.push_back(dStruct);

dStruct.name = "FWeakObjectPtr";
dStruct.definition =
R"(
class FWeakObjectPtr
{
public:
int32_t ObjectIndex;
int32_t ObjectSerialNumber;
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "TWeakObjectPtr";
dStruct.definition =
R"(
template<typename UEType>
class TWeakObjectPtr : public FWeakObjectPtr
{
public:
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "TPersistentObjectPtr";
dStruct.definition =
R"(
template<typename TObjectID>
class TPersistentObjectPtr
{
public:
FWeakObjectPtr WeakPtr;
int32_t TagAtLastTest;
TObjectID ObjectID;
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "FUniqueObjectGuid";
dStruct.definition =
R"(
class FUniqueObjectGuid final
{
public:
uint32_t A;
uint32_t B;
uint32_t C;
uint32_t D;
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "TLazyObjectPtr";
dStruct.definition =
R"(
template<typename UEType>
class TLazyObjectPtr : public TPersistentObjectPtr<FUniqueObjectGuid>
{
public:
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "FSoftObjectPath_";
dStruct.definition =
R"(
struct FSoftObjectPath_
{
public:
FName AssetPathName;
FString SubPathString;
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "FSoftObjectPtr";
dStruct.definition =
R"(
class FSoftObjectPtr : public TPersistentObjectPtr<FSoftObjectPath_>
{
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "TSoftObjectPtr";
dStruct.definition =
R"(
template<typename UEType>
class TSoftObjectPtr : public FSoftObjectPtr
{
public:
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "TSoftClassPtr";
dStruct.definition =
R"(
template<typename UEType>
class TSoftClassPtr : public FSoftObjectPtr
{
public:
};
)";

definedStructs.push_back(dStruct);

dStruct.name = "TPair";
dStruct.definition =
R"(
Expand Down
6 changes: 6 additions & 0 deletions UEDumper/Engine/Generation/SDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,14 @@ void SDKGeneration::generatePackage(

//first we generate enums

std::unordered_set<std::string> definedEnums;

for (const auto& enu : package.enums)
{
if (definedEnums.contains(enu.cppName))
continue;
definedEnums.insert(enu.cppName);

stream << "/// Enum " << enu.fullName << std::endl;
char buf[100] = { 0 };
sprintf_s(buf, "Size: 0x%02d (%d bytes)", enu.size, enu.size);
Expand Down
27 changes: 22 additions & 5 deletions UEDumper/Engine/UEClasses/UnrealClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,18 @@ std::string UObject::getSecondPackageName() const
bool UObject::IsA(const UClass* staticClass) const
{
if (!ClassPrivate) return false;
UClass* oldSup = nullptr;
for (auto super = getClass(); super; super = super->getSuper<UClass>())
{
if (!super)
if (!super || oldSup == super)
return false;
std::string fullname = super->getFullName();
if (super == staticClass)
{
//printf("%s\n", fullname.c_str());
return true;
}
oldSup = super;
}
return false;

Expand Down Expand Up @@ -443,6 +445,16 @@ fieldType UProperty::getType()
if (const auto cast = castTo<UObjectPropertyBase>(); cast->getPropertyClass())
return{ true, PropertyType::WeakObjectProperty, UObjectPropertyBase::weakTypeName(), cast->getSubTypes() };
};
if (IsA<USoftObjectProperty>())
{
if (const auto cast = castTo<UObjectPropertyBase>(); cast->getPropertyClass())
return{ true, PropertyType::SoftObjectProperty, UObjectPropertyBase::softTypeName(), cast->getSubTypes() };
};
if (IsA<ULazyObjectProperty>())
{
if (const auto cast = castTo<UObjectPropertyBase>(); cast->getPropertyClass())
return{ true, PropertyType::LazyObjectProperty, UObjectPropertyBase::lazyTypeName(), cast->getSubTypes() };
};
if (IsA<UObjectPropertyBase>())
{
if (const auto cast = castTo<UObjectPropertyBase>(); cast->getPropertyClass())
Expand Down Expand Up @@ -565,6 +577,11 @@ UClass* UWeakObjectProperty::staticClass()
return ObjectsManager::findObject<UClass>("/Script/CoreUObject.WeakObjectProperty");
}

UClass* USoftObjectProperty::staticClass()
{
return ObjectsManager::findObject<UClass>("/Script/CoreUObject.SoftObjectProperty");
}

UProperty* UInterfaceProperty::getInterfaceClass() const
{
UREADORNULL(UProperty, InterfaceClass)
Expand All @@ -575,10 +592,10 @@ UClass* UInterfaceProperty::staticClass()
return ObjectsManager::findObject<UClass>("/Script/CoreUObject.InterfaceProperty");
}

std::string UWeakObjectProperty::typeName()
{
return "struct TWeakObjectPtr<struct " + castTo<UStructProperty>()->typeName() + ">";
}
//std::string UWeakObjectProperty::typeName()
//{
// return "struct TWeakObjectPtr<struct " + castTo<UStructProperty>()->typeName() + ">";
//}

UClass* UClassProperty::getMetaClass() const
{
Expand Down
14 changes: 12 additions & 2 deletions UEDumper/Engine/UEClasses/UnrealClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ class UObjectPropertyBase : public UProperty

std::string typeName() const { return getPropertyClass()->getCName(); }
static std::string weakTypeName() { return "TWeakObjectPtr"; }
static std::string softTypeName() { return "TSoftObjectPtr"; }
static std::string lazyTypeName() { return "TLazyObjectPtr"; }
//only use on wak or lazy types!
std::vector<fieldType> getSubTypes() const { return std::vector<fieldType>{ {true, PropertyType::ObjectProperty, getPropertyClass()->getCName()}}; }
Expand Down Expand Up @@ -679,7 +680,16 @@ class UWeakObjectProperty : public UObjectPropertyBase
public:
using UObjectPropertyBase::UObjectPropertyBase;

std::string typeName();
//std::string typeName();
static UClass* staticClass();
};

class USoftObjectProperty : public UObjectPropertyBase
{
public:
using UObjectPropertyBase::UObjectPropertyBase;

//std::string typeName();
static UClass* staticClass();
};

Expand Down Expand Up @@ -1029,7 +1039,7 @@ class FSoftClassProperty : public FProperty

UClass* getMetaClass() const;

static std::string typeName() { return "TWeakObjectPtr"; }
static std::string typeName() { return "TSoftObjectPtr"; }

std::vector<fieldType> getSubTypes() const { return std::vector<fieldType>{ {true, PropertyType::ObjectProperty, getMetaClass()->getCName()}}; }

Expand Down
6 changes: 3 additions & 3 deletions UEDumper/Engine/Userdefined/Offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ inline std::vector<Offset> setOffsets()
{
std::vector<Offset> offsets;

offsets.push_back({ OFFSET_ADDRESS | OFFSET_DS, "OFFSET_GNAMES", 0xDEADBEEF });
offsets.push_back({ OFFSET_ADDRESS | OFFSET_DS, "OFFSET_GOBJECTS", 0xDEADBEEF });
offsets.push_back({ OFFSET_ADDRESS | OFFSET_DS | OFFSET_LIVE_EDITOR, "OFFSET_GWORLD", 0xDEADBEEF });
offsets.push_back({ OFFSET_ADDRESS | OFFSET_DS, "OFFSET_GNAMES", 0x69E81E8 });
offsets.push_back({ OFFSET_ADDRESS | OFFSET_DS, "OFFSET_GOBJECTS", 0x69ECDB0 });
offsets.push_back({ OFFSET_ADDRESS | OFFSET_DS | OFFSET_LIVE_EDITOR, "OFFSET_GWORLD", 0x6B1D668 });

//offsets.push_back({ OFFSET_ADDRESS | OFFSET_DH, "OFFSET_GNAMES", 0x562D340 });
//offsets.push_back({ OFFSET_ADDRESS | OFFSET_DH, "OFFSET_GOBJECTS", 0x545C6E0 });
Expand Down
Loading

0 comments on commit f62d458

Please sign in to comment.