Skip to content

Commit

Permalink
Added additional checks to "GetCVARs" function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyall committed Aug 9, 2024
1 parent 8fc90b8 commit 2ca9622
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,14 @@ void GetCVARs()

// Cache all console objects
ConsoleObjects = Unreal::GetConsoleObjects(singletonAddr);
bCachedConsoleObjects = true;
spdlog::info("Console CVARs: Cached all console objects.");

if (ConsoleObjects.Num() != 0) {
bCachedConsoleObjects = true;
spdlog::info("Console CVARs: Cached all console objects.");
}
else {
spdlog::info("Console CVARs: ConsoleObjects TMap is not valid.");
}
}
else if (!ConsoleManagerSingletonScanResult) {
spdlog::error("Console CVARs: Pattern scan failed.");
Expand Down
11 changes: 11 additions & 0 deletions src/helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,18 @@ namespace Unreal

SDK::TMap<SDK::FString, FConsoleObject*> GetConsoleObjects(uintptr_t singletonAddr)
{
if (singletonAddr == 0)
{
return SDK::TMap<SDK::FString, FConsoleObject*>();
}

SDK::uint8** Singleton = reinterpret_cast<SDK::uint8**>(singletonAddr);

if (Singleton == nullptr || *Singleton == nullptr )
{
return SDK::TMap<SDK::FString, FConsoleObject*>();
}

return *reinterpret_cast<SDK::TMap<SDK::FString, FConsoleObject*>*>(*Singleton + 8);
}

Expand Down

0 comments on commit 2ca9622

Please sign in to comment.