Skip to content

Commit

Permalink
Adding library initialization and finalization to library tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDrab committed Jul 30, 2017
1 parent 0635b2a commit 65212ff
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 27 deletions.
16 changes: 8 additions & 8 deletions gui/AboutForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gui/AboutForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, ExtCtrls,
ComCtrls;
ComCtrls, Vcl.Imaging.jpeg;

Type
TAboutBox = class(TForm)
Expand Down
9 changes: 8 additions & 1 deletion gui/HookObjects.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
hooUnwatchClass,
hooWatchDriver,
hooUnwatchDriver,
hooLibraryInitialize,
hooLibraryFinalize,
hooMax
);

Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -418,6 +423,8 @@
hooStart : Result := 'Load';
hooStop : Result := 'Unload';
hooUnhook : Result := 'Uninstall';
hooLibraryInitialize : Result := 'Connect';
hooLibraryFinalize : Result := 'Disconnect';
end;
end;

Expand Down
3 changes: 0 additions & 3 deletions gui/HookProgressForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ object HookProgressFrm: THookProgressFrm
Height = 49
Align = alBottom
TabOrder = 0
ExplicitWidth = 468
object CloseButton: TButton
Left = 144
Top = 6
Expand Down Expand Up @@ -72,7 +71,5 @@ object HookProgressFrm: THookProgressFrm
TabOrder = 1
ViewStyle = vsReport
OnAdvancedCustomDrawItem = ProgressListViewAdvancedCustomDrawItem
ExplicitLeft = 16
ExplicitWidth = 573
end
end
20 changes: 6 additions & 14 deletions gui/IRPMon.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file modified gui/IRPMon.res
Binary file not shown.
1 change: 1 addition & 0 deletions gui/MainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
begin
FAppEvents.Free;
WriteSettings;
taskList.Add(hooLibraryFinalize, serviceTask);
If UnloadOnExitMenuItem.Checked Then
taskList.Add(hooStop, serviceTask);

Expand Down

0 comments on commit 65212ff

Please sign in to comment.