Skip to content

Commit

Permalink
[Bugfix] Fixed an issue with freechat (#396)
Browse files Browse the repository at this point in the history
Enable freechat by pretending to be an adult.
  • Loading branch information
cddjr committed Jul 8, 2022
1 parent aedf784 commit cb1f4bc
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 10 deletions.
2 changes: 2 additions & 0 deletions AmongUsMenu.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<ClCompile Include="gui\tabs\sabotage_tab.cpp" />
<ClCompile Include="gui\tabs\settings_tab.cpp" />
<ClCompile Include="gui\tabs\tasks_tab.cpp" />
<ClCompile Include="hooks\AccountManager.cpp" />
<ClCompile Include="hooks\AirshipStatus.cpp" />
<ClCompile Include="hooks\Camera.cpp" />
<ClCompile Include="hooks\DirectX.cpp" />
Expand All @@ -68,6 +69,7 @@
<ClCompile Include="hooks\NoShadowBehaviour.cpp" />
<ClCompile Include="hooks\PlainDoor.cpp" />
<ClCompile Include="hooks\PlayerPhysics.cpp" />
<ClCompile Include="hooks\PlayerStorageManager.cpp" />
<ClCompile Include="hooks\PolusShipStatus.cpp" />
<ClCompile Include="hooks\RoleManager.cpp" />
<ClCompile Include="hooks\SaveManager.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions AmongUsMenu.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@
<ClCompile Include="hooks\SaveManager.cpp">
<Filter>hooks</Filter>
</ClCompile>
<ClCompile Include="hooks\AccountManager.cpp">
<Filter>hooks</Filter>
</ClCompile>
<ClCompile Include="hooks\PlayerStorageManager.cpp">
<Filter>hooks</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="appdata\il2cpp-api-functions.h">
Expand Down
4 changes: 4 additions & 0 deletions appdata/il2cpp-functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ DO_APP_FUNC(void, EOSManager_LoginFromAccountTab, (EOSManager* __this, MethodInf
DO_APP_FUNC(bool, EOSManager_HasFinishedLoginFlow, (EOSManager* __this, MethodInfo* method), "Assembly-CSharp, System.Boolean EOSManager::HasFinishedLoginFlow()");
DO_APP_FUNC(void, EOSManager_InitializePlatformInterface, (EOSManager* __this, MethodInfo* method), "Assembly-CSharp, System.Void EOSManager::InitializePlatformInterface()");
DO_APP_FUNC(bool, EOSManager_IsFreechatAllowed, (EOSManager* __this, MethodInfo* method), "Assembly-CSharp, System.Boolean EOSManager::IsFreechatAllowed()");
DO_APP_FUNC(void, EOSManager_UpdatePermissionKeys, (EOSManager* __this, void* callback, MethodInfo* method), "Assembly-CSharp, System.Void EOSManager::UpdatePermissionKeys(System.Action)");

DO_APP_FUNC(void, TextMeshPro_SetFaceColor, (TextMeshPro* __this, Color32 color, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TextMeshPro::SetFaceColor(UnityEngine.Color32)");
DO_APP_FUNC(void, TextMeshPro_SetOutlineColor, (TextMeshPro* __this, Color32 color, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TextMeshPro::SetOutlineColor(UnityEngine.Color32)");
Expand All @@ -211,3 +212,6 @@ DO_APP_FUNC(PlayerControl*, GameData_PlayerInfo_get_Object, (GameData_PlayerInfo
DO_APP_FUNC(GameData_PlayerOutfit*, GameData_PlayerInfo_get_DefaultOutfit, (GameData_PlayerInfo* __this, MethodInfo* method), "Assembly-CSharp, GameData.PlayerOutfit GameData+PlayerInfo::get_DefaultOutfit()");
DO_APP_FUNC(String*, GameData_PlayerOutfit_get_PlayerName, (GameData_PlayerOutfit* __this, MethodInfo* method), "Assembly-CSharp, System.String GameData+PlayerOutfit::get_PlayerName()");
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)");
142 changes: 137 additions & 5 deletions appdata/il2cpp-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -4368,8 +4368,7 @@ namespace app
bool DontDestroy;
};

struct EOSManager__Fields
{
struct EOSManager__Fields {
struct DestroyableSingleton_1_EOSManager___Fields _;
struct String* loginCredentialId;
struct String* productName;
Expand All @@ -4392,20 +4391,22 @@ namespace app
void* userId;
void* deviceIDuserID;
bool announcementsVisible;
bool hasShownSigninScreen;
bool attemptAuthAgain;
uint32_t numLinkedAccounts;
void* linkedExternalAccounts;
void* redeemDLCChoice;
void* editAccountUsername;
void* askToMergeAccount;
struct String* freeChatKey;
struct String* customNameKey;
struct String* friendsListKey;
int32_t ageOfConsent;
struct String* kwsUserId;
bool isKWSMinor;
void* continuanceToken;
struct String* exchangeToken;
struct String* platformAuthToken;
bool authExpiredCallbackTriggered;
bool silentLoginFailed;
bool hasTriedStartupDeviceID;
void* validateOldDLC;
bool isRedeemingDLC;
void* s_eosPlatformInterface;
Expand Down Expand Up @@ -12313,5 +12314,136 @@ struct RoleEffectAnimation__Array {

#pragma endregion

#pragma region AccountManager
#if defined(_CPLUSPLUS_)
enum class KWSPermissionStatus__Enum : int32_t {
Granted = 0x00000000,
Rejected = 0x00000001,
Pending = 0x00000002,
};

#else
enum KWSPermissionStatus__Enum {
KWSPermissionStatus__Enum_Granted = 0x00000000,
KWSPermissionStatus__Enum_Rejected = 0x00000001,
KWSPermissionStatus__Enum_Pending = 0x00000002,
};

#endif

#if defined(_CPLUSPLUS_)
enum class EOSManager_AccountLoginStatus__Enum : int32_t {
Offline = 0x00000000,
LoggedIn = 0x00000001,
WaitingForParent = 0x00000002,
};

#else
enum EOSManager_AccountLoginStatus__Enum {
EOSManager_AccountLoginStatus__Enum_Offline = 0x00000000,
EOSManager_AccountLoginStatus__Enum_LoggedIn = 0x00000001,
EOSManager_AccountLoginStatus__Enum_WaitingForParent = 0x00000002,
};

#endif

struct DestroyableSingleton_1_AccountManager___Fields {
struct MonoBehaviour__Fields _;
bool DontDestroy;
};

struct AccountManager__Fields {
struct DestroyableSingleton_1_AccountManager___Fields _;
struct AccountTab* accountTab;
void* enterGuardianEmailWindow;
void* updateGuardianEmailWindow;
void* guardianEmailConfirmWindow;
void* genericInfoDisplayBox;
void* enterDateOfBirthScreen;
struct GameObject* waitingText;
struct GameObject* postLoadWaiting;
struct GameObject* privacyPolicyBg;
void* signInScreen;
void* PrivacyPolicy;
void* chatModeMenuScreen;
#if defined(_CPLUSPLUS_)
KWSPermissionStatus__Enum freeChatAllowed;
#else
int32_t freeChatAllowed;
#endif
#if defined(_CPLUSPLUS_)
KWSPermissionStatus__Enum customDisplayName;
#else
int32_t customDisplayName;
#endif
#if defined(_CPLUSPLUS_)
KWSPermissionStatus__Enum friendsListAllowed;
#else
int32_t friendsListAllowed;
#endif
void* OnLoggedInStatusChange;
#if defined(_CPLUSPLUS_)
EOSManager_AccountLoginStatus__Enum prevLoggedInStatus;
#else
int32_t prevLoggedInStatus;
#endif
};

struct AccountManager {
void* klass;
MonitorData* monitor;
struct AccountManager__Fields fields;
};
#pragma endregion

#pragma region PlayerStorageManager
struct DestroyableSingleton_1_PlayerStorageManager___Fields {
struct MonoBehaviour__Fields _;
bool DontDestroy;
};

struct PlayerStorageManager_CloudPlayerPrefs {
struct String* ActivePodType;
struct String* receiptRedemptionAccounts;
uint32_t PlatformsLimitedItemsValidated;
uint32_t IsAdult;
};

#if defined(_CPLUSPLUS_)
enum class UpdateState__Enum : int32_t {
Connecting = 0x00000000,
Failed = 0x00000001,
Success = 0x00000002,
PartialSuccess = 0x00000003,
};

#else
enum UpdateState__Enum {
UpdateState__Enum_Connecting = 0x00000000,
UpdateState__Enum_Failed = 0x00000001,
UpdateState__Enum_Success = 0x00000002,
UpdateState__Enum_PartialSuccess = 0x00000003,
};

#endif

struct PlayerStorageManager__Fields {
struct DestroyableSingleton_1_PlayerStorageManager___Fields _;
struct PlayerStorageManager_CloudPlayerPrefs _PlayerPrefs_k__BackingField;
#if defined(_CPLUSPLUS_)
UpdateState__Enum _PlayerStorageLoadState_k__BackingField;
#else
int32_t _PlayerStorageLoadState_k__BackingField;
#endif
void* playerStorage;
void* saveRoutine;
};

struct PlayerStorageManager {
void* klass;
MonitorData* monitor;
struct PlayerStorageManager__Fields fields;
};
#pragma endregion

}
11 changes: 11 additions & 0 deletions hooks/AccountManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "pch-il2cpp.h"
#include "_hooks.h"
#include "logger.h"

void dAccountManager_UpdateKidAccountDisplay(AccountManager* __this, MethodInfo* method) {
// grant permissions
__this->fields.freeChatAllowed = KWSPermissionStatus__Enum::Granted;
__this->fields.customDisplayName = KWSPermissionStatus__Enum::Granted;
__this->fields.friendsListAllowed = KWSPermissionStatus__Enum::Granted;
app::AccountManager_UpdateKidAccountDisplay(__this, method);
}
2 changes: 1 addition & 1 deletion hooks/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void dChatBubble_SetName(ChatBubble* __this, String* playerName, bool isDead, bo

void dChatController_Update(ChatController* __this, MethodInfo* method)
{
SaveManager__TypeInfo->static_fields->chatModeType = 1;
//SaveManager__TypeInfo->static_fields->chatModeType = (int32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
SaveManager__TypeInfo->static_fields->isGuest = false;
ChatController_Update(__this, method);
}
10 changes: 8 additions & 2 deletions hooks/EOSManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ void dEOSManager_InitializePlatformInterface(EOSManager* __this, MethodInfo* met

bool dEOSManager_IsFreechatAllowed(EOSManager* __this, MethodInfo* method)
{
SaveManager__TypeInfo->static_fields->chatModeType = (uint32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
return true;
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) {
__this->fields.isKWSMinor = false;
app::EOSManager_UpdatePermissionKeys(__this, callback, method);
}
8 changes: 8 additions & 0 deletions hooks/PlayerStorageManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "pch-il2cpp.h"
#include "_hooks.h"
#include "logger.h"

void dPlayerStorageManager_OnReadPlayerPrefsComplete(PlayerStorageManager* __this, void* data, MethodInfo* method) {
app::PlayerStorageManager_OnReadPlayerPrefsComplete(__this, data, method);
__this->fields._PlayerPrefs_k__BackingField.IsAdult = 1;
}
6 changes: 6 additions & 0 deletions hooks/_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void DetourInitilization() {
HOOKFUNC(PlayerControl_TurnOnProtection);
HOOKFUNC(AmongUsClient_OnGameEnd);
HOOKFUNC(InnerNetClient_DisconnectInternal);
HOOKFUNC(AccountManager_UpdateKidAccountDisplay);
HOOKFUNC(PlayerStorageManager_OnReadPlayerPrefsComplete);
HOOKFUNC(EOSManager_UpdatePermissionKeys);


if (!HookFunction(&(PVOID&)oPresent, dPresent, "D3D_PRESENT_FUNCTION")) return;
Expand Down Expand Up @@ -234,6 +237,9 @@ void DetourUninitialization()
UNHOOKFUNC(PlayerControl_TurnOnProtection);
UNHOOKFUNC(AmongUsClient_OnGameEnd);
UNHOOKFUNC(InnerNetClient_DisconnectInternal);
UNHOOKFUNC(AccountManager_UpdateKidAccountDisplay);
UNHOOKFUNC(PlayerStorageManager_OnReadPlayerPrefsComplete);
UNHOOKFUNC(EOSManager_UpdatePermissionKeys);

if (DetourDetach(&(PVOID&)oPresent, dPresent) != 0) return;

Expand Down
5 changes: 4 additions & 1 deletion hooks/_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void dVersionShower_Start(VersionShower* __this, MethodInfo* method);
void dEOSManager_LoginFromAccountTab(EOSManager* __this, MethodInfo* method);
void dEOSManager_InitializePlatformInterface(EOSManager* __this, MethodInfo* method);
bool dEOSManager_IsFreechatAllowed(EOSManager* __this, MethodInfo* method);
void dEOSManager_UpdatePermissionKeys(EOSManager* __this, void* callback, MethodInfo* method);
void dChatController_Update(ChatController* __this, MethodInfo* method);
void dInnerNetClient_EnqueueDisconnect(InnerNetClient* __this, DisconnectReasons__Enum reason, String* stringReason, MethodInfo* method);
void dInnerNetClient_DisconnectInternal(InnerNetClient* __this, DisconnectReasons__Enum reason, String* stringReason, MethodInfo* method);
Expand All @@ -70,4 +71,6 @@ void dRoleManager_AssignRolesFromList(List_1_GameData_PlayerInfo_* players, int3
void dPlayerPhysics_FixedUpdate (PlayerPhysics* __this, MethodInfo* method);
bool dSaveManager_GetPurchase(String* itemKey, String* bundleKey, MethodInfo* method);
void dPlayerControl_TurnOnProtection(PlayerControl* __this, bool visible, int32_t colorId, MethodInfo* method);
void dAmongUsClient_OnGameEnd(AmongUsClient* __this, Object* endGameResult, 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);
11 changes: 10 additions & 1 deletion used_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,13 @@ RoleEffectAnimation__Fields
PlayerControl__Fields
PlayerMaterial_Properties
CosmeticsLayer__Fields
SaveManager__StaticFields
SaveManager__StaticFields
DestroyableSingleton_1_AccountManager___Fields
AccountManager__Fields
KWSPermissionStatus__Enum
EOSManager_AccountLoginStatus__Enum
DestroyableSingleton_1_PlayerStorageManager___Fields
PlayerStorageManager_CloudPlayerPrefs
PlayerStorageManager__Fields
UpdateState__Enum
EOSManager__Fields

0 comments on commit cb1f4bc

Please sign in to comment.