コード例 #1
0
ファイル: MemoryModule.cs プロジェクト: xiju2003/Malwaria
        protected virtual void Dispose()
        {
            if (dataHandle.IsAllocated)
            {
                dataHandle.Free();
            }

            if (this.initialized)
            {
                this.dllEntry(new IntPtr(this.codeBase), DllReason.DLL_PROCESS_DETACH, IntPtr.Zero);
                this.initialized = false;
            }

            if (this.modules.Count > 0)
            {
                foreach (IntPtr module in this.modules)
                {
                    if (module != new IntPtr(-1) || module != IntPtr.Zero) // INVALID_HANDLE
                    {
                        NativeDeclarations.FreeLibrary(module);
                    }
                }
            }

            if (this.codeBase != null)
            {
                NativeDeclarations.VirtualFree(new IntPtr(this.codeBase), 0, AllocationType.RELEASE);
            }

            this.Disposed = true;
        }