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

Commit

Permalink
Update to 2022.10.25s(2449) (#438)
Browse files Browse the repository at this point in the history
* Update to 2022.10.25s

Compatible with 2022.10.18e

* fix Hook

* Deprecated SaveManager_XXX functions
  • Loading branch information
cddjr authored Oct 21, 2022
1 parent eceb352 commit ce9404d
Show file tree
Hide file tree
Showing 21 changed files with 106 additions and 122 deletions.
2 changes: 1 addition & 1 deletion appdata/il2cpp-classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ DO_APP_CLASS(ShipStatus, "Assembly-CSharp, ShipStatus");
DO_APP_CLASS(GameOptionsData, "Assembly-CSharp, GameOptionsData");
DO_APP_CLASS(Camera, "UnityEngine.CoreModule, UnityEngine.Camera");
DO_APP_CLASS(LobbyBehaviour, "Assembly-CSharp, LobbyBehaviour");
DO_APP_CLASS(SaveManager, "Assembly-CSharp, SaveManager");
//DO_APP_CLASS(SaveManager, "Assembly-CSharp, SaveManager");
DO_APP_CLASS(MeetingHud, "Assembly-CSharp, MeetingHud");
//DO_APP_CLASS(DestroyableSingleton_1_RoleManager_, "Assembly-CSharp, DestroyableSingleton_1_RoleManager_");
13 changes: 12 additions & 1 deletion appdata/il2cpp-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ DO_APP_FUNC(void, InnerNetClient_DisconnectInternal, (InnerNetClient* __this, Di

DO_APP_FUNC(void, PlayerPhysics_FixedUpdate, (PlayerPhysics* __this, MethodInfo* method), "Assembly-CSharp, System.Void PlayerPhysics::FixedUpdate()");

// deprecated
DO_APP_FUNC(String*, SaveManager_get_PlayerName, (MethodInfo* method), "Assembly-CSharp, System.String SaveManager::get_PlayerName()");
// deprecated
DO_APP_FUNC(void, SaveManager_set_PlayerName, (String* value, MethodInfo* method), "Assembly-CSharp, System.Void SaveManager::set_PlayerName(System.String)");
// deprecated
DO_APP_FUNC(bool, SaveManager_GetPurchase, (String* itemKey, String* bundleKey, MethodInfo* method), "Assembly-CSharp, System.Boolean SaveManager::GetPurchase(System.String, System.String)");

DO_APP_FUNC(void, PlayerControl_TurnOnProtection, (PlayerControl* __this, bool visible, int32_t colorId, MethodInfo* method), "Assembly-CSharp, System.Void PlayerControl::TurnOnProtection(System.Boolean, System.Int32)");
Expand All @@ -216,4 +221,10 @@ DO_APP_FUNC(String*, GameData_PlayerOutfit_get_PlayerName, (GameData_PlayerOutfi
DO_APP_FUNC(String*, GameData_PlayerInfo_get_PlayerName, (GameData_PlayerInfo* __this, MethodInfo* method), "Assembly-CSharp, System.String GameData+PlayerInfo::get_PlayerName()");

DO_APP_FUNC(void, AccountManager_UpdateKidAccountDisplay, (AccountManager* __this, MethodInfo* method), "Assembly-CSharp, System.Void AccountManager::UpdateKidAccountDisplay()");
DO_APP_FUNC(void, PlayerStorageManager_OnReadPlayerPrefsComplete, (PlayerStorageManager* __this, void* data, MethodInfo* method), "Assembly-CSharp, System.Void PlayerStorageManager::OnReadPlayerPrefsComplete(Epic.OnlineServices.PlayerDataStorage.ReadFileCallbackInfo)");
DO_APP_FUNC(void, PlayerStorageManager_OnReadPlayerPrefsComplete, (PlayerStorageManager* __this, void* data, MethodInfo* method), "Assembly-CSharp, System.Void PlayerStorageManager::OnReadPlayerPrefsComplete(Epic.OnlineServices.PlayerDataStorage.ReadFileCallbackInfo)");

// 2022.10.25s
DO_APP_FUNC(PlayerData*, DataManager_get_Player, (MethodInfo* method), "Assembly-CSharp, AmongUs.Data.Player.PlayerData AmongUs.Data.DataManager::get_Player()");
DO_APP_FUNC(String*, PlayerCustomizationData_get_Name, (PlayerCustomizationData* __this, MethodInfo* method), "Assembly-CSharp, System.String AmongUs.Data.Player.PlayerCustomizationData::get_Name()");
DO_APP_FUNC(void, PlayerCustomizationData_set_Name, (PlayerCustomizationData* __this, String* value, MethodInfo* method), "Assembly-CSharp, System.Void AmongUs.Data.Player.PlayerCustomizationData::set_Name(System.String)");
DO_APP_FUNC(bool, PlayerPurchasesData_GetPurchase, (PlayerPurchasesData* __this, String* itemKey, String* bundleKey, MethodInfo* method), "Assembly-CSharp, System.Boolean PlayerPurchasesData::GetPurchase(System.String, System.String)");
93 changes: 5 additions & 88 deletions appdata/il2cpp-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -12187,96 +12187,9 @@ struct RoleEffectAnimation__Array {
};

struct SaveManager {
struct SaveManager__Class* klass;
Il2CppClass* klass;
MonitorData* monitor;
};

struct SaveManager__VTable {
VirtualInvokeData Equals;
VirtualInvokeData Finalize;
VirtualInvokeData GetHashCode;
VirtualInvokeData ToString;
};

struct SaveManager__StaticFields {
int32_t lastSchemaVersion;
bool loaded;
bool loadedStats;
bool loadedAnnounce;
bool loadedQCFavorites;
bool loadedStoreTabViewDates;
bool loadedCachedPurchases;
void* OnColorBlindChanged;
void* OnStreamerModeChanged;
struct String* lastPlayerName;
uint32_t colorConfig;
struct String* lastPet;
struct String* lastHat;
struct String* lastSkin;
struct String* lastVisor;
struct String* lastNamePlate;
bool showOnlineHelp;
bool warnedAboutGuestModeProgression;
int32_t privacyPolicyVersion;
bool askRedeemDLC;
bool showMinPlayerWarning;
void* purchases;
struct String* lastCosmicube;
struct String* storeBundlesViewDate;
struct String* storeHatsViewDate;
struct String* storeOutfitsViewDate;
struct String* storeVisorsViewDate;
struct String* storePetsViewDate;
struct String* storeNameplatesViewDate;
struct String* storeCosmicubeViewDate;
int32_t accountLoginStatus;
bool hasLoggedIn;
bool isGuest;
struct String* guardianEmail;
struct String* epicAccountId;
bool deleteDeviceIDFailed;
struct String* dobInfo;
struct String* birthDateSetDate;
int32_t birthDateDay;
int32_t birthDateMonth;
int32_t birthDateYear;
uint32_t playerLevel;
uint32_t playerXp;
uint32_t playerXpRequiredForNextLevel;
struct Announcement lastAnnounce;
void* quickChatFavorites;
int32_t chatModeType;
struct GameOptionsData* hostOptionsData;
struct GameOptionsData* searchOptionsData;
uint8_t showAdsScreen;
bool screenshake;
bool censorChat;
bool enableFriendsListInvites;
bool crossplayAllPlatforms;
bool streamerMode;
bool colorblindMode;
uint8_t sfxVolume;
uint8_t musicVolume;
bool vsync;
uint32_t lastLanguage;
#if defined(_CPLUSPLUS_)
ControlTypes__Enum touchConfig;
#else
int32_t touchConfig;
#endif
bool enableMouseMovement;
float joyStickSize;
void* purchaseFile;
};

struct SaveManager__Class {
Il2CppClass_0 _0;
Il2CppRuntimeInterfaceOffsetPair* interfaceOffsets;
struct SaveManager__StaticFields* static_fields;
const Il2CppRGCTXData* rgctx_data;
Il2CppClass_1 _1;
struct SaveManager__VTable vtable;
};
#pragma endregion

#pragma region DestroyableSingleton_1_RoleManager_
Expand Down Expand Up @@ -12557,4 +12470,8 @@ struct RoleEffectAnimation__Array {
};
#pragma endregion

typedef Il2CppObject PlayerData;
typedef Il2CppObject PlayerCustomizationData;
typedef Il2CppObject PlayerPurchasesData;

}
25 changes: 13 additions & 12 deletions framework/il2cpp-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,21 @@ void output_assembly_methods(const Il2CppAssembly* assembly) {
}
}

class ScopedThreadAttacher
{
public:
ScopedThreadAttacher() : m_AttachedThread(nullptr) {
ScopedThreadAttacher::ScopedThreadAttacher() : m_AttachedThread(nullptr) {
if (il2cpp_thread_current() == nullptr)
m_AttachedThread = il2cpp_thread_attach(il2cpp_domain_get());
}
~ScopedThreadAttacher() {
if (m_AttachedThread)
il2cpp_thread_detach(m_AttachedThread);
}
}

private:
Il2CppThread* m_AttachedThread;
};
ScopedThreadAttacher::~ScopedThreadAttacher() {
detach();
}

void ScopedThreadAttacher::detach() {
if (m_AttachedThread) {
il2cpp_thread_detach(m_AttachedThread);
m_AttachedThread = nullptr;
}
}

bool cctor_finished(Il2CppClass* klass)
{
Expand Down
12 changes: 11 additions & 1 deletion framework/il2cpp-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,14 @@ namespace app {
E* _Ptr;
};
}
}
}

class ScopedThreadAttacher {
public:
ScopedThreadAttacher();
~ScopedThreadAttacher();

void detach();
private:
Il2CppThread* m_AttachedThread;
};
4 changes: 2 additions & 2 deletions gui/esp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static ImVec2 WorldToScreen(Vector2 pos)
return value;
}

struct PlayerData
struct EspPlayerData
{
ImVec2 Position = { 0.0f, 0.0f };
ImVec4 Color{ 0.0f, 0.0f, 0.0f, 0.0f };
Expand All @@ -67,7 +67,7 @@ typedef struct Drawing
{
std::mutex m_DrawingMutex;

std::array<PlayerData, Game::MAX_PLAYERS> m_Players;
std::array<EspPlayerData, Game::MAX_PLAYERS> m_Players;

ImVec2 LocalPosition{ 0.0f, 0.0f };
} drawing_t;
Expand Down
2 changes: 1 addition & 1 deletion hooks/AirshipStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void dAirshipStatus_OnEnable(AirshipStatus* __this, MethodInfo* method)

State.mapType = Settings::MapType::Airship;

State.userName = convert_from_string(SaveManager__TypeInfo->static_fields->lastPlayerName);
State.userName = GetPlayerName();
ResetOriginalAppearance();
}

Expand Down
2 changes: 0 additions & 2 deletions hooks/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,5 @@ void dChatBubble_SetName(ChatBubble* __this, String* playerName, bool isDead, bo

void dChatController_Update(ChatController* __this, MethodInfo* method)
{
//SaveManager__TypeInfo->static_fields->chatModeType = (int32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
SaveManager__TypeInfo->static_fields->isGuest = false;
ChatController_Update(__this, method);
}
2 changes: 0 additions & 2 deletions hooks/EOSManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ void dEOSManager_InitializePlatformInterface(EOSManager* __this, MethodInfo* met
bool dEOSManager_IsFreechatAllowed(EOSManager* __this, MethodInfo* method)
{
return app::EOSManager_IsFreechatAllowed(__this, method);
//SaveManager__TypeInfo->static_fields->chatModeType = (uint32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
//return true;
}

void dEOSManager_UpdatePermissionKeys(EOSManager* __this, void* callback, MethodInfo* method) {
Expand Down
4 changes: 2 additions & 2 deletions hooks/InnerNetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ void dInnerNetClient_Update(InnerNetClient* __this, MethodInfo* method)
static int nameChangeCycleDelay = 0; //If we spam too many name changes, we're banned

if (nameChangeCycleDelay <= 0 && !State.activeImpersonation) {
if ((convert_from_string(SaveManager__TypeInfo->static_fields->lastPlayerName) != State.userName) && !State.userName.empty()) {
SaveManager__TypeInfo->static_fields->lastPlayerName = convert_to_string(State.userName);
if ((GetPlayerName() != State.userName) && !State.userName.empty()) {
SetPlayerName(State.userName);
LOG_INFO("Name mismatch, setting name to \"" + State.userName + "\"");
if (IsInGame())
State.rpcQueue.push(new RpcSetName(State.userName));
Expand Down
2 changes: 1 addition & 1 deletion hooks/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
Profiler::EndSample("WalkEventCreation");
}
app::GameData_PlayerOutfit* outfit = GetPlayerOutfit(playerData);
PlayerData espPlayerData;
EspPlayerData espPlayerData;
espPlayerData.Position = WorldToScreen(playerPos);
if (outfit != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion hooks/PolusShipStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void dPolusShipStatus_OnEnable(PolusShipStatus* __this, MethodInfo* method)

State.mapType = Settings::MapType::Pb;

State.userName = convert_from_string(SaveManager__TypeInfo->static_fields->lastPlayerName);
State.userName = GetPlayerName();
ResetOriginalAppearance();
}
6 changes: 6 additions & 0 deletions hooks/SaveManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
#include "state.hpp"
#include "game.h"

// deprecated
bool dSaveManager_GetPurchase(String* itemKey, String* bundleKey, MethodInfo* method)
{
return true;
}

// v2022.10.25s
bool dPlayerPurchasesData_GetPurchase(PlayerPurchasesData* __this, String* itemKey, String* bundleKey, MethodInfo* method) {
return true;
}
2 changes: 1 addition & 1 deletion hooks/ShipStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ void dShipStatus_OnEnable(ShipStatus* __this, MethodInfo* method) {

State.mapType = (Settings::MapType)(__this->fields.Type);

State.userName = convert_from_string(SaveManager__TypeInfo->static_fields->lastPlayerName);
State.userName = GetPlayerName();
ResetOriginalAppearance();
}
11 changes: 9 additions & 2 deletions hooks/_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ void DetourInitilization() {
HOOKFUNC(ChatController_Update);
HOOKFUNC(InnerNetClient_EnqueueDisconnect);
HOOKFUNC(PlayerPhysics_FixedUpdate);
HOOKFUNC(SaveManager_GetPurchase);
if (SaveManager_GetPurchase != nullptr)
HOOKFUNC(SaveManager_GetPurchase);
if (PlayerPurchasesData_GetPurchase != nullptr) // v2022.10.25s
HOOKFUNC(PlayerPurchasesData_GetPurchase);
HOOKFUNC(PlayerControl_TurnOnProtection);
HOOKFUNC(AmongUsClient_OnGameEnd);
HOOKFUNC(InnerNetClient_DisconnectInternal);
Expand All @@ -170,7 +173,11 @@ void DetourUninitialization()
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());

UNHOOKFUNC(SaveManager_GetPurchase);

if (SaveManager_GetPurchase != nullptr)
UNHOOKFUNC(SaveManager_GetPurchase);
if (PlayerPurchasesData_GetPurchase != nullptr) // v2022.10.25s
UNHOOKFUNC(PlayerPurchasesData_GetPurchase);
UNHOOKFUNC(PlayerPhysics_FixedUpdate);
UNHOOKFUNC(GameObject_SetActive);
UNHOOKFUNC(SceneManager_Internal_ActiveSceneChanged);
Expand Down
3 changes: 2 additions & 1 deletion hooks/_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,5 @@ bool dSaveManager_GetPurchase(String* itemKey, String* bundleKey, MethodInfo* me
void dPlayerControl_TurnOnProtection(PlayerControl* __this, bool visible, int32_t colorId, MethodInfo* method);
void dAmongUsClient_OnGameEnd(AmongUsClient* __this, Object* endGameResult, MethodInfo* method);
void dAccountManager_UpdateKidAccountDisplay(AccountManager* __this, MethodInfo* method);
void dPlayerStorageManager_OnReadPlayerPrefsComplete(PlayerStorageManager* __this, void* data, MethodInfo* method);
void dPlayerStorageManager_OnReadPlayerPrefsComplete(PlayerStorageManager* __this, void* data, MethodInfo* method);
bool dPlayerPurchasesData_GetPurchase(PlayerPurchasesData* __this, String* itemKey, String* bundleKey, MethodInfo* method);
1 change: 0 additions & 1 deletion used_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ RoleEffectAnimation__Fields
PlayerControl__Fields
PlayerMaterial_Properties
CosmeticsLayer__Fields
SaveManager__StaticFields
DestroyableSingleton_1_AccountManager___Fields
AccountManager__Fields
KWSPermissionStatus__Enum
Expand Down
2 changes: 2 additions & 0 deletions user/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <filesystem>
#include <fstream>
#include <sstream>
#include <assert.h>

class AUMLogger {
public:
Expand Down Expand Up @@ -42,6 +43,7 @@ class AUMLogger {
#define LOG_ASSERT(EXPR) \
if (!(EXPR)) { \
STREAM_ERROR("(" << #EXPR << ") Assert failed."); \
assert(EXPR); \
exit(1); \
}

Expand Down
5 changes: 3 additions & 2 deletions user/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ void Run(LPVOID lpParam) {
}
hModule = (HMODULE)lpParam;
init_il2cpp();
ScopedThreadAttacher managedThreadAttached;
{
std::ostringstream ss;
ss << "\n\tAmongUsMenu - " << __DATE__ << " - " << __TIME__ << std::endl; // Log amongusmenu info
Expand Down Expand Up @@ -117,12 +118,12 @@ void Run(LPVOID lpParam) {
GAME_STATIC_POINTER(Game::pShipStatus, app::ShipStatus, Instance);
GAME_STATIC_POINTER(Game::pLobbyBehaviour, app::LobbyBehaviour, Instance);
//GAME_STATIC_POINTER(Game::pRoleManager, app::DestroyableSingleton_1_RoleManager_, _instance);
assert(cctor_finished(app::SaveManager__TypeInfo->_0.klass));
State.userName = convert_from_string(app::SaveManager__TypeInfo->static_fields->lastPlayerName);
State.userName = GetPlayerName();

Game::scanGameFunctions();
DetourInitilization();
#if _DEBUG
managedThreadAttached.detach();
DWORD dwWaitResult = WaitForSingleObject(hUnloadEvent, INFINITE);
if (dwWaitResult != WAIT_OBJECT_0) {
STREAM_ERROR("Failed to watch unload signal! dwWaitResult = " << dwWaitResult << " Error " << GetLastError());
Expand Down
Loading

0 comments on commit ce9404d

Please sign in to comment.