85 lines
2.5 KiB
C#
85 lines
2.5 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Microsoft.Win32;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Diagnostics;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class AuthDemo : MonoBehaviour
|
|
{
|
|
private string diskCode = "";
|
|
private string getCodes = "";
|
|
private string revCodes = "";
|
|
string[] CommandLineArgs = Environment.GetCommandLineArgs();
|
|
|
|
void Start()
|
|
{
|
|
bool authState = false;
|
|
|
|
diskCode = Amtlib.GetCode();
|
|
|
|
try
|
|
{
|
|
foreach (string arg in CommandLineArgs)
|
|
{
|
|
if (arg.IndexOf("@argu=") == 0)
|
|
{
|
|
getCodes = arg;
|
|
string[] codes = arg.Replace("@argu=", "").Replace("#argu", "").Split('-');
|
|
StreamReader sr = new StreamReader(Application.dataPath + "\\run.temp");
|
|
string idxes = sr.ReadToEnd().Trim();
|
|
sr.Close();
|
|
|
|
string[] idxArray = idxes.Split('-');
|
|
for (int i = idxArray.Length - 1; i >= 0; i -= 2)
|
|
{
|
|
int ix = int.Parse(idxArray[i]);
|
|
int iy = int.Parse(idxArray[i - 1]);
|
|
|
|
arrayExchange(ref codes, iy, ix);
|
|
}
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
foreach (string code in codes)
|
|
sb.Append(code);
|
|
|
|
revCodes = sb.ToString();
|
|
|
|
if (revCodes.Equals(diskCode))
|
|
{
|
|
authState = true;
|
|
}
|
|
|
|
File.Delete(Application.dataPath + "\\run.temp");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch { }
|
|
|
|
if (!authState)
|
|
{
|
|
//Application.Quit();
|
|
}
|
|
else
|
|
{
|
|
//启动守护进程
|
|
Process proce = new Process();
|
|
proce.StartInfo = new ProcessStartInfo { FileName = Application.dataPath + "\\Managed\\LGZNProtect.exe", CreateNoWindow = true, UseShellExecute = false };
|
|
proce.Start();
|
|
|
|
//进入场景
|
|
SceneManager.LoadScene(1);
|
|
}
|
|
}
|
|
|
|
private void arrayExchange(ref string[] list, int firstIndex, int secondIndex)
|
|
{
|
|
string tempStr = list[firstIndex];
|
|
list[firstIndex] = list[secondIndex];
|
|
list[secondIndex] = tempStr;
|
|
}
|
|
} |