要求如这样的
ReadMemoryAddr('程序名','内存地址')
函数返回的是可识别的字符串.
写WriteMemoryAddr('程序名','内存地址')
能写出这样的函数请发邮件到我邮箱与我联系
[email protected]
ReadMemoryAddr('程序名','内存地址')
函数返回的是可识别的字符串.
写WriteMemoryAddr('程序名','内存地址')
能写出这样的函数请发邮件到我邮箱与我联系
[email protected]
[email protected]谢谢了
[email protected]
给我一份好吗,谢谢了
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TLHelp32, StrUtils;type
TForm1 = class(TForm)
Button1: TButton;
NameEdit: TEdit;
Label1: TLabel;
Label2: TLabel;
AddrEdit: TEdit;
HpVaule: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm} // 返回指定进程ID
function FindProcess(ExeName: string): DWORD;
var
spHandle: THandle;
Found: Bool;
PStruct: TProcessEntry32;
begin
Result := 0;
spHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PStruct.dwSize := Sizeof(PStruct);
Found := Process32First(spHandle, PStruct); while Found do
begin
if AnsiEndsText(ExeName, PStruct.szExefile) then
begin
Result := PStruct.th32ProcessID;
Break;
end; Found := Process32Next(spHandle, PStruct);
end; CloseHandle(spHandle);
end; // 读取指定进程Int
function ReadProcessInt(ProcessID: DWORD; IntAddr: PInteger): Integer;
var
ReadLen: DWORD;
begin
// Result := -1;
if Toolhelp32ReadProcessMemory(ProcessID, IntAddr, Result, 4, ReadLen) = False then Result := -1;
//if (ReadProcessMemory(hProcess, IntAAddr, @Result, 4, ReadLen) = False);
end;procedure TForm1.Button1Click(Sender: TObject);
var
PID: DWORD;
Int: Integer;
begin
PID := FindProcess(NameEdit.Text);
if (PID = 0) then
ShowMessage('未找到指定进程: ' + NameEdit.Text)
else begin
Int := ReadProcessInt(PID, PInteger(StrToInt('$' + AddrEdit.Text)));
if (Int = -1) then
HpVaule.Caption := '读取失败!'
else
HpVaule.Caption := IntToStr(Int);
end;
end;end.