/// <summary> /// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. /// </summary> /// <param name="moduleName">The name of module to eject.</param> public void Eject(string moduleName) { // Fint the module to eject var module = RemoteModules.FirstOrDefault(m => m.Name == moduleName); // Eject the module is it's valid if (module != null) { RemoteModule.InternalEject(MemorySharp, module); } }
/// <summary> /// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. /// </summary> /// <param name="module">The module to eject.</param> public void Eject(RemoteModule module) { // If the module is valid if (!module.IsValid) { return; } // Find if the module is an injected one var injected = InternalInjectedModules.FirstOrDefault(m => m.Equals(module)); if (injected != null) { InternalInjectedModules.Remove(injected); } // Eject the module RemoteModule.InternalEject(MemorySharp, module); }
/// <summary> /// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count. /// </summary> /// <param name="memorySharp">The reference of the <see cref="MemorySharp"/> object.</param> /// <param name="module">The module to eject.</param> internal static void InternalEject(MemorySharp memorySharp, RemoteModule module) { // Call FreeLibrary remotely memorySharp.Threads.CreateAndJoin(memorySharp["kernel32"]["FreeLibrary"].BaseAddress, module.BaseAddress); }