public IDll LoadDll(string path) { var fullPath = Path.GetFullPath(path); if (fullPath == null || !File.Exists(fullPath)) { throw new DllNotFoundException(path); } m_procKernel["LoadLibraryW", true, Encoding.Unicode](fullPath); var dll = new DllWrapper(Path.GetFileName(path), m_processHandle, m_procId, m_procKernel, AllocateAutoScalingShared(4096)); addWeakHandlerFor(dll); return(dll); }
// todo: dispose before buffer disposed or use other memory public DllWrapper(string name, SafeHandle hProcess, int processId, DllWrapper kernel, IAutoScalingSharedBuffer buffer) : base(IntPtr.Zero, true) { m_process = hProcess; m_kernel = kernel; m_buffer = buffer; m_unwrapper = m_kernel.m_unwrapper; m_pid = processId; SetHandle(getHandle(processId, name)); }
public async Task <IDll> LoadDllAsync(string path) { var fullPath = Path.GetFullPath(path); if (fullPath == null || !File.Exists(fullPath)) { throw new DllNotFoundException(path); } await m_procKernel[true, "LoadLibraryW", Encoding.Unicode](fullPath) .ConfigureAwait(false); var dll = new DllWrapper(Path.GetFileName(path), m_processHandle, m_procId, m_procKernel, AllocateAutoScalingShared(4096)); addWeakHandlerFor(dll); return(dll); }
public GlobalMemory(int processId) : base(Kernel.OpenProcess(Kernel.c_allAccess, true, processId), IntPtr.Zero) { m_procId = processId; m_procKernel = DllWrapper.GetKernel(m_procId, m_processHandle, AllocateAutoScalingShared(4096)); }
protected override bool ReleaseHandle() { return(m_kernel["FreeLibrary", true]((int)handle) != 0); }
public CoreWrapper(SafeHandle hProcess, int processId, DllWrapper kernel, IAutoScalingSharedBuffer buffer) : base(c_coreName, hProcess, processId, kernel, buffer) { }