Skip to content

Commit e3835c8

Browse files
committed
devprv lazy initialize
1 parent c7d512a commit e3835c8

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

SystemInformer/devprv.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4013,15 +4013,15 @@ ULONG CALLBACK PhpCmNotifyCallback(
40134013
return ERROR_SUCCESS;
40144014
}
40154015

4016-
BOOLEAN PhDeviceProviderInitialization(
4016+
BOOLEAN PhpDeviceProviderInitialization(
40174017
VOID
40184018
)
40194019
{
40204020
NTSTATUS status;
40214021
CM_NOTIFY_FILTER cmFilter;
40224022

40234023
if (WindowsVersion < WINDOWS_10 || !PhGetIntegerSetting(L"EnableDeviceSupport"))
4024-
return TRUE;
4024+
return FALSE;
40254025

40264026
PhDeviceItemType = PhCreateObjectType(L"DeviceItem", 0, PhpDeviceItemDeleteProcedure);
40274027
PhDeviceTreeType = PhCreateObjectType(L"DeviceTree", 0, PhpDeviceTreeDeleteProcedure);
@@ -4065,3 +4065,20 @@ BOOLEAN PhDeviceProviderInitialization(
40654065

40664066
return TRUE;
40674067
}
4068+
4069+
BOOLEAN PhDeviceProviderInitialization(
4070+
VOID
4071+
)
4072+
{
4073+
static PH_INITONCE initOnce = PH_INITONCE_INIT;
4074+
static BOOLEAN initialized = FALSE;
4075+
4076+
if (PhBeginInitOnce(&initOnce))
4077+
{
4078+
initialized = PhpDeviceProviderInitialization();
4079+
4080+
PhEndInitOnce(&initOnce);
4081+
}
4082+
4083+
return initialized;
4084+
}

SystemInformer/include/devprv.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,14 @@ typedef struct _PH_DEVICE_NOTIFY
443443
LIST_ENTRY ListEntry;
444444
// begin_phapppub
445445
} PH_DEVICE_NOTIFY, *PPH_DEVICE_NOTIFY;
446-
// end_phapppub
447446

447+
PHAPPAPI
448448
BOOLEAN
449+
NTAPI
449450
PhDeviceProviderInitialization(
450451
VOID
451452
);
452453

454+
// end_phapppub
455+
453456
#endif

SystemInformer/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,6 @@ BOOLEAN PhInitializeAppSystem(
10661066
return FALSE;
10671067
if (!PhNetworkProviderInitialization())
10681068
return FALSE;
1069-
if (!PhDeviceProviderInitialization())
1070-
return FALSE;
10711069

10721070
PhSetHandleClientIdFunction(PhGetClientIdName);
10731071

SystemInformer/mainwnd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,6 @@ VOID PhMwpInitializeControls(
532532
PhNetworkTreeListInitialization();
533533
PhInitializeNetworkTreeList(PhMwpNetworkTreeNewHandle);
534534

535-
// N.B. Devices tab is handled by the HardwareDevices plug-in. The provider is managed internally
536-
// such that we can handle notifications and dispatch them to other plug-ins. Here we initialize
537-
// only the device notifications. (jxy-s).
538-
PhMwpInitializesDeviceNotifications();
539-
540535
CurrentPage = PageList->Items[0];
541536
}
542537

@@ -581,6 +576,11 @@ NTSTATUS PhMwpLoadStage1Worker(
581576
ChangeWindowMessageFilterEx(PhMainWndHandle, WM_PH_ACTIVATE, MSGFLT_ADD, NULL);
582577
}
583578

579+
// N.B. Devices tab is handled by the HardwareDevices plug-in. The provider is managed internally
580+
// such that we can handle notifications and dispatch them to other plug-ins. Here we initialize
581+
// only the device notifications. (jxy-s).
582+
PhMwpInitializesDeviceNotifications();
583+
584584
DelayedLoadCompleted = TRUE;
585585
//PostMessage((HWND)Parameter, WM_PH_DELAYED_LOAD_COMPLETED, 0, 0);
586586

SystemInformer/mwpgdev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ VOID PhMwpInitializesDeviceNotifications(
115115
VOID
116116
)
117117
{
118+
if (!PhDeviceProviderInitialization())
119+
return;
120+
118121
PhRegisterCallback(
119122
PhGetGeneralCallback(GeneralCallbackDeviceNotificationEvent),
120123
PhpDeviceProviderCallbackHandler,

plugins/HardwareDevices/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ VOID NTAPI MainWindowShowingCallback(
122122
)
123123
{
124124
AddRemoveDeviceChangeCallback();
125-
if (NetWindowsVersion >= WINDOWS_10)
125+
if (PhDeviceProviderInitialization())
126126
InitializeDevicesTab();
127127
}
128128

0 commit comments

Comments
 (0)