Для начала создаём класс SafeNativeMethods.cs
Запишем в него импорт VirtualProtect из библиотеки kernel32.dll
Далее создадим класс Protect.cs и запишем в него данный код:
Далее просто вызываем метод Initialize() из класса Protect.cs
При попытке сдампить приложение, ничего не получаем)
Запишем в него импорт VirtualProtect из библиотеки kernel32.dll
C#:
namespace DarkScript
{
using System.Runtime.InteropServices;
internal static class SafeNativeMethods
{
[DllImport("kernel32.dll")]
public static extern unsafe bool VirtualProtect(byte* lpAddress, int dwSize, uint flNewProtect, out uint lpflOldProtect);
}
}
Далее создадим класс Protect.cs и запишем в него данный код:
C#:
namespace DarkScript
{
using System;
using System.Runtime.InteropServices;
internal static class Protect
{
public static unsafe void Initialize()
{
byte* ptr = (byte*)(void*)Marshal.GetHINSTANCE(typeof(Protect).Module);
byte* ptr2 = ptr + 60;
ptr2 = ptr + *(uint*)ptr2;
ptr2 += 6;
ushort num = *(ushort*)ptr2;
ptr2 += 14;
ushort num2 = *(ushort*)ptr2;
ptr2 = ptr2 + 4 + num2;
SafeNativeMethods.VirtualProtect(ptr2 - 16, 8, 64U, out uint num3);
*(int*)(ptr2 - 12) = 0;
byte* ptr3 = ptr + *(uint*)(ptr2 - 16);
*(int*)(ptr2 - 16) = 0;
SafeNativeMethods.VirtualProtect(ptr3, 72, 64U, out num3);
byte* ptr4 = ptr + *(uint*)(ptr3 + 8);
*(int*)ptr3 = 0;
*(int*)(ptr3 + 4) = 0;
*(int*)(ptr3 + 8) = 0;
*(int*)(ptr3 + 12) = 0;
SafeNativeMethods.VirtualProtect(ptr4, 4, 64U, out num3);
*(int*)ptr4 = 0;
for (int i = 0; i < num; i++)
{
SafeNativeMethods.VirtualProtect(ptr2, 8, 64U, out num3);
Marshal.Copy(new byte[8], 0, (IntPtr)(void*)ptr2, 8);
ptr2 += 40;
}
}
}
}
Далее просто вызываем метод Initialize() из класса Protect.cs
C#:
Protect.Initialize();
При попытке сдампить приложение, ничего не получаем)
Последнее редактирование: