From bdc3cfd642c5d898885500730f47e13c5ec82267 Mon Sep 17 00:00:00 2001 From: MgAl2O4 <51430403+MgAl2O4@users.noreply.github.com> Date: Wed, 28 Dec 2022 07:57:18 -0500 Subject: [PATCH] updated bluestacks5 window scan --- SINoCOLO/GithubUpdater.cs | 19 +++++-------- SINoCOLO/Properties/AssemblyInfo.cs | 4 +-- SINoCOLO/ScreenReader.cs | 32 ++++++++++++++++++++-- Util-MovieExtract/Util-MovieExtract.csproj | 2 +- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/SINoCOLO/GithubUpdater.cs b/SINoCOLO/GithubUpdater.cs index d1bf30b..6c8bac3 100644 --- a/SINoCOLO/GithubUpdater.cs +++ b/SINoCOLO/GithubUpdater.cs @@ -63,20 +63,15 @@ private static int FindOnlineVersion(out string downloadLink) ReqTree.Timeout = -1; WebResponse RespTree = ReqTree.GetResponse(); - using (Stream dataStream = RespTree.GetResponseStream()) + var respAbsUri = RespTree.ResponseUri.AbsoluteUri; + var matchPattern = "/releases/tag/v"; + int patternPos = respAbsUri.IndexOf(matchPattern); + if (patternPos != 0) { - StreamReader reader = new StreamReader(dataStream); - string responseFromServer = reader.ReadToEnd(); + var versionStr = respAbsUri.Substring(patternPos + matchPattern.Length); + latestVersion = int.Parse(versionStr); - string pattern = "href=\\\".+\\/(releases\\/download\\/.+v(\\d+)\\.zip)\\\""; - Match match = new Regex(pattern).Match(responseFromServer); - if (match.Success) - { - downloadLink = match.Groups[1].Value; - - string versionStr = match.Groups[2].Value; - latestVersion = int.Parse(versionStr); - } + downloadLink = $"releases/download/v{versionStr}/release-v{versionStr}.zip"; } return latestVersion; diff --git a/SINoCOLO/Properties/AssemblyInfo.cs b/SINoCOLO/Properties/AssemblyInfo.cs index d9f4a44..45952a1 100644 --- a/SINoCOLO/Properties/AssemblyInfo.cs +++ b/SINoCOLO/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("30.0.0.0")] -[assembly: AssemblyFileVersion("30.0.0.0")] +[assembly: AssemblyVersion("31.0.0.0")] +[assembly: AssemblyFileVersion("31.0.0.0")] diff --git a/SINoCOLO/ScreenReader.cs b/SINoCOLO/ScreenReader.cs index a2eeaa6..21aaaa4 100644 --- a/SINoCOLO/ScreenReader.cs +++ b/SINoCOLO/ScreenReader.cs @@ -32,7 +32,10 @@ public class GameInfo public Rectangle rectMain; public Rectangle rectClient; - public bool IsValid() { return (process != null) && !process.HasExited && windowMain.Handle != IntPtr.Zero; } + public bool IsValid() + { + return (process != null && windowMain.Handle != IntPtr.Zero && ScreenReader.IsProcessRunning(process.Id)); + } } private List availableGameInfo = new List(); @@ -203,6 +206,21 @@ public WINDOWINFO(Boolean? filler) : this() // Allows automatic initialization [return: MarshalAs(UnmanagedType.Bool)] [DllImport("user32.dll", SetLastError = true)] private static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi); + + [Flags] + public enum ProcessAccessFlags : uint + { + PROCESS_QUERY_LIMITED_INFORMATION = 0x00001000, + } + + [DllImport("kernel32.dll")] + static extern bool GetExitCodeProcess(IntPtr hProcess, out uint lpExitCode); + + [DllImport("kernel32.dll")] + private static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, bool bInheritHandle, int dwProcessId); + + [DllImport("kernel32.dll", SetLastError = true)] + static extern bool CloseHandle(IntPtr handle); #endregion private void UpdateAvailableGames_Bluestack4() @@ -330,7 +348,7 @@ private void UpdateAvailableGames_Bluestack5() //Console.WriteLine(" >> childInput:{0:x}", childHandleInput.ToInt64()); if (childHandleInput != IntPtr.Zero) { - IntPtr childHandleClient = FindWindowEx(childHandleInput, (IntPtr)0, null, "_ctl.Window"); + IntPtr childHandleClient = FindWindowEx(childHandleInput, (IntPtr)0, null, null); //Console.WriteLine(" >> childClient:{0:x}", childHandleClient.ToInt64()); if (childHandleClient != IntPtr.Zero) { @@ -492,5 +510,15 @@ private Bitmap TakeScreenshot() return bitmap; } + + static bool IsProcessRunning(int processID) + { + var handle = OpenProcess(ProcessAccessFlags.PROCESS_QUERY_LIMITED_INFORMATION, false, processID); + + GetExitCodeProcess(handle, out uint exitCode); + CloseHandle(handle); + + return (exitCode == 259); + } } } diff --git a/Util-MovieExtract/Util-MovieExtract.csproj b/Util-MovieExtract/Util-MovieExtract.csproj index bb9b29b..875f223 100644 --- a/Util-MovieExtract/Util-MovieExtract.csproj +++ b/Util-MovieExtract/Util-MovieExtract.csproj @@ -11,7 +11,7 @@ SINoCOLO en-US UAP - 10.0.18362.0 + 10.0.19041.0 10.0.17763.0 14 512