private void BindDelegatesToManualCOMPInvokeFunctionPointers() { if (!this.fDelegatesBound) { IntPtr ptr; this.RuntimeHostInstance.Start(); int ofs = 0x15 * IntPtr.Size; int num2 = 10 * IntPtr.Size; int num3 = 0x39 * IntPtr.Size; this.RuntimeHostPtr = Marshal.GetIUnknownForObject(this.RuntimeHostInstance); this.CurrentDomainFnPtr = (Host_CurrentDomain)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(this.RuntimeHostPtr), ofs), typeof(Host_CurrentDomain)); int errorCode = this.CurrentDomainFnPtr(this.RuntimeHostPtr, out ptr); if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } Guid gUID = typeof(_AppDomain).GUID; errorCode = Marshal.QueryInterface(ptr, ref gUID, out this.DomainObjectPtr); if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } this.GetTypeFnPtr = (AppDomain_GetType)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(this.DomainObjectPtr), num2), typeof(AppDomain_GetType)); errorCode = this.GetTypeFnPtr(this.DomainObjectPtr, out this.DomainTypePtr); if (errorCode < 0) { Marshal.ThrowExceptionForHR(errorCode); } this.InvokeMemberFnPtr = (Type_InvokeMember)Marshal.GetDelegateForFunctionPointer(Marshal.ReadIntPtr(Marshal.ReadIntPtr(this.DomainTypePtr), num3), typeof(Type_InvokeMember)); this.fDelegatesBound = true; } }
public void Dispose() { this.fDelegatesBound = false; this.InvokeMemberFnPtr = null; if (IntPtr.Zero != this.DomainTypePtr) { Marshal.Release(this.DomainTypePtr); this.DomainTypePtr = IntPtr.Zero; } this.GetTypeFnPtr = null; if (IntPtr.Zero != this.DomainObjectPtr) { Marshal.Release(this.DomainObjectPtr); this.DomainObjectPtr = IntPtr.Zero; } this.CurrentDomainFnPtr = null; if (IntPtr.Zero != this.RuntimeHostPtr) { Marshal.Release(this.RuntimeHostPtr); this.RuntimeHostPtr = IntPtr.Zero; } this.RuntimeHostInstance = null; }