forked from cheat-engine/cheat-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Changeoffsetunit.pas
executable file
·162 lines (135 loc) · 3.75 KB
/
Changeoffsetunit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
unit Changeoffsetunit;
{$MODE Delphi}
interface
uses
LCLIntf, Messages, SysUtils, classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, LResources, ExtCtrls,symbolhandler, math, betterControls;
type
{ TChangeOffset }
TChangeOffset = class(TForm)
Cancel: TButton;
Change: TButton;
TabControl1: TTabControl;
cbHexadecimal: TCheckBox;
Edit1: TEdit;
procedure ChangeClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure TabControl1Changing(Sender: TObject;
var AllowChange: Boolean);
procedure TabControl1Change(Sender: TObject);
procedure cbHexadecimalClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
offset: Int64;
FromAddress: ptrUint;
toAddress: ptrUint;
error: integer;
end;
var
ChangeOffset: TChangeOffset;
implementation
resourcestring
rsThisIsNotAnValidValue = 'This is not an valid value';
procedure TChangeOffset.ChangeClick(Sender: TObject);
var temp: ptruint;
s: string;
begin
if tabcontrol1.TabIndex=0 then
begin
if cbHexadecimal.checked then
begin
s:=trim(edit1.text);
if length(s)>1 then
begin
if s[1]='-' then
begin
val('-$'+copy(s,2,length(s)),offset,error);
end
else
val('$'+s,offset,error);
end
else
val('$'+s,offset,error);
end
else
val(edit1.Text,offset,error);
end
else
begin
try
temp:=symhandler.getAddressFromName(edit1.text);
offset:=temp-fromaddress;
except
error:=1;
end;
end;
end;
procedure TChangeOffset.FormCreate(Sender: TObject);
begin
//tabcontrol1.AutoSize:=true;
end;
procedure TChangeOffset.FormShow(Sender: TObject);
var r: trect;
begin
if tabcontrol1.TabIndex=0 then
begin
if cbHexadecimal.Checked then edit1.Text:=IntToHex(toaddress-fromaddress,8) else
edit1.Text:=IntToStr(integer(toaddress-fromaddress));
end
else
begin
edit1.Text:=IntToHex(toaddress,8);
end;
change.autosize:=false;
cancel.autosize:=false;
change.width:=max(change.width, cancel.width);
cancel.width:=max(change.width, cancel.width);
clientheight:=cancel.top+cancel.Height+tabcontrol1.TabHeight+5;
ClientWidth:=(cancel.left+cancel.width)*2;
end;
procedure TChangeOffset.TabControl1Changing(Sender: TObject;
var AllowChange: Boolean);
var controle: integer;
begin
if tabcontrol1.TabIndex=0 then
begin
if cbHexadecimal.checked then val('$'+edit1.Text,offset,controle) else
val(edit1.text,offset,controle);
end else
begin
val('$'+edit1.text,toaddress,controle);
end;
if controle=0 then allowchange:=true else
begin
allowchange:=false;
raise exception.Create(rsThisIsNotAnValidValue);
end;
end;
procedure TChangeOffset.TabControl1Change(Sender: TObject);
begin
if tabcontrol1.TabIndex=0 then
begin
cbHexadecimal.Visible:=true;
if cbHexadecimal.Checked then edit1.Text:=IntToHex(toaddress-fromaddress,8) else
edit1.Text:=IntToStr(integer(toaddress-fromaddress));
end
else
begin
cbHexadecimal.visible:=false;
edit1.Text:=IntToHex(toaddress,8);
end;
end;
procedure TChangeOffset.cbHexadecimalClick(Sender: TObject);
begin
if tabcontrol1.TabIndex=0 then
begin
if cbHexadecimal.Checked then edit1.Text:=IntToHex(toaddress-fromaddress,8) else
edit1.Text:=IntToStr(integer(toaddress-fromaddress));
end;
end;
initialization
{$i Changeoffsetunit.lrs}
end.