📄 addaddress.pas
字号:
unit AddAddress;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Menus,cefuncproc,newkernelhandler,symbolhandler;
type TPointerInfo=record
addresstext:tlabel;
address:Tedit;
offsettext: tlabel;
offset: tedit;
ValueAtAddressText:Tlabel;
FinalDestination: Tlabel;
end;
type
TAddForm = class(TForm)
VarType: TComboBox;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Description: TEdit;
Label3: TLabel;
BitPanel: TPanel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label13: TLabel;
Label14: TLabel;
ValuePanel: TPanel;
Label12: TLabel;
Edit1: TEdit;
NewAddress: TEdit;
Edit2: TEdit;
cbPointer: TCheckBox;
Button3: TButton;
Button4: TButton;
Timer1: TTimer;
cbUnicode: TCheckBox;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure VarTypeChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure NewAddressKeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure cbPointerClick(Sender: TObject);
procedure Edit3KeyPress(Sender: TObject; var Key: Char);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
PointerInfo: Array of TPointerInfo;
procedure offsetKeyPress(Sender: TObject; var Key: Char);
procedure processaddress;
public
{ Public declarations }
end;
var
AddForm: TAddForm;
implementation
uses MainUnit;
{$R *.DFM}
procedure taddform.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;
except
err:=1;
end;
if err>0 then
begin
//everything after this address is wrong
pointerinfo[i].ValueAtAddressText.Caption:='This pointer points to address ????????';
pointerinfo[i].FinalDestination.Caption:='The offset you chose brings it to ????????';
newaddress.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;
//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 ????????';
newaddress.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
newaddress.text:=IntToHex(currentaddress2+currentoffset,8)
else
pointerinfo[i-1].address.text:=IntToHex(currentaddress2+currentoffset,8);
end;
end;
procedure TaddForm.offsetKeyPress(sender: TObject; var key:char);
begin
if key<>'-' then hexadecimal(key);
if cbpointer.Checked then timer1.Interval:=1;
end;
procedure TAddForm.FormCreate(Sender: TObject);
begin
vartype.ItemIndex:=3;
edit2.Text:='1';
NewAddress.text:='00400000';
cbunicode.Checked:=false;
end;
procedure TAddForm.Button2Click(Sender: TObject);
begin
AddForm.close;
end;
procedure TAddForm.Button1Click(Sender: TObject);
var i,j,error: Integer;
address: Dword;
bit: Byte;
vartype2: byte;
nrofbits: integer;
pt: dword;
offsets: array of integer;
interpretedpointer: string;
begin
pt:=0;
if cbpointer.checked then
begin
if pointerinfo[length(pointerinfo)-1].address.text='' then raise exception.Create('Please fill in a pointer address');
try
pt:=symhandler.getaddressfromname(pointerinfo[length(pointerinfo)-1].address.text);
except
raise exception.Create('The pointer address you filled in isn''t a valid address');
end;
//make sure the offsets are valid
setlength(offsets,length(pointerinfo));
for i:=0 to length(pointerinfo)-1 do
begin
if (pointerinfo[i].offset.Text<>'') then
begin
if pointerinfo[i].offset.Text[1]='-' then
val('-$'+copy(pointerinfo[i].offset.Text,2,length(pointerinfo[i].offset.Text)-1),offsets[i],error)
else
val('$'+pointerinfo[i].offset.Text,offsets[i],error);
if error<>0 then raise exception.Create(pointerinfo[i].offset.Text+' is not a valid value');
end else raise exception.Create('You havn''t filled in all offsets');
end;
try
address:=symhandler.getaddressfromname(NewAddress.text);
except
//don't complain
end;
end else address:=symhandler.getaddressfromname(NewAddress.text); //complain when not valid
if RadioButton1.checked then bit:=0 else
if RadioButton2.checked then bit:=1 else
if RadioButton3.checked then Bit:=2 else
if RadioButton4.checked then Bit:=3 else
if RadioButton5.checked then Bit:=4 else
if RadioButton6.checked then Bit:=5 else
if RadioButton7.checked then Bit:=6 else
Bit:=7;
try
nrofbits:=StrToInt(edit2.Text);
except
raise exception.Create(edit2.Text+' is not a valid number');
end;
if valuepanel.visible then
begin
try
bit:=strtoint(edit1.Text);
except
raise exception.Create(edit1.text+' is not a valid value');
end;
end;
case vartype.Itemindex of
0 : VarType2:=5;
1 : VarType2:=0;
2 : VarType2:=1;
3 : VarType2:=2;
4 : VarType2:=6;
5 : VarType2:=3;
6 : VarType2:=4;
7 : Vartype2:=7;
8 : VarType2:=8;
else vartype2:=0;
end;
i:=mainform.NumberOfRecords;
if i=MainForm.NumberOfRecords then
begin
inc(MainForm.NumberOfRecords);
mainform.reserveMem;
if description.text='' then
mainform.memrec[MainForm.NumberOfRecords-1].Description:='No description'
else
mainform.memrec[MainForm.NumberOfRecords-1].Description:=description.text;
mainform.memrec[MainForm.NumberOfRecords-1].Address:=address;
mainform.memrec[MainForm.NumberOfRecords-1].interpretableaddress:=newaddress.text;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -