面对懂C++魔法的大佬无效[狗头]
此代码用于将snoop窥探到你程序的窗体关闭掉,对方如果把snoop的名称或者窗体名称修改则无效
真正阻止snoop之类的程序进行窥探应该保护你程序进程的内存,而不是用投机取巧的办法
snoop窥探原理,在你的程序进程写入一个来自snoop.exe的WPF窗体
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
EventManager.RegisterClassHandler(typeof(Window), Window.LoadedEvent, new RoutedEventHandler(Window_Loaded), true);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Window window = sender as Window;
if (window != null)
{
string assemName = window.GetType().Assembly.FullName;
string mainModuleName = window.GetType().Assembly.ManifestModule.Name;
IDisposable idispose = null;
if (mainModuleName == "Snoop.exe")
{
window.Close();
idispose = window as IDisposable;
}
if (mainModuleName == "Inspector.exe")
{
window.Close();
idispose = window as IDisposable;
}
else if (window.GetType().Name.Equals("SnoopUI"))
{
window.Close();
idispose = window as IDisposable;
}
else if (window.GetType().Name.Equals("Zoomer"))
{
window.Close();
idispose = window as IDisposable;
}
if (idispose != null)
{
idispose.Dispose();
}
}
}
}
标签:IDisposable,技巧,snoop,Window,保护,window,Close,WPF,idispose
From: https://www.cnblogs.com/wandia/p/16870458.html