Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
updated bluestacks5 window scan
Browse files Browse the repository at this point in the history
  • Loading branch information
MgAl2O4 committed Dec 28, 2022
1 parent ceb76ff commit bdc3cfd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
19 changes: 7 additions & 12 deletions SINoCOLO/GithubUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions SINoCOLO/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
32 changes: 30 additions & 2 deletions SINoCOLO/ScreenReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameInfo> availableGameInfo = new List<GameInfo>();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion Util-MovieExtract/Util-MovieExtract.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>SINoCOLO</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
Expand Down

0 comments on commit bdc3cfd

Please sign in to comment.