Система, outofmemory anti-dump method .NET
Здравствуйте, я пытался исправить один метод антидемпинга в памяти - метод удаления заголовка. А код такой:
public enum FreeConsts : uint { MEM_RELEASE = 0x8000 } [DllImport("kernel32.dll")] private static extern IntPtr ZeroMemory(IntPtr addr, IntPtr size); [DllImport("kernel32.dll")] private static extern IntPtr VirtualProtect(IntPtr lpAddress, IntPtr dwSize, IntPtr flNewProtect, ref IntPtr lpflOldProtect); [DllImport("kernel32")] private static extern bool VirtualFree(IntPtr lpAddress, UInt32 dwSize, FreeConsts dwFreeType); [DllImport("kernel32.dll")] public static extern IntPtr GetModuleHandle(string lpModuleName); public static void EraseHeader() { IntPtr address = GetModuleHandle(null); IntPtr dwOld = default(IntPtr); VirtualProtect(address, (IntPtr)4096, (IntPtr)0x40, ref dwOld); ZeroMemory(address, (IntPtr)4096); VirtualFree(address, 0, FreeConsts.MEM_RELEASE); }
Сколько бы раз мне ни показывали:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationExcept ion: The type initializer for 'T???????????????????' threw an exception. ---> Sy stem.TypeInitializationException: The type initializer for 'System.Management.Ma nagementPath' threw an exception. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Threading.Thread.StartInternal(IPrincipal principal, StackCrawlMark & stackMark) at System.Threading.Thread.Start(StackCrawlMark& stackMark) at System.Threading.Thread.Start() at System.Management.MTAHelper.InitWorkerThread() at System.Management.MTAHelper.CreateInMTA(Type type) at System.Management.ManagementPath.CreateWbemPath(String path) at System.Management.ManagementPath..cctor() --- End of inner exception stack trace --- at System.Management.ManagementScope._Clone(ManagementScope scope, Identifier ChangedEventHandler handler) at System.Management.ManagementObjectSearcher..ctor(ManagementScope scope, Ob jectQuery query, EnumerationOptions options) at System.Management.ManagementObjectSearcher..ctor(String queryString) at T???????????????????..cctor() --- End of inner exception stack trace --- at T???????????????????.get_Is64Bit() at ????????????????????.????????????????????() at ????????????????????.????????????????????() at ????????????????????.Main(String[] args) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Objec t[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke Attr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at skip.Program.RunInternal(Byte[] encode, String pass) at skip.Program.Main()
Проблема в том, что когда я загружаю свою сборку много раз, происходит сбой, если это небольшая консоль, но если я использую программу или что-то еще, происходит сбой в .net.
Что я уже пробовал:
Я пробовал с небольшой консольной программой и работает, но когда я использую dll или сборки аварии. покажи мне это
Peter_in_2780
Такая возня с распределением системной памяти может закончиться только слезами.