Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 158344e8a1 | |||
| 8c7b19f2f1 | |||
| 4d9d3319ab | |||
| 45e6f65360 |
37
App.xaml.cs
37
App.xaml.cs
@ -1,5 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Zerolauncher.Manager;
|
using Zerolauncher.Manager;
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ namespace Zerolauncher
|
|||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public static bool needUpdate = false;
|
public static bool needUpdate = false;
|
||||||
|
static Mutex? mutex;
|
||||||
|
|
||||||
static bool TryDeleteDirectory(string path, bool recursive)
|
static bool TryDeleteDirectory(string path, bool recursive)
|
||||||
{
|
{
|
||||||
@ -25,8 +27,43 @@ namespace Zerolauncher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool CheckProcess()
|
||||||
|
{
|
||||||
|
Process[] processes = Process.GetProcesses();
|
||||||
|
Process currentProcess = Process.GetCurrentProcess();
|
||||||
|
bool processExist = false;
|
||||||
|
foreach (Process p in processes)
|
||||||
|
{
|
||||||
|
if (p.ProcessName == currentProcess.ProcessName && p.Id != currentProcess.Id)
|
||||||
|
{
|
||||||
|
processExist = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return processExist;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("User32.dll")]
|
||||||
|
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||||
protected override void OnStartup(StartupEventArgs e)
|
protected override void OnStartup(StartupEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (CheckProcess())
|
||||||
|
{
|
||||||
|
Trace.WriteLine("应用程序已经在运行,将其置于前台并退出");
|
||||||
|
// 应用程序已经在运行,将其置于前台并退出
|
||||||
|
var currentProcess = Process.GetCurrentProcess();
|
||||||
|
foreach (var process in Process.GetProcessesByName(currentProcess.ProcessName))
|
||||||
|
{
|
||||||
|
if (process.Id != currentProcess.Id)
|
||||||
|
{
|
||||||
|
SetForegroundWindow(process.MainWindowHandle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭当前的应用程序实例
|
||||||
|
Shutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
|
|||||||
@ -26,7 +26,6 @@ namespace Zerolauncher.Manager
|
|||||||
}
|
}
|
||||||
if (UpDateManager.state)
|
if (UpDateManager.state)
|
||||||
{
|
{
|
||||||
Trace.WriteLine("lalalala2");
|
|
||||||
UpDateManager.DoUpdate();
|
UpDateManager.DoUpdate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -174,15 +173,22 @@ namespace Zerolauncher.Manager
|
|||||||
var lines = e.Data == null? [""] : e.Data.Split(" ", 2); // 切成两半
|
var lines = e.Data == null? [""] : e.Data.Split(" ", 2); // 切成两半
|
||||||
switch (lines[0])
|
switch (lines[0])
|
||||||
{
|
{
|
||||||
case StaticHandleC.StartDone:
|
case StaticHandleC.LoadDone:
|
||||||
if (gameMode == StaticHandleA.UpdateMode)
|
if (gameMode == StaticHandleA.UpdateMode)
|
||||||
{
|
{
|
||||||
UpDateManager.DoUpdate1();
|
UpDateManager.DoUpdate1();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
||||||
|
break;
|
||||||
|
case StaticHandleC.StartDone:
|
||||||
|
if (gameMode == StaticHandleA.UpdateMode)
|
||||||
|
{
|
||||||
|
UpDateManager.DoUpdate2();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (restartUrl == null)
|
if (restartUrl == null)
|
||||||
{
|
{
|
||||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
|
||||||
Task.Run(async delegate
|
Task.Run(async delegate
|
||||||
{
|
{
|
||||||
if (lines[1] == "True") await Task.Delay(5000);
|
if (lines[1] == "True") await Task.Delay(5000);
|
||||||
@ -191,7 +197,6 @@ namespace Zerolauncher.Manager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Send($"{StaticHandleS.ShowWindow} {ServicesStaticInfo.ServicesName[account.providerId]}-{account.nickName}");
|
|
||||||
Send($"{StaticHandleS.GameSa} {restartUrl}");
|
Send($"{StaticHandleS.GameSa} {restartUrl}");
|
||||||
restartUrl = null;
|
restartUrl = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
using System.Diagnostics;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Runtime.ConstrainedExecution;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Zerolauncher.Manager
|
namespace Zerolauncher.Manager
|
||||||
{
|
{
|
||||||
@ -61,81 +64,117 @@ namespace Zerolauncher.Manager
|
|||||||
switch (game.account.providerId)
|
switch (game.account.providerId)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
game.Send($"{StaticHandleS.HintText} 尝试登玩家{game.account.nickName}到{ServicesStaticInfo.ServicesName[game.account.providerId]}的1服");
|
||||||
{
|
{
|
||||||
var values = new Dictionary<string, string>
|
HttpResponseMessage response;
|
||||||
{
|
|
||||||
{ "loginFrom", "uframe" },
|
|
||||||
{ "postLoginHandler", "default" },
|
|
||||||
{ "layoutSelfAdapting", "true" },
|
|
||||||
{ "externalLogin", "qq" },
|
|
||||||
{ "displayMode", "popup" },
|
|
||||||
{ "layout", "vertical" },
|
|
||||||
{ "appId", "www_home" },
|
|
||||||
{ "mainDivId", "popup_login_div" },
|
|
||||||
{ "includeFcmInfo", "false" },
|
|
||||||
{ "userNameLabel", "4399用户名" },
|
|
||||||
{ "userNameTip", "请输入4399用户名" },
|
|
||||||
{ "welcomeTip", "欢迎回到4399" },
|
|
||||||
{ "username", game.account.userName },
|
|
||||||
{ "password", game.account.userPWD }
|
|
||||||
};
|
|
||||||
|
|
||||||
var content = new FormUrlEncodedContent(values);
|
|
||||||
HttpResponseMessage? response = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = await client.PostAsync("http://ptlogin.4399.com/ptlogin/login.do?v=1", content);
|
response = await client.GetAsync("http://180.97.189.249:2023");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||||
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
|
need_web = $"http://180.97.189.249:2023";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
// eventHandles.__errorCallback('密码错误');
|
int count = 0;
|
||||||
if (responseString.Contains("eventHandles.__errorCallback"))
|
while (responseString.Contains("adfwkey"))
|
||||||
{
|
{
|
||||||
game.Send($"{StaticHandleS.HintText} 登录异常:{responseString.Split("eventHandles.__errorCallback('")[1].Split("'")[0]}");
|
if (count++ <= 10)
|
||||||
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
|
{
|
||||||
|
game.Send($"{StaticHandleS.HintText} 网络被服务器拦截多次,请重试或联系管理员");
|
||||||
|
need_web = $"http://180.97.189.249:2023";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var key = responseString.Split("adfwkey=")[1].Split("\"", 2)[0];
|
||||||
|
game.Send($"{StaticHandleS.HintText} 被服务验证拦截-验证码key:{key}");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await client.GetAsync("http://180.97.189.249:2023");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||||
|
need_web = $"http://180.97.189.249:2023";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
var values = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "lUsername", game.account.userName },
|
||||||
|
{ "lPassword", game.account.userPWD }
|
||||||
|
};
|
||||||
|
var content = new FormUrlEncodedContent(values);
|
||||||
|
HttpResponseMessage response;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = await client.PostAsync("http://180.97.189.249:2023/form/login.php", content);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||||
|
need_web = $"http://180.97.189.249:2023";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
JObject jsonObj = JObject.Parse(responseString);
|
||||||
|
game.Send($"{StaticHandleS.HintText} {jsonObj["title"]}");
|
||||||
|
game.Send($"{StaticHandleS.HintText} {jsonObj["content"]}");
|
||||||
|
if ((int)jsonObj["type"] != 0)
|
||||||
|
{
|
||||||
|
need_web = $"http://180.97.189.249:2023";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
|
if(!game.Send($"{StaticHandleS.HintText} 登录成功,开始解析iframe")) return;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
HttpResponseMessage? response = null;
|
HttpResponseMessage response;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
response = await client.PostAsync("http://web.4399.com/stat/togame.php?target=ddt&server_id=S" + game.account.serverId, null);
|
response = await client.GetAsync("http://180.97.189.249:2023/Play/Play.php?id=1");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
|
||||||
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
|
need_web = $"http://180.97.189.249:2023";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var responseString = await response.Content.ReadAsStringAsync();
|
var responseString = await response.Content.ReadAsStringAsync();
|
||||||
if (!responseString.Contains("name=\"game_box\""))
|
if (!responseString.Contains("var swfPath"))
|
||||||
{
|
{
|
||||||
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确");
|
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确1");
|
||||||
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
|
need_web = $"http://180.97.189.249:2023";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
responseString = responseString.Split("name=\"game_box\"")[1].Split("src=\"")[1].Split("\"")[0];
|
//responseString = "" + responseString.Split("var swfPath")[1].Split("};")[0] + "};";
|
||||||
try
|
string pattern = @"var swfPath = ""(.*?)"";(.*?){(.*?)};";
|
||||||
|
Match match = Regex.Match(responseString, pattern, RegexOptions.Singleline);
|
||||||
|
|
||||||
|
if (!match.Success)
|
||||||
{
|
{
|
||||||
response = await client.PostAsync(responseString, null);
|
game.Send($"{StaticHandleS.HintText} 解析异常:服务器返回数据不正确2");
|
||||||
}
|
//Trace.WriteLine($"---------{responseString}|");
|
||||||
catch (Exception ex)
|
need_web = $"http://180.97.189.249:2023";
|
||||||
{
|
|
||||||
game.Send($"{StaticHandleS.HintText} 网络发生错误,类型:{ex.GetType().Name.Replace(" ", "_")},消息:{ex.Message.Replace(" ", "_")}");
|
|
||||||
need_web = $"http://web.4399.com/stat/togame.php?target=ddt&server_id=S{game.account.serverId}";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
responseString = await response.Content.ReadAsStringAsync();
|
string url = match.Groups[1].Value;
|
||||||
responseString = "http://" + response.RequestMessage.RequestUri.ToString().Split("/")[2] + "/" + responseString.Split("movie\" value='")[1].Split("'")[0];
|
string parameters = match.Groups[3].Value;
|
||||||
Trace.WriteLine(responseString);
|
|
||||||
game.Send($"{StaticHandleS.GameSa} {responseString}");
|
string patternParams = @"(\w+): ""(.*?)""";
|
||||||
|
MatchCollection matches = Regex.Matches(parameters, patternParams);
|
||||||
|
|
||||||
|
url += "?";
|
||||||
|
foreach (Match m in matches)
|
||||||
|
{
|
||||||
|
url += $"{m.Groups[1].Value}={WebUtility.UrlEncode(m.Groups[2].Value)}&";
|
||||||
|
}
|
||||||
|
url = url.TrimEnd('&');
|
||||||
|
Trace.WriteLine(url);
|
||||||
|
game.Send($"{StaticHandleS.GameSa} {url}");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -21,17 +21,17 @@ namespace Zerolauncher.Manager
|
|||||||
bool needMian= false;
|
bool needMian= false;
|
||||||
if(checkMain)
|
if(checkMain)
|
||||||
{
|
{
|
||||||
//string filePath = Process.GetCurrentProcess().MainModule.FileName;
|
string filePath = Process.GetCurrentProcess().MainModule.FileName;
|
||||||
string? now_bit;
|
string? now_bit;
|
||||||
//using (SHA256 sha256 = SHA256.Create())
|
using (SHA256 sha256 = SHA256.Create())
|
||||||
//{
|
{
|
||||||
// using (FileStream fileStream = File.OpenRead(filePath))
|
using (FileStream fileStream = File.OpenRead(filePath))
|
||||||
// {
|
{
|
||||||
// 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);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
now_bit = "67FD2BCB9F6756A82621840896DCE80BB4ACEF22A8D1FF98FC835BE291F5CC84";
|
//now_bit = "170CD25DCCF3FFCCFAA423B85E1715E7CD28959333C4C5F86FB1E73666359998";
|
||||||
needMian = now_bit == CacheSha.GetM() && now_bit != null;
|
needMian = now_bit == CacheSha.GetM() && now_bit != null;
|
||||||
}
|
}
|
||||||
if(!needEngine)
|
if(!needEngine)
|
||||||
@ -85,14 +85,14 @@ namespace Zerolauncher.Manager
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void DoUpdate1()
|
public static void DoUpdate1()
|
||||||
{
|
|
||||||
Task.Run(async () =>
|
|
||||||
{
|
{
|
||||||
updateProcess.Send($"{StaticHandleS.ShowWindow} 自助更新");
|
updateProcess.Send($"{StaticHandleS.ShowWindow} 自助更新");
|
||||||
await Task.Delay(1000);
|
}
|
||||||
|
|
||||||
|
public static void DoUpdate2()
|
||||||
|
{
|
||||||
updateProcess.Send($"{StaticHandleS.UpdateInfo} {UpDateData.tis}");
|
updateProcess.Send($"{StaticHandleS.UpdateInfo} {UpDateData.tis}");
|
||||||
updateProcess.Send($"{StaticHandleS.UseBrowser} {UpDateData.lanzou + UpDateData.auto_packet_url}");
|
updateProcess.Send($"{StaticHandleS.UseBrowser} {UpDateData.lanzou + UpDateData.auto_packet_url}");
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnDownLoadDone(string path)
|
public static void OnDownLoadDone(string path)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
class ServicesStaticInfo
|
class ServicesStaticInfo
|
||||||
{
|
{
|
||||||
public static string[] ServicesName = ["4399大区", "7k7k大区", "第七大道"];
|
public static string[] ServicesName = ["LoveDDTank"];
|
||||||
public static string[] ServicesShortName = ["43", "7k", "7d"];
|
public static string[] ServicesShortName = ["经典"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,12 +14,13 @@
|
|||||||
|
|
||||||
class StaticHandleC
|
class StaticHandleC
|
||||||
{
|
{
|
||||||
public const string StartDone = "0a";
|
public const string LoadDone = "0a";
|
||||||
public const string BrowserDone = "0b";
|
public const string StartDone = "0b";
|
||||||
public const string StartGame = "0c";
|
public const string BrowserDone = "0c";
|
||||||
public const string GameDone = "0d";
|
public const string StartGame = "0d";
|
||||||
public const string Version = "0e";
|
public const string GameDone = "0e";
|
||||||
public const string DownloadDone = "0f";
|
public const string Version = "0f";
|
||||||
|
public const string DownloadDone = "0g";
|
||||||
}
|
}
|
||||||
|
|
||||||
class StaticHandleA
|
class StaticHandleA
|
||||||
|
|||||||
@ -33,6 +33,15 @@ namespace Zerolauncher.dialog
|
|||||||
edit_pwd.Password = acc.userPWD;
|
edit_pwd.Password = acc.userPWD;
|
||||||
edit_nick.Text = acc.nickName;
|
edit_nick.Text = acc.nickName;
|
||||||
}
|
}
|
||||||
|
//return;
|
||||||
|
// 私服用
|
||||||
|
if (ServicesStaticInfo.ServicesName.Length == 1)
|
||||||
|
{
|
||||||
|
cb_pid.SelectedIndex = 0;
|
||||||
|
edit_sid.Text = "1";
|
||||||
|
cb_pid.IsEditable = false;
|
||||||
|
edit_sid.IsEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user