?? main.pas
字號:
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls,ShareDat,IniFiles, RzCmboBx, Mask, RzEdit,
RzSpnEdt, RzButton, RzRadChk, OleCtrls, SHDocVw, RzTabs;
Const
Gametitle='YB_OnlineClient';
GameClass='D3D Window';
AdBarUrl='http://www.ayx.cn/rxad.html';
SetWinLongAddr=$0045306A;
ChangeDispAddr=$00455F2D;
//ExSetWinLongAddr=$00453089;
type
TFrmGameWin = class(TForm)
RunTimer: TTimer;
AdBar: TWebBrowser;
MyPage: TRzPageControl;
TabGame: TRzTabSheet;
TabHelp: TRzTabSheet;
BtnStart: TButton;
SelServer: TRzComboBox;
Bevel: TBevel;
LabHint3: TLabel;
ChkWinMode: TCheckBox;
LabHint1: TLabel;
SelVis: TRzComboBox;
LabVis: TLabel;
ChkShadow: TCheckBox;
ChkLand: TCheckBox;
ChkLing: TCheckBox;
SelectResh: TRzComboBox;
SelectRes: TRzComboBox;
LabRes: TLabel;
LabResh: TLabel;
OpenExe: TOpenDialog;
Label1: TLabel;
procedure BtnStartClick(Sender: TObject);
procedure RunTimerTimer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure AdBarDocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
function SetDllData:Boolean;
Procedure LoadCfg;
Procedure SaveCfg;
function RunGame:Boolean;
public
{ Public declarations }
end;
var
FrmGameWin: TFrmGameWin;
Hook:Boolean;
MyDllHandle:Hwnd;
SetHook:function:Boolean;stdcall;
UnHook:procedure;stdcall;
MyPath,GameExe:String;
NewData:PData;
OrgXres,OrgYres:Integer;
GameSi:TStartUpInfo;
GamePi:TProcessInformation;
WinCode:array [0..5] of byte=($B8, $00, $00, $CE, $84, $90);
JmpCode:array [0..1] of byte=($EB,$5A);
// WinCode:array [0..5] of byte=($B8, $00, $CE, $84, $C8, $90);
implementation
{$R *.dfm}
{$R dll.res}
Procedure TFrmGameWin.LoadCfg;
var MyIni:TIniFile;
begin
MyIni:=TIniFile.Create(MyPath+'RxStar.Ini');
SelectRes.ItemIndex:=MyIni.ReadInteger('Game','Res',2);
SelectResh.ItemIndex:=MyIni.ReadInteger('Game','Resh',2);
SelServer.ItemIndex:=MyIni.ReadInteger('Game','Server',1);
SelVis.ItemIndex:=MyIni.ReadInteger('Game','Vison',1);
ChkWinMode.Checked:=MyIni.ReadBool('Game','WinMode',False);
ChkLand.Checked:=MyIni.ReadBool('Game','Land',False);
ChkLing.Checked:=MyIni.ReadBool('Game','Ling',False);
ChkShadow.Checked:=MyIni.ReadBool('Game','Shadow',False);
GameExe:=MyIni.ReadString('Game','GameFile',MyPath+'Client\Client.exe');
MyIni.Free;
end;
Procedure TFrmGameWin.SaveCfg;
var MyIni:TIniFile;
FileHandle:THandle;
Buf:Byte;
begin
MyIni:=TIniFile.Create(MyPath+'RxStar.Ini');
MyIni.WriteString('Game','GameFile',GameExe);
MyIni.WriteInteger('Game','Res',SelectRes.ItemIndex);
MyIni.WriteInteger('Game','Resh',SelectResh.ItemIndex);
MyIni.WriteInteger('Game','Server',SelServer.ItemIndex);
MyIni.WriteInteger('Game','Vison',SelVis.ItemIndex);
MyIni.WriteBool('Game','WinMode',ChkWinMode.Checked);
MyIni.WriteBool('Game','Land',ChkLand.Checked);
MyIni.WriteBool('Game','Ling',ChkLing.Checked);
MyIni.WriteBool('Game','Shadow',ChkShadow.Checked);
MyIni.Free;
FileHandle:=FileOpen(ExtractFilePath(GameExe)+'YBopt.cfg',fmOpenWrite);
FileSeek(FileHandle, $E, 0); //分辨率 0-3
Buf:=SelectRes.ItemIndex;
FileWrite(FileHandle,buf,1);
FileSeek(FileHandle, $4, 0); //地形 0高 1低
if ChkLand.Checked then Buf:=1 else Buf:=0;
FileWrite(FileHandle,buf,1);
FileSeek(FileHandle, $2, 0); //光線 1開 0關
if ChkLing.Checked then Buf:=1 else Buf:=0;
FileWrite(FileHandle,buf,1);
FileSeek(FileHandle, $3, 0); //陰影 1開 0關
if ChkShadow.Checked then Buf:=1 else Buf:=0;
FileWrite(FileHandle,buf,1);
FileSeek(FileHandle, $6, 0); //視野 2=近 1=中 0=高
Buf:=SelVis.ItemIndex;
FileWrite(FileHandle,Buf, 1);
FileClose(FileHandle);
end;
function TFrmGameWin.RunGame:Boolean;
var Server:Pchar;
WriteByte:DWORD;
begin
Result:=False;
if FileExists(GameExe) then
begin
Case SelServer.ItemIndex of
0:Server:=' sessiondl.rxjh.com.cn 13100';
1:Server:=' sessionsy.rxjh.com.cn 13101';
2:Server:=' sessiongz.rxjh.com.cn 13102';
3:Server:=' sessionsh.rxjh.com.cn 13103';
4:Server:=' sessioncd.rxjh.com.cn 13104';
else Server:=' sessionsh.rxjh.com.cn 13103';
end;
FillChar(GameSi, SizeOf(TStartUpInfo), 0);
FillChar(GamePi, SizeOf(TProcessInformation), 0);
GameSi.cb:=SizeOf(TStartUpInfo);
if Not CreateProcess(Pchar(GameExe),Server,nil,nil,False,CREATE_SUSPENDED,nil,Pchar(ExtractFilePath(GameExe)),GameSi,GamePi) then
begin
Result:=False;
MessageBox(Self.Handle,'無法啟動游戲,請檢查游戲執行文件',PChar('熱血之星'),MB_OK+MB_ICONINFORMATION);
end else begin
if ChkWinMode.Checked then
begin
OpenProcess(PROCESS_ALL_ACCESS, FALSE, GamePi.dwProcessId);
WriteProcessMemory(GamePi.hProcess,pointer(SetWinLongAddr),@WinCode,6,WriteByte);
WriteProcessMemory(GamePi.hProcess,pointer(ChangeDispAddr),@JmpCode,2,WriteByte);
//WriteProcessMemory(GamePi.hProcess,pointer(ExSetWinLongAddr),@ExWinCode,7,WriteByte);
end;
ResumeThread(GamePi.hThread);
Result:=True;
end else begin
OpenExe.InitialDir:=MyPath;
OpenExe.Execute;
GameExe:=OpenExe.FileName;
RunGame;
end;
end;
procedure TFrmGameWin.FormCreate(Sender: TObject);
var DllRes:TResourceStream;
begin
MyPath:=ExtractFilePath(Application.ExeName);
New(NewData);
if FileExists(MyPath+'RxStar.dll') then begin
SetFileAttributes(pchar(MyPath+'RxStar.dll'), FILE_ATTRIBUTE_ARCHIVE);
DeleteFile(MyPath+'RxStar.dll');
end;
if FileExists(MyPath+'RxStar.dll')=False then begin
DllRes:=TResourceStream.Create(HInstance, 'dll', 'dllfile');
DllRes.SaveToFile(MyPath+'RxStar.dll');
DllRes.Free;
end;
SetFileAttributes(pchar(MyPath+'RxStar.dll'), FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_ARCHIVE);
MyDllHandle:=LoadLibrary(Pchar(MyPath+'RxStar.dll'));
@SetHook:=GetProcAddress(MyDllHandle, 'SetHook');
@UnHook:=GetProcAddress(MyDllHandle, 'UnHook');
OrgXres:=GetSystemMetrics(SM_CXSCREEN);
OrgYres:=GetSystemMetrics(SM_CYSCREEN);
LoadCfg;
AdBar.Height:=80;
AdBar.Navigate(AdBarUrl);
end;
procedure TFrmGameWin.BtnStartClick(Sender: TObject);
begin
if Hook=False then begin
SaveCfg;
if RunGame then
begin
SelectRes.Enabled:=False;
SelectResh.Enabled:=False;
SetDllData;
RunTimer.Enabled:=True;
//BtnStart.Enabled:=False;
Application.Minimize;
end;
end;
end;
procedure TFrmGameWin.RunTimerTimer(Sender: TObject);
begin
if (FindWindow(nil,Gametitle)<>0) and (Hook=False) then
begin
NewData^.GameHwnd:=FindWindow(nil,Gametitle);
NewData^.XRes:=OrgXres;
NewData^.YRes:=OrgYres;
Hook:=SetHook;
end;
end;
procedure TFrmGameWin.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnHook;
FreeLibrary(MyDllHandle);
SetFileAttributes(pchar(MyPath+'RxStar.dll'), FILE_ATTRIBUTE_ARCHIVE);
DeleteFile(MyPath+'RxStar.dll');
end;
function TFrmGameWin.SetDllData:Boolean;
var FHandle:LongWord;
begin
Result:=False;
FHandle:=OpenFileMapping(FILE_MAP_ALL_ACCESS, False, 'FISHWINGAME');
if FHandle<>0 then NewData:=MapViewOfFile(FHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if NewData<>nil then
begin
NewData^.GameRes:=SelectRes.ItemIndex;
Case SelectResh.ItemIndex of
0:NewData^.Resh:=60;
1:NewData^.Resh:=70;
2:NewData^.Resh:=75;
3:NewData^.Resh:=80;
4:NewData^.Resh:=85;
5:NewData^.Resh:=90;
6:NewData^.Resh:=100;
end;
Result:=True;
end;
CloseHandle(FHandle);
end;
procedure TFrmGameWin.AdBarDocumentComplete(Sender: TObject;const pDisp: IDispatch; var URL: OleVariant);
begin
AdBar.OleObject.Document.Body.Scroll:='No';
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -