private int WndProc(IntPtr hWnd, int Msg, int wParam, int lParam) { if (Msg != WM_USER) { return(WinImports.CallWindowProc(_oldCallback, hWnd, Msg, wParam, lParam)); } var tmpMsg = (UserMessage)wParam; switch (tmpMsg) { case UserMessage.RunDelegateReturn: Delegate result; if (InvokeReturnFunction.TryDequeue(out result)) { var invokeTarget = result; InvokeReturnValue.Enqueue(invokeTarget.DynamicInvoke()); } return(0); case UserMessage.RunDelegate: Action action; if (InvokeQueue.TryDequeue(out action)) { action.Invoke(); } return(0); } return(WinImports.CallWindowProc(_oldCallback, hWnd, Msg, wParam, lParam)); }
private void btn_ResizeWindow_Click(object sender, EventArgs e) { const short SWP_NOMOVE = 0X2; const short SWP_NOSIZE = 1; const short SWP_NOZORDER = 0X4; const int SWP_SHOWWINDOW = 0x0040; if (Mem.WindowProcHook.HWnD != IntPtr.Zero && Mem.WindowProcHook.HWnD != null) { Size cSize = new Size(); var tmpRect = new WinImports.RECT(); WinImports.GetWindowRect(Mem.WindowProcHook.HWnD, out tmpRect); cSize.Width = tmpRect.Right - tmpRect.Left; cSize.Height = tmpRect.Bottom - tmpRect.Top; int targetWidth = 407; int targetHeight = 316; //set wow window to location and resize WinImports.SetWindowPos(Mem.WindowProcHook.HWnD, 0, 1, 1, targetWidth, targetHeight, SWP_NOZORDER | SWP_SHOWWINDOW); //set bot mainform to a location below GuiCore.MainForm.Location = new Point(1, 1 + targetHeight); } }
private bool WindowProc(IntPtr hWnd, IntPtr lParam) { int procId; WinImports.GetWindowThreadProcessId(hWnd, out procId); if (procId != Memory.Reader.Process.Id) { return(true); } if (!WinImports.IsWindowVisible(hWnd)) { return(true); } var l = WinImports.GetWindowTextLength(hWnd); if (l == 0) { return(true); } var builder = new StringBuilder(l + 1); WinImports.GetWindowText(hWnd, builder, builder.Capacity); if (builder.ToString() == "World of Warcraft") { _hWnd = (int)hWnd; } return(true); }
private void btn_GetWowWindow_Click(object sender, EventArgs e) { const short SWP_NOMOVE = 0X2; const short SWP_NOSIZE = 1; const short SWP_NOZORDER = 0X4; const int SWP_SHOWWINDOW = 0x0040; if (Mem.WindowProcHook.HWnD != IntPtr.Zero && Mem.WindowProcHook.HWnD != null) { Size cSize = new Size(); var tmpRect = new WinImports.RECT(); WinImports.GetWindowRect(Mem.WindowProcHook.HWnD, out tmpRect); cSize.Width = tmpRect.Right - tmpRect.Left; cSize.Height = tmpRect.Bottom - tmpRect.Top; //window location GuiCore.SettingsForm.txt_WowWindowX.Text = tmpRect.Left.ToString(); GuiCore.SettingsForm.txt_WowWindowY.Text = tmpRect.Top.ToString(); //window size GuiCore.SettingsForm.txt_WowWindowWidth.Text = cSize.Width.ToString(); GuiCore.SettingsForm.txt_WowWindowHeigth.Text = cSize.Height.ToString(); } }
internal async void SendDownUp(Keys parKey) { WinImports.PostMessage(_hWnd, (uint)KeySender.KeyModifier.WM_KEYDOWN, (int)parKey, 0); await Task.Delay(100); WinImports.PostMessage(_hWnd, (uint)KeySender.KeyModifier.WM_KEYUP, (int)parKey, 0); }
/// <summary> /// Setup the detour /// </summary> internal static void Init() { modules = new List <string>(Resources.ModulesOfWoW.Split(new[] { Environment.NewLine }, StringSplitOptions.None)); var handle = WinImports.GetModuleHandle("kernel32.dll"); var firstAddr = WinImports.GetProcAddress(handle, "Module32First"); Console.WriteLine("Module32First: " + firstAddr.ToString("X")); var nextAddr = WinImports.GetProcAddress(handle, "Module32Next"); //Registering a delegate pointing to the function we want to detour _module32FirstDelegate = Memory.Reader.RegisterDelegate <_Module32First>(firstAddr); _module32FirstHook = Memory.Reader.Detours.CreateAndApply( _module32FirstDelegate, // The delegate pointing to the function we want to hook new _Module32First(Module32FirstDetour), // the detour which will be called from the function we hooked "Module32First"); // the name of detour // Registering a delegate pointing to the function we want to detour _module32NextDelegate = Memory.Reader.RegisterDelegate <_Module32Next>(nextAddr); _module32NextHook = Memory.Reader.Detours.CreateAndApply( _module32NextDelegate, // The delegate pointing to the function we want to hook new _Module32Next(Module32NextDetour), // the detour which will be called from the function we hooked "Module32Next"); // the name of detour }
/// <summary> /// Detour for Module32Next /// </summary> internal bool Module32NextDetour(IntPtr snapshot, ref WinImports.MODULEENTRY32 module) { _module32NextHook.Remove(); var ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); while (!modules.Contains(module.szModule.ToLower()) && ret) { if (!_protectedItems.Contains(module.szModule.ToLower())) { _protectedItems.Add(module.szModule.ToLower()); File.WriteAllText("C:\\Logs\\myDll.txt", _protectedItems.Aggregate("", (s, s1) => s + "\r\n" + s1)); } _module32NextHook.Remove(); ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); } if (!ret) { if (!modules.Contains(module.szModule.ToLower())) { module = new WinImports.MODULEENTRY32 { dwSize = 548 } } ; WinImports.SetLastError(18); } return(ret); }
/// <summary> /// Detour for Module32Next /// </summary> internal static bool Module32NextDetour(IntPtr snapshot, ref WinImports.MODULEENTRY32 module) { _module32NextHook.Remove(); var ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); while (!modules.Contains(module.szModule.ToLower()) && ret) { _module32NextHook.Remove(); ret = WinImports.Module32Next(snapshot, ref module); _module32NextHook.Apply(); } if (!ret) { if (!modules.Contains(module.szModule.ToLower())) { module = new WinImports.MODULEENTRY32 { dwSize = 548 }; } WinImports.SetLastError(18); } return(ret); }
internal static TClass CreateInterface <TClass>(string module, int offset = 0) where TClass : InteropHelp.INativeWrapper, new() { try { ProcessModule procModule = null; foreach (ProcessModule m in Process.GetCurrentProcess().Modules) { if (m.ModuleName == module) { procModule = m; } } if (procModule == null) { throw new DotaException($"Can't find Module '{module}'"); } IntPtr addrModule = WinImports.LoadLibraryEx(procModule.FileName, IntPtr.Zero, WinImports.LoadLibraryFlags.LoadWithAlteredSearchPath); if (addrModule == IntPtr.Zero) { throw new DotaException($"Can't load Module '{module}'"); } m_callCreateInterface = Native.GetExportFunction <Native.CreateInterface>(addrModule, "CreateInterface"); if (m_callCreateInterface == null) { throw new DotaException($"Interface wasn't created - Module '{module}'"); } IntPtr address = m_callCreateInterface(InterfaceVersions.GetInterfaceIdentifier(typeof(TClass)), IntPtr.Zero); if (address == IntPtr.Zero) { throw new DotaException($"Interface Identifier failed - Module '{module}'"); } if (offset > 0) { address = address + offset; } TClass result = new TClass(); result.SetupFunctions(address); return(result); } catch (DotaException) { return(default(TClass)); } }
static void MainTwo() { // Setting culture for float etc (. instead of ,) CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // ClassicFramework cant be run alone! if (Process.GetCurrentProcess().ProcessName.StartsWith("ClassicFramework")) { if (!Assembly.GetExecutingAssembly().Location.ToLower().Contains("internal")) { MessageBox.Show("Your file structure is corrupt. Please redownload ClassicFramework"); Environment.Exit(-1); } // Do the settings exist? if (!File.Exists(".\\Settings.xml")) { OpenFileDialog loc = new OpenFileDialog(); loc.CheckFileExists = true; loc.CheckPathExists = true; loc.Filter = "executable (*.exe)|*.exe"; loc.FilterIndex = 1; loc.Title = "Please locate your WoW.exe"; if (loc.ShowDialog() == DialogResult.OK) { OOP.Settings.Recreate(loc.FileName); } } Launch.Run(); Environment.Exit(0); } WinImports.LoadLibrary( Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\FastCallDll.dll" ); //WinImports.AllocConsole(); //Logger.Append("We are injected now!"); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); XDocument doc = XDocument.Load(path + "\\Settings.xml"); XElement loot = doc.Element("Settings").Element("AutoLoot"); LuaFunctions.CustomFuncs.AutoLoot.enabled = Convert.ToBoolean(loot.Value); Memory.Init(); RegisterFunctionHook.Init(); UnregisterFunctionHook.Init(); if (LuaFunctions.CustomFuncs.AutoLoot.enabled) { OnRightClickUnitHook.Apply(); OnRightClickObjectHook.Apply(); } Singleton.Initialise(); while (true) { Thread.Sleep(250); } // Run the GUI //Application.Run(new Main()); }
/// <summary> /// The main entry point for the application /// </summary> public async Task LaunchBot() { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; if (!Injected) { await CheckAndInject(); Environment.Exit(0); } else { "Injected!!".Log(Logs.Injected); AppDomain.CurrentDomain.UnhandledException += (sender, args) => { MessageBox.Show("A exception occured! The details were logged"); args.ExceptionObject.ToString().Log(Logs.Exceptions, false); }; AppDomain.CurrentDomain.AssemblyResolve += DependencyLoader.CurrentDomain_AssemblyResolve; #if DEBUG Debugger.Launch(); WinImports.AllocConsole(); DebugAssist.Init(); #endif await SetRealmlist(); try { $"Enabling the login block until the user authenticates".Log(Logs.Injected, true); LoginBlock.Enable(); Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; //$"Bringing up the login window".Log(Logs.Injected, true); //var authenticationView = new AuthenticationView(); //authenticationView.ShowDialog(); //var authenticationModel = (AuthenticationViewModel)authenticationView.DataContext; //if (authenticationModel.Result == null || authenticationModel.Result.Value != DialogResult.OK) //Environment.Exit(0); $"Initialising the bot".Log(Logs.Injected, true); Memory.Init(); $"Disabling the login block".Log(Logs.Injected, true); LoginBlock.Disable(); $"Showing the bots mainwindow".Log(Logs.Injected, true); var mainView = new MainView(); Current.MainWindow = mainView; mainView.Closed += (sender, args) => { Environment.Exit(0); }; mainView.Show(); } catch (Exception e) { e.ToString().Log(Logs.Exceptions); } } }
private void panel1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { WinImports.ReleaseCapture(); WinImports.SendMessage(Handle, WinImports.WM_NCLBUTTONDOWN, WinImports.HT_CAPTION, 0); } }
private MainThread() { WinImports.EnumWindows(WindowProc, IntPtr.Zero); _newCallback = WndProc; // Pins WndProc - will not be garbage collected. _oldCallback = WinImports.SetWindowLong((IntPtr)_hWnd, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(_newCallback)); mtId = Process.GetCurrentProcess().Threads[0].Id; }
/// <summary> /// Detour for Module32First /// </summary> internal static bool Module32FirstDetour(IntPtr snapshot, ref WinImports.MODULEENTRY32 module) { _module32FirstHook.Remove(); var ret = WinImports.Module32First(snapshot, ref module); _module32FirstHook.Apply(); return(ret); }
/// <summary> /// The main entry point for the application. /// </summary> private static void LaunchBot() { SetPaths(); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; if (!AreWeInjected) { LogFiles.PreInjectLog.ClearLog(); LogFiles.QuitLog.ClearLog(); LogFiles.InjectedLog.ClearLog(); "We are not injected yet".Log(LogFiles.PreInjectLog); PrepareAndInject(); Environment.Exit(0); } else { AppDomain.CurrentDomain.UnhandledException += (sender, args) => { MessageBox.Show("A exception occured! The details were logged"); args.ExceptionObject.ToString().Log(LogFiles.Exceptions, false); }; AppDomain.CurrentDomain.AssemblyResolve += DependencyLoader.CurrentDomain_AssemblyResolve; #if DEBUG Debugger.Launch(); WinImports.AllocConsole(); DebugAssist.Init(); #endif SetRealmlist(); try { $"Enabling the login block until the user authenticates".Log(LogFiles.InjectedLog, true); LoginBlock.Enable(); Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; $"Bringing up the login window".Log(LogFiles.InjectedLog, true); var loginWindow = new LoginWindow(); loginWindow.ShowDialog(); var loginModel = (LoginViewModel)loginWindow.DataContext; if (loginModel.Result == null || loginModel.Result.Value != DialogResult.OK) { Environment.Exit(0); } $"Initialising the bot".Log(LogFiles.InjectedLog, true); Memory.Init(); $"Disabling the login block".Log(LogFiles.InjectedLog, true); LoginBlock.Disable(); $"Showing the bots mainwindow".Log(LogFiles.InjectedLog, true); var mainWindow = new MainWindow(); Current.MainWindow = mainWindow; mainWindow.Closed += (sender, args) => { Environment.Exit(0); }; mainWindow.Show(); } catch (Exception e) { e.ToString().Log(LogFiles.Exceptions); } } }
/// <summary> /// set wow window size and location /// </summary> public static void SetWowWindow() { if (!string.IsNullOrEmpty(Settings.Settings.WowWindowHeight) && Settings.Settings.WowWindowHeight != "0" && !string.IsNullOrEmpty(Settings.Settings.WowWindowWidth) && Settings.Settings.WowWindowWidth != "0" && !string.IsNullOrEmpty(Settings.Settings.WowWindowX) && !string.IsNullOrEmpty(Settings.Settings.WowWindowY)) { WinImports.SetWindowPos(Mem.WindowProcHook.HWnD, 0, int.Parse(Settings.Settings.WowWindowX), int.Parse(Settings.Settings.WowWindowY), int.Parse(Settings.Settings.WowWindowWidth), int.Parse(Settings.Settings.WowWindowHeight), SWP_NOZORDER | SWP_SHOWWINDOW); } }
public static unsafe void PrintConsoleWarning(string message) { IntPtr ptrWarning = WinImports.GetProcAddress(WinImports.GetModuleHandle("Tier0.dll"), "Warning"); FMsg warningFunction = (FMsg)Marshal.GetDelegateForFunctionPointer(ptrWarning, typeof(FMsg)); sbyte *msg = MemoryManager.StringToChar(message + "\n"); warningFunction(msg); }
/// <summary> /// Execute the function in the mainthread. See also <see cref="Invoke" /> /// </summary> /// <param name="parDelegate">The function</param> public void Invoke(Action parDelegate) { if (WinImports.GetCurrentThreadId() == mtId) { parDelegate(); return; } InvokeQueue.Enqueue(parDelegate); SendUserMessage(UserMessage.RunDelegate); }
internal static void SendUpDown(Keys parKey) { var tmpThr = new Thread(delegate() { WinImports.SendMessage((int)HWnD, (uint)Action.WM_KEYDOWN, (int)parKey, 0); Thread.Sleep(100); WinImports.SendMessage((int)HWnD, (uint)Action.WM_KEYUP, (int)parKey, 0); }); tmpThr.Start(); }
internal static void ReloadNav() { if (NavPtr == IntPtr.Zero) { if (!File.Exists(pathNavigation)) { File.WriteAllBytes(pathNavigation, Resources.Navigation); } NavPtr = WinImports.LoadLibrary(pathNavigation); } }
internal static void InjectFastcall() { if (FastCallPtr == IntPtr.Zero) { if (!File.Exists(pathFastCall)) { File.WriteAllBytes(pathFastCall, Resources.FastCallDll); } FastCallPtr = WinImports.LoadLibrary(pathFastCall); } }
public static void Init() { if (Applied) { return; } WinImports.EnumWindows(WindowProc, IntPtr.Zero); _newCallback = WndProc; // Pins WndProc - will not be garbage collected. _oldCallback = WinImports.SetWindowLong(HWnD, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(_newCallback)); Applied = true; }
public static void SetWindowTitle(string targetTitle) { int procId; WinImports.GetWindowThreadProcessId(HWnD, out procId); if (procId == Memory.Reader.Process.Id) { if (WinImports.IsWindowVisible(HWnD)) { Constants.WinImports.SetWindowText(HWnD, targetTitle); } } }
private static void LaunchBot() { // Setting culture for float etc (. instead of ,) CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!AreWeInjected) { //var attForm = new AttachForm(); //attForm.ShowDialog(); //switch (attForm.Result) //{ // case AttachFormResult.Fresh: PrepareAndInject(); // break; // case AttachFormResult.Attach: // PrepareAndInject(attForm.AttachTo.PID); // break; //} } else { if (debugMode) { Debugger.Launch(); WinImports.AllocConsole(); Logger.Append("DEBUG BUILD"); DebugAssist.Init(); } SetPaths(); SetRealmlist(); try { GuiCore.MainForm = new Forms.GraphicalMainForm(); GuiCore.SettingsForm = new Forms.GraphicalSettingsForm(); Application.Run(GuiCore.MainForm); } catch (Exception e) { Logger.Append("Startup: " + e.Message + "\r\n", Logger.LogType.Console, "Exceptions.txt"); } } Environment.Exit(0); }
private Navigation() { var calculatePathPtr = WinImports.GetProcAddress(Libs.Instance.PathfinderPtr, "CalculatePath"); _calculatePath = Memory.Reader.RegisterDelegate <CalculatePathDelegate>(calculatePathPtr); var freePathPtr = WinImports.GetProcAddress(Libs.Instance.PathfinderPtr, "FreePathArr"); _freePathArr = Memory.Reader.RegisterDelegate <FreePathArr>(freePathPtr); //Memory.ErasePeHeader(Libs.Instance.PathfinderPtr); //Memory.UnlinkFromPeb("038.mmap"); }
private static int?LaunchWowProcess() { var doc = XDocument.Load(GuiCore.SettingsFilePath); var element = doc.Element("Settings"); var tmpPath = element.Element("WowExePath").Value; var si = new WinImports.STARTUPINFO(); WinImports.PROCESS_INFORMATION pi; WinImports.CreateProcess(tmpPath, null, IntPtr.Zero, IntPtr.Zero, false, WinImports.ProcessCreationFlags.CREATE_DEFAULT_ERROR_MODE, IntPtr.Zero, null, ref si, out pi); return((int)pi.dwProcessId); }
/// <summary> /// Execute the function in the mainthread /// </summary> /// <param name="parDelegate">The function</param> /// <returns>object</returns> /// <remarks> /// <code> /// Lua.Instance.Execute("DoEmote('dance')"); /// Lua.Instance.Execute("DoEmote('dance')"); /// /// MainThread.Instance.Invoke(() => /// { /// Lua.Instance.Execute("DoEmote('dance')"); /// Lua.Instance.Execute("DoEmote('dance')"); /// }); /// </code> /// <br /> /// First two Execute calls will require two invokes while the second two require just one.<br /> /// While it doesnt make a difference for two calls it can mean the difference between a second and a ms.<br /> /// Whenever you call multiple methods that will invoke the MainThread you are free to use the invoke method /// </remarks> public T Invoke <T>(Func <T> parDelegate) { if (WinImports.GetCurrentThreadId() == mtId) { return(parDelegate()); } InvokeReturnFunction.Enqueue(parDelegate); SendUserMessage(UserMessage.RunDelegateReturn); object ret; if (InvokeReturnValue.TryDequeue(out ret)) { return((T)ret); } return(default(T)); }
/// <summary> /// The main entry point for the application. /// </summary> private static void LaunchBot() { SetPaths(); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; if (!AreWeInjected) { LogFiles.PreInjectLog.ClearLog(); LogFiles.QuitLog.ClearLog(); LogFiles.InjectedLog.ClearLog(); "We are not injected yet".Log(LogFiles.PreInjectLog); PrepareAndInject(); Environment.Exit(0); } else { AppDomain.CurrentDomain.UnhandledException += (sender, args) => { MessageBox.Show("A exception occured! The details were logged"); args.ExceptionObject.ToString().Log(LogFiles.Exceptions, false); }; AppDomain.CurrentDomain.AssemblyResolve += DependencyLoader.CurrentDomain_AssemblyResolve; #if DEBUG Debugger.Launch(); WinImports.AllocConsole(); DebugAssist.Init(); #endif SetRealmlist(); try { $"Initialising the bot".Log(LogFiles.InjectedLog, true); Memory.Init(); $"Showing the bots mainwindow".Log(LogFiles.InjectedLog, true); var mainWindow = new MainWindow(); Current.MainWindow = mainWindow; mainWindow.Closed += (sender, args) => { Environment.Exit(0); }; mainWindow.Show(); } catch (Exception e) { e.ToString().Log(LogFiles.Exceptions); } } }
public static TDelegate GetExportFunction <TDelegate>(IntPtr module, string name) where TDelegate : class { try { IntPtr address = WinImports.GetProcAddress(module, name); if (address == IntPtr.Zero) { throw new DotaException($"Can't get Module '{name}' Address"); } return((TDelegate)(object)Marshal.GetDelegateForFunctionPointer(address, typeof(TDelegate))); } catch (DotaException) { return(null); } }
internal static void ErasePeHeader(IntPtr modulePtr) { if (modulePtr == IntPtr.Zero) { return; } WinImports.Protection prot; var dosHeader = modulePtr.ReadAs <WinImports.IMAGE_DOS_HEADER>(); var sizeDosHeader = Marshal.SizeOf(typeof(WinImports.IMAGE_DOS_HEADER)); var sizePeHeader = Marshal.SizeOf(typeof(WinImports.IMAGE_FILE_HEADER)); var peHeaderPtr = modulePtr.Add(dosHeader.e_lfanew); var fileHeader = peHeaderPtr.ReadAs <WinImports.IMAGE_FILE_HEADER>(); var optionalHeaderSize = fileHeader.mSizeOfOptionalHeader; if (optionalHeaderSize != 0) { var optionalHeaderPtr = modulePtr.Add(dosHeader.e_lfanew).Add(sizePeHeader); var optionalHeader = optionalHeaderPtr.ReadAs <WinImports.IMAGE_OPTIONAL_HEADER32>(); WinImports.VirtualProtect(optionalHeaderPtr, (uint)optionalHeaderSize, WinImports.Protection.PAGE_EXECUTE_READWRITE, out prot); for (var i = 0; i < optionalHeaderSize; i++) { optionalHeaderPtr.Add(i).WriteTo <byte>(0); } WinImports.VirtualProtect(optionalHeaderPtr, (uint)optionalHeaderSize, prot, out prot); } WinImports.VirtualProtect(modulePtr, (uint)sizeDosHeader, WinImports.Protection.PAGE_EXECUTE_READWRITE, out prot); for (var i = 0; i < sizeDosHeader; i++) { modulePtr.Add(i).WriteTo <byte>(0); } WinImports.VirtualProtect(modulePtr, (uint)sizeDosHeader, prot, out prot); WinImports.VirtualProtect(peHeaderPtr, (uint)sizePeHeader, WinImports.Protection.PAGE_EXECUTE_READWRITE, out prot); for (var i = 0; i < sizePeHeader; i++) { peHeaderPtr.Add(i).WriteTo <byte>(0); } WinImports.VirtualProtect(modulePtr, (uint)sizeDosHeader, prot, out prot); }