コード例 #1
0
 private static void smethod_6()
 {
     if (verifyFile_0.Length != 0)
     {
         try
         {
             string contents = "";
             ulong  maxValue = ulong.MaxValue;
             MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider();
             IntPtr processHandle = Process32.OpenProcess(Process32.PROCESS_QUERY_INFORMATION | Process32.PROCESS_VM_READ, 0, (uint)process_0.Id);
             if (processHandle == IntPtr.Zero)
             {
                 ulong_0 = ulong.MaxValue;
             }
             else
             {
                 Dictionary <string, MemoryAssemblyEntry> dictionary = new Dictionary <string, MemoryAssemblyEntry>();
                 uint num2 = Process32.smethod_3(processHandle, (long)(process_0.MainModule.BaseAddress.ToInt32() + 0xa1f9cc));
                 uint num3 = 0;
                 bool flag = false;
                 int  num4 = 0;
                 uint num5 = 0;
                 uint num6 = num2;
                 while (num3 < 0x800)
                 {
                     if (num4 >= Assemblies.Length)
                     {
                         break;
                     }
                     try
                     {
                         num3 += 4;
                         if (!flag)
                         {
                             num5 = Process32.smethod_3(processHandle, (long)(num2 + num3));
                             if (num5 == 0)
                             {
                                 continue;
                             }
                             num6 = Process32.smethod_3(processHandle, (long)(num5 + 20));
                             if (num6 == 0)
                             {
                                 continue;
                             }
                             string path = Process32.ReadString(processHandle, (long)num6);
                             if (!path.ToLower().EndsWith(Class3.smethod_10(0x714)) || !File.Exists(path))
                             {
                                 continue;
                             }
                             if (ProtectLoader.Debug)
                             {
                                 UnityEngine.Debug.Log(Class3.smethod_10(0x736) + num5.ToString(Class3.smethod_10(0x758)));
                             }
                             flag = true;
                         }
                         num6 = Process32.smethod_3(processHandle, (long)(num2 + num3));
                         uint num8 = Process32.smethod_3(processHandle, (long)(num6 + 12));
                         if (num8 > 0)
                         {
                             uint num7  = Process32.smethod_3(processHandle, (long)(num6 + 8));
                             uint num9  = Process32.smethod_3(processHandle, (long)(num6 + 20));
                             uint num10 = Process32.smethod_3(processHandle, (long)(num6 + 0x20));
                             if (((num7 > 0) && (num9 > 0)) && (num10 > 0))
                             {
                                 MemoryAssemblyEntry entry2 = new MemoryAssemblyEntry {
                                     Pointer       = (long)num7,
                                     Filesize      = num8,
                                     Filepath      = Process32.ReadString(processHandle, (long)num9),
                                     TargetRuntime = Process32.ReadString(processHandle, (long)num10)
                                 };
                                 if (File.Exists(entry2.Filepath))
                                 {
                                     string str2 = entry2.Filepath.Replace(string_0, "");
                                     dictionary[str2] = entry2;
                                     num4++;
                                     if (ProtectLoader.Debug)
                                     {
                                         UnityEngine.Debug.Log(string.Concat(new object[] { Class3.smethod_10(0x760), entry2.Pointer.ToString(Class3.smethod_10(0x758)), Class3.smethod_10(0x78c), entry2.Filesize, Class3.smethod_10(0x7b8), str2, Class3.smethod_10(0x7e4), entry2.Filepath, Class3.smethod_10(0x810), entry2.TargetRuntime }));
                                     }
                                 }
                             }
                         }
                         continue;
                     }
                     catch (Exception exception)
                     {
                         ulong_0 = ulong.MaxValue;
                         if (ProtectLoader.Debug)
                         {
                             UnityEngine.Debug.LogError(exception.ToString());
                         }
                         return;
                     }
                 }
                 if (!flag)
                 {
                     ulong_0 = ulong.MaxValue;
                     if (ProtectLoader.Debug)
                     {
                         UnityEngine.Debug.LogError(Class3.smethod_10(0x848));
                     }
                 }
                 else
                 {
                     foreach (VerifyFile file in verifyFile_0)
                     {
                         MemoryAssemblyEntry entry3;
                         if (!File.Exists(file.Filename))
                         {
                             break;
                         }
                         contents = contents + file.Filename + Class3.smethod_10(0x8a4);
                         string str4 = Path.GetFileName(file.Filename).Replace(Class3.smethod_10(0x8ac), Class3.smethod_10(0x8b2));
                         if (dictionary.TryGetValue(file.Filename, out entry3))
                         {
                             if (file.Filesize != entry3.Filesize)
                             {
                                 break;
                             }
                             byte[] buffer = Process32.ReadBytes(processHandle, entry3.Pointer, (int)entry3.Filesize);
                             if ((buffer == null) || (buffer.Length != entry3.Filesize))
                             {
                                 break;
                             }
                             maxValue ^= BitConverter.ToUInt64(provider.ComputeHash(buffer), 0);
                             maxValue ^= BitConverter.ToUInt64(provider.ComputeHash(Encoding.UTF8.GetBytes(file.Filename)), 0);
                         }
                         else if ((str4.Contains(Class3.smethod_10(0x8b8)) && !(str4 == Class3.smethod_10(0x8ce))) && !(Path.GetExtension(str4).ToLower() != Class3.smethod_10(0x8f0)))
                         {
                             UnityEngine.Debug.LogError(Class3.smethod_10(0x8fc) + str4);
                         }
                         else
                         {
                             maxValue ^= BitConverter.ToUInt64(provider.ComputeHash(File.ReadAllBytes(file.Filename)), 0);
                             maxValue ^= BitConverter.ToUInt64(provider.ComputeHash(Encoding.UTF8.GetBytes(file.Filename)), 0);
                         }
                     }
                     Process32.CloseHandle(processHandle);
                     ulong_0 = maxValue;
                     if (ProtectLoader.Debug)
                     {
                         contents = contents + Class3.smethod_10(0x93e) + ulong_0.ToString(Class3.smethod_10(0x5fe));
                         File.WriteAllText(Path.Combine(Application.dataPath, Class3.smethod_10(0x95c)), contents);
                         System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
                         foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                         {
                             list.Add(assembly.GetName().Name);
                         }
                         File.WriteAllLines(Path.Combine(Application.dataPath, Class3.smethod_10(0x984)), list.ToArray());
                     }
                     if ((network_0 != null) && network_0.Connected)
                     {
                         Assembly[]             assemblies = Assemblies;
                         NetLink.Network.Packet packet     = new NetLink.Network.Packet(NetLink.Network.PacketType.DataStream, NetLink.Network.PacketFlag.Compressed, null);
                         packet.Write <ushort>(MessageType.Checksum);
                         packet.Write <ulong>(ulong_0);
                         packet.Write <int>(assemblies.Length);
                         foreach (Assembly assembly2 in assemblies)
                         {
                             string str5 = (assembly2.EscapedCodeBase == null) ? "" : assembly2.Location;
                             packet.Write <string>(assembly2.GetName().Name);
                             packet.Write <string>(str5);
                         }
                         packet.Write <int>(string_2.Length);
                         foreach (string str6 in string_2)
                         {
                             packet.Write <string>(str6);
                         }
                         network_0.Send(packet);
                     }
                     thread_1 = null;
                     Thread.Sleep(10);
                 }
             }
         }
         catch (Exception exception2)
         {
             UnityEngine.Debug.LogError(Class3.smethod_10(0x9b4) + exception2.Message);
         }
     }
 }