📄 archiveeditunit.pas
字号:
{
name:(1999.12.1 -jhx1)
江湖行 II jhx2
2002.10.13 renamed to 'GamePaladin II'
CopyRight:XuGanQuan gqxunet#163.com
Description:A game cheat tool
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}
unit ArchiveEditUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Gauges, ComCtrls, ToolWin, StdCtrls, Buttons, ExtCtrls,ChildFormUnit,
ImgList, Menus;
resourcestring
String_Filenotask='没有文件搜索任务,请新建加入;';
String_Filenoresult='搜索次数: 0 , 找到数目:0 ';
String_FileScanResult='搜索次数:%d , 找到数目:%d ';
String_FileInScan='当前的文件搜索任务正在进行,请等待.';
String_FileInScanTitle='文件搜索任务进行信息';
String_InvalidInput='无效的输入数据,请检查.';
String_Addtask='还没有文件搜索任务 ,是否现在创建?';
String_Addtasktitle='没有文件搜索任务信息';
String_InScan='当前的任务正在进行,请等待.';
String_InScanTitle='任务进行信息';
String_FileTaskinvalid='对应的存档文件不存在. ';
String_FileTypeNoMatch='输入的类型不匹配上次类型(高阶/低阶),'+
'你想进行新类型的搜索吗?';
String_FileTypeNoMatchTitle='输入的类型不匹配信息';
String_FileAskRepeatInitLowLevelTitle='文件低阶搜索重复初始化信息';
String_FileAskRepeatInitLowLevel='已经进行了初始化文件的低阶搜索,'#13#10+
'是否再次初始化?';
String_FileNoResultAgainTitle='无结果信息';
String_FileNoResultAgain='抱歉,找不到任何匹配的地址,是否再次搜索?';
String_InvalidByte='%s 不是合法的 Byte 类型数据,请检查';
String_InvalidWord='%s 不是合法的 Word 类型数据,请检查';
String_InvalidDword='%s 不是合法的 Dword 类型数据,请检查';
String_InvalidInt64='%s 不是合法的 Int64 类型数据,请检查k';
String_InvalidSingle='%s 不是合法的 Single 类型数据,请检查';
String_InvalidDouble='%s 不是合法的 Double 类型数据,请检查';
String_InvalidString='%s 不是合法的 Text 类型数据,请检查';
String_FileTaskResult='任务: %s '#13#10'找到 %d 个地址,'#13#10'用时 %f 秒.';
String_FileTaskResultTitle='搜索结果';
String_FileInitialLowLevel='文件搜索任务:%s'#13#10'低阶搜索初始化完成.';
type
TArchiveEditForm = class(TChildForm)
temp_Panel1: TPanel;
ToolBar1: TToolBar;
AddFIle_TB: TToolButton;
delFile_tb: TToolButton;
Filetasks_LV: TListView;
Splitter1: TSplitter;
Panel1: TPanel;
Splitter2: TSplitter;
Panel2: TPanel;
Scan_bn: TSpeedButton;
EditFile_Sb: TSpeedButton;
InputHelp_SB: TSpeedButton;
Value_Edit: TEdit;
VarType_CB: TComboBox;
Panel3: TPanel;
File_Info_SearchResult_LB: TLabel;
File_info_Name_LB: TLabel;
Edit_LV: TListView;
Found_LV: TListView;
Panel4: TPanel;
Scan_Gauge: TGauge;
ImageList1: TImageList;
DisplayFileScanProcess: TTimer;
PopupMenu1: TPopupMenu;
delFiletask_menu: TMenuItem;
N1: TMenuItem;
ClearFileTask_menu: TMenuItem;
PopupMenu2: TPopupMenu;
PopupMenu3: TPopupMenu;
Addtolists: TMenuItem;
N2: TMenuItem;
EditAddress: TMenuItem;
DeleteFileEditAddress: TMenuItem;
ClearAllAddress: TMenuItem;
N4: TMenuItem;
ModifyFileEdit: TMenuItem;
EditFileAddress: TMenuItem;
StaticText1: TStaticText;
procedure AddFIle_TBClick(Sender: TObject);
procedure delFile_tbClick(Sender: TObject);
procedure Filetasks_LVEdited(Sender: TObject; Item: TListItem;
var S: String);
procedure Filetasks_LVClick(Sender: TObject);
procedure Scan_bnClick(Sender: TObject);
procedure DisplayFileScanProcessTimer(Sender: TObject);
procedure InputHelp_SBClick(Sender: TObject);
procedure Value_EditKeyPress(Sender: TObject; var Key: Char);
procedure VarType_CBChange(Sender: TObject);
procedure ClearFileTask_menuClick(Sender: TObject);
procedure Found_LVDblClick(Sender: TObject);
procedure Found_LVMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure EditFile_SbClick(Sender: TObject);
procedure EditAddressClick(Sender: TObject);
procedure DeleteFileEditAddressClick(Sender: TObject);
procedure ClearAllAddressClick(Sender: TObject);
procedure ModifyFileEditClick(Sender: TObject);
procedure Edit_LVMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure EditFileAddressClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure InitFiletask(theID:Integer);
function checkandGetFileSize(FileName:string):Dword;
Procedure AddTasktoList(theIndex:integer);
Procedure UpdateTaskInfo(theIndex:integer);
Procedure AddFoundToListView(theIndex:integer);
Procedure RaiseInputError;
function AnalyseScan(theIndex:Integer):integer;
function CheckForScan:boolean;
function ReadFileData(theFileName:String;theAddress:Dword;Valuetype:integer):string;
end;
Type
TFileFirstScanThread=class(TThread)
private
TheTaskIndex:integer;
protected
procedure Execute; override;
public
constructor Create(theIndex:Integer);
end;
type
TFileNextScanThread=class(TThread)
private
TheTaskIndex:integer;
protected
procedure Execute; override;
public
constructor Create(theIndex:Integer);
end;
const
Auto_value=0;
Byte_value=1;
word_value=2;
Dword_value=3;
int64_value=4;
Single_value=5;
Double_Value=6;
String_Value=7;
CommonLevel_Value=10;
Number_Scan = 101;
String_Scan=102;
LowLevel_Value=20;
InitialLowLevel_Scan =201;
Increased_Scan =202;
Decreased_Scan = 203;
Changed_Scan = 204;
Unchanged_Scan = 205;
const Max_FileTaskNUm=255;
type
TFiletask=record
Applyed:Boolean; ///占用
name:String;
index:integer;
FilepathName:String;
ScanType:integer; //Number_Scan:= ]
OldScanType:integer;
VarType:integer; //选择某一类型后,实际搜索类型auto
OldVarType:integer;
ScanValue:string;
TotalProcess:Dword; ///应扫描总的地指数
NowProcess:Dword; ////扫描数量
InSearchProcess:Boolean; ///是否正在扫描,防止多次点击
SearchTimes:DWORD; //扫描次数
AttachedNum:DWORD;
SaveFileName:String; ///存档文件最新备份
AddressMemStream:TMemoryStream; //几下每个符合的地址
end;
var theFileTask:array[1..Max_FileTaskNUm]of TFiletask;
CurrentFileTaskIndex:Integer;
ListToFileTaskIndex:array[1..Max_FileTaskNUm] of Integer; //listview 对应任务Index
FileTaskNUm:Integer=0; ///任务个数
ErrorInputNum:BYTE;
CanUpdateFileTask:Integer=-999; ///防止更新闪烁,
var
ArchiveEditForm: TArchiveEditForm;
implementation
uses AddFileTaskUnit, InputhelpUnit, FileRecordUnit, FileEditUnit;
{$R *.dfm}
////
function TArchiveEditForm.checkAndGetFileSize(FileName:string):Dword;
var FHandle:Integer;
TempSize:Int64;
begin
result:=0;
if not FileExists(FileName) then
begin
showmessage(format(string_NotExists,[FileName]));
exit;
end;
FHandle := FileOpen(FileName, fmOpenWrite or fmShareDenyNone);
try
begin
if (FHandle<0) then
begin
showmessage(format(string_cannotopen,[FileName]));
exit;
end;
TempSize:=GetFileSize(FHandle,nil);
if (TempSize=0) or (TempSize>=$4000000) then
begin
showmessage(format(String_InvalidFile,[FileName]));
exit;
end else result:=Tempsize;
end;
finally
FileClose(FHandle);
end;
end;
//////////////初始化任务//////////////////////////////////
procedure TArchiveEditForm.InitFiletask(theID:Integer);
begin
with theFileTask[theId] do
begin
Applyed:=True;
name:='';
//index:integer;
FilepathName:='';
ScanType:=Number_Scan; //Number_Scan:= ]
OldScanType:=ScanType;
VarType:=Auto_value; //选择某一类型后,实际搜索类型auto
OldVarType:=Auto_value;
ScanValue:='';
TotalProcess:=0;
NowProcess:=0;
SearchTimes:=0;
AttachedNum:=0;
InSearchProcess:=False;
SaveFileName:='';
if Assigned(AddressmemStream)then
AddressMemStream.SetSize(0) else
AddressMemStream:=TmemoryStream.Create;
end;
end;
Procedure TArchiveEditForm.AddTasktoList(theIndex:integer);
begin
with FileTasks_LV.Items.Add do
begin
Caption:=theFileTask[theIndex].Name;
end;
end;
Procedure TArchiveEditForm.UpdateTaskInfo(theIndex:integer);
begin
if FiletaskNum=0 then
begin
File_info_Name_LB.Caption:=String_Filenotask;
File_Info_SearchResult_LB.Caption:=String_Filenoresult;
Found_lv.Clear;
end else
begin
With theFileTask[theIndex] do
begin
File_info_Name_LB.Caption:=Name;
File_Info_SearchResult_LB.Caption:=Format(String_FileScanResult,[SearchTimes,AttachedNum]);
end;
end;
end;
///////////////////////////////////
//////////根据输入的值判断scantype//////////////////////////////////////////////////
Function GetScanTypeAndTempVar(InputValue:String;theFiletaskIndex:integer):Integer;
var Len:integer;
begin
Result:=-999;
with theFiletask[theFiletaskIndex] do
begin
Len:=length(inputValue);
if InputValue='' then
Exit
else if inputvalue[1]='?' then
begin
VarType:=LowLevel_value;
Result:=InitialLowLevel_Scan;
end
else if InputValue[1]='!' then
begin
VarType:=LowLevel_value;
Result:=Changed_Scan;
end
else if InputValue[1]='=' then
begin
VarType:=LowLevel_value;
Result:=UnChanged_Scan;
end
else if InputValue[1]='+' then
begin
VarType:=LowLevel_value;
Result:=Increased_scan;
end
else if InputValue[1]='-' then
begin
VarType:=LowLevel_value;
Result:=Decreased_scan ;
end
else if (
((Len>2) and ( Len<255) ) and
(
((InputValue[1]='"') and (InputValue[Len]='"')) or
((InputValue[1]='''') and (InputValue[Len]=''''))
)
)
then
begin
ScanValue:=Copy(inputValue,2,Len-2);
VarType:=CommonLevel_value;
Result:=String_Scan;
end
else begin
ScanValue:=inputValue;
/////Vartype必须考虑Combobox的选择
Result:=Number_Scan;
end;
end; ///with end;
end;
//////////////////////////////////////////////////////////////////
/////////////hex to int///////////////////////////////////////////////////////////////////////////////
Function HexIntChange(inStr:string):String;
var Len:integer;
TempString:String;
begin
Len:=Length(inStr);
if (Len>2) and ( UpperCase(instr[1])+UpperCase(instr[2])='0X' )then
begin
TempString:='$'+Copy(Instr,3,Len-2);
try
Result:=inttoStr(Strtoint(TempString));
except
showmessage(String_InvalidInput);
end;
Exit;
end;
if (Len>1) and (instr[1]='$') then
begin
try
Result:=inttoStr(Strtoint(instr));
except
showmessage(String_InvalidInput);
end;
Exit;
end;
result:=instr;
end;
////////////根据输入值判断输出可用///////////////////////////////////////////////////////
Function GetVarTypeAndVarValue(InputValue:String;theFileTaskIndex:integer):Integer;
var ByteTemp:Byte;
WordTemp:word;
DwordTemp:Dword;
Int64Temp:int64;
SingleTemp:Single;
DoubleTemp:Double;
ECode:integer;
begin
Result:=-999; //error value
with theFileTask[theFileTaskIndex] do
begin
if (ScanType<>Number_Scan) and (ScanType<>String_Scan) then
begin
Result:=LowLevel_value;
Exit;
end;
if (ScanType=String_Scan) then
begin
ScanValue:=inputvalue;
Result:=CommonLevel_value;
Exit;
end;
if ScanType=Number_Scan then
begin
if (VarType=Auto_value) then
begin
//is integer
if pos('.',inputValue)=0 then
try
begin
inputValue:=HexIntChange(inputValue);
val(inputvalue,int64Temp,Ecode);
if Ecode>0 then Exit;
ScanValue:=inputValue;
if (int64Temp shr 8)=0 then Result:=Byte_value
else if (int64Temp shr 16)=0 then Result:=Word_value
else if (int64Temp shr 32)=0 then Result:=DWord_value
else if (int64Temp shr 64)=0 then Result:=Int64_value
else Result:=Int64_value;
exit;
end;
except
Exit;
end;
//is float
if pos('.',inputValue)>0 then
try
begin
val(inputValue,DoubleTemp,Ecode);
if Ecode>0 then Exit;
ScanValue:=inputValue;
if ( DoubleTemp-Exp(ln(2)*128)>0 ) or ( DoubleTemp-Exp(ln(2)*(-126))<0) then
Result:=Double_value else
Result:=single_value;
exit;
end;
except
exit;
end;
end///Auto_value
else
begin
case VarType of
Byte_value: begin
val(InputValue,ByteTemp,Ecode);
if Ecode<>0 then Exit else
begin
ScanValue:=InputValue;
Result:=Byte_value;
end;
end;
Word_value: begin
val(InputValue,WordTemp,Ecode);
if Ecode<>0 then Exit else
begin
ScanValue:=InputValue;
Result:=Word_value;
end;
end;
Dword_value: begin
val(InputValue,DwordTemp,Ecode);
if Ecode<>0 then Exit else
begin
ScanValue:=InputValue;
Result:=DWord_value;
end;
end;
Int64_value: begin
val(InputValue,int64Temp,Ecode);
if Ecode<>0 then Exit else
begin
ScanValue:=InputValue;
Result:=Int64_value;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -