forked from AlexanderBagel/ProcessMemoryMap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuSelectAddress.pas
More file actions
151 lines (137 loc) · 3.47 KB
/
Copy pathuSelectAddress.pas
File metadata and controls
151 lines (137 loc) · 3.47 KB
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
////////////////////////////////////////////////////////////////////////////////
//
// ****************************************************************************
// * Project : ProcessMM
// * Unit Name : uSelectAddress.pas
// * Purpose : Äèàëîã äëÿ âûáîðà àäðåñà
// * Author : Àëåêñàíäð (Rouse_) Áàãåëü
// * Copyright : © Fangorn Wizards Lab 1998 - 2016.
// * Version : 1.0.1
// * Home Page : http://rouse.drkb.ru
// * Home Blog : http://alexander-bagel.blogspot.ru
// ****************************************************************************
// * Stable Release : http://rouse.drkb.ru/winapi.php#pmm2
// * Latest Source : https://github.com/AlexanderBagel/ProcessMemoryMap
// ****************************************************************************
//
unit uSelectAddress;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls;
type
TdlgSelectAddress = class(TForm)
Label1: TLabel;
Label2: TLabel;
edInt: TEdit;
lblHex: TLabel;
edHex: TEdit;
btnCancel: TButton;
btnOk: TButton;
edSize: TEdit;
lblSizeInt: TLabel;
lblSize: TLabel;
procedure edIntKeyPress(Sender: TObject; var Key: Char);
procedure edIntChange(Sender: TObject);
procedure edHexChange(Sender: TObject);
private
InChange: Boolean;
public
function ShowDlg(ShowSize: Boolean): TModalResult;
end;
var
dlgSelectAddress: TdlgSelectAddress;
implementation
uses
uUtils;
{$R *.dfm}
function TrimZeros(const Value: string): string;
var
I: Integer;
begin
Result := '';
for I := 1 to Length(Value) do
if Value[I] <> '0' then
begin
Result := Copy(Value, I, Length(Value));
Break;
end;
if Result = '' then
Result := '0';
end;
procedure TdlgSelectAddress.edHexChange(Sender: TObject);
var
I: Int64;
TmpValue: string;
begin
if InChange then Exit;
InChange := True;
try
TmpValue := edHex.Text;
if TmpValue = '' then
begin
edHex.Text := '0';
btnOk.Enabled := True;
Exit;
end;
if HexValueToInt64(TmpValue, I) then
lblHex.Font.Color := clWindowText
else
lblHex.Font.Color := clRed;
edInt.Text := IntToStr(I);
finally
InChange := False;
end;
end;
procedure TdlgSelectAddress.edIntChange(Sender: TObject);
var
I: Int64;
Edit: TEdit;
begin
if InChange then Exit;
InChange := True;
try
Edit := Sender as TEdit;
if Edit.Text = '' then
Edit.Text := '0';
if not TryStrToInt64(Edit.Text, I) then
begin
ShowErrorHint(Edit.Handle);
Edit.Text := '0';
end;
if Edit = edInt then
begin
edHex.Text := TrimZeros(IntToHex(StrToInt64Def(Edit.Text, 0), 16));
lblHex.Font.Color := clWindowText;
end;
finally
InChange := False;
end;
end;
procedure TdlgSelectAddress.edIntKeyPress(Sender: TObject; var Key: Char);
begin
if not CharInSet(Key, [#8, #22, '0'..'9']) then
begin
Key := #0;
ShowErrorHint((Sender as TEdit).Handle);
end;
end;
function TdlgSelectAddress.ShowDlg(ShowSize: Boolean): TModalResult;
var
Offset: Integer;
begin
if ShowSize then
begin
Caption := 'Process Memory Map - Dump Address';
lblSize.Visible := True;
lblSizeInt.Visible := True;
edSize.Visible := True;
Offset := edSize.Top - edHex.Top;
btnOk.Top := btnOk.Top + Offset;
btnCancel.Top := btnCancel.Top + Offset;
Height := Height + Offset;
end;
Result := ShowModal;
end;
end.