📄 unit_mypro.pas
字号:
unit Unit_MyPro;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls,DB, DBTables,ShellAPI, ShlObj,Registry,TlHelp32,WinSock,SUIForm,SUIThemes;
type
TGuild=record
name:String;
char1:String;
char2:String;
count:integer;
end;
PGuild=^TGuild;
TWgInfo=record
WgName:String;
WgPath:String;
end;
PWgInfo=^TWgInfo;
function FindDir(handle:THandle):String;
function HostToIP(Name: string; var Ip: string): Boolean;
function Idx_Guild(GuildList:TList;GuildPath:string):boolean;
procedure SetMir3(VerCode:int64);
function CheckEi:Boolean;
var
AppPath:String;
Reg_SvrIp,ServerUrl:String;
Reg_SvrPort,Select_idx:integer;
ServerS,Updates,Wgs:TList;
Pic_Memo:TMemoryStream;
ExeTitle,ExeVer:String;
ExeType:Word;
implementation
function FindDir(handle:THandle):String;
var
TitleName : string;
lpItemID : PItemIDList;
BrowseInfo : TBrowseInfo;
DisplayName : array[0..MAX_PATH] of char;
TempPath : array[0..MAX_PATH] of char;
begin
Result:='';
FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
BrowseInfo.hwndOwner := Handle;
BrowseInfo.pszDisplayName := @DisplayName;
TitleName := '请选择一个目录:';
BrowseInfo.lpszTitle := PChar(TitleName);
BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
lpItemID := SHBrowseForFolder(BrowseInfo);
if lpItemId <> nil then begin
SHGetPathFromIDList(lpItemID, TempPath);
Result:=TempPath;
if Copy(Result,length(Result),1)<>'\' then Result:=Result+'\';
GlobalFreePtr(lpItemID);
end;
end;
Function StrToIp(Str:String):String;
var
ip,ip1,ip2,ip3,ip4:string;
begin
ip1:=Trim(Copy(Str,1,3));
ip2:=Trim(Copy(Str,5,3));
ip3:=Trim(Copy(Str,9,3));
ip4:=Trim(Copy(Str,13,3));
if ip1+ip2+ip3+ip4<>'' then
begin
Try
if (StrToInt(ip1)<0) or (StrToInt(ip1)>255) then ip1:='255';
if (StrToInt(ip2)<0) or (StrToInt(ip2)>255) then ip2:='255';
if (StrToInt(ip3)<0) or (StrToInt(ip3)>255) then ip3:='255';
if (StrToInt(ip4)<0) or (StrToInt(ip4)>255) then ip4:='255';
Ip:=ip1+'.'+ip2+'.'+ip3+'.'+ip4;
except
ip:='';
end;
end
else ip:='';
Result:=ip;
end;
function HostToIP(Name: string; var Ip: string): Boolean;
var
wsdata : TWSAData;
hostName : array [0..255] of char;
hostEnt : PHostEnt;
addr : PChar;
begin
WSAStartup ($0101, wsdata);
try
gethostname (hostName, sizeof (hostName));
StrPCopy(hostName, Name);
hostEnt := gethostbyname (hostName);
if Assigned (hostEnt) then
if Assigned (hostEnt^.h_addr_list) then
begin
addr := hostEnt^.h_addr_list^;
if Assigned (addr) then
begin
IP := Format ('%d.%d.%d.%d', [byte (addr [0]),byte (addr [1]), byte (addr [2]), byte (addr [3])]);
Result := True;
end
else
Result := False;
end
else Result := False
else
begin Result := False; end;
finally
WSACleanup;
end
end;
function Idx_Guild(GuildList:TList;GuildPath:string):boolean;
var
Guilds_txt,Guild_txt:TStrings;
i,j,count,lxcount:integer;
GuildName,Str:String;
Guild:PGuild;
Jsbz,lxbz:boolean;
begin
GuildList.Clear;
Result:=True;
if not FileExists(GuildPath+'Guildlist.txt') then
begin
Result:=False;
exit;
end;
Guilds_txt:=TStringList.create;
Guild_txt:=TStringList.create;
Guilds_txt.LoadFromFile(GuildPath+'Guildlist.txt');
for i := 0 to Guilds_txt.Count-1 do
begin
New(Guild);
GuildName:=Trim(Guilds_txt[i]);
Guild_txt.Clear;
count:=0;
lxcount:=0;
jsbz:=False;
if Copy(GuildName,1,1)<>';' then
begin
if FileExists(GuildPath+'Guilds\'+GuildName+'.txt') then
begin
Guild.name:=GuildName;
Guild_txt.LoadFromFile(GuildPath+'Guilds\'+GuildName+'.txt');
for j:=0 to Guild_txt.Count-1 do
begin
str:=Trim(Guild_txt[j]);
if Copy(Str,1,1)='#' then
begin
jsbz:=True;
if StrToInt(Trim(Copy(Str,2,pos(' ',str)-1)))=1 then lxbz:=true;
end;
if (Copy(Str,1,1)='+') and Jsbz then
begin
count:=count+1;
if lxbz and (lxcount=0) then
begin
Guild.char1:=Trim(Copy(Str,2,length(Str)-1));
lxcount:=1;
end
else
begin
if lxbz and (lxcount=1) then
begin
Guild.char2:=Trim(Copy(Str,2,length(Str)-1));
lxcount:=2;
end;
end;
end;
end;
Guild.count:=count;
end;
GuildList.Add(Guild);
end;
end;
Guilds_txt.free;
Guild_txt.Free;
end;
procedure SetMir3(VerCode:int64);
var
s:string;
byte1:longint;
byte3:byte;
Found:boolean;
byte2:integer;
HProcess,HSnapshot:THandle;
lpNumberOfBytesWritten: DWORD;
appe:TProcessEntry32;
begin
HSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
appe.dwSize:= SizeOf(appe);
found:= Process32First(HSnapshot, appe);
while Integer(found) <> 0 do
begin
try
s:=ExtractFileName(appe.szExeFile);
if (UpperCase(s)='KINGFOREISERVER') or (UpperCase(s)='EISERVER.EXE') then
begin
HProcess:=OpenProcess(PROCESS_ALL_ACCESS,true,appe.th32ProcessID);
byte1:=VerCode;
byte2:=$51fc52;
//byte2为效验码地址
WriteProcessMemory(HProcess,ptr(byte2),@byte1,4,lpNumberOfBytesWritten);
byte3:=$74;
byte2:=$51fc56;
//byte2为效验码地址
WriteProcessMemory(HProcess,ptr(byte2),@byte3,1,lpNumberOfBytesWritten);
exit;
end;
except
end;
Found:=Process32Next(HSnapshot,appe);
end;
CloseHandle(HSnapshot);
end;
function CheckEi:Boolean;
var
s:string;
Found:boolean;
HProcess,HSnapshot:THandle;
lpNumberOfBytesWritten: DWORD;
appe:TProcessEntry32;
begin
Result:=False;
HSnapshot:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
appe.dwSize:= SizeOf(appe);
found:= Process32First(HSnapshot, appe);
while Integer(found) <> 0 do
begin
try
s:=ExtractFileName(appe.szExeFile);
if (UpperCase(s)='KINGFOREISERVER') or (UpperCase(s)='EISERVER.EXE') then
begin
Result:=True;
exit;
end;
except
end;
Found:=Process32Next(HSnapshot,appe);
end;
CloseHandle(HSnapshot);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -