Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
Update to 2021.12.15 (#252)
Browse files Browse the repository at this point in the history
* temporarily removed assertions

* features seem to work despite the cctor_finished not being set
* version.dll won't work reliably due to race condition...
* fixed CTD in Chat.cpp when player is NULL
* renamed some classes / vars to avoid conflicts with game classes
* added one new field to InnerNetClient. haven't thoroughly checked if the update added others
* regression in console logging: shapeshifters are named "ERROR" sometimes. refer to b728102

* added debug spam, temp-fixed CTD bug

* PlayerControl has CTD in the vector's push_back method. wasn't able to fully debug it yet, so i just commented it out for now.
* CTD is likely from bad GetEventPlayerControl(*Game::pLocalPlayer).value() or the vector missing an element or something

* fixed event walking crashing due to pLocalPlayer which is being dereferenced at some points of the game. we need to use "__this" as the PlayerControl* anyways. So it will save the correct playercontrol source now

* Update gitparams.h

Co-authored-by: kotae4 <[email protected]>
  • Loading branch information
v0idp and kotae4 authored Dec 17, 2021
1 parent d00c514 commit c1a96e9
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 79 deletions.
98 changes: 51 additions & 47 deletions appdata/il2cpp-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -7430,53 +7430,6 @@ namespace app
};
#pragma endregion

#pragma region EngineerRole

struct EngineerRole__Fields {
struct RoleBehaviour__Fields _;
struct Vent *currentTarget;
float cooldownSecondsRemaining;
float inVentTimeRemaining;
};

struct EngineerRole__VTable {
VirtualInvokeData Equals;
VirtualInvokeData Finalize;
VirtualInvokeData GetHashCode;
VirtualInvokeData ToString;
VirtualInvokeData CanUse;
VirtualInvokeData DidWin;
VirtualInvokeData Deinitialize;
VirtualInvokeData SpawnTaskHeader;
VirtualInvokeData UseAbility;
VirtualInvokeData OnMeetingStart;
VirtualInvokeData OnVotingComplete;
VirtualInvokeData Initialize;
VirtualInvokeData SetUsableTarget;
VirtualInvokeData SetPlayerTarget;
VirtualInvokeData SetCooldown;
};

struct EngineerRole__StaticFields {
};

struct EngineerRole__Class {
Il2CppClass_0 _0;
Il2CppRuntimeInterfaceOffsetPair *interfaceOffsets;
struct EngineerRole__StaticFields *static_fields;
const Il2CppRGCTXData *rgctx_data;
Il2CppClass_1 _1;
struct EngineerRole__VTable vtable;
};

struct EngineerRole {
struct EngineerRole__Class *klass;
MonitorData *monitor;
struct EngineerRole__Fields fields;
};

#pragma endregion

#pragma region GameData_PlayerInfo
struct __declspec(align(4)) GameData_PlayerInfo__Fields
{
Expand Down Expand Up @@ -9160,6 +9113,7 @@ struct EngineerRole {
int32_t msgNum;
struct String* networkAddress;
int32_t networkPort;
bool useDtls;
void* connection;
#if defined(_CPLUSPLUS_)
MatchMakerModes__Enum mode;
Expand Down Expand Up @@ -11392,6 +11346,56 @@ struct EngineerRole {
};
#pragma endregion

#pragma region EngineerRole
struct EngineerRole__Fields
{
struct RoleBehaviour__Fields _;
struct Vent* currentTarget;
float cooldownSecondsRemaining;
float inVentTimeRemaining;
};

struct EngineerRole
{
struct EngineerRole__Class* klass;
void* monitor;
struct EngineerRole__Fields fields;
};

struct EngineerRole__VTable
{
VirtualInvokeData Equals;
VirtualInvokeData Finalize;
VirtualInvokeData GetHashCode;
VirtualInvokeData ToString;
VirtualInvokeData CanUse;
VirtualInvokeData DidWin;
VirtualInvokeData Deinitialize;
VirtualInvokeData SpawnTaskHeader;
VirtualInvokeData UseAbility;
VirtualInvokeData OnMeetingStart;
VirtualInvokeData OnVotingComplete;
VirtualInvokeData Initialize;
VirtualInvokeData SetUsableTarget;
VirtualInvokeData SetPlayerTarget;
VirtualInvokeData SetCooldown;
};

struct EngineerRole__StaticFields
{
};

struct EngineerRole__Class
{
Il2CppClass_0 _0;
Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets;
struct EngineerRole__StaticFields* static_fields;
const Il2CppRGCTXData* rgctx_data;
Il2CppClass_1 _1;
struct EngineerRole__VTable vtable;
};
#pragma endregion

#pragma region RoleManager
struct RoleManager__Fields
{
Expand Down
10 changes: 9 additions & 1 deletion framework/il2cpp-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ bool cctor_finished(Il2CppClass* klass)
timeout -= 10;
}

if (timeout <= 0) return false;
if (timeout <= 0)
{
STREAM_DEBUG("Class " << klass->name << " Timed out waiting for initialized || initialized_and_no_error");
return false;
}
//Then we wait for the static constructor to finish
timeout = CCTOR_TIMEOUT;

Expand All @@ -253,5 +257,9 @@ bool cctor_finished(Il2CppClass* klass)
std::this_thread::sleep_for(std::chrono::milliseconds(10));
timeout -= 10;
}
if (timeout <= 0)
{
STREAM_DEBUG("Class " << klass->name << " Timed out waiting for cctor_finished");
}
return (timeout > 0);
}
12 changes: 6 additions & 6 deletions gui/esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <imgui/imgui_internal.h>

drawing_t* Esp::s_Instance = new drawing_t();
ImGuiWindow* Window = nullptr;
ImGuiWindow* CurrentWindow = nullptr;

static void RenderText(const char* text, const ImVec2& pos, const ImVec4& color, const bool outlined = true, const bool centered = true)
{
Expand All @@ -22,25 +22,25 @@ static void RenderText(const char* text, const ImVec2& pos, const ImVec4& color,

if (outlined)
{
Window->DrawList->AddText(nullptr, 0.f,
CurrentWindow->DrawList->AddText(nullptr, 0.f,
{ ImScreen.x - 1.f, ImScreen.y + 1.f },
ImGui::GetColorU32(IM_COL32_BLACK), text);
}

Window->DrawList->AddText(nullptr, 0.f, ImScreen, ImGui::GetColorU32(color), text);
CurrentWindow->DrawList->AddText(nullptr, 0.f, ImScreen, ImGui::GetColorU32(color), text);
}

static void RenderLine(const ImVec2& start, const ImVec2& end, const ImVec4& color, bool shadow = false) noexcept
{
if (shadow)
{
Window->DrawList->AddLine(
CurrentWindow->DrawList->AddLine(
{ start.x + 1.0f, start.y + 1.0f },
{ end.x + 1.0f, end.y + 1.0f },
ImGui::GetColorU32(color) & IM_COL32_A_MASK);
}

Window->DrawList->AddLine(start, end, ImGui::GetColorU32(color));
CurrentWindow->DrawList->AddLine(start, end, ImGui::GetColorU32(color));
}

static void RenderBox(const ImVec2 top, const ImVec2 bottom, const float height, const float width, const ImVec4& color, const bool wantsShadow = true)
Expand All @@ -60,7 +60,7 @@ static void RenderBox(const ImVec2 top, const ImVec2 bottom, const float height,

void Esp::Render()
{
Window = ImGui::GetCurrentWindow();
CurrentWindow = ImGui::GetCurrentWindow();

drawing_t& instance = Esp::GetDrawing();

Expand Down
3 changes: 2 additions & 1 deletion hooks/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ void dChatController_AddChat(ChatController* __this, PlayerControl* sourcePlayer
bool wasDead = false;
GameData_PlayerInfo* player = GetPlayerData(sourcePlayer);
GameData_PlayerInfo* local = GetPlayerData(*Game::pLocalPlayer);
if (player->fields.IsDead && !local->fields.IsDead) {

if (player != NULL && player->fields.IsDead && local != NULL && !local->fields.IsDead) {
local->fields.IsDead = true;
wasDead = true;
}
Expand Down
2 changes: 1 addition & 1 deletion hooks/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
dPlayerControl_fixedUpdateCount++;
if (dPlayerControl_fixedUpdateCount >= dPlayerControl_fixedUpdateTimer) {
dPlayerControl_fixedUpdateCount = 0;
State.events[__this->fields.PlayerId][EVENT_WALK].push_back(new WalkEvent(GetEventPlayerControl(*Game::pLocalPlayer).value(), localPos));
State.events[__this->fields.PlayerId][EVENT_WALK].push_back(new WalkEvent(GetEventPlayerControl(__this).value(), localPos));
}

PlayerData espPlayerData;
Expand Down
4 changes: 2 additions & 2 deletions user/gitparams.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#define GIT_CUR_COMMIT 988415bdf5e63d2b75f50d71035c3ba7f2968c22
#define GIT_BRANCH main
#define GIT_CUR_COMMIT f43dca40e6ade5efd234d166a55babe129b9f8a7
#define GIT_BRANCH 2021.12.15
18 changes: 9 additions & 9 deletions user/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <iostream>
#include "utility.h"

Logger Log;
AUMLogger Log;

void Logger::Create()
void AUMLogger::Create()
{
auto path = getModulePath(NULL);
auto logPath = path.parent_path() / "aum-log.txt";
Expand All @@ -17,7 +17,7 @@ void Logger::Create()
this->filePath = logPath;
}

void Logger::Write(std::string verbosity, std::string source, std::string message)
void AUMLogger::Write(std::string verbosity, std::string source, std::string message)
{
std::stringstream ss;
ss << "[" << verbosity << " - " << source << "] " << message << std::endl;
Expand All @@ -28,32 +28,32 @@ void Logger::Write(std::string verbosity, std::string source, std::string messag
file.close();
}

void Logger::Debug(std::string source, std::string message)
void AUMLogger::Debug(std::string source, std::string message)
{
Write("DEBUG", source, message);
}

void Logger::Error(std::string source, std::string message)
void AUMLogger::Error(std::string source, std::string message)
{
Write("ERROR", source, message);
}

void Logger::Info(std::string source, std::string message)
void AUMLogger::Info(std::string source, std::string message)
{
Write("INFO", source, message);
}

void Logger::Debug(std::string message)
void AUMLogger::Debug(std::string message)
{
Debug("AUM", message);
}

void Logger::Error(std::string message)
void AUMLogger::Error(std::string message)
{
Error("AUM", message);
}

void Logger::Info(std::string message)
void AUMLogger::Info(std::string message)
{
Info("AUM", message);
}
4 changes: 2 additions & 2 deletions user/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <fstream>
#include <sstream>

class Logger {
class AUMLogger {
public:
void Create();
void Write(std::string verbosity, std::string source, std::string message);
Expand Down Expand Up @@ -39,4 +39,4 @@ class Logger {
LOG_ERROR(ss.str()); \
} while (0)

extern Logger Log;
extern AUMLogger Log;
33 changes: 23 additions & 10 deletions user/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,30 @@ void Run(LPVOID lpParam) {
output_class_methods(klass);
*/
#endif
GAME_STATIC_POINTER(Game::pAmongUsClient, app::AmongUsClient, Instance);
GAME_STATIC_POINTER(Game::pGameData, app::GameData, Instance);
GAME_STATIC_POINTER(Game::pGameOptionsData, app::PlayerControl, GameOptions);
GAME_STATIC_POINTER(Game::pAllPlayerControls, app::PlayerControl, AllPlayerControls);
GAME_STATIC_POINTER(Game::pLocalPlayer, app::PlayerControl, LocalPlayer);
GAME_STATIC_POINTER(Game::pShipStatus, app::ShipStatus, Instance);
GAME_STATIC_POINTER(Game::pLobbyBehaviour, app::LobbyBehaviour, Instance);
STREAM_DEBUG("AmongUsClient__TypeInfo: " << std::hex << app::AmongUsClient__TypeInfo << "\n\tHas Static Constructor: " << (app::AmongUsClient__TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::AmongUsClient__TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
//GAME_STATIC_POINTER(Game::pAmongUsClient, app::AmongUsClient, Instance);
Game::pAmongUsClient = &(app::AmongUsClient__TypeInfo->static_fields->Instance);
STREAM_DEBUG("GameData__TypeInfo: " << std::hex << app::GameData__TypeInfo << "\n\tHas Static Constructor: " << (app::GameData__TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::GameData__TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
//GAME_STATIC_POINTER(Game::pGameData, app::GameData, Instance);
Game::pGameData = &(app::GameData__TypeInfo->static_fields->Instance);
STREAM_DEBUG("PlayerControl__TypeInfo: " << std::hex << app::PlayerControl__TypeInfo << "\n\tHas Static Constructor: " << (app::PlayerControl__TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::PlayerControl__TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
//GAME_STATIC_POINTER(Game::pGameOptionsData, app::PlayerControl, GameOptions);
Game::pGameOptionsData = &(app::PlayerControl__TypeInfo->static_fields->GameOptions);
//GAME_STATIC_POINTER(Game::pAllPlayerControls, app::PlayerControl, AllPlayerControls);
Game::pAllPlayerControls = &(app::PlayerControl__TypeInfo->static_fields->AllPlayerControls);
//GAME_STATIC_POINTER(Game::pLocalPlayer, app::PlayerControl, LocalPlayer);
Game::pLocalPlayer = &(app::PlayerControl__TypeInfo->static_fields->LocalPlayer);
STREAM_DEBUG("ShipStatus__TypeInfo: " << std::hex << app::ShipStatus__TypeInfo << "\n\tHas Static Constructor: " << (app::ShipStatus__TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::ShipStatus__TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
//GAME_STATIC_POINTER(Game::pShipStatus, app::ShipStatus, Instance);
Game::pShipStatus = &(app::ShipStatus__TypeInfo->static_fields->Instance);
STREAM_DEBUG("LobbyBehaviour__TypeInfo: " << std::hex << app::LobbyBehaviour__TypeInfo << "\n\tHas Static Constructor: " << (app::LobbyBehaviour__TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::LobbyBehaviour__TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
//GAME_STATIC_POINTER(Game::pLobbyBehaviour, app::LobbyBehaviour, Instance);
Game::pLobbyBehaviour = &(app::LobbyBehaviour__TypeInfo->static_fields->Instance);
//STREAM_DEBUG("DestroyableSingleton_1_RoleManager___TypeInfo: " << std::hex << app::DestroyableSingleton_1_RoleManager___TypeInfo << "\n\tHas Static Constructor: " << (app::DestroyableSingleton_1_RoleManager___TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::DestroyableSingleton_1_RoleManager___TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
//GAME_STATIC_POINTER(Game::pRoleManager, app::DestroyableSingleton_1_RoleManager_, _instance);

assert(cctor_finished(SaveManager__TypeInfo->_0.klass));
State.userName = convert_from_string(SaveManager__TypeInfo->static_fields->lastPlayerName);
STREAM_DEBUG("SaveManager__TypeInfo: " << std::hex << app::SaveManager__TypeInfo << "\n\tHas Static Constructor: " << (app::SaveManager__TypeInfo->_0.klass->has_cctor ? "true" : "false") << "\n\tIs Static Constructor Finished: " << (app::SaveManager__TypeInfo->_0.klass->cctor_finished ? "true" : "false"));
assert(cctor_finished(app::SaveManager__TypeInfo->_0.klass));
State.userName = convert_from_string(app::SaveManager__TypeInfo->static_fields->lastPlayerName);

DetourInitilization();
#if _DEBUG
Expand Down

0 comments on commit c1a96e9

Please sign in to comment.