日期:2014-05-20  浏览次数:20906 次

怎么取程序句柄,对内存读
怎么取一个程序的句柄,然后对内存地址0c0890c0读操作??

------解决方案--------------------
取程序的句柄用FINDWINDOW和FINDWINDOWEX这两个API函数,两个函数的具体用法请查询API手册,网上到处都是,这两个函数都返回一个句柄类型(也可以是INT32类型)的值,最后就用楼上那位朋友说的ReadprocessMemory()这个API来读内存!

------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace FindCale
{
static class Program
{

/// <summary>
/// 获取窗口标题的句柄
/// </summary>
/// <param name= "类名 "> 指定类名,不指定可以输入Null </param>
/// <param name= "程序标题 "> 查找窗体的标题名称 </param>
/// <returns> </returns>
[DllImport( "user32.dll ", EntryPoint = "FindWindow ")]
public static extern int FindWindow(string 类名,string 程序标题 );

//[DllImport( "user32.dll ",EntryPoint= " ")]

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new Form1());
int hwnd = Program.FindWindow(null, "计算器 ");
if (hwnd != 0)
{
MessageBox.Show( "计算器句柄_ " + hwnd.ToString());
}
else { MessageBox.Show( "计算器没有运行 "); }
}
}
}