Skip to content

Instantly share code, notes, and snippets.

@davidzech
Created April 23, 2014 02:36
Show Gist options
  • Save davidzech/11201102 to your computer and use it in GitHub Desktop.
Save davidzech/11201102 to your computer and use it in GitHub Desktop.
Curses stuipd League of Legends hack
using Coherent.UI.Binding;
using Curse.Companion.Scripting;
using Curse.CurseClient.Shared;
using Curse.Logging;
using Curse.Tools.LoL;
using EasyHook;
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
namespace Curse.Companion
{
public class InternalLoLTimers : IDisposable
{
private LocalHook localHook_0;
private bool bool_0;
private ConcurrentQueue<byte[]> concurrentQueue_0;
private Thread thread_0;
private ENET.Connection connection_0;
private string string_0;
private Dictionary<string, Dictionary<uint, object>> dictionary_0;
private List<string> list_0;
private Dictionary<uint, int> dictionary_1;
private Dictionary<string, int> dictionary_2;
private string string_1;
private int PbhbrrdInw;
private float float_0;
private DateTime dateTime_0;
private bool bool_1;
private Dictionary<string, Dictionary<string, InternalLoLTimers.AbilityEventData>> dictionary_3;
private Dictionary<string, ReplayRealm> dictionary_4;
public List<InternalLoLTimers.CampDefinition> AllCamps;
public List<InternalLoLTimers.CampDefinition> SummonersRiftCamps;
public Dictionary<uint, string> CampNameByCreepName;
public Dictionary<string, int> CreepCountByCampName;
public Dictionary<string, InternalLoLTimers.CampDefinition> CampDefinitionByCampName;
public bool _endOfGame;
public Dictionary<uint, Dictionary<int, InternalLoLTimers.AbilityChargeData>> AbilityChargeDataByUnitIdAndSlot;
private Dictionary<uint, string> dqmbewWsSf;
private Dictionary<uint, string> dictionary_5;
public List<uint> bruteforce;
public Dictionary<uint, InternalLoLTimers.PlayerEventData> AccumulatedPlayerData;
private readonly object object_0;
public InternalLoLTimers()
{
Class11.FG5wmHOzBXSvR();
this.concurrentQueue_0 = new ConcurrentQueue<byte[]>();
this.dictionary_0 = new Dictionary<string, Dictionary<uint, object>>();
this.list_0 = new List<string>()
{
"",
""
};
this.dictionary_1 = new Dictionary<uint, int>();
this.dictionary_2 = new Dictionary<string, int>();
this.string_1 = "";
this.PbhbrrdInw = -2;
this.dateTime_0 = DateTime.Now;
this.dictionary_3 = new Dictionary<string, Dictionary<string, InternalLoLTimers.AbilityEventData>>();
this.dictionary_4 = new Dictionary<string, ReplayRealm>();
List<InternalLoLTimers.CampDefinition> campDefinitions = new List<InternalLoLTimers.CampDefinition>();
string str = Class8.smethod_10(6794);
int[] numArray = new int[] { 1164118836, 1114636288, 1173193468 };
List<string> strs = new List<string>()
{
Class8.smethod_10(6824),
Class8.smethod_10(6852)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str, 1, numArray, 115f, 300f, strs, 0));
string str1 = Class8.smethod_10(6878);
int[] numArray1 = new int[] { 1163057882, 1114636288, 1170373316 };
List<string> strs1 = new List<string>()
{
Class8.smethod_10(6908),
Class8.smethod_10(6920)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str1, 2, numArray1, 100f, 50f, strs1, 0));
string str2 = Class8.smethod_10(6942);
int[] numArray2 = new int[] { 1170530406, 1114636288, 1168482427 };
List<string> strs2 = new List<string>()
{
Class8.smethod_10(6972),
Class8.smethod_10(7000)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str2, 3, numArray2, 100f, 50f, strs2, 0));
string str3 = Class8.smethod_10(7016);
int[] numArray3 = new int[] { 1172897004, 1114636288, 1165173566 };
List<string> strs3 = new List<string>()
{
Class8.smethod_10(7046),
Class8.smethod_10(6852)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str3, 4, numArray3, 115f, 300f, strs3, 0));
string str4 = Class8.smethod_10(7072);
int[] numArray4 = new int[] { 1173841597, 1114636288, 1159618410 };
List<string> strs4 = new List<string>()
{
Class8.smethod_10(7102),
Class8.smethod_10(7126)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str4, 5, numArray4, 100f, 60f, strs4, 0));
string str5 = Class8.smethod_10(7140);
int[] numArray5 = new int[] { 1175703060, 1114636288, 1166215229 };
List<string> strs5 = new List<string>()
{
Class8.smethod_10(7170)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str5, 6, numArray5, 150f, 360f, strs5, 1));
string str6 = Class8.smethod_10(7186);
int[] numArray6 = new int[] { 1176652396, 1114636288, 1171577062 };
List<string> strs6 = new List<string>()
{
Class8.smethod_10(6824),
Class8.smethod_10(6852)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str6, 7, numArray6, 115f, 300f, strs6, 0));
string str7 = Class8.smethod_10(7216);
int[] numArray7 = new int[] { 1176923672, 1114636288, 1174250341 };
List<string> strs7 = new List<string>()
{
Class8.smethod_10(6908),
Class8.smethod_10(6920)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str7, 8, numArray7, 100f, 50f, strs7, 0));
string str8 = Class8.smethod_10(7246);
int[] numArray8 = new int[] { 1173152498, 1114636288, 1175488927 };
List<string> strs8 = new List<string>()
{
Class8.smethod_10(6972),
Class8.smethod_10(7000)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str8, 9, numArray8, 100f, 50f, strs8, 0));
string str9 = Class8.smethod_10(7276);
int[] numArray9 = new int[] { 1170948589, 1114636288, 1176855104 };
List<string> strs9 = new List<string>()
{
Class8.smethod_10(7046),
Class8.smethod_10(6852)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str9, 10, numArray9, 115f, 300f, strs9, 0));
string str10 = Class8.smethod_10(7308);
int[] numArray10 = new int[] { 1169527734, 1114636288, 1178228197 };
List<string> strs10 = new List<string>()
{
Class8.smethod_10(7102),
Class8.smethod_10(7126)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str10, 11, numArray10, 100f, 60f, strs10, 0));
string str11 = Class8.smethod_10(7340);
int[] numArray11 = new int[] { 1167049718, 1114636288, 1176512985 };
List<string> strs11 = new List<string>()
{
Class8.smethod_10(7372)
};
campDefinitions.Add(new InternalLoLTimers.CampDefinition(str11, 12, numArray11, 900f, 420f, strs11, 2));
this.SummonersRiftCamps = campDefinitions;
this.AbilityChargeDataByUnitIdAndSlot = new Dictionary<uint, Dictionary<int, InternalLoLTimers.AbilityChargeData>>();
this.dqmbewWsSf = new Dictionary<uint, string>();
this.dictionary_5 = new Dictionary<uint, string>();
this.bruteforce = new List<uint>()
{
3328981
};
this.AccumulatedPlayerData = new Dictionary<uint, InternalLoLTimers.PlayerEventData>();
this.object_0 = new object();
base();
try
{
string commandLineArgs = Environment.GetCommandLineArgs()[4];
char[] chrArray = new char[] { ' ' };
this.string_0 = commandLineArgs.Split(chrArray)[2];
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), Class8.smethod_10(7426));
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), string.Format(Class8.smethod_10(7480), this.string_0));
this.ComputeCreepCamps();
this.ComputeAbilities();
this.ComputeRealms();
this.connection_0 = new ENET.Connection(this.string_0)
{
Callback = new ENET.Connection.GDelegate0(this.Callback)
};
Logger.Info(Class8.smethod_10(7508), null);
this.localHook_0 = LocalHook.Create(LocalHook.GetProcAddress(Class8.smethod_10(7550), Class8.smethod_10(7574)), new InternalLoLTimers.Delegate0(this.method_2), this);
this.localHook_0.ThreadACL.SetExclusiveACL(new int[1]);
this.thread_0 = new Thread(new ThreadStart(this.method_1))
{
IsBackground = true
};
this.thread_0.Start();
Logger.Info(Class8.smethod_10(7600), null);
}
catch (Exception exception)
{
Logger.Error(exception, null, null);
}
}
public void Callback(ENET.GamePacket packet)
{
List<uint> nums;
try
{
if ((int)packet.data.Length < 1)
{
return;
}
}
catch (Exception exception)
{
Logger.Error(exception, Class8.smethod_10(7904), null);
return;
}
uint num = packet.data[0];
if (num == 254 && (int)packet.data.Length >= 7)
{
num = BitConverter.ToUInt16(packet.data, 5);
}
int num1 = (int)(num >> 8);
uint num2 = num & 255;
int num3 = -1;
try
{
if (num1 < this.list_0.Count)
{
string str = string.Format(Class8.smethod_10(7960), num2);
int num4 = 0;
while (num4 < this.list_0[num1].Length)
{
if (this.list_0[num1].Substring(num4, 2) == str)
{
num3 = num4 / 2 + 1000 * num1;
goto Label1;
}
else
{
num4 = num4 + 2;
}
}
}
Label1:
}
catch (Exception exception1)
{
Logger.Error(exception1, Class8.smethod_10(7980), null);
return;
}
int num5 = num3;
switch (num5)
{
case 0:
{
try
{
this._endOfGame = true;
Logger.Info(Class8.smethod_10(8070), null);
CompanionManager.Instance.ChangeGameState(GameStates.EndOfGame);
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8094));
CompanionManager.Instance.TriggerShutdown();
break;
}
catch (Exception exception2)
{
Logger.Error((Exception)exception2, Class8.smethod_10(8136), null);
break;
}
break;
}
case 1:
{
try
{
int num6 = packet.data[65];
uint num7 = BitConverter.ToUInt32(packet.data, 1);
if (this.GetTeam(num7) == this.PbhbrrdInw)
{
uint num8 = BitConverter.ToUInt32(packet.data, 12);
string item = null;
string item1 = string.Format(Class8.smethod_10(4628), num7);
string str1 = string.Format(Class8.smethod_10(4628), num7);
if (this.dqmbewWsSf.ContainsKey(num7))
{
item1 = this.dqmbewWsSf[num7];
}
if (this.dictionary_5.ContainsKey(num7))
{
str1 = this.dictionary_5[num7];
}
Dictionary<uint, object> nums1 = this.dictionary_0[Class8.smethod_10(8152)];
int num9 = 2;
if (nums1.ContainsKey(num8))
{
item = (string)nums1[num8];
}
else if (this.dictionary_0.ContainsKey(str1))
{
nums1 = this.dictionary_0[str1];
if (nums1.ContainsKey(num8))
{
item = string.Concat(Class8.smethod_10(8184)[(int)((long)nums1[num8])]);
num9 = 1;
}
}
if (item != null)
{
InternalLoLTimers.AbilityEventData single = new InternalLoLTimers.AbilityEventData();
if (num9 != 1)
{
single.AbilitySlot = "";
single.AbilityName = item;
}
else
{
single.AbilitySlot = item;
}
single.PlayerName = item1;
single.HeroName = str1;
single.PlayerSlot = 0;
single.CooldownTime = BitConverter.ToSingle(packet.data, 78 + num6 * 17);
float single1 = BitConverter.ToSingle(packet.data, 78 + num6 * 17 + 30);
single.AbilityType = (float)num9;
DateTime now = DateTime.Now;
double deltaTime = this.GetDeltaTime(now);
TimeSpan dateTime = now - new DateTime(1970, 1, 1);
single.Time = (float)((double)this.float_0 + deltaTime);
single.EpochTime = dateTime.TotalMilliseconds;
if (num9 == 1)
{
int item2 = (int)((long)nums1[num8]) - 1;
float single2 = 0f;
if (this.method_4(num7, item2, single.Time, 1, single.CooldownTime, single1, out single2))
{
single.CooldownTime = single2;
}
}
List<uint> nums2 = new List<uint>();
for (int i = 0; i < num6; i++)
{
nums2.Add(BitConverter.ToUInt32(packet.data, 66 + i * 17));
}
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8198), single);
InternalLoLTimers.AbilityEventData abilityEventDatum = single;
if (nums2.Count > 0)
{
nums = nums2;
}
else
{
nums = null;
}
this.method_7(abilityEventDatum, nums);
}
}
break;
}
catch (Exception exception4)
{
Exception exception3 = exception4;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), exception3.ToString());
Logger.Error((Exception)exception3, Class8.smethod_10(8244), null);
break;
}
break;
}
case 2:
{
try
{
uint num10 = BitConverter.ToUInt32(packet.data, 5);
string str2 = this.wxevKuYvtK(packet.data, 23);
string str3 = this.wxevKuYvtK(packet.data, 151);
if (!this.dqmbewWsSf.ContainsKey(num10))
{
this.dqmbewWsSf.Add(num10, str2);
}
else
{
this.dqmbewWsSf[num10] = str2;
}
if (!this.dictionary_5.ContainsKey(num10))
{
this.dictionary_5.Add(num10, str3);
}
else
{
this.dictionary_5[num10] = str3;
}
int num11 = BitConverter.ToInt32(packet.data, 9);
int num12 = 1 ^ packet.data[15];
int num13 = packet.data[18];
int num14 = packet.data[19];
if (!this.dictionary_1.ContainsKey(num10))
{
this.dictionary_1.Add(num10, num12);
if (!this.dictionary_2.ContainsKey(str2))
{
this.dictionary_2.Add(str2, num12);
}
if (str2 == this.string_1)
{
this.PbhbrrdInw = num12;
}
InternalLoLTimers.PlayerEventData playerEventDatum = new InternalLoLTimers.PlayerEventData()
{
PlayerName = str2,
HeroName = str3,
ClientID = num11,
TeamID = num12,
TeamSlot = num13,
SkinID = num14
};
this.AccumulatedPlayerData.Add(num10, playerEventDatum);
}
break;
}
catch (Exception exception6)
{
Exception exception5 = exception6;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), exception5.ToString());
Logger.Error((Exception)exception5, Class8.smethod_10(8260), null);
break;
}
break;
}
case 3:
case 5:
{
break;
}
case 4:
{
try
{
int[] numArray = new int[] { BitConverter.ToInt32(packet.data, 5), BitConverter.ToInt32(packet.data, 9), BitConverter.ToInt32(packet.data, 13) };
string str4 = this.FindCampNameFromPosition(numArray);
if (str4 != null)
{
this.CreepCountByCampName[str4] = 0;
InternalLoLTimers.CampDefinition campDefinition = this.CampDefinitionByCampName[str4];
InternalLoLTimers.JungleEventData float0 = new InternalLoLTimers.JungleEventData()
{
CampName = str4,
RespawnTime = 0f,
CampSlot = campDefinition.Slot
};
DateTime now1 = DateTime.Now;
double deltaTime1 = this.GetDeltaTime(now1);
TimeSpan timeSpan = now1 - new DateTime(1970, 1, 1);
float0.Time = (float)((double)this.float_0 + deltaTime1);
float0.EpochTime = timeSpan.TotalMilliseconds;
float0.Hidden = 0;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8276), float0);
}
break;
}
catch (Exception exception8)
{
Exception exception7 = exception8;
Logger.Error((Exception)exception7, Class8.smethod_10(8326), null);
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), string.Concat(Class8.smethod_10(8342), exception7.ToString()));
break;
}
break;
}
case 6:
{
try
{
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8354));
break;
}
catch (Exception exception9)
{
Logger.Error((Exception)exception9, Class8.smethod_10(8398), null);
break;
}
break;
}
case 7:
{
try
{
if (BitConverter.ToInt32(packet.data, 5) == -1)
{
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8414));
}
break;
}
catch (Exception exception10)
{
Logger.Error((Exception)exception10, Class8.smethod_10(8462), null);
break;
}
break;
}
case 8:
{
try
{
uint num15 = BitConverter.ToUInt32(packet.data, 1);
if (this.GetTeam(num15) == this.PbhbrrdInw)
{
string item3 = null;
if (this.dqmbewWsSf.ContainsKey(num15))
{
item3 = this.dqmbewWsSf[num15];
}
if (item3 != null)
{
string str5 = this.wxevKuYvtK(packet.data, 7);
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), string.Format(Class8.smethod_10(8478), item3, str5));
}
}
break;
}
catch (Exception exception11)
{
Logger.Error((Exception)exception11, Class8.smethod_10(8520), null);
break;
}
break;
}
case 9:
{
try
{
uint num16 = BitConverter.ToUInt32(packet.data, 1);
if (this.GetTeam(num16) == this.PbhbrrdInw)
{
string item4 = string.Format(Class8.smethod_10(4628), num16);
if (this.dqmbewWsSf.ContainsKey(num16))
{
item4 = this.dqmbewWsSf[num16];
}
InternalLoLTimers.SkillUpEventData skillUpEventDatum = new InternalLoLTimers.SkillUpEventData()
{
PlayerName = item4,
AbilitySlot = string.Concat(Class8.smethod_10(8536)[packet.data[5]]),
TotalPoints = packet.data[6]
};
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8548), skillUpEventDatum);
}
break;
}
catch (Exception exception12)
{
Logger.Error((Exception)exception12, Class8.smethod_10(8586), null);
break;
}
break;
}
case 10:
{
try
{
if (this._endOfGame || this.bool_1)
{
InternalLoLTimers.GameTimeEventData totalMilliseconds = new InternalLoLTimers.GameTimeEventData()
{
Time = BitConverter.ToSingle(packet.data, 5)
};
DateTime dateTime1 = DateTime.Now;
TimeSpan timeSpan1 = dateTime1 - new DateTime(1970, 1, 1);
totalMilliseconds.EpochTime = timeSpan1.TotalMilliseconds;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8740), totalMilliseconds);
this.float_0 = totalMilliseconds.Time;
this.dateTime_0 = dateTime1;
break;
}
else
{
this.bool_1 = true;
if (!CompanionManager.Instance.IsGameLoaded)
{
CompanionManager.Instance.ChangeGameState(GameStates.InGame);
CompanionManager.Instance.IsGameLoaded = true;
Logger.Info(Class8.smethod_10(8602), null);
this.SubmitPlayerData();
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8688), Class8.smethod_10(8724));
}
break;
}
}
catch (Exception exception13)
{
Logger.Error((Exception)exception13, Class8.smethod_10(8780), null);
break;
}
break;
}
case 11:
{
try
{
if (!this._endOfGame && !CompanionManager.Instance.IsGameLoaded)
{
CompanionManager.Instance.ChangeGameState(GameStates.InGame);
CompanionManager.Instance.IsGameLoaded = true;
Logger.Info(Class8.smethod_10(8798), null);
this.SubmitPlayerData();
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8688), Class8.smethod_10(8724));
}
break;
}
catch (Exception exception14)
{
Logger.Error((Exception)exception14, Class8.smethod_10(8894), null);
break;
}
break;
}
case 12:
{
try
{
uint num17 = BitConverter.ToUInt32(packet.data, 1);
if (this.GetTeam(num17) == this.PbhbrrdInw)
{
uint num18 = BitConverter.ToUInt32(packet.data, 6);
string item5 = string.Format(Class8.smethod_10(4628), num18);
string item6 = null;
string str6 = string.Format(Class8.smethod_10(4628), num17);
if (this.dqmbewWsSf.ContainsKey(num17))
{
item6 = this.dqmbewWsSf[num17];
}
if (this.dictionary_5.ContainsKey(num17))
{
str6 = this.dictionary_5[num17];
}
Dictionary<uint, object> nums3 = this.dictionary_0[Class8.smethod_10(8152)];
int num19 = 2;
if (nums3.ContainsKey(num18))
{
item5 = (string)nums3[num18];
}
else if (this.dictionary_0.ContainsKey(str6))
{
nums3 = this.dictionary_0[str6];
if (nums3.ContainsKey(num18))
{
item5 = string.Concat(Class8.smethod_10(8184)[(int)((long)nums3[num18])]);
num19 = 1;
}
}
if (item5 != null && item6 != null)
{
InternalLoLTimers.AbilityEventData abilityEventDatum1 = new InternalLoLTimers.AbilityEventData();
if (num19 != 1)
{
abilityEventDatum1.AbilitySlot = "";
abilityEventDatum1.AbilityName = item5;
}
else
{
abilityEventDatum1.AbilitySlot = item5;
}
abilityEventDatum1.PlayerName = item6;
abilityEventDatum1.HeroName = str6;
abilityEventDatum1.PlayerSlot = 0;
abilityEventDatum1.CooldownTime = (float)packet.data[5];
abilityEventDatum1.AbilityType = (float)num19;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8912), abilityEventDatum1);
}
}
break;
}
catch (Exception exception15)
{
Logger.Error((Exception)exception15, Class8.smethod_10(8970), null);
break;
}
break;
}
case 13:
{
try
{
ulong num20 = BitConverter.ToUInt64(packet.data, 5);
string str7 = this.wxevKuYvtK(packet.data, 13);
string str8 = this.wxevKuYvtK(packet.data, 45);
string string0 = this.string_0;
InternalLoLTimers.GameStartEventData gameStartEventDatum = new InternalLoLTimers.GameStartEventData()
{
PlayerName = str8,
GameID = string.Format(Class8.smethod_10(4608), num20),
GameRealm = str7,
GameRegion = this.GetRegionFromRealmName(str7),
GameKey = string0
};
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8988), gameStartEventDatum);
CompanionManager.Instance.GameID = string.Format(Class8.smethod_10(4608), num20);
this.string_1 = str8;
if (this.PbhbrrdInw == -2 && this.dictionary_2.ContainsKey(str8))
{
this.PbhbrrdInw = this.dictionary_2[str8];
}
break;
}
catch (Exception exception16)
{
Logger.Error((Exception)exception16, Class8.smethod_10(9030), null);
break;
}
break;
}
case 14:
{
try
{
this.bool_1 = true;
InternalLoLTimers.GameMapEventData gameMapEventDatum = new InternalLoLTimers.GameMapEventData()
{
MapID = packet.data[6]
};
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(9048), gameMapEventDatum);
break;
}
catch (Exception exception18)
{
Exception exception17 = exception18;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), exception17.ToString());
Logger.Error((Exception)exception17, Class8.smethod_10(9086), null);
break;
}
break;
}
case 15:
{
try
{
if ((int)packet.data.Length >= 14)
{
int num21 = BitConverter.ToInt32(packet.data, 9);
int num22 = packet.data[13];
string str9 = string.Format(Class8.smethod_10(9104), num21);
if (this.CampDefinitionByCampName.ContainsKey(str9))
{
InternalLoLTimers.CampDefinition campDefinition1 = this.CampDefinitionByCampName[str9];
InternalLoLTimers.JungleEventData jungleEventDatum = new InternalLoLTimers.JungleEventData()
{
CampName = str9,
RespawnTime = campDefinition1.RespawnTime,
CampSlot = campDefinition1.Slot
};
DateTime now2 = DateTime.Now;
double deltaTime2 = this.GetDeltaTime(now2);
TimeSpan dateTime2 = now2 - new DateTime(1970, 1, 1);
jungleEventDatum.Time = (float)((double)this.float_0 + deltaTime2);
jungleEventDatum.EpochTime = dateTime2.TotalMilliseconds;
jungleEventDatum.Hidden = num22 & 1;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8276), jungleEventDatum);
}
}
break;
}
catch (Exception exception20)
{
Exception exception19 = exception20;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), exception19.ToString());
Logger.Error((Exception)exception19, Class8.smethod_10(9138), null);
break;
}
break;
}
case 16:
{
try
{
uint num23 = BitConverter.ToUInt32(packet.data, 1);
string item7 = string.Format(Class8.smethod_10(4628), num23);
string item8 = string.Format(Class8.smethod_10(4628), num23);
if (this.dqmbewWsSf.ContainsKey(num23))
{
item7 = this.dqmbewWsSf[num23];
}
if (this.dictionary_5.ContainsKey(num23))
{
item8 = this.dictionary_5[num23];
}
int num24 = packet.data[5];
float single3 = BitConverter.ToSingle(packet.data, 6);
BitConverter.ToSingle(packet.data, 10);
num24 = num24 & 127;
int num25 = ((num24 & 64) == 64 ? 2 : 1);
string str10 = Class8.smethod_10(9156);
if (num24 >= 0 && num24 <= 3)
{
str10 = string.Concat(Class8.smethod_10(8536)[num24]);
}
if (num25 == 1)
{
InternalLoLTimers.AbilityEventData float01 = new InternalLoLTimers.AbilityEventData();
if (num25 != 1)
{
float01.AbilitySlot = "";
float01.AbilityName = str10;
}
else
{
float01.AbilitySlot = str10;
}
float01.PlayerName = item7;
float01.HeroName = item8;
float01.PlayerSlot = 0;
float01.CooldownTime = single3;
float01.AbilityType = (float)num25;
DateTime now3 = DateTime.Now;
double deltaTime3 = this.GetDeltaTime(now3);
TimeSpan timeSpan2 = now3 - new DateTime(1970, 1, 1);
float01.Time = (float)((double)this.float_0 + deltaTime3);
float01.EpochTime = timeSpan2.TotalMilliseconds;
float single4 = 0f;
if (this.method_4(num23, num24, float01.Time, 0, float01.CooldownTime, 0f, out single4))
{
float01.CooldownTime = single4;
}
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8198), float01);
}
break;
}
catch (Exception exception22)
{
Exception exception21 = exception22;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), exception21.ToString());
Logger.Error(Class8.smethod_10(9162), exception21);
break;
}
break;
}
default:
{
switch (num5)
{
case 1000:
{
break;
}
case 1001:
{
try
{
uint num26 = BitConverter.ToUInt32(packet.data, 1);
int num27 = packet.data[8];
int num28 = BitConverter.ToInt32(packet.data, 12);
float single5 = BitConverter.ToSingle(packet.data, 20);
float single6 = BitConverter.ToSingle(packet.data, 24);
string item9 = string.Format(Class8.smethod_10(4628), num26);
string item10 = string.Format(Class8.smethod_10(4628), num26);
if (this.dqmbewWsSf.ContainsKey(num26))
{
item9 = this.dqmbewWsSf[num26];
}
if (this.dictionary_5.ContainsKey(num26))
{
item10 = this.dictionary_5[num26];
}
this.method_3(num26, num27, num28, single5, single6);
string str11 = Class8.smethod_10(9156);
if (num27 >= 0 && num27 <= 3)
{
str11 = string.Concat(Class8.smethod_10(8536)[num27]);
}
InternalLoLTimers.AbilityEventData totalMilliseconds1 = new InternalLoLTimers.AbilityEventData()
{
AbilitySlot = str11,
PlayerName = item9,
HeroName = item10,
PlayerSlot = 0,
CooldownTime = 0f,
AbilityType = 1f
};
DateTime dateTime3 = DateTime.Now;
double deltaTime4 = this.GetDeltaTime(dateTime3);
TimeSpan timeSpan3 = dateTime3 - new DateTime(1970, 1, 1);
totalMilliseconds1.Time = (float)((double)this.float_0 + deltaTime4);
totalMilliseconds1.EpochTime = timeSpan3.TotalMilliseconds;
float single7 = 0f;
if (this.method_4(num26, num27, totalMilliseconds1.Time, 0, totalMilliseconds1.CooldownTime, 0f, out single7))
{
totalMilliseconds1.CooldownTime = single7;
}
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8198), totalMilliseconds1);
}
catch (Exception exception24)
{
Exception exception23 = exception24;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), exception23.ToString());
Logger.Error(Class8.smethod_10(9162), exception23);
}
break;
}
default:
{
return;
}
}
break;
}
}
}
public void ComputeAbilities()
{
byte[] numArray = this.LoadEmbeddedData(Class8.smethod_10(6668));
int num = 0;
if (numArray[0] == 239)
{
num = 3;
}
string str = Encoding.UTF8.GetString(numArray, num, (int)numArray.Length - num);
Dictionary<string, object> strs = JsonConvert.DeserializeObject<Dictionary<string, object>>(str);
this.dictionary_0 = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<uint, object>>>(JsonConvert.SerializeObject(strs[Class8.smethod_10(6730)]));
List<string> strs1 = new List<string>()
{
(string)strs[Class8.smethod_10(6752)],
(string)strs[Class8.smethod_10(6764)]
};
this.list_0 = strs1;
}
public void ComputeCreepCamps()
{
this.AllCamps = new List<InternalLoLTimers.CampDefinition>();
foreach (InternalLoLTimers.CampDefinition summonersRiftCamp in this.SummonersRiftCamps)
{
List<string> strs = new List<string>();
foreach (string creepName in summonersRiftCamp.CreepNames)
{
for (int i = 1; i <= 1; i++)
{
for (int j = 1; j <= 9; j++)
{
string str = Class8.smethod_10(7660);
object[] campNumber = new object[] { creepName, summonersRiftCamp.CampNumber, i, j };
strs.Add(string.Format(str, campNumber));
}
}
}
this.AllCamps.Add(new InternalLoLTimers.CampDefinition(summonersRiftCamp.Name, summonersRiftCamp.CampNumber, summonersRiftCamp.PositionRaw, summonersRiftCamp.InitialTime, summonersRiftCamp.RespawnTime, strs, summonersRiftCamp.Slot));
}
this.CampNameByCreepName = new Dictionary<uint, string>();
this.CreepCountByCampName = new Dictionary<string, int>(StringComparer.InvariantCultureIgnoreCase);
this.CampDefinitionByCampName = new Dictionary<string, InternalLoLTimers.CampDefinition>(StringComparer.InvariantCultureIgnoreCase);
foreach (InternalLoLTimers.CampDefinition allCamp in this.AllCamps)
{
this.CampDefinitionByCampName.Add(allCamp.Name, allCamp);
this.CreepCountByCampName.Add(allCamp.Name, 0);
foreach (string creepName1 in allCamp.CreepNames)
{
}
}
}
public void ComputeRealms()
{
foreach (KeyValuePair<string, ReplayRealm> realm in ReplayRealm.Realms)
{
this.dictionary_4.Add(realm.Value.RealmNameNumbered, realm.Value);
}
}
public void Dispose()
{
try
{
lock (this.object_0)
{
this.bool_0 = true;
if (this.localHook_0 != null)
{
this.localHook_0.ThreadACL.SetInclusiveACL(new int[1]);
this.localHook_0.Dispose();
}
}
}
catch (Exception exception)
{
Logger.Error(exception, null, null);
}
}
public string FindCampNameFromPosition(int[] position)
{
string name;
List<InternalLoLTimers.CampDefinition>.Enumerator enumerator = this.AllCamps.GetEnumerator();
try
{
Label2:
while (enumerator.MoveNext())
{
InternalLoLTimers.CampDefinition current = enumerator.Current;
for (int i = 0; i < 3; i++)
{
if (i != 1)
{
if (current.PositionRaw[i] != position[i])
{
goto Label2;
}
if (i == 2)
{
name = current.Name;
return name;
}
}
}
}
return null;
}
finally
{
((IDisposable)enumerator).Dispose();
}
return name;
}
public string FindCampNameFromPosition(int x, int y, int z)
{
int[] numArray = new int[] { x, y, z };
return this.FindCampNameFromPosition(numArray);
}
public double GetDeltaTime(DateTime when)
{
return (when - this.dateTime_0).TotalSeconds;
}
public string GetRegionFromRealmName(string realm)
{
if (!this.dictionary_4.ContainsKey(realm))
{
return Class8.smethod_10(6776);
}
return this.dictionary_4[realm].RealmName;
}
public int GetTeam(uint uid)
{
if (!this.dictionary_1.ContainsKey(uid))
{
return -1;
}
return this.dictionary_1[uid];
}
public byte[] LoadEmbeddedData(string name)
{
Assembly assembly = typeof(AddonManager).Assembly;
string[] manifestResourceNames = assembly.GetManifestResourceNames();
for (int i = 0; i < (int)manifestResourceNames.Length; i++)
{
string str = manifestResourceNames[i];
if (str.StartsWith(Class8.smethod_10(292)))
{
Stream manifestResourceStream = assembly.GetManifestResourceStream(str);
if (manifestResourceStream != null)
{
string str1 = str.Replace(Class8.smethod_10(6604), "");
string lowerInvariant = str1.Replace('.', '/');
int num = lowerInvariant.LastIndexOf('/');
char[] chrArray = new char[] { '.' };
str1.Split(chrArray)[0].ToLowerInvariant();
lowerInvariant = lowerInvariant.Remove(num, 1);
lowerInvariant = lowerInvariant.Insert(num, Class8.smethod_10(450));
lowerInvariant = lowerInvariant.ToLowerInvariant();
if (lowerInvariant.Equals(name, StringComparison.InvariantCultureIgnoreCase))
{
return this.method_0(manifestResourceStream);
}
}
}
}
return null;
}
private byte[] method_0(Stream stream_0)
{
byte[] array;
using (MemoryStream memoryStream = new MemoryStream())
{
stream_0.CopyTo(memoryStream);
array = memoryStream.ToArray();
}
return array;
}
private void method_1()
{
byte[] numArray;
while (!this.bool_0)
{
try
{
while (this.concurrentQueue_0.Count > 0 && this.concurrentQueue_0.TryDequeue(out numArray) && numArray != null)
{
try
{
this.connection_0.AddUDPPacket(numArray);
}
catch
{
}
}
Thread.Sleep(100);
}
catch (Exception exception)
{
Logger.Error(exception, null, null);
break;
}
}
}
[HandleProcessCorruptedStateExceptions]
private SocketError method_2([In] IntPtr intptr_0, [In][Out] ref Struct0 struct0_0, [In] int int_0, out int int_1, [In][Out] ref SocketFlags socketFlags_0, [In] IntPtr intptr_1, [In] IntPtr intptr_2, [In] IntPtr intptr_3, [In] IntPtr intptr_4)
{
SocketError socketError = SocketError.Success;
try
{
socketError = InternalLoLTimers.WSARecvFrom(intptr_0, ref struct0_0, int_0, out int_1, ref socketFlags_0, intptr_1, intptr_2, intptr_3, intptr_4);
if (socketError != SocketError.Success)
{
int_1 = 0;
}
else if (int_1 > 0)
{
byte[] numArray = new byte[int_1];
Marshal.Copy(struct0_0.intptr_0, numArray, 0, int_1);
this.concurrentQueue_0.Enqueue(numArray);
}
}
catch (Exception exception1)
{
Exception exception = exception1;
int_1 = 0;
Logger.Error(exception, null, null);
this.Dispose();
}
return socketError;
}
private void method_3(uint uint_0, int int_0, int int_1, float float_1, float float_2)
{
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), string.Format(Class8.smethod_10(9180), int_0, int_1, float_1));
if (int_1 == 0 && float_1 == 0f)
{
return;
}
double deltaTime = this.GetDeltaTime(DateTime.Now);
float_1 = float_1 + (float)((double)this.float_0 + deltaTime);
if (!this.AbilityChargeDataByUnitIdAndSlot.ContainsKey(uint_0))
{
this.AbilityChargeDataByUnitIdAndSlot.Add(uint_0, new Dictionary<int, InternalLoLTimers.AbilityChargeData>());
}
if (this.AbilityChargeDataByUnitIdAndSlot[uint_0].ContainsKey(int_0))
{
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].ChargeCount = int_1;
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].NextChargeTime = float_1;
if (float_2 != 0f)
{
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].EachChargeTime = float_2;
}
}
else
{
this.AbilityChargeDataByUnitIdAndSlot[uint_0].Add(int_0, new InternalLoLTimers.AbilityChargeData(int_1, float_1, float_2));
}
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].AtCapacity = float_2 == 0f;
}
private bool method_4(uint uint_0, int int_0, float float_1, int int_1, float float_2, float float_3, out float float_4)
{
float_4 = float_2;
if (!this.AbilityChargeDataByUnitIdAndSlot.ContainsKey(uint_0))
{
return false;
}
if (!this.AbilityChargeDataByUnitIdAndSlot[uint_0].ContainsKey(int_0))
{
return false;
}
float_4 = Math.Max(float_4, this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].EarliestCooldownTime - float_1);
InternalLoLTimers.AbilityChargeData item = this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0];
item.ChargeCount = item.ChargeCount - int_1;
if (float_3 != 0f)
{
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].EachChargeTime = float_3;
}
if (this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].AtCapacity)
{
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].NextChargeTime = float_1 + this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].EachChargeTime;
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].AtCapacity = int_1 == 0;
}
if (this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].ChargeCount > 0)
{
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), string.Format(Class8.smethod_10(9360), float_4));
}
else
{
float_4 = this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].NextChargeTime - float_1;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7384), string.Format(Class8.smethod_10(9268), float_4));
}
this.AbilityChargeDataByUnitIdAndSlot[uint_0][int_0].EarliestCooldownTime = float_1 + float_4;
return true;
}
private void method_5(Dictionary<string, InternalLoLTimers.AbilityEventData> recent, string string_2, double double_0, string string_3 = "")
{
double deltaTime = this.GetDeltaTime(DateTime.Now);
float float0 = (float)((double)this.float_0 + deltaTime);
List<InternalLoLTimers.AbilityEventData> abilityEventDatas = new List<InternalLoLTimers.AbilityEventData>();
for (int i = 0; i < string_2.Length; i++)
{
string str = string.Concat(string_2[i]);
if (string_3.IndexOf(str) == -1 && recent.ContainsKey(str))
{
InternalLoLTimers.AbilityEventData item = recent[str];
if (item.Time + item.CooldownTime > float0)
{
item.CooldownTime = item.CooldownTime - (float)double_0;
abilityEventDatas.Add(item);
}
}
}
foreach (InternalLoLTimers.AbilityEventData abilityEventData in abilityEventDatas)
{
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(8198), abilityEventData);
if (!recent.ContainsKey(abilityEventData.AbilitySlot))
{
recent.Add(abilityEventData.AbilitySlot, abilityEventData);
}
else
{
recent[abilityEventData.AbilitySlot] = abilityEventData;
}
}
}
private void method_6(uint uint_0, uint uint_1)
{
}
private void method_7(InternalLoLTimers.AbilityEventData abilityEventData_0, List<uint> targets = null)
{
}
public void SubmitPlayerData()
{
try
{
List<uint> list = (
from x in this.AccumulatedPlayerData
orderby x.Key
select x.Key).ToList<uint>();
Dictionary<int, int> nums = new Dictionary<int, int>();
int num = 0;
foreach (uint num1 in list)
{
int teamID = this.AccumulatedPlayerData[num1].TeamID;
if (nums.ContainsKey(teamID))
{
continue;
}
int num2 = num;
num = num2 + 1;
nums.Add(teamID, num2);
}
int[] numArray = new int[num];
foreach (uint num3 in list)
{
InternalLoLTimers.PlayerEventData item = this.AccumulatedPlayerData[num3];
if (item.TeamSlot != numArray[item.TeamID])
{
string str = Class8.smethod_10(7692);
object[] playerName = new object[] { item.PlayerName, item.TeamID, item.TeamSlot, numArray[item.TeamID] };
Logger.Warn(string.Format(str, playerName), null);
}
int num4 = numArray[item.TeamID];
int num5 = num4;
numArray[item.TeamID] = num4 + 1;
item.TeamSlot = num5;
this.AccumulatedPlayerData[num3] = item;
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7858), item);
}
}
catch
{
foreach (KeyValuePair<uint, InternalLoLTimers.PlayerEventData> keyValuePair in
from x in this.AccumulatedPlayerData
orderby x.Key
select x)
{
BaseSingleton<ScriptManager>.Instance.QueueEvent(Class8.smethod_10(7858), keyValuePair.Value);
}
}
}
[DllImport("ws2_32.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode, ExactSpelling=false, SetLastError=true)]
internal static extern SocketError WSARecvFrom([In] IntPtr intptr_0, [In][Out] ref Struct0 struct0_0, [In] int int_0, out int int_1, [In][Out] ref SocketFlags socketFlags_0, [In] IntPtr intptr_1, [In] IntPtr intptr_2, [In] IntPtr intptr_3, [In] IntPtr intptr_4);
private string wxevKuYvtK(byte[] byte_0, int int_0)
{
int int0 = int_0;
while (int_0 < (int)byte_0.Length && byte_0[int_0] != 0)
{
int_0++;
}
byte[] numArray = new byte[int_0 - int0];
Array.Copy(byte_0, int0, numArray, 0, int_0 - int0);
return Encoding.UTF8.GetString(numArray);
}
public class AbilityChargeData
{
public int ChargeCount;
public float NextChargeTime;
public float EachChargeTime;
public bool AtCapacity;
public float EarliestCooldownTime;
public AbilityChargeData(int ChargeCount, float NextChargeTime, float EachChargeTime)
{
Class11.FG5wmHOzBXSvR();
base();
this.ChargeCount = ChargeCount;
this.NextChargeTime = NextChargeTime;
this.EachChargeTime = EachChargeTime;
this.AtCapacity = false;
this.EarliestCooldownTime = 0f;
}
}
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct AbilityEventData
{
[DataMember]
public int PlayerSlot;
[DataMember]
public string PlayerName;
[DataMember]
public string HeroName;
[DataMember]
public string AbilitySlot;
[DataMember]
public string AbilityName;
[DataMember]
public float AbilityType;
[DataMember]
public float CooldownTime;
[DataMember]
public float Time;
[DataMember]
public double EpochTime;
}
public class CampDefinition
{
public string Name;
public int CampNumber;
public int[] PositionRaw;
public float InitialTime;
public float RespawnTime;
public List<string> CreepNames;
public int Slot;
public CampDefinition(string Name, int CampNumber, int[] PositionRaw, float InitialTime, float RespawnTime, List<string> CreepNames, int Slot = 0)
{
Class11.FG5wmHOzBXSvR();
base();
this.Name = Name;
this.CampNumber = CampNumber;
this.PositionRaw = PositionRaw;
this.InitialTime = InitialTime;
this.RespawnTime = RespawnTime;
this.CreepNames = CreepNames;
this.Slot = Slot;
}
}
[UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet=CharSet.Unicode, SetLastError=true)]
private delegate SocketError Delegate0([In] IntPtr socketHandle, [In][Out] ref Struct0 buffer, [In] int bufferCount, out int bytesTransferred, [In][Out] ref SocketFlags socketFlags, [In] IntPtr socketAddressPointer, [In] IntPtr socketAddressSizePointer, [In] IntPtr overlapped, [In] IntPtr completionRoutine);
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct GameMapEventData
{
[DataMember]
public int MapID;
}
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct GameStartEventData
{
[DataMember]
public string GameID;
[DataMember]
public string GameKey;
[DataMember]
public string GameRealm;
[DataMember]
public string GameRegion;
[DataMember]
public string PlayerName;
}
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct GameTimeEventData
{
[DataMember]
public float Time;
[DataMember]
public double EpochTime;
}
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct JungleEventData
{
[DataMember]
public int CampSlot;
[DataMember]
public string CampName;
[DataMember]
public float RespawnTime;
[DataMember]
public float Time;
[DataMember]
public double EpochTime;
[DataMember]
public int Hidden;
}
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct PlayerEventData
{
[DataMember]
public string PlayerName;
[DataMember]
public int ClientID;
[DataMember]
public int TeamID;
[DataMember]
public int TeamSlot;
[DataMember]
public string HeroName;
[DataMember]
public int SkinID;
}
[CoherentType(PropertyBindingFlags.All)]
[DataContract]
public struct SkillUpEventData
{
[DataMember]
public string PlayerName;
[DataMember]
public string AbilitySlot;
[DataMember]
public int TotalPoints;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment