release 5.19

This commit is contained in:
1415ddfer 2024-05-19 10:43:41 +08:00
parent ff2a27a08d
commit cf7aa467b9
6 changed files with 98 additions and 57 deletions

View File

@ -24,11 +24,11 @@ namespace Zerolauncher.Manager
MessageBox.Show("正在更新游戏数据请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning); MessageBox.Show("正在更新游戏数据请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
return true; return true;
} }
if (UpDateManager.state) //if (UpDateManager.state)
{ //{
UpDateManager.DoUpdate(); // UpDateManager.DoUpdate();
return true; // return true;
} //}
var key = AccToKey(account); var key = AccToKey(account);
if (mGame.ContainsKey(key)) { return false; } if (mGame.ContainsKey(key)) { return false; }
if (CacheSha.errorCode != 0) { if (CacheSha.errorCode != 0) {
@ -136,6 +136,7 @@ namespace Zerolauncher.Manager
mHandle = 0; mHandle = 0;
process = EngineShell.CheckEngineSafe(gameMode); process = EngineShell.CheckEngineSafe(gameMode);
process.OutputDataReceived += Handle; process.OutputDataReceived += Handle;
process.ErrorDataReceived += Handle;
process.Exited += Process_Exited; process.Exited += Process_Exited;
process.Start(); process.Start();
@ -154,11 +155,11 @@ namespace Zerolauncher.Manager
private void Process_Exited(object? sender, EventArgs e) private void Process_Exited(object? sender, EventArgs e)
{ {
//Trace.WriteLine( Trace.WriteLine(
// $"Exit time : {process.ExitTime}\n" + $"Exit time : {process.ExitTime}\n" +
// $"Exit code : {process.ExitCode}\n" + $"Exit code : {process.ExitCode}\n" +
// $"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}"); $"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
//Trace.WriteLine($"进程已退出:{account.nickName}"); Trace.WriteLine($"进程已退出:{account.nickName}");
if (gameMode != StaticHandleA.GameMode) return; if (gameMode != StaticHandleA.GameMode) return;
if ( restartUrl == null) if ( restartUrl == null)
{ {
@ -192,7 +193,7 @@ namespace Zerolauncher.Manager
Task.Run(async delegate Task.Run(async delegate
{ {
if (lines[1] == "True") await Task.Delay(5000); if (lines[1] == "True") await Task.Delay(5000);
_ = LoginManager.DoLogin(this); LoginManager.DoLogin(this);
}); });
} }
else else
@ -205,6 +206,7 @@ namespace Zerolauncher.Manager
mHandle = int.Parse(lines[1]); mHandle = int.Parse(lines[1]);
break; break;
case StaticHandleC.BrowserDone: case StaticHandleC.BrowserDone:
Trace.WriteLine($"尝试让游戏退出:{account.nickName}");
restartUrl = lines[1]; restartUrl = lines[1];
Send(StaticHandleS.CloseGame); Send(StaticHandleS.CloseGame);
break; break;
@ -214,6 +216,13 @@ namespace Zerolauncher.Manager
case StaticHandleC.DownloadDone: case StaticHandleC.DownloadDone:
UpDateManager.OnDownLoadDone(lines[1]); UpDateManager.OnDownLoadDone(lines[1]);
break; break;
case StaticHandleC.TakeVerify:
var args = lines[1].Split(' ');
_ = LoginManager.DoVerify(this, args[0], args[1]);
break;
default:
Trace.WriteLine($"from client:{e.Data}");
break;
} }
} }
@ -242,45 +251,45 @@ namespace Zerolauncher.Manager
{ {
bool is_first_luancher = EngineManager.CheckEmpy(); bool is_first_luancher = EngineManager.CheckEmpy();
#region #region
if (mod == StaticHandleA.UpdateMode) //if (mod == StaticHandleA.UpdateMode)
{ //{
if (DataStream.dataStream.ecs.Length > 10) // if (DataStream.dataStream.ecs.Length > 10)
{ // {
string? now_bit; // string? now_bit;
using (SHA256 sha256 = SHA256.Create()) // using (SHA256 sha256 = SHA256.Create())
{ // {
using (FileStream fileStream = File.OpenRead(engine_file)) // using (FileStream fileStream = File.OpenRead(engine_file))
{ // {
byte[] hashBytes = sha256.ComputeHash(fileStream); // byte[] hashBytes = sha256.ComputeHash(fileStream);
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); // now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
} // }
} // }
if (DataStream.dataStream.ecs != now_bit) // if (DataStream.dataStream.ecs != now_bit)
{ // {
Trace.WriteLine("lalalala" + DataStream.dataStream.ecs); // Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
throw new FileReadException("error esu1!"); // throw new FileReadException("error esu1!");
} // }
} // }
} //}
else if (!is_check && is_first_luancher) //else if (!is_check && is_first_luancher)
{ //{
string? now_bit; // string? now_bit;
using (SHA256 sha256 = SHA256.Create()) // using (SHA256 sha256 = SHA256.Create())
{ // {
using (FileStream fileStream = File.OpenRead(engine_file)) // using (FileStream fileStream = File.OpenRead(engine_file))
{ // {
byte[] hashBytes = sha256.ComputeHash(fileStream); // byte[] hashBytes = sha256.ComputeHash(fileStream);
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty); // now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
} // }
} // }
if (CacheSha.GetE() != now_bit) // if (CacheSha.GetE() != now_bit)
{ // {
Trace.WriteLine("lalalala1"); // Trace.WriteLine("lalalala1");
throw new FileReadException("error esu0!"); // throw new FileReadException("error esu0!");
} // }
if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); } // if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
is_check = true; // is_check = true;
} //}
#endregion #endregion
var process = new Process var process = new Process
@ -292,7 +301,8 @@ namespace Zerolauncher.Manager
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true, CreateNoWindow = true,
RedirectStandardInput = true, RedirectStandardInput = true,
RedirectStandardOutput = true RedirectStandardOutput = true,
RedirectStandardError = true
}, },
EnableRaisingEvents = true EnableRaisingEvents = true
}; };

View File

@ -1,6 +1,8 @@
using Newtonsoft.Json.Linq; using System.Diagnostics;
using System.Drawing;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using Zerolauncher.util;
namespace Zerolauncher.Manager namespace Zerolauncher.Manager
{ {
@ -59,7 +61,7 @@ namespace Zerolauncher.Manager
} }
public static async Task DoLogin(SingleGame game) public static void DoLogin(SingleGame game)
{ {
var client = new HttpClient(); var client = new HttpClient();
client.DefaultRequestVersion = HttpVersion.Version20; client.DefaultRequestVersion = HttpVersion.Version20;
@ -87,5 +89,26 @@ namespace Zerolauncher.Manager
//} //}
game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.providerId + 4} {ServicesStaticInfo.ServerIds[game.account.serverId]} {game.account.userName} {game.account.userPWD}"); game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.providerId + 4} {ServicesStaticInfo.ServerIds[game.account.serverId]} {game.account.userName} {game.account.userPWD}");
} }
public static async Task DoVerify(SingleGame game, string vid, string cookie)
{
var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(3);
client.DefaultRequestHeaders.Add("Cookie", cookie);
try
{
var response = await client.GetAsync($"https://www.917play.com.tw/ddt_webserver/verify?{vid}");
var bin = response.Content.ReadAsStream();
if (OnnxManager.onnxVerify == null) OnnxManager.onnxVerify = new OnnxVerify();
var verify = OnnxManager.onnxVerify.RunInference(new Bitmap(bin));
game.Send($"{StaticHandleS.VerifyDone} {verify}");
Trace.WriteLine(verify);
}
catch (Exception ex)
{
Trace.WriteLine($"{StaticHandleS.HintText} 请求验证码时网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
}
}
} }
} }

View File

@ -10,6 +10,7 @@
public const string GameSa = "f0"; public const string GameSa = "f0";
public const string CloseGame = "g0"; public const string CloseGame = "g0";
public const string UpdateInfo = "h0"; public const string UpdateInfo = "h0";
public const string VerifyDone = "i0";
} }
class StaticHandleC class StaticHandleC
@ -21,6 +22,7 @@
public const string GameDone = "0e"; public const string GameDone = "0e";
public const string Version = "0f"; public const string Version = "0f";
public const string DownloadDone = "0g"; public const string DownloadDone = "0g";
public const string TakeVerify = "0i";
} }
class StaticHandleA class StaticHandleA

View File

@ -67,6 +67,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="plugin\model.bin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ZeroEngine.exe"> <None Update="ZeroEngine.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>

View File

@ -37,7 +37,6 @@ namespace Zerolauncher.dialog
} }
cb_pid.SelectedIndex = 0; cb_pid.SelectedIndex = 0;
cb_sid.SelectedIndex = 0;
cb_pid.IsEditable = false; cb_pid.IsEditable = false;
} }

View File

@ -7,6 +7,10 @@ using System.Drawing;
namespace Zerolauncher.util namespace Zerolauncher.util
{ {
public class OnnxManager public class OnnxManager
{
public static OnnxVerify? onnxVerify;
}
public class OnnxVerify
{ {
private string _modelPath; private string _modelPath;
private InferenceSession _session; private InferenceSession _session;
@ -19,7 +23,7 @@ namespace Zerolauncher.util
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9" "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
]; ];
public OnnxManager(string modelPath = "ocr/model.onnx") public OnnxVerify(string modelPath = "plugin/model.bin")
{ {
_modelPath = modelPath; _modelPath = modelPath;
_session = new InferenceSession(_modelPath); _session = new InferenceSession(_modelPath);