iSafer_Main.pas
资源名称:00011511.rar [点击查看]
上传用户:xiuanze55
上传日期:2017-08-03
资源大小:1080k
文件大小:28k
源码类别:
Delphi控件源码
开发平台:
Delphi
- unit iSafer_Main;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, TrayIcon, Menus, StdCtrls, Buttons, ComCtrls, ExtCtrls, ImgList,
- Registry, ShellAPI, IniFiles;
- type
- TForm_Main = class(TForm)
- TrayIcon: TTrayIcon;
- Popup_Tray: TPopupMenu;
- Tray_Open: TMenuItem;
- N2: TMenuItem;
- Tray_Close: TMenuItem;
- Tray_Option: TMenuItem;
- Image_Skin: TImage;
- Btn_Safer: TImage;
- Btn_Option: TImage;
- Btn_Vaccine: TImage;
- Label_Message: TLabel;
- Btn_Minimize: TImage;
- Btn_Close: TImage;
- mnuTrayAbout: TMenuItem;
- Tray_VirusVaccine: TMenuItem;
- Tray_Help: TMenuItem;
- ScreenLock: TMenuItem;
- Lock: TMenuItem;
- N1: TMenuItem;
- ChangePassword: TMenuItem;
- //For Init and Uinit fire wall
- procedure PSMFW_InitActionExecute(Sender: TObject);
- procedure PSMFW_UnInitActionExecute(Sender: TObject);
- procedure BtnStatusCheck(BtnCaller: String);
- procedure FormCreate(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure TrayIconClick(Sender: TObject);
- procedure TrayIconDblClick(Sender: TObject);
- procedure Tray_OpenClick(Sender: TObject);
- procedure Tray_OptionClick(Sender: TObject);
- procedure Tray_CloseClick(Sender: TObject);
- procedure Btn_SaferMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Btn_SaferMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Btn_SaferMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Btn_SaferClick(Sender: TObject);
- procedure Btn_OptionMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Btn_OptionMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Btn_OptionMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Btn_OptionClick(Sender: TObject);
- procedure Btn_VaccineMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Btn_VaccineMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Btn_VaccineMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Btn_VaccineClick(Sender: TObject);
- procedure Btn_MinimizeClick(Sender: TObject);
- procedure Btn_CloseClick(Sender: TObject);
- procedure Image_SkinMouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Image_SkinMouseMove(Sender: TObject; Shift: TShiftState; X,
- Y: Integer);
- procedure Image_SkinMouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Label_MessageMouseMove(Sender: TObject; Shift: TShiftState;
- X, Y: Integer);
- procedure Tray_VirusVaccineClick(Sender: TObject);
- procedure Tray_HelpClick(Sender: TObject);
- procedure mnuTrayAboutClick(Sender: TObject);
- procedure LockClick(Sender: TObject);
- procedure ChangePasswordClick(Sender: TObject);
- //procedure Tray_ChangePasswordClick(Sender: TObject);
- //procedure Tray_LockScreenClick(Sender: TObject);
- //procedure cmdScreenLockClick(Sender: TObject);
- private
- { Private declarations }
- public
- Setup_9x: Boolean;
- bFWStart: Boolean;
- bFWBlock: Boolean;
- bLogStart: Boolean;
- lastTime: TSystemTime;
- //DDT 20040326
- procedure TrapMSG(var MSGX: TMessage);
- //
- end;
- var
- Form_Main: TForm_Main;
- OS: TOSVersionInfo;
- bMouseDown: Boolean;
- posX, posY: Integer;
- SourceRect, DestRect: TRect;
- Stat_Safer, Stat_Option, Stat_Vaccine: Integer; // 滚瓢 惑怕 (0:Normal, 1:Over, 2:Click)
- //Some parameters used for debugging.
- LogWindowParam: Boolean;
- UnInjectLibParam:Boolean;
- //ScreenLock*********************
- ScreenLockDLLHandle: THandle;
- //*******************************
- implementation
- uses iSafer_Resource, iSafer_Option,madCodeHook, FWDebug, ISaferAbout,
- iSafer_FWRule;// iShieldUnit_95, iShieldUnit_NT;
- {$R *.dfm}
- //DDT 20040326
- procedure TForm_Main.TrapMSG(var MSGX: TMessage);
- begin
- case MSGX.Msg of
- WM_USER + 10:// User run Second Instance
- Tray_OpenClick(nil);
- else WndProc(MSGX);
- end;
- End;
- //DDT END
- {
- Init FireWall
- }
- procedure TForm_Main.PSMFW_InitActionExecute(Sender: TObject); // 规拳寒 扁瓷 角青
- var
- i, nTemp: Integer;
- nLevel: Integer;
- strLine, strTemp: String;
- ruleItem: array[0..3] of String;
- bSuccess: Boolean;
- strFileName: String;
- ListItem: TListItem;
- TempFile: TextFile;
- IniFile: TIniFile;
- bCheck:Boolean;
- begin
- //Start Firewall
- bCheck:= InjectLibrary(ALL_SESSIONS Or SYSTEM_PROCESSES, 'PSMFireW.dll');
- if( not bCheck) then
- begin
- Showmessage('Error in starting Firewall!'#13#10'You must have the administrator right to start Firewall.');
- Form_Main.bFWStart:=false;
- end
- else
- begin //Successfully started FireWall
- Form_Main.bFWStart:=true;
- ApplyFWStatus(0);
- end;
- // iSafer 滚瓢 惑怕 汲沥
- if bFWStart then begin
- with Form_Main do begin
- SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- Form_Main.Label_Message.Caption:= 'Firewall is started';
- end else begin
- with Form_Main do begin
- SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- Form_Main.Label_Message.Caption:= 'Firewall is stopped';
- end;
- Application.ProcessMessages;
- end;
- {
- Unintialized FireWall
- }
- procedure TForm_Main.PSMFW_UnInitActionExecute(Sender: TObject); // 规拳寒 扁瓷 吝瘤
- var
- bCheck:Boolean;
- begin
- //Stop FireWall
- //bCheck:=UnInjectLibrary (ALL_SESSIONS Or SYSTEM_PROCESSES, 'PSMFireW.dll');
- //For test, Uninject will be called in some special case !!!!!!!!
- if(UnInjectLibParam) then
- bCheck:=UnInjectLibrary (ALL_SESSIONS Or SYSTEM_PROCESSES, 'PSMFireW.dll')
- else
- bCheck:=True; //From March 16, UnInject willnot be called when Stopping FW
- if not bCheck then
- Showmessage('Error stopping Firewall!')
- else
- begin
- bFWStart:=false; //Successfully stop FireWall
- ApplyFWStatus(2);//Set FW Stop-status
- end;
- // iSafer 滚瓢 惑怕 汲沥
- //Form_Main.bFWStart:= Form_Option.FDriverLoaded;
- if bFWStart then begin
- with Form_Main do begin
- SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- Form_Main.Label_Message.Caption:= 'Firewall is started';
- end else begin
- with Form_Main do begin
- SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- Form_Main.Label_Message.Caption:= 'Firewall is stopped';
- end;
- {Start FW service here ! Feb 13, 2004}
- end;
- // 滚瓢 惑怕 眉农窍扁
- procedure TForm_Main.BtnStatusCheck(BtnCaller: String);
- begin
- // 滚瓢 惑怕 函版
- if (BtnCaller <> 'Btn_Safer') and (Stat_Safer = 1) then begin
- Stat_Safer:= 0;
- Application.ProcessMessages;
- if bFWStart then begin
- SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end else begin
- SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end;
- Application.ProcessMessages;
- end;
- if (BtnCaller <> 'Btn_Option') and (Stat_Option = 1) then begin
- Stat_Option:= 0;
- Application.ProcessMessages;
- SourceRect:= Rect((0*50)+1, (4*30)+1, (0*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
- DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
- Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- if (BtnCaller <> 'Btn_Vaccine') and (Stat_Vaccine = 1) then begin
- Stat_Vaccine:= 0;
- Application.ProcessMessages;
- SourceRect:= Rect((0*50)+1, (5*30)+1, (0*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
- DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
- Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- end;
- procedure TForm_Main.FormCreate(Sender: TObject);
- var
- sDir: array [0..255] of Char;
- IniFile: TIniFile;
- reg: TRegistry;
- begin
- {// 吝汗 角青 规瘤
- CreateMutex(nil, False, 'iSafer - PSMKorea');
- if GetLastError=ERROR_ALREADY_EXISTS then begin
- showmessage('橇肺弊伐捞 捞固 角青吝涝聪促.');
- Halt(0);
- end;}
- //DDT 20040306
- WindowProc:=TrapMSG;//Change the WindowProc to User's proc.
- //DDT END
- // 函荐 檬扁汲沥
- Setup_9x:= False;
- bFWStart:= False;
- bFWBlock:= False;
- bLogStart:= False;
- GetLocalTime(lastTime);
- bMouseDown:= False;
- posX:= 0;
- posY:= 0;
- Stat_Safer:= 0;
- Stat_Option:= 0;
- Stat_Vaccine:= 0;
- // Form 檬扁困摹 汲沥
- Form_Main.Left:= GetSystemMetrics(SM_CXFULLSCREEN)-Form_Main.Width;
- Form_Main.Top:= GetSystemMetrics(SM_CYFULLSCREEN)+GetSystemMetrics(SM_CYCAPTION)-Form_Main.Height;
- {
- // OS 滚傈 沥焊 舅酒郴扁
- ZeroMemory(@OS,SizeOf(OS));
- OS.dwOSVersionInfoSize:=SizeOf(OS);
- GetVersionEx(OS);
- // PC 规拳寒 葛碘 汲摹/角青 咯何 眉农 (for Win 9x)
- if OS.dwPlatformId <> VER_PLATFORM_WIN32_NT then begin
- if (ParamStr(1) = '/b') then begin
- IniFile:= TIniFile.Create(ExtractFilePath(Application.ExeName) + 'safer.ini');
- IniFile.WriteInteger('FW', 'Setup_9x', 1);
- IniFile.Free;
- Halt(0);
- end else begin
- IniFile:= TIniFile.Create(ExtractFilePath(Application.ExeName) + 'safer.ini');
- if (IniFile.ReadInteger('FW', 'Setup_9x', 0) = 1) then Setup_9x:= True;
- IniFile.Free;
- end;
- end;
- // PC 规拳寒 葛碘 汲摹 (for Win 9x)
- if (OS.dwPlatformId <> VER_PLATFORM_WIN32_NT) and (not Setup_9x) then begin
- // 1. iLoader.vxd, iShield.vxd 甫 WindowsSystem 弃歹俊 汗荤茄促.
- GetSystemDirectory(sDir, sizeof(sDir));
- CopyFile('iLoader.vxd', PChar(String(sDir) + 'iLoader.vxd'), True);
- CopyFile('iShield.vxd', PChar(String(sDir) + 'iShield.vxd'), True);
- // 2. 饭瘤胶飘府俊 沥焊甫 殿废茄促.
- reg:= TRegistry.Create;
- reg.RootKey:= HKEY_LOCAL_MACHINE;
- reg.OpenKey('SystemCurrentControlSetServicesVxDILOADER', true);
- reg.WriteString('StaticVxd', 'iloader.vxd');
- reg.CloseKey;
- reg.Free;
- // 3. 矫累橇肺弊伐俊 沥焊甫 殿废茄促.
- reg:= TRegistry.Create;
- reg.RootKey:= HKEY_LOCAL_MACHINE;
- reg.OpenKey('SoftwareMicrosoftWindowsCurrentVersionRun', true);
- reg.WriteString('iSafer Manager', ExtractFilePath(Application.ExeName) + 'iSafer.exe /b');
- reg.CloseKey;
- reg.Free;
- end;
- }
- LogWindowParam:=False;
- UnInjectLibParam:=False;
- if(ParamCount>=1) and(ParamStr(1)='debug') then
- begin
- Application.CreateForm(TDebugFW, DebugFW);
- LogWindowParam:=True;
- end;
- if ((ParamCount>=1) and(ParamStr(1)='uninject')) then
- begin
- UnInjectLibParam:=True;
- end ;
- if ((ParamCount>=2) and (ParamStr(1)='debug')and(ParamStr(2)='uninject')) then
- begin
- LogWindowParam:=True;
- UnInjectLibParam:=True;
- end;
- end;
- procedure TForm_Main.FormDestroy(Sender: TObject);
- begin
- //UnInit FireWall in the case it is running FW --HUY Note
- if bFWStart then begin
- //if not UnInjectLibrary (ALL_SESSIONS Or SYSTEM_PROCESSES, 'PSMFireW.dll')
- // then Showmessage('Error stopping Firewall!');
- //bFWStart:=False;
- //PSMFW_UnInitActionExecute(NIl);
- bFWStart:=false; //Successfully stop FireWall
- ApplyFWStatus(2);//Set FW Stop-status
- end;
- // Tray Icon 角青 辆丰窍扁
- TrayIcon.Active:= False;
- end;
- procedure TForm_Main.FormClose(Sender: TObject; var Action: TCloseAction);
- begin
- // 肺弊沤祸 辆丰
- {
- if bFWStart then begin
- if OS.dwPlatformId = VER_PLATFORM_WIN32_NT then begin
- iShieldUnit_NT.iShieldSetLogCallback(nil);
- iShieldUnit_NT.iShieldUnInitDriver;
- end else if Form_Main.Setup_9x then begin
- iShieldUnit_95.iShieldSetLogCallback(nil);
- iShieldUnit_95.iShieldUnInitDriver;
- end;
- end;
- }
- //Unitial FW huynote
- // Tray Icon 角青 辆丰窍扁
- TrayIcon.Active:= False;
- end;
- procedure TForm_Main.TrayIconClick(Sender: TObject);
- begin
- Tray_OpenClick(self);
- end;
- procedure TForm_Main.TrayIconDblClick(Sender: TObject);
- begin
- Tray_OpenClick(self);
- end;
- procedure TForm_Main.Tray_OpenClick(Sender: TObject);
- begin
- // Application 焊咯林扁
- if (not IsWindowVisible(Form_Main.Handle)) then begin
- ShowWindow(Application.Handle,SW_SHOWMINIMIZED);
- ShowWindow(Application.Handle,SW_SHOWNORMAL);
- end;
- SetForegroundWindow(Form_Main.Handle);
- // Tray Icon 角青 辆丰窍扁
- TrayIcon.Active:= False;
- end;
- procedure TForm_Main.Tray_OptionClick(Sender: TObject);
- begin
- Btn_OptionClick(self);
- end;
- procedure TForm_Main.Tray_CloseClick(Sender: TObject);
- begin
- Btn_CloseClick(self);
- end;
- procedure TForm_Main.Btn_SaferMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Safer 滚瓢 Down
- begin
- Stat_Safer:= 2;
- Application.ProcessMessages;
- if bFWStart then begin
- SourceRect:= Rect((2*50)+1, (3*30)+1, (2*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end else begin
- SourceRect:= Rect((2*50)+1, (2*30)+1, (2*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end;
- Application.ProcessMessages;
- end;
- procedure TForm_Main.Btn_SaferMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer); // Safer 滚瓢 Move
- begin
- if (Stat_Safer = 0) then begin
- Stat_Safer:= 1;
- Application.ProcessMessages;
- if bFWStart then begin
- SourceRect:= Rect((1*50)+1, (3*30)+1, (1*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end else begin
- SourceRect:= Rect((1*50)+1, (2*30)+1, (1*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end;
- BtnStatusCheck('Btn_Safer');
- Application.ProcessMessages;
- end;
- end;
- procedure TForm_Main.Btn_SaferMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Safer 滚瓢 Up
- begin
- if (Stat_Safer > 0) then begin
- Stat_Safer:= 0;
- Application.ProcessMessages;
- if bFWStart then begin
- SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end else begin
- SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end;
- Application.ProcessMessages;
- end;
- end;
- //Start FirWall
- procedure TForm_Main.Btn_SaferClick(Sender: TObject); // Safer 滚瓢 Click
- begin
- Stat_Safer:= 0;
- Application.ProcessMessages;
- if bFWStart then begin
- SourceRect:= Rect((0*50)+1, (3*30)+1, (0*50)+Btn_Safer.Width, (3*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end else begin
- SourceRect:= Rect((0*50)+1, (2*30)+1, (0*50)+Btn_Safer.Width, (2*30)+Btn_Safer.Height);
- DestRect:= Rect(0, 0, Btn_Safer.Width-1, Btn_Safer.Height-1);
- Btn_Safer.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- end;
- Application.ProcessMessages;
- {Started Already}
- if bFWStart then begin
- if Application.MessageBox('Do you really want to stop the firewall?', 'iSafer', MB_YESNO) = IDYES then begin
- PSMFW_UnInitActionExecute(nil);
- end;
- end else
- {Start FireWall!!!}
- begin
- PSMFW_InitActionExecute(nil);
- end;
- end;
- procedure TForm_Main.Btn_OptionMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Option 滚瓢 Down
- begin
- Stat_Option:= 2;
- Application.ProcessMessages;
- SourceRect:= Rect((2*50)+1, (4*30)+1, (2*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
- DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
- Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- procedure TForm_Main.Btn_OptionMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer); // Option 滚瓢 Move
- begin
- if (Stat_Option = 0) then begin
- Stat_Option:= 1;
- Application.ProcessMessages;
- SourceRect:= Rect((1*50)+1, (4*30)+1, (1*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
- DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
- Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- BtnStatusCheck('Btn_Option');
- Application.ProcessMessages;
- end;
- end;
- procedure TForm_Main.Btn_OptionMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Option 滚瓢 Up
- begin
- if (Stat_Option > 0) then begin
- Stat_Option:= 0;
- Application.ProcessMessages;
- SourceRect:= Rect((0*50)+1, (4*30)+1, (0*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
- DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
- Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- end;
- procedure TForm_Main.Btn_OptionClick(Sender: TObject); // Option 滚瓢 Click
- begin
- Stat_Option:= 0;
- Application.ProcessMessages;
- SourceRect:= Rect((0*50)+1, (4*30)+1, (0*50)+Btn_Option.Width, (4*30)+Btn_Option.Height);
- DestRect:= Rect(0, 0, Btn_Option.Width-1, Btn_Option.Height-1);
- Btn_Option.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- // Show firewall option dialogs
- Form_Option.Show;
- //For debug
- if(ParamCount>=1) and(ParamStr(1)='debug') then
- begin
- DebugFW.Show;
- end
- end;
- procedure TForm_Main.Btn_VaccineMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Vaccine 滚瓢 Down
- begin
- Stat_Vaccine:= 2;
- Application.ProcessMessages;
- SourceRect:= Rect((2*50)+1, (5*30)+1, (2*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
- DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
- Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- procedure TForm_Main.Btn_VaccineMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer); // Vaccine 滚瓢 Move
- begin
- if (Stat_Vaccine = 0) then begin
- Stat_Vaccine:= 1;
- Application.ProcessMessages;
- SourceRect:= Rect((1*50)+1, (5*30)+1, (1*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
- DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
- Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- BtnStatusCheck('Btn_Vaccine');
- Application.ProcessMessages;
- end;
- end;
- procedure TForm_Main.Btn_VaccineMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer); // Vaccine 滚瓢 Up
- begin
- if (Stat_Vaccine > 0) then begin
- Stat_Vaccine:= 0;
- Application.ProcessMessages;
- SourceRect:= Rect((0*50)+1, (5*30)+1, (0*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
- DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
- Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- end;
- end;
- procedure TForm_Main.Btn_VaccineClick(Sender: TObject); // Vaccine 滚瓢 Click
- begin
- Btn_Vaccine.Enabled:=False;
- LockClick(nil);
- Btn_Vaccine.Enabled:=True;
- {
- Stat_Vaccine:= 0;
- Application.ProcessMessages;
- SourceRect:= Rect((0*50)+1, (5*30)+1, (0*50)+Btn_Vaccine.Width, (5*30)+Btn_Vaccine.Height);
- DestRect:= Rect(0, 0, Btn_Vaccine.Width-1, Btn_Vaccine.Height-1);
- Btn_Vaccine.Canvas.CopyRect(DestRect, Form_Resource.Image_BtnList.Canvas, SourceRect);
- Application.ProcessMessages;
- Btn_Vaccine.Enabled:=False;
- //20031212: Includes full path
- ShellExecute(handle, 'Open', Pchar(ExtractFilePath(Application.ExeName)+'vSafer.exe'), nil, nil, SW_SHOW);
- Btn_Vaccine.Enabled:=True;
- }
- end;
- procedure TForm_Main.Btn_MinimizeClick(Sender: TObject); // 弥家拳 滚瓢 Click
- begin
- // Tray Icon 角青窍扁
- TrayIcon.Active:= True;
- // Application 见扁扁
- if(Form_Option.Visible)then
- Form_Option.Close;
- Application.Minimize;
- ShowWindow(Application.Handle,SW_HIDE);
- end;
- procedure TForm_Main.Btn_CloseClick(Sender: TObject); // 辆丰 滚瓢 Click
- begin
- if Application.MessageBox('Do you really want to exit?', 'iSafer', MB_YESNO) = IDYES then begin
- PSMFW_UnInitActionExecute(nil);
- Halt(0);
- end;
- end;
- procedure TForm_Main.Image_SkinMouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- // Form 捞悼窍扁
- bMouseDown:= True;
- posX:= X;
- posY:= Y;
- end;
- procedure TForm_Main.Image_SkinMouseMove(Sender: TObject;
- Shift: TShiftState; X, Y: Integer);
- var
- tmpX, tmpY: Integer;
- begin
- if bMouseDown then begin
- // Form 捞悼窍扁
- tmpX:= Form_Main.Left + (X - posX);
- tmpY:= Form_Main.Top + (Y - posY);
- if tmpX < 0 then tmpX:= 0;
- if tmpX > GetSystemMetrics(SM_CXFULLSCREEN)-Form_Main.Width then tmpX:= GetSystemMetrics(SM_CXFULLSCREEN)-Form_Main.Width;
- if tmpY < 0 then tmpY:= 0;
- if tmpY > GetSystemMetrics(SM_CYFULLSCREEN)+GetSystemMetrics(SM_CYCAPTION)-Form_Main.Height then tmpY:= GetSystemMetrics(SM_CYFULLSCREEN)+GetSystemMetrics(SM_CYCAPTION)-Form_Main.Height;
- Form_Main.Left:= tmpX;
- Form_Main.Top:= tmpY;
- end else begin
- if (Stat_Safer = 1) or (Stat_Option = 1) or (Stat_Vaccine = 1) then begin
- BtnStatusCheck('');
- end;
- end;
- end;
- procedure TForm_Main.Image_SkinMouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- // Form 捞悼窍扁
- bMouseDown:= False;
- end;
- procedure TForm_Main.Label_MessageMouseMove(Sender: TObject;Shift: TShiftState; X, Y: Integer);
- begin
- if (Stat_Safer = 1) or (Stat_Option = 1) or (Stat_Vaccine = 1) then begin
- BtnStatusCheck('');
- end;
- end;
- // Add on 10th March, 2004
- procedure TForm_Main.Tray_VirusVaccineClick(Sender: TObject);
- begin
- ShellExecute(handle, 'Open', Pchar(ExtractFilePath(Application.ExeName)+'vSafer.exe'), nil, nil, SW_SHOW);
- end;
- //Execuate help utility
- procedure TForm_Main.Tray_HelpClick(Sender: TObject);
- begin
- ShellExecute(handle, 'Open', Pchar(ExtractFilePath(Application.ExeName)+'iSaferHelp.chm'), nil, nil, SW_SHOW);
- end;
- procedure TForm_Main.mnuTrayAboutClick(Sender: TObject);
- begin
- ISaferAboutDlg.ShowModal();
- end;
- procedure TForm_Main.LockClick(Sender: TObject);
- type
- tLockScrFunc = function(HWND: DWORD): DWord; stdcall;
- var
- LockScr: tLockScrFunc;
- begin
- {If the ScreenLock DLL is not loaded yet, load it}
- if ScreenLockDLLHandle < 32 then ScreenLockDLLHandle:= LoadLibrary('PSMScrLk.dll');
- if ScreenLockDLLHandle < 32 then ShowMessage('Error loading PSMScrLk.dll!')
- else
- begin
- @LockScr:= GetProcAddress(ScreenLockDLLHandle, 'LockScr');
- if not (@LockScr = nil) then begin
- LockScr(0);
- end;
- {NOTE!!!: DO NOT CALL FreeLibrary(), we must keep the process in the DLL running!!!}
- {We will call FreeLibrary() when iSafer exits}
- {FreeLibrary(ScreenLockDLLHandle);}
- end;
- end;
- procedure TForm_Main.ChangePasswordClick(Sender: TObject);
- type
- tChangePWFunc = function(): DWord; stdcall;
- var
- ChangePW: tChangePWFunc;
- begin
- {If the ScreenLock DLL is not loaded yet, load it}
- if ScreenLockDLLHandle < 32 then ScreenLockDLLHandle:= LoadLibrary('PSMScrLk.dll');
- if ScreenLockDLLHandle < 32 then ShowMessage('Error loading PSMScrLk.dll!')
- else
- begin
- @ChangePW:= GetProcAddress(ScreenLockDLLHandle, 'ChangePW');
- if not (@ChangePW = nil) then begin
- ChangePW();
- end;
- {NOTE!!!: DO NOT CALL FreeLibrary(), we must keep the process in the DLL running!!!}
- {We will call FreeLibrary() when iSafer exits}
- {FreeLibrary(ScreenLockDLLHandle);}
- end;
- end;
- end.