Added Wine detection support
This commit is contained in:
@@ -83,7 +83,7 @@ Public Class frmAddWizard
|
||||
Dim sName As String = txtName.Text
|
||||
Dim sProcessFullPath As String = txtProcessPath.Text
|
||||
Dim sProcessPath As String = Path.GetDirectoryName(sProcessFullPath)
|
||||
Dim sProcess As String
|
||||
Dim sProcess As String = Path.GetFileNameWithoutExtension(sProcessFullPath)
|
||||
Dim sProcessSummaryText As String = Path.GetFileName(sProcessFullPath) & " (" & sProcessPath & ")"
|
||||
Dim sSavePath As String = txtSavePath.Text
|
||||
Dim bIsAbsolute As Boolean = mgrPath.IsAbsolute(sSavePath)
|
||||
@@ -100,13 +100,6 @@ Public Class frmAddWizard
|
||||
sSavePath = mgrPath.DetermineRelativePath(sProcessPath, sSavePath)
|
||||
End If
|
||||
|
||||
'Unix Handler
|
||||
If mgrCommon.IsUnix Then
|
||||
sProcess = Path.GetFileName(sProcessFullPath)
|
||||
Else
|
||||
sProcess = Path.GetFileNameWithoutExtension(sProcessFullPath)
|
||||
End If
|
||||
|
||||
'Build Summary Listview
|
||||
lstSummary.Clear()
|
||||
lstSummary.Columns.Add("Item")
|
||||
|
||||
@@ -942,7 +942,7 @@ Public Class frmGameManager
|
||||
oApp.ID = txtID.Text
|
||||
End If
|
||||
oApp.Name = mgrPath.ValidateForFileSystem(txtName.Text)
|
||||
If Path.HasExtension(txtProcess.Text) And Not mgrCommon.IsUnix Then
|
||||
If Path.HasExtension(txtProcess.Text) Then
|
||||
If txtProcess.Text.ToLower.EndsWith(".exe") Then
|
||||
oApp.ProcessName = Path.GetFileNameWithoutExtension(txtProcess.Text)
|
||||
Else
|
||||
|
||||
@@ -563,8 +563,8 @@ Public Class frmMain
|
||||
sMainCommand = sFullCommand.Split(cDelimters, 2)(0)
|
||||
|
||||
'Parse Command
|
||||
Select Case sMainCommand
|
||||
Case "SQL"
|
||||
Select Case sMainCommand.ToLower
|
||||
Case "sql"
|
||||
'Run a SQL command directly on any database
|
||||
'Usage: SQL {Local or Remote} SQL Command
|
||||
|
||||
@@ -579,9 +579,9 @@ Public Class frmMain
|
||||
Exit Select
|
||||
End If
|
||||
|
||||
If sCommand(1) = "Local" Then
|
||||
If sCommand(1).ToLower = "local" Then
|
||||
oDatabase = New mgrSQLite(mgrSQLite.Database.Local)
|
||||
ElseIf sCommand(1) = "Remote" Then
|
||||
ElseIf sCommand(1).ToLower = "remote" Then
|
||||
oDatabase = New mgrSQLite(mgrSQLite.Database.Remote)
|
||||
Else
|
||||
mgrCommon.ShowMessage(frmMain_ErrorCommandBadParam, New String() {sCommand(1), sCommand(0)}, MsgBoxStyle.Exclamation)
|
||||
@@ -596,7 +596,7 @@ Public Class frmMain
|
||||
mgrCommon.ShowMessage(frmMain_CommandFail, MsgBoxStyle.Exclamation)
|
||||
End If
|
||||
|
||||
Case "DEBUG"
|
||||
Case "debug"
|
||||
'Enable or disable various debug modes
|
||||
'Usage: DEBUG Mode {Enable or Disable}
|
||||
|
||||
@@ -610,17 +610,17 @@ Public Class frmMain
|
||||
Exit Select
|
||||
End If
|
||||
|
||||
If sCommand(2) = "Enable" Then
|
||||
If sCommand(2).ToLower = "enable" Then
|
||||
bDebugEnable = True
|
||||
ElseIf sCommand(2) = "Disable" Then
|
||||
ElseIf sCommand(2).ToLower = "disable" Then
|
||||
bDebugEnable = False
|
||||
Else
|
||||
mgrCommon.ShowMessage(frmMain_ErrorCommandBadParam, New String() {sCommand(1), sCommand(0)}, MsgBoxStyle.Exclamation)
|
||||
Exit Select
|
||||
End If
|
||||
|
||||
Select Case sCommand(1)
|
||||
Case "Process"
|
||||
Select Case sCommand(1).ToLower
|
||||
Case "process"
|
||||
bProcessDebugMode = bDebugEnable
|
||||
mgrCommon.ShowMessage(frmMain_CommandSucess, MsgBoxStyle.Exclamation)
|
||||
End Select
|
||||
|
||||
@@ -85,17 +85,66 @@ Public Class mgrProcesses
|
||||
Next
|
||||
End Sub
|
||||
|
||||
'This function will only works correctly on Unix
|
||||
Private Function GetUnixProcessArguments(ByVal prs As Process) As String()
|
||||
Dim sArguments As String
|
||||
Try
|
||||
sArguments = File.ReadAllText("/proc/" & prs.Id.ToString() & "/cmdline")
|
||||
Return sArguments.Split(vbNullChar)
|
||||
Catch ex As Exception
|
||||
Return New String() {String.Empty}
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'This function will only works correctly on Unix
|
||||
Private Function GetUnixProcessWorkingDirectory(ByVal prs As Process) As String
|
||||
Dim prsls As Process
|
||||
Dim slsinfo As String()
|
||||
|
||||
'This is the best way I can think of to determine the end point of a symlink without doing even more crazy shit
|
||||
Try
|
||||
prsls = New Process
|
||||
prsls.StartInfo.FileName = "/bin/bash"
|
||||
prsls.StartInfo.Arguments = "-c ""ls -l /proc/" & prs.Id.ToString & " | grep cwd"""
|
||||
prsls.StartInfo.UseShellExecute = False
|
||||
prsls.StartInfo.RedirectStandardOutput = True
|
||||
prsls.StartInfo.CreateNoWindow = True
|
||||
prsls.Start()
|
||||
slsinfo = prsls.StandardOutput.ReadToEnd().Split(" ")
|
||||
Return slsinfo(slsinfo.Length - 1).TrimEnd
|
||||
Catch ex As Exception
|
||||
Return String.Empty
|
||||
End Try
|
||||
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
|
||||
Dim sProcessList As String = String.Empty
|
||||
Dim bWineProcess As Boolean = False
|
||||
|
||||
For Each prsCurrent As Process In prsList
|
||||
|
||||
'This needs to be wrapped due to issues with Mono.
|
||||
Try
|
||||
sProcessCheck = prsCurrent.ProcessName
|
||||
If bDebugMode Then sProcessList &= sProcessCheck & vbCrLf
|
||||
|
||||
'Unix Handler
|
||||
'We need some special handling for Wine processes
|
||||
If mgrCommon.IsUnix And sProcessCheck.ToLower = "wine-preloader" Then
|
||||
Dim sWinePath As String()
|
||||
'We can't use Path.GetFileName here, Wine uses the Windows seperator in arguments and the Unix version of the function expects a different one.
|
||||
sWinePath = GetUnixProcessArguments(prsCurrent)(0).Split("\")
|
||||
sProcessCheck = sWinePath(sWinePath.Length - 1).Replace(".exe", "")
|
||||
bWineProcess = True
|
||||
Else
|
||||
bWineProcess = False
|
||||
End If
|
||||
|
||||
If bDebugMode And mgrCommon.IsUnix Then
|
||||
sProcessList &= prsCurrent.Id & " " & prsCurrent.ProcessName & " " & GetUnixProcessArguments(prsCurrent)(0) & vbCrLf
|
||||
ElseIf bDebugMode Then
|
||||
sProcessList &= prsCurrent.Id & " " & prsCurrent.ProcessName & vbCrLf
|
||||
End If
|
||||
Catch ex As Exception
|
||||
'Do Nothing
|
||||
End Try
|
||||
@@ -113,7 +162,11 @@ Public Class mgrProcesses
|
||||
|
||||
If Not oGame.AbsolutePath Or oGame.Duplicate Then
|
||||
Try
|
||||
oGame.ProcessPath = Path.GetDirectoryName(prsCurrent.MainModule.FileName)
|
||||
If Not bWineProcess Then
|
||||
oGame.ProcessPath = Path.GetDirectoryName(prsCurrent.MainModule.FileName)
|
||||
Else
|
||||
oGame.ProcessPath = GetUnixProcessWorkingDirectory(prsCurrent)
|
||||
End If
|
||||
Catch exWin32 As System.ComponentModel.Win32Exception
|
||||
'If an exception occurs the process is:
|
||||
'Running as administrator and the app isn't.
|
||||
|
||||
Reference in New Issue
Block a user