コード例 #1
0
        private static IntPtr FindProxyDllInfo(SafeLibraryHandle lib, Guid clsid)
        {
            try
            {
                GetProxyDllInfo get_proxy_dllinfo = lib.GetFunctionPointer <GetProxyDllInfo>();
                IntPtr          pInfo;
                IntPtr          pId;
                get_proxy_dllinfo(out pInfo, out pId);
                return(pInfo);
            }
            catch (Win32Exception)
            {
            }

            IntPtr psfactory = IntPtr.Zero;

            try
            {
                DllGetClassObject dll_get_class_object = lib.GetFunctionPointer <DllGetClassObject>();
                Guid IID_IPSFactoryBuffer = COMInterfaceEntry.IID_IPSFactoryBuffer;

                int hr = dll_get_class_object(ref clsid, ref IID_IPSFactoryBuffer, out psfactory);
                if (hr != 0)
                {
                    throw new Win32Exception(hr);
                }

                // The PSFactoryBuffer object seems to be structured like on Win10 at least.
                // VTABLE*
                // Reference Count
                // ProxyFileInfo*

                IntPtr pInfo = Marshal.ReadIntPtr(psfactory, 2 * IntPtr.Size);
                // TODO: Should add better checks here,
                // for example VTable should be in COMBASE and the pointer should be in the
                // server DLL's rdata section. But this is probably good enough for now.
                using (SafeLibraryHandle module = COMUtilities.SafeGetModuleHandle(pInfo))
                {
                    if (module == null || lib.DangerousGetHandle() != module.DangerousGetHandle())
                    {
                        return(IntPtr.Zero);
                    }
                }

                return(pInfo);
            }
            catch (Win32Exception)
            {
                return(IntPtr.Zero);
            }
            finally
            {
                if (psfactory != IntPtr.Zero)
                {
                    Marshal.Release(psfactory);
                }
            }
        }
コード例 #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool valid_dll = false;

            try
            {
                using (SafeLibraryHandle lib = COMUtilities.SafeLoadLibrary(textBoxDbgHelp.Text))
                {
                    if (lib.GetFunctionPointer("SymInitializeW") != IntPtr.Zero)
                    {
                        valid_dll = true;
                    }
                }
            }
            catch (Win32Exception)
            {
            }

            if (!valid_dll)
            {
                MessageBox.Show(this, "Invalid DBGHELP.DLL file", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Environment.Is64BitProcess)
            {
                Properties.Settings.Default.DbgHelpPath64 = textBoxDbgHelp.Text;
            }
            else
            {
                Properties.Settings.Default.DbgHelpPath32 = textBoxDbgHelp.Text;
            }
            Properties.Settings.Default.SymbolPath        = textBoxSymbolPath.Text;
            Properties.Settings.Default.SymbolsConfigured = true;
            try
            {
                Properties.Settings.Default.Save();
            }
            catch (Exception ex)
            {
                Program.ShowError(this, ex);
            }
            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #3
0
 private void GetFunc <T>(ref T f) where T : class
 {
     f = _dbghelp_lib.GetFunctionPointer <T>();
 }