当前位置: 首页>>代码示例>>C#>>正文


C# Converter.ConvertFromIntPtr方法代码示例

本文整理汇总了C#中Converter.ConvertFromIntPtr方法的典型用法代码示例。如果您正苦于以下问题:C# Converter.ConvertFromIntPtr方法的具体用法?C# Converter.ConvertFromIntPtr怎么用?C# Converter.ConvertFromIntPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Converter的用法示例。


在下文中一共展示了Converter.ConvertFromIntPtr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EntryPoint

        public static int EntryPoint(string pwzArgument)
        {
            Debug.WriteLine("[KeeFarceDLL] Starting");
            //string processName = Process.GetCurrentProcess().ProcessName;
            //MessageBox.Show("The current process is " + processName + " and I am running C# code! Yuss!");

            if (is64Bit)
            {
                Debug.WriteLine("[KeeFarceDLL] Target is 64 bit");
            }

            // Retrieve the DocumentManagerEx object off the heap
            // TODO: KeePass can support multiple password files , so should probably modify this to load 
            // ALL of the DocumentManagerEx's into a list and process 'em, as opposed to just breaking
            // after finding the first one.
            IntPtr docManagerPtr = IntPtr.Zero;
            using (DataTarget dataTarget = DataTarget.AttachToProcess(Process.GetCurrentProcess().Id, 5000, AttachFlag.Passive))
            {
                string dacLocation = dataTarget.ClrVersions[0].TryGetDacLocation();
                ClrRuntime runtime = CreateRuntimeHack(dataTarget, dacLocation, 4, 5);
                Debug.WriteLine("[KeeFarceDLL] Attached to process.");

                ClrHeap heap = runtime.GetHeap();
                foreach (ulong obj in heap.EnumerateObjects())
                {
                    
                    ClrType type = heap.GetObjectType(obj);
                    
                    ulong size = type.GetSize(obj);
                    if (type.Name == "KeePass.UI.DocumentManagerEx")
                    {
                        Debug.WriteLine("[KeeFarceDLL] Found DocumentManagerEx at: " + obj.ToString("X") + " " + type.Name);
                        docManagerPtr = (IntPtr)obj;
                        break;
                    }
                }
                
                if(docManagerPtr == IntPtr.Zero) {
                    // Didn't find a document manager, time to return.
                    Debug.WriteLine("[KeeFarceDLL] No DocumentManagerEx found");
                    return 1;
                }

            }
 
            // Get the DocumentManagerEx object
            Converter<object> ptrconv = new Converter<object>();
            object documentManagerEx = ptrconv.ConvertFromIntPtr(docManagerPtr);
            var info = new DocumentManagerExInfo(documentManagerEx);
            int r = doExport(info.ActiveDatabase, info.RootGroup, exportFile);

            return r;
        }
开发者ID:Tourountzis,项目名称:KeeFarce,代码行数:53,代码来源:main.cs


注:本文中的Converter.ConvertFromIntPtr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。