forked from iH8sn0w/iBooty
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodProcessCmd.vb
More file actions
119 lines (96 loc) · 4.37 KB
/
modProcessCmd.vb
File metadata and controls
119 lines (96 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Option Strict Off
Option Explicit On
Imports System.Environment
Imports System.IO
Imports System.Windows.Forms.FileDialog
Imports System.Reflection
Module modProcessCmd
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'Constants
Public Const NORMAL_PRIORITY_CLASS As Integer = &H20
Public Const HIGH_PRIORITY_CLASS As Integer = &H80
Public Const INFINITE As Short = -1
Private Const STARTF_USESHOWWINDOW As Short = 1
Private Const SW_HIDE As Short = 0
'public Types
Public Structure STARTUPINFO
Dim cb As Integer
Dim lpReserved As String
Dim lpDesktop As String
Dim lpTitle As String
Dim dwX As Integer
Dim dwY As Integer
Dim dwXSize As Integer
Dim dwYSize As Integer
Dim dwXCountChars As Integer
Dim dwYCountChars As Integer
Dim dwFillAttribute As Integer
Dim dwFlags As Integer
Dim wShowWindow As Short
Dim cbReserved2 As Short
Dim lpReserved2 As Integer
Dim hStdInput As Integer
Dim hStdOutput As Integer
Dim hStdError As Integer
End Structure
Public Structure PROCESS_INFORMATION
Dim hProcess As Integer
Dim hThread As Integer
Dim dwProcessID As Integer
Dim dwThreadID As Integer
End Structure
'API Declarations
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Integer, ByVal dwMilliseconds As Integer) As Integer
'UPGRADE_WARNING: Structure PROCESS_INFORMATION may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
'UPGRADE_WARNING: Structure STARTUPINFO may require marshalling attributes to be passed as an argument in this Declare statement. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="C429C3A5-5D47-4CD9-8F51-74A1616405DC"'
Public Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Integer, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Integer, ByVal lpThreadAttributes As Integer, ByVal bInheritHandles As Integer, ByVal dwCreationFlags As Integer, ByVal lpEnvironment As Integer, ByVal lpCurrentDirectory As Integer, ByRef lpStartupInfo As STARTUPINFO, ByRef lpProcessInformation As PROCESS_INFORMATION) As Integer
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer
'example use
'cmdline = "%comspec% /c """ & App.Path & "\7z.exe x -oIPSW ,original.ipsw"""
'or
'cmdline = "7z.exe x -oIPSW ,original.ipsw"
'or
'cmdline = "DEL fstab.original /f /q"
'ExecCmd (cmdline, True) 'False = show windows
Public Function ExecCmd(ByVal cmdline As String, Optional ByVal HideWindow As Boolean = False) As Integer
Dim Proc As PROCESS_INFORMATION
Dim start As STARTUPINFO = Nothing
Dim ReturnValue As Short
'Hide window?
If (HideWindow) Then
start.dwFlags = STARTF_USESHOWWINDOW
start.wShowWindow = SW_HIDE
End If
'Initialize The STARTUPINFO Structure
start.cb = Len(start)
'Start The Shelled Application
ReturnValue = CreateProcessA(0, cmdline, 0, 0, 1, HIGH_PRIORITY_CLASS, 0, 0, start, Proc)
'Wait for The Shelled Application to Finish
Do
ReturnValue = WaitForSingleObject(Proc.hProcess, 0)
System.Windows.Forms.Application.DoEvents()
Sleep(100)
Loop Until ReturnValue <> 258
'Close Handle to Shelled Application
ReturnValue = CloseHandle(Proc.hProcess)
End Function
Sub Delay(ByVal dblSecs As Double)
Const OneSec As Double = 1.0# / (1440.0# * 60.0#)
Dim dblWaitTil As Date
Now.AddSeconds(OneSec)
dblWaitTil = Now.AddSeconds(OneSec).AddSeconds(dblSecs)
Do Until Now > dblWaitTil
Application.DoEvents() ' Allow windows messages to be processed
Loop
End Sub
Public Function File_Exists(ByVal strFile As String) As Boolean
If strFile.Length <> 0 Then
Dim oFile As New FileInfo(strFile)
If oFile.Exists = True Then
File_Exists = True
Else
File_Exists = False
End If
End If
End Function
End Module