【发布时间】:2020-09-01 02:43:26
【问题描述】:
所以,当我点击开始调试时,它显示的是我的主窗口而不是另一个窗口,这是我想要测试的。
这是主窗口代码。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using EasyExploits;
using System.Windows.Forms;
using System.Diagnostics;
using System.Net;
using System.Threading;
using System.Linq.Expressions;
using MeguSploit;
namespace Exploit_Template
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
Module m = new Module();
public MainWindow()
{
InitializeComponent();
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
using (StreamReader s = new StreamReader("./Bin/Languages/Lua.xshd"))
{
using (XmlTextReader reader = new XmlTextReader(s))
{
TextEditor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, HighlightingManager.Instance);
}
}
DirectoryInfo di = new DirectoryInfo("./Scripts");
FileInfo[] f = di.GetFiles("*.txt");
foreach (FileInfo fi in f)
{
ListBox.Items.Add(fi.Name);
}
DirectoryInfo din = new DirectoryInfo("./Scripts");
FileInfo[] file = din.GetFiles("*.lua");
foreach (FileInfo fil in file)
{
ListBox.Items.Add(fil.Name);
}
}
private void Exit_Click(object sender, RoutedEventArgs e)
{
System.Windows.Application.Current.Shutdown();
}
private void Minimize_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void Load_Click(object sender, RoutedEventArgs e)
{
if (ListBox.SelectedIndex != -1)
{
TextEditor.Text = File.ReadAllText($"./Scripts/{ListBox.SelectedItem}");
}
}
private void Refresh_Click(object sender, RoutedEventArgs e)
{
ListBox.Items.Clear();
DirectoryInfo di = new DirectoryInfo("./Scripts");
FileInfo[] f = di.GetFiles("*.txt");
foreach (FileInfo fi in f)
{
ListBox.Items.Add(fi.Name);
}
DirectoryInfo din = new DirectoryInfo("./Scripts");
FileInfo[] file = din.GetFiles("*.lua");
foreach (FileInfo fil in file)
{
ListBox.Items.Add(fil.Name);
}
}
private void ExecuteL_Click(object sender, RoutedEventArgs e)
{
if (ListBox.SelectedIndex != -1)
{
m.ExecuteScript(File.ReadAllText($"./Scripts/{ListBox.SelectedItem}"));
}
}
private void Execute_Click(object sender, RoutedEventArgs e)
{
m.ExecuteScript(TextEditor.Text);
Status.Content = "Executed!";
}
private void Clear_Click(object sender, RoutedEventArgs e)
{
TextEditor.Text = "";
Status.Content = "Ready!";
}
private void OpenFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Txt Files (*.txt)|*.txt|Lua Files (*.lua)|*.lua";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
TextEditor.Text = File.ReadAllText(ofd.FileName);
}
}
private void ExecuteFile_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog ef = new OpenFileDialog();
ef.Filter = "Txt Files (*.txt)|*.txt|Lua Files (*.lua)|*.lua";
if (ef.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
m.ExecuteScript(ef.FileName);
}
}
private void SaveFile_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Txt Files (*.txt)|*.txt|Lua Files (*.lua)|*.lua";
if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
File.WriteAllText(sfd.FileName, TextEditor.Text);
}
}
private void Attach_Click(object sender, RoutedEventArgs e)
{
m.LaunchExploit();
Status.Content = "Injected!";
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
}
}
}
这是我想首先启动的窗口。
using Exploit_Template;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MeguSploit
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
Process.Start("https://shrinkme.io/BWe0");
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
if (Pass.Text == new WebClient().DownloadString("https://pastebin.com/raw/VTGJqX6k") || Pass.Text == "stefanradu2005eadminsiesmekrau")
{
MessageBox.Show("Thank you for using MeguSploit");
this.Hide();
MainWindow main = new MainWindow();
main.Show();
}
else
{
MessageBox.Show("Sorry the key is invalid", "Key Invalid");
}
}
private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
this.DragMove();
}
}
}
我真的需要帮助,我是编程界的新手。提前致谢。我也不想从头开始,因为我会浪费很多时间。这将是最后的选择。
【问题讨论】:
-
更改 Application.Run(new MainWindow ());在 program.cs 中的表单
-
@mehdifarhadi 这应该是一个答案,而不是评论;)
-
@mehdifarhadi 实际上他在 WPF 应用程序中而不是在 winform 中,因此对于入口点,他应该使用
App.g.cs但更容易在 App.xaml 中更改StartupUri
标签: c# .net wpf windows visual-studio