From 65212ffaf79f4b627888b874a941028e2430e90a Mon Sep 17 00:00:00 2001 From: Martin Drab Date: Sun, 30 Jul 2017 20:51:55 +0200 Subject: [PATCH] Adding library initialization and finalization to library tasks --- gui/AboutForm.dfm | 16 ++++++++-------- gui/AboutForm.pas | 2 +- gui/HookObjects.pas | 9 ++++++++- gui/HookProgressForm.dfm | 3 --- gui/IRPMon.dpr | 20 ++++++-------------- gui/IRPMon.res | Bin 299048 -> 299048 bytes gui/MainForm.pas | 1 + 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/gui/AboutForm.dfm b/gui/AboutForm.dfm index bd51517..f110b6d 100644 --- a/gui/AboutForm.dfm +++ b/gui/AboutForm.dfm @@ -1054,17 +1054,17 @@ object AboutBox: TAboutBox Font.Name = 'Tahoma' Font.Style = [fsBold] Items.ItemData = { - 05570100000500000000000000FFFFFFFFFFFFFFFF01000000FFFFFFFF000000 - 0007560065007200730069006F006E000330002E003600E0759C1700000000FF + 05530100000500000000000000FFFFFFFFFFFFFFFF01000000FFFFFFFF000000 + 0007560065007200730069006F006E000330002E00360030B84A1400000000FF FFFFFFFFFFFFFF01000000FFFFFFFF000000000641007500740068006F007200 - 0B4D0061007200740069006E00200044007200E100620050769C1700000000FF + 0B4D0061007200740069006E00200044007200E1006200C822461400000000FF FFFFFFFFFFFFFF01000000FFFFFFFF00000000074C006900630065006E007300 - 65000846007200650065007700610072006500A8759C1700000000FFFFFFFFFF + 650008460072006500650077006100720065000023461400000000FFFFFFFFFF FFFFFF01000000FFFFFFFF0000000008520065006C0065006100730065006400 - 0C330031002E002000310030002E0020003200300031003600480BED05000000 - 00FFFFFFFFFFFFFFFF01000000FFFFFFFF000000000743006F006E0074006100 - 63007400146D0061007200740069006E002E006400720061006200400065006D - 00610069006C002E0063007A00D0254212FFFFFFFFFFFFFFFFFFFF} + 0A35002E00200038002E00200032003000310037007023461400000000FFFFFF + FFFFFFFFFF01000000FFFFFFFF000000000743006F006E007400610063007400 + 146D0061007200740069006E002E006400720061006200400065006D00610069 + 006C002E0063007A00E0234614FFFFFFFFFFFFFFFFFFFF} ReadOnly = True RowSelect = True ParentFont = False diff --git a/gui/AboutForm.pas b/gui/AboutForm.pas index b3f8da2..84c4a57 100644 --- a/gui/AboutForm.pas +++ b/gui/AboutForm.pas @@ -9,7 +9,7 @@ Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, - ComCtrls; + ComCtrls, Vcl.Imaging.jpeg; Type TAboutBox = class(TForm) diff --git a/gui/HookObjects.pas b/gui/HookObjects.pas index bf2cb50..d804eb1 100644 --- a/gui/HookObjects.pas +++ b/gui/HookObjects.pas @@ -26,6 +26,8 @@ hooUnwatchClass, hooWatchDriver, hooUnwatchDriver, + hooLibraryInitialize, + hooLibraryFinalize, hooMax ); @@ -389,7 +391,7 @@ Constructor TDriverTaskObject.Create(ASCHandle:SC_HANDLE; AServiceName:WideString; AServiceDisplayName:WideString = ''; AServiceDescription:WideString = ''; AFileName:WideString = ''); begin -Inherited Create('Driver', AServiceName, [hooHook, hooUnhook, hooStart, hooStop]); +Inherited Create('Driver', AServiceName, [hooHook, hooUnhook, hooStart, hooStop, hooLibraryInitialize, hooLibraryFinalize]); FServiceName := AServiceName; FServiceDisplayName := AServiceDisplayName; FServiceDescription := AServiceDescription; @@ -399,11 +401,14 @@ Function TDriverTaskObject.Operation(AOperationType:EHookObjectOperation):Cardinal; begin +Result := ERROR_SUCCESS; Case AOperationType Of hooHook: Result := Install; hooStart : Result := Load; hooStop : Result := Unload; hooUnhook : Result := Uninstall; + hooLibraryInitialize : Result := IRPMonDllInitialize; + hooLibraryFinalize : IRPMonDllFInalize; Else Result := ERROR_NOT_SUPPORTED; end; @@ -418,6 +423,8 @@ hooStart : Result := 'Load'; hooStop : Result := 'Unload'; hooUnhook : Result := 'Uninstall'; + hooLibraryInitialize : Result := 'Connect'; + hooLibraryFinalize : Result := 'Disconnect'; end; end; diff --git a/gui/HookProgressForm.dfm b/gui/HookProgressForm.dfm index f1b54f8..8add6e5 100644 --- a/gui/HookProgressForm.dfm +++ b/gui/HookProgressForm.dfm @@ -24,7 +24,6 @@ object HookProgressFrm: THookProgressFrm Height = 49 Align = alBottom TabOrder = 0 - ExplicitWidth = 468 object CloseButton: TButton Left = 144 Top = 6 @@ -72,7 +71,5 @@ object HookProgressFrm: THookProgressFrm TabOrder = 1 ViewStyle = vsReport OnAdvancedCustomDrawItem = ProgressListViewAdvancedCustomDrawItem - ExplicitLeft = 16 - ExplicitWidth = 573 end end diff --git a/gui/IRPMon.dpr b/gui/IRPMon.dpr index 5b35b30..55e36bc 100644 --- a/gui/IRPMon.dpr +++ b/gui/IRPMon.dpr @@ -85,26 +85,18 @@ If IsWow64Process(GetCurrentProcess, wow64) Then serviceTask.SetCompletionCallback(OnServiceTaskComplete, Nil); taskList.Add(hooHook, serviceTask); taskList.Add(hooStart, serviceTask); + taskList.Add(hooLibraryInitialize, serviceTask); With THookProgressFrm.Create(Application, taskList) Do begin ShowModal; Free; end; - err := IRPMonDllInitialize; - If err = ERROR_SUCCESS Then - begin - Application.CreateForm(TMainFrm, MainFrm); - MainFrm.TaskList := taskList; - MainFrm.ServiceTask := serviceTask; - Application.Run; - IRPMonDllFinalize; - end - Else begin - WinErrorMessage('Unable to initialize irpmondll.dll', err); - If driverStarted Then - taskList.Add(hooStop, serviceTask); - end; + Application.CreateForm(TMainFrm, MainFrm); + MainFrm.TaskList := taskList; + MainFrm.ServiceTask := serviceTask; + Application.Run; + IRPMonDllFinalize; serviceTask.Free; taskList.Free; diff --git a/gui/IRPMon.res b/gui/IRPMon.res index 688a5aa4d051741c55b214df1d690b230f77e4cd..d5a1423e0f74c8ef76265b9462962fc5595abb61 100644 GIT binary patch delta 27 jcmZ3nKxoARp$R2Shm{)3TFV$)%a~frn75X(Z0ZL9o&pN~ delta 27 jcmZ3nKxoARp$R2SJyMNjt!0d@WlXJQ%v;M?HuVDlnVbs0 diff --git a/gui/MainForm.pas b/gui/MainForm.pas index 72baae0..9ebfbb2 100644 --- a/gui/MainForm.pas +++ b/gui/MainForm.pas @@ -164,6 +164,7 @@ begin FAppEvents.Free; WriteSettings; +taskList.Add(hooLibraryFinalize, serviceTask); If UnloadOnExitMenuItem.Checked Then taskList.Add(hooStop, serviceTask);