From 962cdfa20a43bbb4d3b612308bc75db312fd87b4 Mon Sep 17 00:00:00 2001
From: Joaquin <67109235+Taiga74164@users.noreply.github.com>
Date: Sun, 12 Jun 2022 00:46:44 -0600
Subject: [PATCH] In-game Browser
me and @RyujinZX
---
cheat-library/cheat-library.vcxproj | 2 +
cheat-library/cheat-library.vcxproj.filters | 6 +
cheat-library/src/appdata/il2cpp-functions.h | 19 ++++
cheat-library/src/appdata/il2cpp-types.h | 103 ++++++++++++++++++
cheat-library/src/user/cheat/cheat.cpp | 4 +-
.../src/user/cheat/visuals/Browser.cpp | 99 +++++++++++++++++
.../src/user/cheat/visuals/Browser.h | 26 +++++
7 files changed, 258 insertions(+), 1 deletion(-)
create mode 100644 cheat-library/src/user/cheat/visuals/Browser.cpp
create mode 100644 cheat-library/src/user/cheat/visuals/Browser.h
diff --git a/cheat-library/cheat-library.vcxproj b/cheat-library/cheat-library.vcxproj
index 2add32f..51c3fc4 100644
--- a/cheat-library/cheat-library.vcxproj
+++ b/cheat-library/cheat-library.vcxproj
@@ -50,6 +50,7 @@
true
+
@@ -163,6 +164,7 @@
+
diff --git a/cheat-library/cheat-library.vcxproj.filters b/cheat-library/cheat-library.vcxproj.filters
index dbe9540..20245a6 100644
--- a/cheat-library/cheat-library.vcxproj.filters
+++ b/cheat-library/cheat-library.vcxproj.filters
@@ -234,6 +234,9 @@
Header Files
+
+ Header Files
+
@@ -426,6 +429,9 @@
Source Files
+
+ Source Files
+
diff --git a/cheat-library/src/appdata/il2cpp-functions.h b/cheat-library/src/appdata/il2cpp-functions.h
index 283eceb..077f93b 100644
--- a/cheat-library/src/appdata/il2cpp-functions.h
+++ b/cheat-library/src/appdata/il2cpp-functions.h
@@ -164,6 +164,25 @@ DO_APP_FUNC(0x065546E0, Transform*, Transform_GetChild, (Transform* __this, int3
DO_APP_FUNC(0x0652EA10, Component_1*, Component_1_GetComponent_1, (Component_1* __this, String* type, MethodInfo* method));
DO_APP_FUNC(0x0662F520, void, GameObject_SetActive, (GameObject* __this, bool value, MethodInfo* method));
+// Browser
+DO_APP_FUNC(0x0662F100, GameObject*, GameObject_CreatePrimitive, (PrimitiveType__Enum type, MethodInfo* method));
+DO_APP_FUNC(0x0662F700, Transform*, GameObject_get_transform, (GameObject* __this, MethodInfo* method));
+DO_APP_FUNC(0x06555EF0, void, Transform_set_localRotation, (Transform* __this, Quaternion value, MethodInfo* method));
+DO_APP_FUNC(0x065548E0, void, Transform_set_localScale, (Transform* __this, Vector3 value, MethodInfo* method));
+DO_APP_FUNC(0x06555EE0, void, Transform_set_localPosition, (Transform* __this, Vector3 value, MethodInfo* method));
+DO_APP_FUNC(0x0662F090, Component_1*, GameObject_AddComponentInternal, (GameObject* __this, String* className, MethodInfo* method));
+DO_APP_FUNC(0x064296D0, void, Browser_Show, (Browser* __this, MethodInfo* method));
+DO_APP_FUNC(0x06427060, void, Browser_Hide, (Browser* __this, MethodInfo* method));
+DO_APP_FUNC(0x00C21580, void, Browser_set_EnableRendering, (Browser* __this, bool value, MethodInfo* method));
+DO_APP_FUNC(0x0642C5D0, void, Browser_set_Url, (Browser* __this, String* value, MethodInfo* method));
+DO_APP_FUNC(0x064273E0, void, Browser_LoadURL, (Browser* __this, String* url, bool force, MethodInfo* method));
+DO_APP_FUNC(0x06427610, void, Browser_OnDestroy, (Browser* __this, MethodInfo* method));
+DO_APP_FUNC(0x0642A200, void, Browser_Update, (Browser* __this, MethodInfo* method));
+DO_APP_FUNC(0x06427100, void, Browser_LateUpdate, (Browser* __this, MethodInfo* method));
+DO_APP_FUNC(0x06429770, void, Browser_Stop, (Browser* __this, MethodInfo* method));
+DO_APP_FUNC(0x06550910, void, Object_1_Destroy_1, (Object_1* obj, MethodInfo* method));
+DO_APP_FUNC(0x0662F0A0, Component_1*, GameObject_AddComponent, (GameObject* __this, Type* componentType, MethodInfo* method));
+DO_APP_FUNC(0x065508C0, void, Object_1_DestroyImmediate_1, (Object_1* obj, MethodInfo* method));
// Utility
DO_APP_FUNC(0x03551B60, String*, Text_get_text, (Text* __this, MethodInfo* method));
diff --git a/cheat-library/src/appdata/il2cpp-types.h b/cheat-library/src/appdata/il2cpp-types.h
index 3393357..ea4e9b3 100644
--- a/cheat-library/src/appdata/il2cpp-types.h
+++ b/cheat-library/src/appdata/il2cpp-types.h
@@ -3818,6 +3818,12 @@ namespace app {
void* m_CachedPtr;
};
+ struct Object_1 {
+ struct Object_1__Class* klass;
+ MonitorData* monitor;
+ struct Object_1__Fields fields;
+ };
+
struct Component_1__Fields {
struct Object_1__Fields _;
};
@@ -11538,6 +11544,103 @@ namespace app {
struct MonoFriendInformationDialog__Fields fields;
};
+ struct Color32 {
+ int32_t rgba;
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+ uint8_t a;
+ };
+
+ enum class PrimitiveType__Enum : int32_t {
+ Sphere = 0x00000000,
+ Capsule = 0x00000001,
+ Cylinder = 0x00000002,
+ Cube = 0x00000003,
+ Plane = 0x00000004,
+ Quad = 0x00000005,
+ };
+
+ enum class BrowserNative_ContextMenuOrigin__Enum : int32_t {
+ Editable = 0x00000002,
+ Image = 0x00000004,
+ Selection = 0x00000008,
+ Other = 0x00000001,
+ };
+
+ enum class Browser_NewWindowAction__Enum : int32_t {
+ Ignore = 0x00000001,
+ Redirect = 0x00000002,
+ NewBrowser = 0x00000003,
+ NewWindow = 0x00000004,
+ };
+
+ struct Browser__Fields {
+ struct MonoBehaviour__Fields _;
+ bool offScreen;
+ struct IBrowserUI* _uiHandler;
+ bool uiHandlerAssigned;
+ struct String* _url;
+ int32_t _width;
+ int32_t _height;
+ bool generateMipmap;
+ struct Color32 baseColor;
+ float _zoom;
+ struct Action_2_String_String_* onConsoleMessage;
+ BrowserNative_ContextMenuOrigin__Enum allowContextMenuOn;
+ Browser_NewWindowAction__Enum newWindowAction;
+ struct INewWindowHandler* _NewWindowHandler_k__BackingField;
+ bool _EnableRendering_k__BackingField;
+ bool _EnableInput_k__BackingField;
+ struct CookieManager* _CookieManager_k__BackingField;
+ int32_t browserId;
+ int32_t unsafeBrowserId;
+ bool browserIdRequested;
+ struct Texture2D* texture;
+ struct Action_1_UnityEngine_Texture2D_* afterResize;
+ bool textureIsOurs;
+ bool forceNextRender;
+ bool isPopup;
+ struct List_1_System_Action_* thingsToDo;
+ struct List_1_System_Action_* onloadActions;
+ struct List_1_System_Object_* thingsToRemember;
+ int32_t nextCallbackId;
+ struct Dictionary_2_System_Int32_ZenFulcrum_EmbeddedBrowser_Browser_JSResultFunc_* registeredCallbacks;
+ struct BrowserNative_ReadyFunc* onNativeReady;
+ struct Action_1_ZenFulcrum_EmbeddedBrowser_JSONNode_* onLoad;
+ struct Action_1_ZenFulcrum_EmbeddedBrowser_JSONNode_* onFetch;
+ struct Action_1_ZenFulcrum_EmbeddedBrowser_JSONNode_* onFetchError;
+ struct Action_1_ZenFulcrum_EmbeddedBrowser_JSONNode_* onCertError;
+ struct Action* onSadTab;
+ struct Action* onTextureUpdated;
+ struct Action* onNavStateChange;
+ struct Action_2_Int32_ZenFulcrum_EmbeddedBrowser_JSONNode_* onDownloadStarted;
+ struct Action_2_Int32_ZenFulcrum_EmbeddedBrowser_JSONNode_* onDownloadStatus;
+ struct Action_3_String_Boolean_String_* onNodeFocus;
+ struct Action_1_ZenFulcrum_EmbeddedBrowser_JSONNode_* onUniWebviewMsgReceive;
+ struct Action_1_ZenFulcrum_EmbeddedBrowser_JSONNode_* onBeforeNavigationMsgReceive;
+ struct Action_2_Boolean_Boolean_* onBrowserFocus;
+ struct BrowserFocusState* focusState;
+ struct BrowserInput* browserInput;
+ struct Browser* overlay;
+ bool skipNextLoad;
+ bool loadPending;
+ struct BrowserNavState* navState;
+ bool newWindowHandlerSet;
+ struct INewWindowHandler* newWindowHandler;
+ struct DialogHandler* dialogHandler;
+ struct Action* pageReplacer;
+ float pageReplacerPriority;
+ struct List_1_System_Action_* thingsToDoClone;
+ struct Color32__Array* colorBuffer;
+ };
+
+ struct Browser {
+ struct Browser__Class* klass;
+ MonitorData* monitor;
+ struct Browser__Fields fields;
+ };
+
#if !defined(_GHIDRA_) && !defined(_IDA_)
}
#endif
diff --git a/cheat-library/src/user/cheat/cheat.cpp b/cheat-library/src/user/cheat/cheat.cpp
index 18f7d8e..3c5b76b 100644
--- a/cheat-library/src/user/cheat/cheat.cpp
+++ b/cheat-library/src/user/cheat/cheat.cpp
@@ -45,6 +45,7 @@
#include
#include
#include
+#include
#include "GenshinCM.h"
@@ -101,7 +102,8 @@ namespace cheat
FEAT_INST(ChestIndicator),
FEAT_INST(ProfileChanger),
FEAT_INST(PaimonFollow),
- FEAT_INST(HideUI)
+ FEAT_INST(HideUI),
+ FEAT_INST(Browser)
});
#undef FEAT_INST
diff --git a/cheat-library/src/user/cheat/visuals/Browser.cpp b/cheat-library/src/user/cheat/visuals/Browser.cpp
new file mode 100644
index 0000000..1be0197
--- /dev/null
+++ b/cheat-library/src/user/cheat/visuals/Browser.cpp
@@ -0,0 +1,99 @@
+#include "pch-il2cpp.h"
+#include "Browser.h"
+
+#include
+#include
+#include
+
+#include
+
+namespace cheat::feature
+{
+ app::GameObject* planeObject = nullptr;
+ app::Component_1* BrowserComponents = nullptr;
+ static std::string f_URL;
+
+ Browser::Browser() : Feature(),
+ NF(f_Enabled, "Browser", "Visuals", false),
+ toBeUpdate(), nextUpdate(0)
+ {
+ events::GameUpdateEvent += MY_METHOD_HANDLER(Browser::OnGameUpdate);
+ }
+
+ const FeatureGUIInfo& Browser::GetGUIInfo() const
+ {
+ static const FeatureGUIInfo info{ "Browser", "Visuals", false };
+ return info;
+ }
+
+ void Browser::DrawMain()
+ {
+ ConfigWidget(f_Enabled, "Create in-game Browser");
+ ImGui::InputText("URL", &f_URL);
+ }
+
+ bool Browser::NeedStatusDraw() const
+ {
+ return f_Enabled;
+ }
+
+ void Browser::DrawStatus()
+ {
+ ImGui::Text("Browser");
+ }
+
+ Browser& Browser::GetInstance()
+ {
+ static Browser instance;
+ return instance;
+ }
+
+ void Browser::OnGameUpdate()
+ {
+ auto currentTime = util::GetCurrentTimeMillisec();
+ if (currentTime < nextUpdate)
+ return;
+
+ if (f_Enabled) {
+ if (planeObject == nullptr) {
+
+ auto PrimitiveType = app::PrimitiveType__Enum::Plane;
+ planeObject = app::GameObject_CreatePrimitive(PrimitiveType, nullptr);
+
+ app::Transform* planeObject_Transform = app::GameObject_get_transform(planeObject, nullptr);
+ app::Quaternion planeObject_Transform_Quaternion = { 0.5, 0.5, -0.5, 0.5};
+ auto avatarPos = app::ActorUtils_GetAvatarPos(nullptr);
+ auto relativePos = app::WorldShiftManager_GetRelativePosition(avatarPos, nullptr);
+ app::Vector3 planeObject_Transform_Vector3 = { relativePos.x, relativePos.y + 3, relativePos.z };
+ app::Vector3 planeObject_Transform_Scale = { 1, 1, 1};
+
+ app::Transform_set_localPosition(planeObject_Transform, planeObject_Transform_Vector3, nullptr);
+ app::Transform_set_localScale(planeObject_Transform, planeObject_Transform_Scale, nullptr);
+ app::Transform_set_localRotation(planeObject_Transform, planeObject_Transform_Quaternion, nullptr);
+ }
+
+ if (planeObject != nullptr) {
+ if (BrowserComponents == nullptr) {
+ std::string custom_url = f_URL.length() < 2 || f_URL.c_str() == "" ? "https://www.google.com/" : f_URL.c_str();
+
+ BrowserComponents = app::GameObject_AddComponentInternal(planeObject, string_to_il2cppi("Browser"), nullptr);
+ reinterpret_cast(BrowserComponents)->fields._url = string_to_il2cppi(custom_url);
+ reinterpret_cast(BrowserComponents)->fields._width = 1920;
+ reinterpret_cast(BrowserComponents)->fields._height = 1080;
+ reinterpret_cast(BrowserComponents)->fields.forceNextRender = true;
+ reinterpret_cast(BrowserComponents)->fields._EnableInput_k__BackingField = true;
+ }
+ }
+ }
+ else {
+ if (planeObject != nullptr && BrowserComponents != nullptr)
+ {
+ app::Object_1_DestroyImmediate_1(reinterpret_cast(planeObject), nullptr);
+ app::Object_1_DestroyImmediate_1(reinterpret_cast(BrowserComponents), nullptr);
+ planeObject = nullptr;
+ BrowserComponents = nullptr;
+ }
+ }
+ nextUpdate = currentTime + (int)f_DelayUpdate;
+ }
+}
\ No newline at end of file
diff --git a/cheat-library/src/user/cheat/visuals/Browser.h b/cheat-library/src/user/cheat/visuals/Browser.h
new file mode 100644
index 0000000..d6f0760
--- /dev/null
+++ b/cheat-library/src/user/cheat/visuals/Browser.h
@@ -0,0 +1,26 @@
+#pragma once
+#include
+#include
+#include
+
+namespace cheat::feature
+{
+ class Browser : public Feature
+ {
+ public:
+ config::Field> f_Enabled;
+
+ static Browser& GetInstance();
+ const FeatureGUIInfo& GetGUIInfo() const override;
+ void DrawMain() override;
+ virtual bool NeedStatusDraw() const override;
+ void DrawStatus() override;
+
+ private:
+ SafeQueue toBeUpdate;
+ SafeValue nextUpdate;
+ int f_DelayUpdate = 20.f;
+ void OnGameUpdate();
+ Browser();
+ };
+}
\ No newline at end of file