Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 3c964cf

Browse files
committed
2.0.7
* More unstripping fixes. Explorer now works 100% on a blank Unity project (so should therefore work on any Unity game, regardless of stripping). * Some cleanups
1 parent 184b037 commit 3c964cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1279
-1201
lines changed

src/CacheObject/CacheMember.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ public void DrawArgsInput()
123123
label = $"<i>[{label} = {this.m_arguments[i].DefaultValue ?? "null"}]</i>";
124124
}
125125

126-
GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]);
126+
GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
127127

128128
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
129129

130130
GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
131131
GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) });
132-
this.m_argumentInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
132+
this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) });
133133

134134
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
135135

src/CacheObject/CacheMethod.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ public void DrawGenericArgsInput()
182182
}
183183
var input = this.GenericArgInput[i];
184184

185-
GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]);
185+
GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
186186

187187
GUI.skin.label.alignment = TextAnchor.MiddleCenter;
188188
GUILayout.Label(
189189
$"<color={Syntax.StructGreen}>{this.GenericArgs[i].Name}</color>",
190190
new GUILayoutOption[] { GUILayout.Width(15) }
191191
);
192-
this.GenericArgInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
192+
this.GenericArgInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
193193
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
194194
GUILayout.Label(types, new GUILayoutOption[0]);
195195

src/Explorer.csproj

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,19 @@
262262
<Compile Include="UI\WindowBase.cs" />
263263
<Compile Include="UI\WindowManager.cs" />
264264
<Compile Include="Unstrip\ImageConversion\ImageConversionUnstrip.cs" />
265-
<Compile Include="Unstrip\IMGUI\Internal_GUIUtility.cs" />
266-
<Compile Include="Unstrip\IMGUI\Internal_TextEditor.cs" />
265+
<Compile Include="Unstrip\IMGUI\GUIUtilityUnstrip.cs" />
266+
<Compile Include="Unstrip\IMGUI\TextEditorUnstrip.cs" />
267267
<Compile Include="Helpers\ICallHelper.cs" />
268268
<Compile Include="Unstrip\LayerMask\LayerMaskUnstrip.cs" />
269+
<Compile Include="Unstrip\Resources\ResourcesUnstrip.cs" />
269270
<Compile Include="Unstrip\Scene\SceneUnstrip.cs" />
270-
<Compile Include="Unstrip\IMGUI\GUIUnstrip.cs" />
271-
<Compile Include="Unstrip\IMGUI\Internal_LayoutUtility.cs" />
272-
<Compile Include="Unstrip\IMGUI\Internal_ScrollViewState.cs" />
273-
<Compile Include="Unstrip\IMGUI\Internal_SliderHandler.cs" />
271+
<Compile Include="Unstrip\IMGUI\GUIHelper.cs" />
272+
<Compile Include="Unstrip\IMGUI\LayoutUtilityUnstrip.cs" />
273+
<Compile Include="Unstrip\IMGUI\ScrollViewStateUnstrip.cs" />
274+
<Compile Include="Unstrip\IMGUI\SliderHandlerUnstrip.cs" />
274275
<Compile Include="Properties\AssemblyInfo.cs" />
275-
<Compile Include="Unstrip\IMGUI\Internal.cs" />
276-
<Compile Include="Unstrip\IMGUI\Internal_SliderState.cs" />
276+
<Compile Include="Unstrip\IMGUI\GUIUnstrip.cs" />
277+
<Compile Include="Unstrip\IMGUI\SliderStateUnstrip.cs" />
277278
</ItemGroup>
278279
<ItemGroup>
279280
<None Include="ILRepack.targets" />

src/ExplorerCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Explorer
1212
public class ExplorerCore
1313
{
1414
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
15-
public const string VERSION = "2.0.6";
15+
public const string VERSION = "2.0.7";
1616
public const string AUTHOR = "Sinai";
1717
public const string GUID = "com.sinai.explorer";
1818

src/Helpers/ICallHelper.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
using System.Runtime.InteropServices;
66
using System.Text;
77
using System.Reflection;
8+
using System.Diagnostics.CodeAnalysis;
89

910
namespace Explorer.Helpers
1011
{
12+
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "External methods")]
1113
public static class ICallHelper
1214
{
1315
private static readonly Dictionary<string, Delegate> iCallCache = new Dictionary<string, Delegate>();
@@ -32,14 +34,8 @@ public static T GetICall<T>(string iCallName) where T : Delegate
3234
return (T)iCall;
3335
}
3436

35-
#region External
36-
#pragma warning disable IDE1006 // Naming Styles
37-
3837
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
3938
public static extern IntPtr il2cpp_resolve_icall([MarshalAs(UnmanagedType.LPStr)] string name);
40-
41-
#pragma warning restore IDE1006
42-
#endregion
4339
}
4440
}
4541
#endif

src/Helpers/ReflectionHelpers.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Reflection;
66
using UnityEngine;
77
using BF = System.Reflection.BindingFlags;
8+
using System.Diagnostics.CodeAnalysis;
89
#if CPP
910
using ILType = Il2CppSystem.Type;
1011
using UnhollowerBaseLib;
@@ -14,6 +15,7 @@
1415

1516
namespace Explorer.Helpers
1617
{
18+
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "External methods")]
1719
public class ReflectionHelpers
1820
{
1921
public static BF CommonFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
@@ -51,36 +53,33 @@ public static object Il2CppCast(object obj, Type castTo)
5153
.GetField("NativeClassPtr", BF.Public | BF.Static)
5254
.GetValue(null);
5355

54-
if (castToPtr == IntPtr.Zero)
55-
{
56-
ExplorerCore.LogWarning($"[Il2CppCast] Could not get an IntPtr for castTo '{castTo.FullName}'!");
57-
//return obj;
58-
}
59-
6056
ClassPointers.Add(castTo, castToPtr);
6157
}
6258
else
6359
{
6460
castToPtr = ClassPointers[castTo];
6561
}
6662

67-
IntPtr objPtr = ilObj.Pointer;
68-
var classPtr = il2cpp_object_get_class(objPtr);
63+
if (castToPtr == IntPtr.Zero)
64+
return obj;
65+
66+
var classPtr = il2cpp_object_get_class(ilObj.Pointer);
6967

7068
if (!il2cpp_class_is_assignable_from(castToPtr, classPtr))
7169
return obj;
7270

73-
if (RuntimeSpecificsStore.IsInjected(classPtr))
74-
return UnhollowerBaseLib.Runtime.ClassInjectorBase.GetMonoObjectFromIl2CppPointer(objPtr);
71+
if (RuntimeSpecificsStore.IsInjected(castToPtr))
72+
return UnhollowerBaseLib.Runtime.ClassInjectorBase.GetMonoObjectFromIl2CppPointer(ilObj.Pointer);
7573

76-
return Activator.CreateInstance(castTo, objPtr);
74+
return Activator.CreateInstance(castTo, ilObj.Pointer);
7775
}
7876

7977
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
8078
public static extern bool il2cpp_class_is_assignable_from(IntPtr klass, IntPtr oklass);
8179

8280
[DllImport("GameAssembly", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
8381
public static extern IntPtr il2cpp_object_get_class(IntPtr obj);
82+
8483
#endif
8584

8685
public static Type GetTypeByName(string fullName)

src/Input/InputManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
using UnityEngine;
44
using Explorer.Input;
55
using Explorer.Helpers;
6+
using System.Diagnostics.CodeAnalysis;
67
#if CPP
78
using UnhollowerBaseLib;
89
#endif
910

1011
namespace Explorer
1112
{
13+
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Unity style")]
1214
public static class InputManager
1315
{
1416
private static IAbstractInput m_inputModule;
@@ -49,7 +51,6 @@ public static void Init()
4951
#endif
5052

5153
#if CPP
52-
#pragma warning disable IDE1006
5354
// public extern static string compositionString { get; }
5455

5556
internal delegate IntPtr d_get_compositionString();
@@ -82,8 +83,6 @@ public static Vector2 compositionCursorPos
8283
iCall.Invoke(ref value);
8384
}
8485
}
85-
86-
#pragma warning restore IDE1006
8786
#endif
8887
}
8988
}

src/Input/InputSystem.cs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,64 @@ namespace Explorer.Input
1010
{
1111
public class InputSystem : IAbstractInput
1212
{
13-
public static Type TKeyboard => _keyboard ?? (_keyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
14-
private static Type _keyboard;
13+
public static Type TKeyboard => m_tKeyboard ?? (m_tKeyboard = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Keyboard"));
14+
private static Type m_tKeyboard;
1515

16-
public static Type TMouse => _mouse ?? (_mouse = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Mouse"));
17-
private static Type _mouse;
16+
public static Type TMouse => m_tMouse ?? (m_tMouse = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Mouse"));
17+
private static Type m_tMouse;
1818

19-
public static Type TKey => _key ?? (_key = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Key"));
20-
private static Type _key;
19+
public static Type TKey => m_tKey ?? (m_tKey = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Key"));
20+
private static Type m_tKey;
2121

22-
private static PropertyInfo _btnIsPressedProp;
23-
private static PropertyInfo _btnWasPressedProp;
22+
private static PropertyInfo m_btnIsPressedProp;
23+
private static PropertyInfo m_btnWasPressedProp;
2424

25-
private static object CurrentKeyboard => _currentKeyboard ?? (_currentKeyboard = _kbCurrentProp.GetValue(null, null));
26-
private static object _currentKeyboard;
27-
private static PropertyInfo _kbCurrentProp;
28-
private static PropertyInfo _kbIndexer;
25+
private static object CurrentKeyboard => m_currentKeyboard ?? (m_currentKeyboard = m_kbCurrentProp.GetValue(null, null));
26+
private static object m_currentKeyboard;
27+
private static PropertyInfo m_kbCurrentProp;
28+
private static PropertyInfo m_kbIndexer;
2929

30-
private static object CurrentMouse => _currentMouse ?? (_currentMouse = _mouseCurrentProp.GetValue(null, null));
31-
private static object _currentMouse;
32-
private static PropertyInfo _mouseCurrentProp;
30+
private static object CurrentMouse => m_currentMouse ?? (m_currentMouse = m_mouseCurrentProp.GetValue(null, null));
31+
private static object m_currentMouse;
32+
private static PropertyInfo m_mouseCurrentProp;
3333

34-
private static object LeftMouseButton => _lmb ?? (_lmb = _leftButtonProp.GetValue(CurrentMouse, null));
35-
private static object _lmb;
36-
private static PropertyInfo _leftButtonProp;
34+
private static object LeftMouseButton => m_lmb ?? (m_lmb = m_leftButtonProp.GetValue(CurrentMouse, null));
35+
private static object m_lmb;
36+
private static PropertyInfo m_leftButtonProp;
3737

38-
private static object RightMouseButton => _rmb ?? (_rmb = _rightButtonProp.GetValue(CurrentMouse, null));
39-
private static object _rmb;
40-
private static PropertyInfo _rightButtonProp;
38+
private static object RightMouseButton => m_rmb ?? (m_rmb = m_rightButtonProp.GetValue(CurrentMouse, null));
39+
private static object m_rmb;
40+
private static PropertyInfo m_rightButtonProp;
4141

42-
private static object MousePositionInfo => _pos ?? (_pos = _positionProp.GetValue(CurrentMouse, null));
43-
private static object _pos;
44-
private static PropertyInfo _positionProp;
45-
private static MethodInfo _readVector2InputMethod;
42+
private static object MousePositionInfo => m_pos ?? (m_pos = m_positionProp.GetValue(CurrentMouse, null));
43+
private static object m_pos;
44+
private static PropertyInfo m_positionProp;
45+
private static MethodInfo m_readVector2InputMethod;
4646

47-
public Vector2 MousePosition => (Vector2)_readVector2InputMethod.Invoke(MousePositionInfo, new object[0]);
47+
public Vector2 MousePosition => (Vector2)m_readVector2InputMethod.Invoke(MousePositionInfo, new object[0]);
4848

4949
public bool GetKeyDown(KeyCode key)
5050
{
5151
var parsedKey = Enum.Parse(TKey, key.ToString());
52-
var actualKey = _kbIndexer.GetValue(CurrentKeyboard, new object[] { parsedKey });
52+
var actualKey = m_kbIndexer.GetValue(CurrentKeyboard, new object[] { parsedKey });
5353

54-
return (bool)_btnWasPressedProp.GetValue(actualKey, null);
54+
return (bool)m_btnWasPressedProp.GetValue(actualKey, null);
5555
}
5656

5757
public bool GetKey(KeyCode key)
5858
{
5959
var parsed = Enum.Parse(TKey, key.ToString());
60-
var actualKey = _kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed });
60+
var actualKey = m_kbIndexer.GetValue(CurrentKeyboard, new object[] { parsed });
6161

62-
return (bool)_btnIsPressedProp.GetValue(actualKey, null);
62+
return (bool)m_btnIsPressedProp.GetValue(actualKey, null);
6363
}
6464

6565
public bool GetMouseButtonDown(int btn)
6666
{
6767
switch (btn)
6868
{
69-
case 0: return (bool)_btnWasPressedProp.GetValue(LeftMouseButton, null);
70-
case 1: return (bool)_btnWasPressedProp.GetValue(RightMouseButton, null);
69+
case 0: return (bool)m_btnWasPressedProp.GetValue(LeftMouseButton, null);
70+
case 1: return (bool)m_btnWasPressedProp.GetValue(RightMouseButton, null);
7171
// case 2: return (bool)_btnWasPressedProp.GetValue(MiddleMouseButton, null);
7272
default: throw new NotImplementedException();
7373
}
@@ -77,8 +77,8 @@ public bool GetMouseButton(int btn)
7777
{
7878
switch (btn)
7979
{
80-
case 0: return (bool)_btnIsPressedProp.GetValue(LeftMouseButton, null);
81-
case 1: return (bool)_btnIsPressedProp.GetValue(RightMouseButton, null);
80+
case 0: return (bool)m_btnIsPressedProp.GetValue(LeftMouseButton, null);
81+
case 1: return (bool)m_btnIsPressedProp.GetValue(RightMouseButton, null);
8282
// case 2: return (bool)_btnIsPressedProp.GetValue(MiddleMouseButton, null);
8383
default: throw new NotImplementedException();
8484
}
@@ -88,21 +88,21 @@ public void Init()
8888
{
8989
ExplorerCore.Log("Initializing new InputSystem support...");
9090

91-
_kbCurrentProp = TKeyboard.GetProperty("current");
92-
_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
91+
m_kbCurrentProp = TKeyboard.GetProperty("current");
92+
m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
9393

9494
var btnControl = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Controls.ButtonControl");
95-
_btnIsPressedProp = btnControl.GetProperty("isPressed");
96-
_btnWasPressedProp = btnControl.GetProperty("wasPressedThisFrame");
95+
m_btnIsPressedProp = btnControl.GetProperty("isPressed");
96+
m_btnWasPressedProp = btnControl.GetProperty("wasPressedThisFrame");
9797

98-
_mouseCurrentProp = TMouse.GetProperty("current");
99-
_leftButtonProp = TMouse.GetProperty("leftButton");
100-
_rightButtonProp = TMouse.GetProperty("rightButton");
98+
m_mouseCurrentProp = TMouse.GetProperty("current");
99+
m_leftButtonProp = TMouse.GetProperty("leftButton");
100+
m_rightButtonProp = TMouse.GetProperty("rightButton");
101101

102-
_positionProp = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Pointer")
102+
m_positionProp = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.Pointer")
103103
.GetProperty("position");
104104

105-
_readVector2InputMethod = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.InputControl`1")
105+
m_readVector2InputMethod = ReflectionHelpers.GetTypeByName("UnityEngine.InputSystem.InputControl`1")
106106
.MakeGenericType(typeof(Vector2))
107107
.GetMethod("ReadValue");
108108
}

src/Input/LegacyInput.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,34 @@ namespace Explorer.Input
1010
{
1111
public class LegacyInput : IAbstractInput
1212
{
13-
public static Type TInput => _input ?? (_input = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
14-
private static Type _input;
13+
public static Type TInput => m_tInput ?? (m_tInput = ReflectionHelpers.GetTypeByName("UnityEngine.Input"));
14+
private static Type m_tInput;
1515

16-
private static PropertyInfo _mousePositionProp;
17-
private static MethodInfo _getKeyMethod;
18-
private static MethodInfo _getKeyDownMethod;
19-
private static MethodInfo _getMouseButtonMethod;
20-
private static MethodInfo _getMouseButtonDownMethod;
16+
private static PropertyInfo m_mousePositionProp;
17+
private static MethodInfo m_getKeyMethod;
18+
private static MethodInfo m_getKeyDownMethod;
19+
private static MethodInfo m_getMouseButtonMethod;
20+
private static MethodInfo m_getMouseButtonDownMethod;
2121

22-
public Vector2 MousePosition => (Vector3)_mousePositionProp.GetValue(null, null);
22+
public Vector2 MousePosition => (Vector3)m_mousePositionProp.GetValue(null, null);
2323

24-
public bool GetKey(KeyCode key) => (bool)_getKeyMethod.Invoke(null, new object[] { key });
24+
public bool GetKey(KeyCode key) => (bool)m_getKeyMethod.Invoke(null, new object[] { key });
2525

26-
public bool GetKeyDown(KeyCode key) => (bool)_getKeyDownMethod.Invoke(null, new object[] { key });
26+
public bool GetKeyDown(KeyCode key) => (bool)m_getKeyDownMethod.Invoke(null, new object[] { key });
2727

28-
public bool GetMouseButton(int btn) => (bool)_getMouseButtonMethod.Invoke(null, new object[] { btn });
28+
public bool GetMouseButton(int btn) => (bool)m_getMouseButtonMethod.Invoke(null, new object[] { btn });
2929

30-
public bool GetMouseButtonDown(int btn) => (bool)_getMouseButtonDownMethod.Invoke(null, new object[] { btn });
30+
public bool GetMouseButtonDown(int btn) => (bool)m_getMouseButtonDownMethod.Invoke(null, new object[] { btn });
3131

3232
public void Init()
3333
{
3434
ExplorerCore.Log("Initializing Legacy Input support...");
3535

36-
_mousePositionProp = TInput.GetProperty("mousePosition");
37-
_getKeyMethod = TInput.GetMethod("GetKey", new Type[] { typeof(KeyCode) });
38-
_getKeyDownMethod = TInput.GetMethod("GetKeyDown", new Type[] { typeof(KeyCode) });
39-
_getMouseButtonMethod = TInput.GetMethod("GetMouseButton", new Type[] { typeof(int) });
40-
_getMouseButtonDownMethod = TInput.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) });
36+
m_mousePositionProp = TInput.GetProperty("mousePosition");
37+
m_getKeyMethod = TInput.GetMethod("GetKey", new Type[] { typeof(KeyCode) });
38+
m_getKeyDownMethod = TInput.GetMethod("GetKeyDown", new Type[] { typeof(KeyCode) });
39+
m_getMouseButtonMethod = TInput.GetMethod("GetMouseButton", new Type[] { typeof(int) });
40+
m_getMouseButtonDownMethod = TInput.GetMethod("GetMouseButtonDown", new Type[] { typeof(int) });
4141
}
4242
}
4343
}

0 commit comments

Comments
 (0)