我在VB.NET中创建了一个小程序,将Dll注入进程。这将有助于我学习逆向工程和表单设计。唯一的问题是我把表格变成了无边框形式,这意味着我无法拖动它。所以我做的是添加了一个覆盖表单大小的GroupBox元素。我希望能够单击并拖动GroupBox并移动整个表单,就好像它是表单本身并且不是无边界的。这可能听起来令人困惑,但到目前为止,这是我的代码。
Private Sub Loader_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DLLs.Name = "DLLs"
Button1.Text = "Browse"
Label1.Text = "Waiting for process.exe"
Timer1.Interval = 50
Timer1.Start()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "DLL (*.dll) |*.dll"
OpenFileDialog1.ShowDialog()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For i As Integer = (DLLs.SelectedItems.Count - 1) To 0 Step -1
DLLs.Items.Remove(DLLs.SelectedItems(i))
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If IO.File.Exists(OpenFileDialog1.FileName) Then
Dim TargetProcess As Process() = Process.GetProcessesByName(Textbox1.Text)
If TargetProcess.Length = 0 Then
Me.Label1.Text = ("Waiting for process.exe")
Else
Timer1.Stop()
Me.Label1.Text = "Successfully injected"
Call Inject()
End If
Else
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If IO.File.Exists(OpenFileDialog1.FileName) Then
Dim TargetProcess As Process() = Process.GetProcessesByName(Textbox1.Text)
If TargetProcess.Length = 0 Then
Me.Label1.Text = ("Waiting for process.exe")
Else
Timer1.Stop()
Me.Label1.Text = "Successfully injected"
Call Inject()
End If
Else
End If
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
Dim FileName As String
FileName = OpenFileDialog1.FileName.Substring(OpenFileDialog1.FileName.LastIndexOf("\"))
Dim DllFileName As String = FileName.Replace("\", "")
Me.DLLs.Items.Add(DllFileName)
End Sub
Private Sub DLLs_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DLLs.SelectedIndexChanged
Me.TopMost = True
End Sub
答案 0 :(得分:1)
假设您的群组是“GroupBox1”:
http://localhost:3000/articles
答案 1 :(得分:0)
下面是我用来处理类似情况的代码。如果要单击要拖动的表单上的任何位置,则必须为表单上的每个控件创建“MouseDown”和“MouseMove”处理程序。
Private m_CursorOffset As Point
Public Sub GroupBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles GroupBox1.MouseDown
If e.Button = Windows.Forms.MouseButtons.Left Then
m_CursorOffset = e.Location
End If
End Sub
Public Sub GroupBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles GroupBox1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
'Distance we moved
Dim d As Point = New Point(e.X - m_CursorOffset.X, e.Y - m_CursorOffset.Y)
'New location of the form
Dim adjustedLocation As New Point(Me.Location.X + d.X, Me.Location.Y + d.Y)
' Set the new position of our form
Me.Location = adjustedLocation
End If
End Sub