Detection rewrite for issue #153 - Pass 2
This commit is contained in:
@@ -38,7 +38,7 @@ Public Class frmChooseGame
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub SaveSelection()
|
Private Sub SaveSelection()
|
||||||
oGame.ProcessPath = oProcess.GameInfo.ProcessPath
|
oGame.ProcessPath = oProcess.ProcessPath
|
||||||
mgrMonitorList.DoListUpdate(oGame)
|
mgrMonitorList.DoListUpdate(oGame)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|||||||
@@ -266,14 +266,9 @@ Public Class frmMain
|
|||||||
frm.Process = oProcess
|
frm.Process = oProcess
|
||||||
oResult = frm.ShowDialog()
|
oResult = frm.ShowDialog()
|
||||||
If oResult = DialogResult.OK Then
|
If oResult = DialogResult.OK Then
|
||||||
Dim sProcessPath As String
|
|
||||||
'Reload settings
|
'Reload settings
|
||||||
LoadGameSettings()
|
LoadGameSettings()
|
||||||
'Retain the process path from old object
|
|
||||||
sProcessPath = oProcess.GameInfo.ProcessPath
|
|
||||||
oProcess.GameInfo = frm.Game
|
oProcess.GameInfo = frm.Game
|
||||||
'Set the process path into the new object
|
|
||||||
oProcess.GameInfo.ProcessPath = sProcessPath
|
|
||||||
'A game was set, return and continue
|
'A game was set, return and continue
|
||||||
Return True
|
Return True
|
||||||
Else
|
Else
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ Imports System.Text.RegularExpressions
|
|||||||
Public Class mgrProcessDetection
|
Public Class mgrProcessDetection
|
||||||
|
|
||||||
Private prsFoundProcess As Process
|
Private prsFoundProcess As Process
|
||||||
|
Private sProcessPath As String
|
||||||
Private dStartTime As DateTime = Now, dEndTime As DateTime = Now
|
Private dStartTime As DateTime = Now, dEndTime As DateTime = Now
|
||||||
Private lTimeSpent As Long = 0
|
Private lTimeSpent As Long = 0
|
||||||
Private oGame As clsGame
|
Private oGame As clsGame
|
||||||
@@ -20,6 +21,15 @@ Public Class mgrProcessDetection
|
|||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
|
Property ProcessPath As String
|
||||||
|
Get
|
||||||
|
Return sProcessPath
|
||||||
|
End Get
|
||||||
|
Set(value As String)
|
||||||
|
sProcessPath = value
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
|
|
||||||
Property StartTime As DateTime
|
Property StartTime As DateTime
|
||||||
Get
|
Get
|
||||||
Return dStartTime
|
Return dStartTime
|
||||||
@@ -91,7 +101,7 @@ Public Class mgrProcessDetection
|
|||||||
Dim sFullCommand As String = String.Empty
|
Dim sFullCommand As String = String.Empty
|
||||||
Try
|
Try
|
||||||
sFullCommand = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline").Replace(vbNullChar, " ")
|
sFullCommand = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline").Replace(vbNullChar, " ")
|
||||||
Catch ex As Exception
|
Catch
|
||||||
'Do Nothing
|
'Do Nothing
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
@@ -161,10 +171,10 @@ Public Class mgrProcessDetection
|
|||||||
|
|
||||||
Private Sub FilterDetected(ByVal oDetectedGames As ArrayList, ByVal bWineProcess As Boolean)
|
Private Sub FilterDetected(ByVal oDetectedGames As ArrayList, ByVal bWineProcess As Boolean)
|
||||||
Dim bMatch As Boolean = False
|
Dim bMatch As Boolean = False
|
||||||
Dim sProcessPath As String
|
|
||||||
Dim sFullCommand As String
|
Dim sFullCommand As String
|
||||||
Dim oNotDetectedWithParameters As New ArrayList
|
Dim oNotDetectedWithParameters As New ArrayList
|
||||||
Dim oDetectedWithParameters As New ArrayList
|
Dim oDetectedWithParameters As New ArrayList
|
||||||
|
Dim oNotDetectedWithProcessPath As New ArrayList
|
||||||
Dim oDetectedWithProcessPath As New ArrayList
|
Dim oDetectedWithProcessPath As New ArrayList
|
||||||
|
|
||||||
'Get parameters of the found process
|
'Get parameters of the found process
|
||||||
@@ -174,6 +184,9 @@ Public Class mgrProcessDetection
|
|||||||
sFullCommand = GetWindowsCommand(FoundProcess)
|
sFullCommand = GetWindowsCommand(FoundProcess)
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'Get Process Path
|
||||||
|
ProcessPath = GetProcessPath(bWineProcess)
|
||||||
|
|
||||||
'Look for any games using parameters and any matches
|
'Look for any games using parameters and any matches
|
||||||
For Each oDetectedGame As clsGame In oDetectedGames
|
For Each oDetectedGame As clsGame In oDetectedGames
|
||||||
If oDetectedGame.Parameter <> String.Empty Then
|
If oDetectedGame.Parameter <> String.Empty Then
|
||||||
@@ -201,13 +214,14 @@ Public Class mgrProcessDetection
|
|||||||
GameInfo = oDetectedGames(0)
|
GameInfo = oDetectedGames(0)
|
||||||
Duplicate = False
|
Duplicate = False
|
||||||
Else
|
Else
|
||||||
'Get Process Path
|
|
||||||
sProcessPath = GetProcessPath(bWineProcess)
|
|
||||||
|
|
||||||
'Check if we have any exact matches based on process path
|
'Check if we have any exact matches based on process path
|
||||||
For Each oDetectedGame As clsGame In oDetectedGames
|
For Each oDetectedGame As clsGame In oDetectedGames
|
||||||
If oDetectedGame.ProcessPath = sProcessPath Then
|
If oDetectedGame.ProcessPath <> String.Empty Then
|
||||||
|
If oDetectedGame.ProcessPath = ProcessPath Then
|
||||||
oDetectedWithProcessPath.Add(oDetectedGame)
|
oDetectedWithProcessPath.Add(oDetectedGame)
|
||||||
|
Else
|
||||||
|
oNotDetectedWithProcessPath.Add(oDetectedGame)
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
@@ -215,12 +229,23 @@ Public Class mgrProcessDetection
|
|||||||
If oDetectedWithProcessPath.Count = 1 Then
|
If oDetectedWithProcessPath.Count = 1 Then
|
||||||
GameInfo = oDetectedWithProcessPath(0)
|
GameInfo = oDetectedWithProcessPath(0)
|
||||||
Duplicate = False
|
Duplicate = False
|
||||||
|
Else
|
||||||
|
'Remove any games with a process path that does not match the current process
|
||||||
|
For Each oGameNotDetected As clsGame In oNotDetectedWithProcessPath
|
||||||
|
oDetectedGames.Remove(oGameNotDetected)
|
||||||
|
Next
|
||||||
|
|
||||||
|
'If only a single game remains, set it as current game and we're done
|
||||||
|
If oDetectedGames.Count = 1 Then
|
||||||
|
GameInfo = oDetectedGames(0)
|
||||||
|
Duplicate = False
|
||||||
Else
|
Else
|
||||||
'We've done all we can, the user must selected which game they were playing when the process ends
|
'We've done all we can, the user must selected which game they were playing when the process ends
|
||||||
Duplicate = True
|
Duplicate = True
|
||||||
oDuplicateGames = oDetectedGames
|
oDuplicateGames = oDetectedGames
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Function SearchRunningProcesses(ByVal hshScanList As Hashtable, ByRef bNeedsPath As Boolean, ByRef bWineProcess As Boolean, ByRef iErrorCode As Integer, ByVal bDebugMode As Boolean) As Boolean
|
Public Function SearchRunningProcesses(ByVal hshScanList As Hashtable, ByRef bNeedsPath As Boolean, ByRef bWineProcess As Boolean, ByRef iErrorCode As Integer, ByVal bDebugMode As Boolean) As Boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user