This repository was archived by the owner on Mar 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit1.pas
More file actions
326 lines (290 loc) · 7.95 KB
/
Unit1.pas
File metadata and controls
326 lines (290 loc) · 7.95 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,
keygen, match, BRegExp2;
type
TForm1 = class(TForm)
EditOutFileName: TEdit;
Label3: TLabel;
EditPreFixed: TEdit;
EditVarStr: TEdit;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
EditPostFixed: TEdit;
RadioGroupType: TRadioGroup;
GroupBoxKeyGen: TGroupBox;
GroupBoxSerch: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
EditSearchRegular: TEdit;
Button2: TButton;
Button3: TButton;
SaveDialog1: TSaveDialog;
Timer1: TTimer;
GroupBoxOutFile: TGroupBox;
Button4: TButton;
RadioGroupDir: TRadioGroup;
Label1: TLabel;
Label2: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
RadioGroupPriority: TRadioGroup;
Label11: TLabel;
EditSerchClassical: TEdit;
Label12: TLabel;
ListBox1: TListBox;
Label13: TLabel;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure GroupBoxSerchClick(Sender: TObject);
private
{ Private 宣言 }
KeyGenerator: TKeyGenerater;
MatchTester: TMatchTester;
FFailinThread: Boolean;
FStartTime: TDateTime;
F1secStartTime: TDateTime;
F1secsCount: Integer;
FLastAddTrip: String;
procedure SearchStart;
procedure SearchStop;
procedure AddTrip(newTrip: String);
public
{ Public 宣言 }
procedure EmergencyStop;
end;
var
Form1: TForm1;
TripList: TTripList;
BReg: TBRegExp;
implementation
{$R *.dfm}
uses
Math;
procedure TForm1.FormCreate(Sender: TObject);
begin
SaveDialog1.InitialDir := ExtractFilePath(Application.ExeName);
TripList := TTripList.Create;
BReg := TBRegExp.Create;
if BReg.IsLoaded then
begin
RadioButton3.Enabled := True;
Label1.Visible := False;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if KeyGenerator <> nil then
begin
KeyGenerator.Terminate;
KeyGenerator.WaitFor;
KeyGenerator.Free;
end;
if MatchTester <> nil then
begin
MatchTester.Terminate;
MatchTester.WaitFor;
MatchTester.Free;
end;
TripList.Free;
BReg.Free;
end;
procedure TForm1.AddTrip(newTrip: String);
begin
if newTrip = '' then
Exit;
if FLastAddTrip = newTrip then
Exit;
FLastAddTrip := newTrip;
if ListBox1.Count > 10 then
ListBox1.Items.Delete(0);
ListBox1.Items.Add(newTrip);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
mCount,sCount: Integer;
nDay: TDateTime;
begin
if FFailinThread then
begin
FFailinThread := False;
SearchStop;
Exit;
end;
mCount := 0;
sCount := 0;
if KeyGenerator <> nil then
EditVarStr.Text := KeyGenerator.varString;
if MatchTester <> nil then
begin
mCount := MatchTester.MatchCount;
sCount := MatchTester.SearchCount;
end;
Label2.Caption := 'search: ' + IntToStr(sCount) +
' / found: ' + IntToStr(mCount);
nDay := Now;
Label8.Caption := Format('%n',[sCount / ((nDay - FStartTime) * 60*60*24)])
+ ' keys/sec';
Label12.Caption := Format('%n',[(sCount - F1secsCount)/ ((nDay - F1secStartTime) * 60*60*24)])
+ ' keys/sec';
Label9.Caption := IntToStr(Floor(nDay - FStartTime)) + ' days ' +
FormatDateTime('hh:mm:ss',nDay - FStartTime);
if mCount <> 0 then
Label10.Caption := Format('%n',[((nDay - FStartTime) * 60*60*24) / mCount])
+ ' sec/found';
AddTrip(MatchTester.LastTrip);
F1secStartTime := nDay;
F1secsCount := sCount;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
EditOutFileName.Text := SaveDialog1.FileName;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SearchStart;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
SearchStop;
end;
procedure TForm1.SearchStop;
var
i: Integer;
begin
if KeyGenerator = nil then
Exit;
Label11.Visible := True;
Application.ProcessMessages;
KeyGenerator.Terminate;
Timer1.Enabled := False;
EditVarStr.Text := KeyGenerator.varString;
MatchTester.Terminate;
MatchTester.WaitFor;
FreeAndNil(MatchTester);
KeyGenerator.WaitFor;
FreeAndNil(KeyGenerator);
GroupBoxKeyGen.Enabled := True;
GroupBoxSerch.Enabled := True;
GroupBoxOutFile.Enabled := True;
RadioGroupPriority.Enabled := True;
with GroupBoxOutFile do
for i := 0 to ControlCount-1 do
begin
Controls[i].Enabled := True;
end;
with GroupBoxKeyGen do
for i := 0 to ControlCount-1 do
begin
Controls[i].Enabled := True;
end;
with GroupBoxSerch do
for i := 0 to ControlCount-1 do
begin
Controls[i].Enabled := True;
end;
if not BReg.IsLoaded then
begin
RadioButton3.Enabled := False;
end;
GroupBoxSerchClick(nil);
Button2.Enabled := True;
Button3.Enabled := False;
Label11.Visible := False;
end;
procedure TForm1.EmergencyStop;
begin
FFailinThread := True;
end;
procedure TForm1.SearchStart;
var
i: Integer;
begin
if MatchTester <> nil then
Exit;
if RadioGroupPriority.ItemIndex > ord(tpNormal) then
begin
MessageBeep(MB_ICONEXCLAMATION);
if MessageDlg('priorityが高すぎると固まります。'#13#10'強行しますか?',
mtWarning,[mbOK, mbAbort],0) = mrAbort then
Exit;
end;
RadioGroupPriority.Enabled := False;
MatchTester := TMatchTester.Create;
KeyGenerator := TKeyGenerater.Create;
GroupBoxKeyGen.Enabled := False;
GroupBoxSerch.Enabled := False;
GroupBoxOutFile.Enabled := False;
with GroupBoxOutFile do
for i := 0 to ControlCount-1 do
begin
Controls[i].Enabled := False;
end;
with GroupBoxKeyGen do
for i := 0 to ControlCount-1 do
begin
Controls[i].Enabled := False;
end;
with GroupBoxSerch do
for i := 0 to ControlCount-1 do
begin
Controls[i].Enabled := False;
end;
Button2.Enabled := False;
Button3.Enabled := True;
with KeyGenerator do
begin
preFixed := EditPreFixed.Text;
postFixed := EditPostFixed.Text;
varString := EditVarStr.Text;
SerachType := TSearchType(RadioGroupType.ItemIndex);
SerachForward := (RadioGroupDir.ItemIndex = 0);
end;
with MatchTester do
begin
OutFileName := EditOutFileName.Text;
if RadioButton1.Checked then
MatchType := mtClassicFront;
if RadioButton2.Checked then
MatchType := mtClassicBack;
if RadioButton3.Checked then
MatchType := mtRegular;
if MatchType = mtRegular then
MatchText := EditSearchRegular.Text
else
MatchText := EditSerchClassical.Text;
end;
MatchTester.Resume;
KeyGenerator.Resume;
Timer1.Enabled := True;
FStartTime := Now;
F1secStartTime := FStartTime;
F1secsCount:= 0;
end;
procedure TForm1.GroupBoxSerchClick(Sender: TObject);
begin
if RadioButton1.Checked or RadioButton2.Checked then
begin
EditSerchClassical.Enabled := True;
EditSearchRegular.Enabled := False;
end;
if RadioButton3.Checked then
begin
EditSerchClassical.Enabled := False;
EditSearchRegular.Enabled := True;
end;
end;
end.