This repository was archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathHelpers.cs
106 lines (101 loc) · 3.45 KB
/
Helpers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using Il2CppInspector.Cpp.UnityHeaders;
using System.Collections.Generic;
using System.IO;
using Unitor.Core.Reflection;
namespace Unitor.Core
{
public static class Helpers
{
public static UnityVersion FromAssetFile(string filePath)
{
using var file = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var reader = new BinaryReader(file, System.Text.Encoding.UTF8);
var possibleOffsets = new List<int> { 0x14, 0x30 };
foreach (var offset in possibleOffsets)
{
file.Position = offset;
var bytes = new List<byte>();
var maxLength = 15;
byte b;
while ((b = reader.ReadByte()) != 0 && bytes.Count < maxLength)
{
bytes.Add(b);
}
var unityString = System.Text.Encoding.UTF8.GetString(bytes.ToArray());
return new UnityVersion(unityString);
}
return null;
}
public static bool IsUnityMonobehaviourMessage(UnitorMethod m)
{
return new List<string> {
"Awake",
"FixedUpdate",
"LateUpdate",
"OnAnimatorIK",
"OnAnimatorMove",
"OnApplicationFocus",
"OnApplicationPause",
"OnApplicationQuit",
"OnAudioFilterRead",
"OnBecameInvisible",
"OnBecameVisible",
"OnCollisionEnter",
"OnCollisionEnter2D",
"OnCollisionExit",
"OnCollisionExit2D",
"OnCollisionStay",
"OnCollisionStay2D",
"OnConnectedToServer",
"OnControllerColliderHit",
"OnDestroy",
"OnDisable",
"OnDisconnectedFromServer",
"OnDrawGizmos",
"OnDrawGizmosSelected",
"OnEnable",
"OnFailedToConnect",
"OnFailedToConnectToMasterServer",
"OnGUI",
"OnJointBreak",
"OnJointBreak2D",
"OnMasterServerEvent",
"OnMouseDown",
"OnMouseDrag",
"OnMouseEnter",
"OnMouseExit",
"OnMouseOver",
"OnMouseUp",
"OnMouseUpAsButton",
"OnNetworkInstantiate",
"OnParticleCollision",
"OnParticleSystemStopped",
"OnParticleTrigger",
"OnParticleUpdateJobScheduled",
"OnPlayerConnected",
"OnPlayerDisconnected",
"OnPostRender",
"OnPreCull",
"OnPreRender",
"OnRenderImage",
"OnRenderObject",
"OnSerializeNetworkView",
"OnServerInitialized",
"OnTransformChildrenChanged",
"OnTransformParentChanged",
"OnTriggerEnter",
"OnTriggerEnter2D",
"OnTriggerExit",
"OnTriggerExit2D",
"OnTriggerStay",
"OnTriggerStay2D",
"OnValidate",
"OnWillRenderObject",
"Reset",
"Start",
"Update",
"ctor"
}.Contains(m.Name);
}
}
}