public void Dispose() { if (_initialized) { if (_dllEntry != null) { _dllEntry.Invoke(pCode, DllReason.DLL_PROCESS_DETACH, IntPtr.Zero); } _initialized = false; } if (ImportModules != null) { foreach (IntPtr m in ImportModules) { if (!PtrIsInvalidHandle(m)) { Win.FreeLibrary(m); } } ImportModules = null; } if (pCode != IntPtr.Zero) { Win.VirtualFree(pCode, IntPtr.Zero, AllocationType.RELEASE); pCode = IntPtr.Zero; pNTHeaders = IntPtr.Zero; } Disposed = true; }