Fixed more problems with issue #98

This commit is contained in:
Michael J. Seiferling
2018-02-14 10:23:18 -06:00
parent 1ab0e77918
commit 978242d0dd
3 changed files with 22 additions and 24 deletions
-18
View File
@@ -258,24 +258,6 @@ Public Class mgrCommon
Return dFileSize
End Function
Public Shared Function IsMatch(ByRef oGame As clsGame, ByRef sProcessCheck As String) As Boolean
If oGame.IsRegEx Then
Try
If Regex.IsMatch(sProcessCheck, oGame.ProcessName) Then
Return True
End If
Catch
'Ignore malformed regular expressions that may have passed validation
End Try
Else
If oGame.ProcessName = sProcessCheck Then
Return True
End If
End If
Return False
End Function
Public Shared Function WildcardToRegex(ByVal sPattern As String) As String
Dim sRegEx As String
sRegEx = sPattern.Replace("*", ".*")
+2 -1
View File
@@ -1,4 +1,5 @@
Imports GBM.My.Resources
Imports System.Text.RegularExpressions
Imports System.Collections.Specialized
Imports System.IO
@@ -88,7 +89,7 @@ Public Class mgrMonitorList
Case eListTypes.ScanList
For Each de As DictionaryEntry In hshList
oCompareGame = DirectCast(de.Value, clsGame)
If mgrCommon.IsMatch(oCompareGame, oGame.ProcessName) Then
If Regex.IsMatch(oGame.ProcessName, oCompareGame.ProcessName) Or (oGame.ProcessName = oCompareGame.ProcessName) Then
DirectCast(hshList.Item(oCompareGame.ProcessName), clsGame).Duplicate = True
oGame.ProcessName = oGame.ProcessName & ":" & oGame.Name
oGame.Duplicate = True
+20 -5
View File
@@ -91,10 +91,7 @@ Public Class mgrProcesses
sProcess = o.ProcessName.Split(":")(0)
If o.Duplicate = True And (sProcess = oGame.TrueProcess Or Regex.IsMatch(sProcess, oGame.TrueProcess)) Then
If o.Parameter <> String.Empty And FullCommand.Contains(o.Parameter) Then
oGame = o.ShallowCopy
Return True
ElseIf o.Parameter = String.Empty Then
If (o.Parameter <> String.Empty And FullCommand.Contains(o.Parameter)) Or (o.Parameter = String.Empty And FullCommand = String.Empty) Then
oDuplicateGames.Add(o.ShallowCopy)
End If
End If
@@ -163,6 +160,24 @@ Public Class mgrProcesses
End Try
End Function
Private Function IsMatch(ByRef oGame As clsGame, ByRef sProcessCheck As String) As Boolean
If oGame.IsRegEx Then
Try
If Regex.IsMatch(sProcessCheck, oGame.ProcessName) Then
Return True
End If
Catch
'Ignore malformed regular expressions that may have passed validation
End Try
Else
If oGame.ProcessName = sProcessCheck Then
Return True
End If
End If
Return False
End Function
Public Function SearchRunningProcesses(ByVal hshScanList As Hashtable, ByRef bNeedsPath As Boolean, ByRef iErrorCode As Integer, ByVal bDebugMode As Boolean) As Boolean
Dim prsList() As Process = Process.GetProcesses
Dim sProcessCheck As String = String.Empty
@@ -200,7 +215,7 @@ Public Class mgrProcesses
'Detection Pass 1
For Each oCurrentGame As clsGame In hshScanList.Values
If mgrCommon.IsMatch(oCurrentGame, sProcessCheck) Then
If IsMatch(oCurrentGame, sProcessCheck) Then
prsFoundProcess = prsCurrent
oGame = oCurrentGame.ShallowCopy
bPass = True