-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <spdlog/spdlog.h> | ||
|
||
#include "FProperty.hpp" | ||
|
||
namespace sdk { | ||
void FProperty::bruteforce_fproperty_offset(FProperty* x_prop, FProperty* y_prop, FProperty* z_prop) { | ||
SPDLOG_INFO("[FProperty] Bruteforcing offset field via FVector heuristic..."); | ||
|
||
if (x_prop == nullptr || y_prop == nullptr || z_prop == nullptr) { | ||
SPDLOG_ERROR("[FProperty] Failed to bruteforce offset field"); | ||
return; | ||
} | ||
|
||
// It has to be at least ahead of the next offset | ||
bool found = false; | ||
for (auto i = FField::s_next_offset + sizeof(void*); i < 0x200; i += 4) try { | ||
const auto x_offset = *(uint32_t*)((uintptr_t)x_prop + i); | ||
const auto y_offset = *(uint32_t*)((uintptr_t)y_prop + i); | ||
const auto z_offset = *(uint32_t*)((uintptr_t)z_prop + i); | ||
|
||
// float for UE4, double for UE5 | ||
if (x_offset == 0 && | ||
(y_offset == sizeof(float) || y_offset == sizeof(double)) && | ||
((z_offset == sizeof(float) * 2) || (z_offset == sizeof(double) * 2))) | ||
{ | ||
SPDLOG_INFO("[FProperty] Found offset field at offset 0x{:X}", i); | ||
s_offset_offset = i; | ||
found = true; | ||
break; | ||
} | ||
} catch(...) { | ||
continue; | ||
} | ||
|
||
if (!found) { | ||
SPDLOG_ERROR("[FProperty] Failed to bruteforce offset field"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include "UClass.hpp" | ||
#include "FField.hpp" | ||
|
||
namespace sdk { | ||
class FProperty : public FField { | ||
public: | ||
int32_t get_offset() const { | ||
return *(int32_t*)((uintptr_t)this + s_offset_offset); | ||
} | ||
|
||
// Given xyz props from FVector, find the offset which matches up with all of them | ||
static void bruteforce_fproperty_offset(FProperty* x_prop, FProperty* y_prop, FProperty* z_prop); | ||
|
||
private: | ||
static inline uint32_t s_offset_offset{0x0}; // idk | ||
|
||
friend class UStruct; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters