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

Commit cb1f4bc

Browse files
authored
[Bugfix] Fixed an issue with freechat (#396)
Enable freechat by pretending to be an adult.
1 parent aedf784 commit cb1f4bc

File tree

11 files changed

+197
-10
lines changed

11 files changed

+197
-10
lines changed

AmongUsMenu.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<ClCompile Include="gui\tabs\sabotage_tab.cpp" />
5757
<ClCompile Include="gui\tabs\settings_tab.cpp" />
5858
<ClCompile Include="gui\tabs\tasks_tab.cpp" />
59+
<ClCompile Include="hooks\AccountManager.cpp" />
5960
<ClCompile Include="hooks\AirshipStatus.cpp" />
6061
<ClCompile Include="hooks\Camera.cpp" />
6162
<ClCompile Include="hooks\DirectX.cpp" />
@@ -68,6 +69,7 @@
6869
<ClCompile Include="hooks\NoShadowBehaviour.cpp" />
6970
<ClCompile Include="hooks\PlainDoor.cpp" />
7071
<ClCompile Include="hooks\PlayerPhysics.cpp" />
72+
<ClCompile Include="hooks\PlayerStorageManager.cpp" />
7173
<ClCompile Include="hooks\PolusShipStatus.cpp" />
7274
<ClCompile Include="hooks\RoleManager.cpp" />
7375
<ClCompile Include="hooks\SaveManager.cpp" />

AmongUsMenu.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@
289289
<ClCompile Include="hooks\SaveManager.cpp">
290290
<Filter>hooks</Filter>
291291
</ClCompile>
292+
<ClCompile Include="hooks\AccountManager.cpp">
293+
<Filter>hooks</Filter>
294+
</ClCompile>
295+
<ClCompile Include="hooks\PlayerStorageManager.cpp">
296+
<Filter>hooks</Filter>
297+
</ClCompile>
292298
</ItemGroup>
293299
<ItemGroup>
294300
<ClInclude Include="appdata\il2cpp-api-functions.h">

appdata/il2cpp-functions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ DO_APP_FUNC(void, EOSManager_LoginFromAccountTab, (EOSManager* __this, MethodInf
185185
DO_APP_FUNC(bool, EOSManager_HasFinishedLoginFlow, (EOSManager* __this, MethodInfo* method), "Assembly-CSharp, System.Boolean EOSManager::HasFinishedLoginFlow()");
186186
DO_APP_FUNC(void, EOSManager_InitializePlatformInterface, (EOSManager* __this, MethodInfo* method), "Assembly-CSharp, System.Void EOSManager::InitializePlatformInterface()");
187187
DO_APP_FUNC(bool, EOSManager_IsFreechatAllowed, (EOSManager* __this, MethodInfo* method), "Assembly-CSharp, System.Boolean EOSManager::IsFreechatAllowed()");
188+
DO_APP_FUNC(void, EOSManager_UpdatePermissionKeys, (EOSManager* __this, void* callback, MethodInfo* method), "Assembly-CSharp, System.Void EOSManager::UpdatePermissionKeys(System.Action)");
188189

189190
DO_APP_FUNC(void, TextMeshPro_SetFaceColor, (TextMeshPro* __this, Color32 color, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TextMeshPro::SetFaceColor(UnityEngine.Color32)");
190191
DO_APP_FUNC(void, TextMeshPro_SetOutlineColor, (TextMeshPro* __this, Color32 color, MethodInfo* method), "Unity.TextMeshPro, System.Void TMPro.TextMeshPro::SetOutlineColor(UnityEngine.Color32)");
@@ -211,3 +212,6 @@ DO_APP_FUNC(PlayerControl*, GameData_PlayerInfo_get_Object, (GameData_PlayerInfo
211212
DO_APP_FUNC(GameData_PlayerOutfit*, GameData_PlayerInfo_get_DefaultOutfit, (GameData_PlayerInfo* __this, MethodInfo* method), "Assembly-CSharp, GameData.PlayerOutfit GameData+PlayerInfo::get_DefaultOutfit()");
212213
DO_APP_FUNC(String*, GameData_PlayerOutfit_get_PlayerName, (GameData_PlayerOutfit* __this, MethodInfo* method), "Assembly-CSharp, System.String GameData+PlayerOutfit::get_PlayerName()");
213214
DO_APP_FUNC(String*, GameData_PlayerInfo_get_PlayerName, (GameData_PlayerInfo* __this, MethodInfo* method), "Assembly-CSharp, System.String GameData+PlayerInfo::get_PlayerName()");
215+
216+
DO_APP_FUNC(void, AccountManager_UpdateKidAccountDisplay, (AccountManager* __this, MethodInfo* method), "Assembly-CSharp, System.Void AccountManager::UpdateKidAccountDisplay()");
217+
DO_APP_FUNC(void, PlayerStorageManager_OnReadPlayerPrefsComplete, (PlayerStorageManager* __this, void* data, MethodInfo* method), "Assembly-CSharp, System.Void PlayerStorageManager::OnReadPlayerPrefsComplete(Epic.OnlineServices.PlayerDataStorage.ReadFileCallbackInfo)");

appdata/il2cpp-types.h

Lines changed: 137 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,8 +4368,7 @@ namespace app
43684368
bool DontDestroy;
43694369
};
43704370

4371-
struct EOSManager__Fields
4372-
{
4371+
struct EOSManager__Fields {
43734372
struct DestroyableSingleton_1_EOSManager___Fields _;
43744373
struct String* loginCredentialId;
43754374
struct String* productName;
@@ -4392,20 +4391,22 @@ namespace app
43924391
void* userId;
43934392
void* deviceIDuserID;
43944393
bool announcementsVisible;
4395-
bool hasShownSigninScreen;
43964394
bool attemptAuthAgain;
43974395
uint32_t numLinkedAccounts;
43984396
void* linkedExternalAccounts;
4399-
void* redeemDLCChoice;
44004397
void* editAccountUsername;
4398+
void* askToMergeAccount;
4399+
struct String* freeChatKey;
4400+
struct String* customNameKey;
4401+
struct String* friendsListKey;
44014402
int32_t ageOfConsent;
44024403
struct String* kwsUserId;
4404+
bool isKWSMinor;
44034405
void* continuanceToken;
44044406
struct String* exchangeToken;
44054407
struct String* platformAuthToken;
44064408
bool authExpiredCallbackTriggered;
44074409
bool silentLoginFailed;
4408-
bool hasTriedStartupDeviceID;
44094410
void* validateOldDLC;
44104411
bool isRedeemingDLC;
44114412
void* s_eosPlatformInterface;
@@ -12313,5 +12314,136 @@ struct RoleEffectAnimation__Array {
1231312314

1231412315
#pragma endregion
1231512316

12317+
#pragma region AccountManager
12318+
#if defined(_CPLUSPLUS_)
12319+
enum class KWSPermissionStatus__Enum : int32_t {
12320+
Granted = 0x00000000,
12321+
Rejected = 0x00000001,
12322+
Pending = 0x00000002,
12323+
};
12324+
12325+
#else
12326+
enum KWSPermissionStatus__Enum {
12327+
KWSPermissionStatus__Enum_Granted = 0x00000000,
12328+
KWSPermissionStatus__Enum_Rejected = 0x00000001,
12329+
KWSPermissionStatus__Enum_Pending = 0x00000002,
12330+
};
12331+
12332+
#endif
12333+
12334+
#if defined(_CPLUSPLUS_)
12335+
enum class EOSManager_AccountLoginStatus__Enum : int32_t {
12336+
Offline = 0x00000000,
12337+
LoggedIn = 0x00000001,
12338+
WaitingForParent = 0x00000002,
12339+
};
12340+
12341+
#else
12342+
enum EOSManager_AccountLoginStatus__Enum {
12343+
EOSManager_AccountLoginStatus__Enum_Offline = 0x00000000,
12344+
EOSManager_AccountLoginStatus__Enum_LoggedIn = 0x00000001,
12345+
EOSManager_AccountLoginStatus__Enum_WaitingForParent = 0x00000002,
12346+
};
12347+
12348+
#endif
12349+
12350+
struct DestroyableSingleton_1_AccountManager___Fields {
12351+
struct MonoBehaviour__Fields _;
12352+
bool DontDestroy;
12353+
};
12354+
12355+
struct AccountManager__Fields {
12356+
struct DestroyableSingleton_1_AccountManager___Fields _;
12357+
struct AccountTab* accountTab;
12358+
void* enterGuardianEmailWindow;
12359+
void* updateGuardianEmailWindow;
12360+
void* guardianEmailConfirmWindow;
12361+
void* genericInfoDisplayBox;
12362+
void* enterDateOfBirthScreen;
12363+
struct GameObject* waitingText;
12364+
struct GameObject* postLoadWaiting;
12365+
struct GameObject* privacyPolicyBg;
12366+
void* signInScreen;
12367+
void* PrivacyPolicy;
12368+
void* chatModeMenuScreen;
12369+
#if defined(_CPLUSPLUS_)
12370+
KWSPermissionStatus__Enum freeChatAllowed;
12371+
#else
12372+
int32_t freeChatAllowed;
12373+
#endif
12374+
#if defined(_CPLUSPLUS_)
12375+
KWSPermissionStatus__Enum customDisplayName;
12376+
#else
12377+
int32_t customDisplayName;
12378+
#endif
12379+
#if defined(_CPLUSPLUS_)
12380+
KWSPermissionStatus__Enum friendsListAllowed;
12381+
#else
12382+
int32_t friendsListAllowed;
12383+
#endif
12384+
void* OnLoggedInStatusChange;
12385+
#if defined(_CPLUSPLUS_)
12386+
EOSManager_AccountLoginStatus__Enum prevLoggedInStatus;
12387+
#else
12388+
int32_t prevLoggedInStatus;
12389+
#endif
12390+
};
12391+
12392+
struct AccountManager {
12393+
void* klass;
12394+
MonitorData* monitor;
12395+
struct AccountManager__Fields fields;
12396+
};
12397+
#pragma endregion
12398+
12399+
#pragma region PlayerStorageManager
12400+
struct DestroyableSingleton_1_PlayerStorageManager___Fields {
12401+
struct MonoBehaviour__Fields _;
12402+
bool DontDestroy;
12403+
};
12404+
12405+
struct PlayerStorageManager_CloudPlayerPrefs {
12406+
struct String* ActivePodType;
12407+
struct String* receiptRedemptionAccounts;
12408+
uint32_t PlatformsLimitedItemsValidated;
12409+
uint32_t IsAdult;
12410+
};
12411+
12412+
#if defined(_CPLUSPLUS_)
12413+
enum class UpdateState__Enum : int32_t {
12414+
Connecting = 0x00000000,
12415+
Failed = 0x00000001,
12416+
Success = 0x00000002,
12417+
PartialSuccess = 0x00000003,
12418+
};
12419+
12420+
#else
12421+
enum UpdateState__Enum {
12422+
UpdateState__Enum_Connecting = 0x00000000,
12423+
UpdateState__Enum_Failed = 0x00000001,
12424+
UpdateState__Enum_Success = 0x00000002,
12425+
UpdateState__Enum_PartialSuccess = 0x00000003,
12426+
};
12427+
12428+
#endif
12429+
12430+
struct PlayerStorageManager__Fields {
12431+
struct DestroyableSingleton_1_PlayerStorageManager___Fields _;
12432+
struct PlayerStorageManager_CloudPlayerPrefs _PlayerPrefs_k__BackingField;
12433+
#if defined(_CPLUSPLUS_)
12434+
UpdateState__Enum _PlayerStorageLoadState_k__BackingField;
12435+
#else
12436+
int32_t _PlayerStorageLoadState_k__BackingField;
12437+
#endif
12438+
void* playerStorage;
12439+
void* saveRoutine;
12440+
};
12441+
12442+
struct PlayerStorageManager {
12443+
void* klass;
12444+
MonitorData* monitor;
12445+
struct PlayerStorageManager__Fields fields;
12446+
};
12447+
#pragma endregion
1231612448

1231712449
}

hooks/AccountManager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "pch-il2cpp.h"
2+
#include "_hooks.h"
3+
#include "logger.h"
4+
5+
void dAccountManager_UpdateKidAccountDisplay(AccountManager* __this, MethodInfo* method) {
6+
// grant permissions
7+
__this->fields.freeChatAllowed = KWSPermissionStatus__Enum::Granted;
8+
__this->fields.customDisplayName = KWSPermissionStatus__Enum::Granted;
9+
__this->fields.friendsListAllowed = KWSPermissionStatus__Enum::Granted;
10+
app::AccountManager_UpdateKidAccountDisplay(__this, method);
11+
}

hooks/Chat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void dChatBubble_SetName(ChatBubble* __this, String* playerName, bool isDead, bo
5151

5252
void dChatController_Update(ChatController* __this, MethodInfo* method)
5353
{
54-
SaveManager__TypeInfo->static_fields->chatModeType = 1;
54+
//SaveManager__TypeInfo->static_fields->chatModeType = (int32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
5555
SaveManager__TypeInfo->static_fields->isGuest = false;
5656
ChatController_Update(__this, method);
5757
}

hooks/EOSManager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ void dEOSManager_InitializePlatformInterface(EOSManager* __this, MethodInfo* met
2525

2626
bool dEOSManager_IsFreechatAllowed(EOSManager* __this, MethodInfo* method)
2727
{
28-
SaveManager__TypeInfo->static_fields->chatModeType = (uint32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
29-
return true;
28+
return app::EOSManager_IsFreechatAllowed(__this, method);
29+
//SaveManager__TypeInfo->static_fields->chatModeType = (uint32_t)QuickChatModes__Enum::FreeChatOrQuickChat;
30+
//return true;
31+
}
32+
33+
void dEOSManager_UpdatePermissionKeys(EOSManager* __this, void* callback, MethodInfo* method) {
34+
__this->fields.isKWSMinor = false;
35+
app::EOSManager_UpdatePermissionKeys(__this, callback, method);
3036
}

hooks/PlayerStorageManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "pch-il2cpp.h"
2+
#include "_hooks.h"
3+
#include "logger.h"
4+
5+
void dPlayerStorageManager_OnReadPlayerPrefsComplete(PlayerStorageManager* __this, void* data, MethodInfo* method) {
6+
app::PlayerStorageManager_OnReadPlayerPrefsComplete(__this, data, method);
7+
__this->fields._PlayerPrefs_k__BackingField.IsAdult = 1;
8+
}

hooks/_hooks.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ void DetourInitilization() {
155155
HOOKFUNC(PlayerControl_TurnOnProtection);
156156
HOOKFUNC(AmongUsClient_OnGameEnd);
157157
HOOKFUNC(InnerNetClient_DisconnectInternal);
158+
HOOKFUNC(AccountManager_UpdateKidAccountDisplay);
159+
HOOKFUNC(PlayerStorageManager_OnReadPlayerPrefsComplete);
160+
HOOKFUNC(EOSManager_UpdatePermissionKeys);
158161

159162

160163
if (!HookFunction(&(PVOID&)oPresent, dPresent, "D3D_PRESENT_FUNCTION")) return;
@@ -234,6 +237,9 @@ void DetourUninitialization()
234237
UNHOOKFUNC(PlayerControl_TurnOnProtection);
235238
UNHOOKFUNC(AmongUsClient_OnGameEnd);
236239
UNHOOKFUNC(InnerNetClient_DisconnectInternal);
240+
UNHOOKFUNC(AccountManager_UpdateKidAccountDisplay);
241+
UNHOOKFUNC(PlayerStorageManager_OnReadPlayerPrefsComplete);
242+
UNHOOKFUNC(EOSManager_UpdatePermissionKeys);
237243

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

hooks/_hooks.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void dVersionShower_Start(VersionShower* __this, MethodInfo* method);
6161
void dEOSManager_LoginFromAccountTab(EOSManager* __this, MethodInfo* method);
6262
void dEOSManager_InitializePlatformInterface(EOSManager* __this, MethodInfo* method);
6363
bool dEOSManager_IsFreechatAllowed(EOSManager* __this, MethodInfo* method);
64+
void dEOSManager_UpdatePermissionKeys(EOSManager* __this, void* callback, MethodInfo* method);
6465
void dChatController_Update(ChatController* __this, MethodInfo* method);
6566
void dInnerNetClient_EnqueueDisconnect(InnerNetClient* __this, DisconnectReasons__Enum reason, String* stringReason, MethodInfo* method);
6667
void dInnerNetClient_DisconnectInternal(InnerNetClient* __this, DisconnectReasons__Enum reason, String* stringReason, MethodInfo* method);
@@ -70,4 +71,6 @@ void dRoleManager_AssignRolesFromList(List_1_GameData_PlayerInfo_* players, int3
7071
void dPlayerPhysics_FixedUpdate (PlayerPhysics* __this, MethodInfo* method);
7172
bool dSaveManager_GetPurchase(String* itemKey, String* bundleKey, MethodInfo* method);
7273
void dPlayerControl_TurnOnProtection(PlayerControl* __this, bool visible, int32_t colorId, MethodInfo* method);
73-
void dAmongUsClient_OnGameEnd(AmongUsClient* __this, Object* endGameResult, MethodInfo* method);
74+
void dAmongUsClient_OnGameEnd(AmongUsClient* __this, Object* endGameResult, MethodInfo* method);
75+
void dAccountManager_UpdateKidAccountDisplay(AccountManager* __this, MethodInfo* method);
76+
void dPlayerStorageManager_OnReadPlayerPrefsComplete(PlayerStorageManager* __this, void* data, MethodInfo* method);

0 commit comments

Comments
 (0)