Skip to content

Commit

Permalink
Little fix
Browse files Browse the repository at this point in the history
  • Loading branch information
guttir14 committed Jul 10, 2021
1 parent 52e8bc2 commit 3e5d972
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 2 additions & 0 deletions Dumper/Dumper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<ConformanceMode>false</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard>
<CallingConvention>FastCall</CallingConvention>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -94,6 +95,7 @@
<ControlFlowGuard>
</ControlFlowGuard>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
10 changes: 4 additions & 6 deletions Dumper/generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ uint8* TUObjectArray::GetObjectPtr(uint32 id) const {
void TUObjectArray::Dump(std::function<void(uint8 *)> callback) const {
for (uint32 i = 0; i < NumElements; i++) {
uint8* object = GetObjectPtr(i);
if (!object) {
continue;
}
if (!object) continue;
callback(object);
}
}
Expand All @@ -65,11 +63,11 @@ UE_UObject TUObjectArray::FindObject(const std::string &name) const {
return nullptr;
}

void TUObjectArray::ForEachObjectOfClass(const UE_UClass cmp, std::function<void(uint8 *)> callback) const {
for (uint32 i = 0u; i < NumElements; i++) {
void TUObjectArray::ForEachObjectOfClass(const UE_UClass cmp, std::function<bool(uint8*)> callback) const {
for (uint32 i = 0; i < NumElements; i++) {
UE_UObject object = GetObjectPtr(i);
if (object && object.IsA(cmp) && object.GetName().find("_Default") == std::string::npos) {
callback(object);
if (callback(object)) return;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Dumper/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct TUObjectArray {
uint8* GetObjectPtr(uint32 id) const;
void Dump(std::function<void(uint8*)> callback) const;
class UE_UObject FindObject(const std::string &name) const;
void ForEachObjectOfClass(const class UE_UClass cmp, std::function<void(uint8*)> callback) const;
void ForEachObjectOfClass(const class UE_UClass cmp, std::function<bool(uint8*)> callback) const;
bool IsObject(UE_UObject address) const;
};

Expand Down
18 changes: 8 additions & 10 deletions Dumper/wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,9 +1012,10 @@ void UE_UPackage::FillPadding(UE_UStruct object, std::vector<Member>& members, u
auto size = end - offset;
if (findPointers && size >= 8) {

auto normalized = (offset + 7) & ~7;
if (normalized != offset) {
auto diff = normalized - offset;
auto normalizedOffset = (offset + 7) & ~7;

if (normalizedOffset != offset) {
auto diff = normalizedOffset - offset;
GeneratePadding(members, offset, diff);
offset += diff;
}
Expand Down Expand Up @@ -1059,14 +1060,14 @@ void UE_UPackage::FillPadding(UE_UStruct object, std::vector<Member>& members, u

ObjObjects.ForEachObjectOfClass((UE_UClass)object, callback);

auto prevOFfset = offset;
auto start = offset;
for (uint32 i = 0; i < num; i++) {
auto ptr = pointers[i];
if (ptr && ptr != (uint64)-1) {

auto ptrObject = UE_UObject((void*)ptr);

auto ptrOffset = prevOFfset + i * 8;
auto ptrOffset = start + i * 8;
if (ptrOffset > offset) {
GeneratePadding(members, offset, ptrOffset - offset);
offset = ptrOffset;
Expand All @@ -1077,11 +1078,8 @@ void UE_UPackage::FillPadding(UE_UStruct object, std::vector<Member>& members, u
m.Size = 8;

if (ptrObject.IsA<UE_UObject>()) {
auto ptrClass = ptrObject.GetClass();
auto ptrClassName = ptrClass.GetCppName();
m.Type = "struct " + ptrClassName + "*";
auto ptrName = ptrObject.GetName();
m.Name = ptrName;
m.Type = "struct " + ptrObject.GetClass().GetCppName() + "*";
m.Name = ptrObject.GetName();
}
else {
m.Type = "void*";
Expand Down

0 comments on commit 3e5d972

Please sign in to comment.