📄 formaddresschangeunit.pas
字号:
unit formAddressChangeUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,cefuncproc,newkernelhandler,symbolhandler;
type TPointerInfo=record
addresstext:tlabel;
address:Tedit;
offsettext: tlabel;
offset: tedit;
ValueAtAddressText:Tlabel;
FinalDestination: Tlabel;
end;
type
TformAddressChange = class(TForm)
editAddress: TEdit;
Button1: TButton;
Button2: TButton;
cbPointer: TCheckBox;
Label1: TLabel;
BitPanel: TPanel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
Label2: TLabel;
Button3: TButton;
Button4: TButton;
Timer1: TTimer;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure cbPointerClick(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure editAddressKeyPress(Sender: TObject; var Key: Char);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
pointerinfo: array of TPointerinfo;
procedure offsetKeyPress(sender: TObject; var key:char);
procedure processaddress;
public
{ Public declarations }
index: integer;
index2: integer;
end;
var
formAddressChange: TformAddressChange;
implementation
uses MainUnit;
{$R *.dfm}
procedure Tformaddresschange.processaddress;
var i,j,err,err2: integer;
currentaddress,currentaddress2,currentoffset: dword;
read:dword;
check: boolean;
begin
if length(pointerinfo)=0 then exit;
for i:=length(pointerinfo)-1 downto 0 do
begin
try
currentaddress:=symhandler.getaddressfromname(pointerinfo[i].address.Text);
err:=0; //no exception...
except
err:=1;
end;
if err>0 then
begin
//everything after this address is wrong
editaddress.text:='????????';
pointerinfo[i].ValueAtAddressText.Caption:='This pointer points to address ????????';
pointerinfo[i].FinalDestination.Caption:='The offset you chose brings it to ????????';
for j:=i-1 downto 0 do
begin
pointerinfo[j].address.text:='Result of next pointer';
pointerinfo[j].ValueAtAddressText.Caption:='This pointer points to address ????????';
pointerinfo[j].FinalDestination.Caption:='The offset you chose brings it to ????????';
end;
exit;
end;
//still here so that address was right
check:=readprocessmemory(processhandle,pointer(currentaddress),@currentaddress2,4,read);
if length(pointerinfo[i].offset.text)>0 then
begin
if pointerinfo[i].offset.text[1]='-' then
val('-$'+copy(pointerinfo[i].offset.text,2,length(pointerinfo[i].offset.text)),currentoffset,err2)
else
val('$'+pointerinfo[i].offset.text,currentoffset,err2);
end else err2:=1;
if (not check) or (read<4) or (err2>0) then
begin
//everything after this address is wrong
if (check) or (read=4) then
pointerinfo[i].ValueAtAddressText.Caption:='This pointer points to address '+IntToHex(currentaddress2,8)
else
pointerinfo[i].ValueAtAddressText.Caption:='This pointer points to address ????????';
pointerinfo[i].FinalDestination.Caption:='The offset you chose brings it to ????????';
editaddress.text:='????????';
for j:=i-1 downto 0 do
begin
pointerinfo[j].address.text:='Result of next pointer';
pointerinfo[j].ValueAtAddressText.Caption:='This pointer points to address ????????';
pointerinfo[j].FinalDestination.Caption:='The offset you chose brings it to ????????';
end;
exit;
end;
//address+offset are correct AND the address is readable
pointerinfo[i].ValueAtAddressText.Caption:='This pointer points to address '+IntToHex(currentAddress2,8);
pointerinfo[i].FinalDestination.Caption:='The offset you chose brings it to '+IntToHex(currentAddress2+currentoffset,8);
if i=0 then
editaddress.text:=IntToHex(currentaddress2+currentoffset,8)
else
pointerinfo[i-1].address.text:=IntToHex(currentaddress2+currentoffset,8);
end;
end;
procedure Tformaddresschange.offsetKeyPress(sender: TObject; var key:char);
begin
if key<>'-' then hexadecimal(key);
if cbpointer.Checked then timer1.Interval:=1;
end;
procedure TformAddressChange.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
action:=cafree;
end;
procedure TformAddressChange.FormShow(Sender: TObject);
var i: integer;
tmp:string;
begin
// if memrec[scrollbar1.position+(sender as TLabel).tag].VarType=5 then //bit
// adr:=inputbox('Address','Give the new address: (use ^ to specify the startbit)',address[(sender as TLabel).tag].caption);
if mainform.memrec[index].IsPointer then
begin
tmp:=mainform.address[index2].Caption;
if tmp='P->????????' then
editaddress.text:='00000000'
else
editaddress.text:=copy(tmp,4,length(tmp));
cbPointer.Checked:=true;
end
else
begin
if mainform.memrec[index].interpretableaddress<>'' then
editaddress.Text:=mainform.memrec[index].interpretableaddress
else
editaddress.Text:=IntToHex(mainform.memrec[index].address,8);
if mainform.memrec[index].VarType=5 then
begin
bitpanel.Visible:=true;
case mainform.memrec[index].Bit of
0: radiobutton1.checkeD:=true;
1: radiobutton2.checkeD:=true;
2: radiobutton3.checkeD:=true;
3: radiobutton4.checkeD:=true;
4: radiobutton5.checkeD:=true;
5: radiobutton6.checkeD:=true;
6: radiobutton7.checkeD:=true;
7: radiobutton8.checkeD:=true;
end;
width:=288;
end else width:=158;
end;
if mainform.memrec[index].IsPointer then
begin
cbPointer.Checked:=true;
for i:=1 to length(mainform.memrec[index].pointers)-1 do button3.Click; //add lines
//fill the lines
for i:=0 to length(pointerinfo)-1 do
begin
pointerinfo[i].offset.text:=IntToHex(mainform.memrec[index].pointers[i].offset,1);
if i=length(pointerinfo)-1 then
begin
if mainform.memrec[index].pointers[i].Interpretableaddress<>'' then
pointerinfo[i].address.text:=mainform.memrec[index].pointers[i].Interpretableaddress
else
pointerinfo[i].address.text:=IntToHex(mainform.memrec[index].pointers[i].Address,8);
end;
end;
if mainform.memrec[index].pointers[length(mainform.memrec[index].pointers)-1].Interpretableaddress<>'' then
pointerinfo[length(pointerinfo)-1].address.text:=mainform.memrec[index].pointers[length(mainform.memrec[index].pointers)-1].Interpretableaddress;
end;
processaddress;
end;
procedure TformAddressChange.cbPointerClick(Sender: TObject);
var i: integer;
begin
if cbpointer.checked then
begin
width:=435;
editAddress.Enabled:=false;
button3.visible:=true;
button4.visible:=true;
//create a address+offset combination and disable the normal address
setlength(pointerinfo,1);
pointerinfo[length(pointerinfo)-1].addresstext:=Tlabel.Create(self);
with pointerinfo[length(pointerinfo)-1].addresstext do
begin
top:=112;
left:=4;
caption:='Address of pointer';
parent:=self;
end;
pointerinfo[length(pointerinfo)-1].address:=TEdit.create(self);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -