3
3
* plugin support
4
4
*
5
5
* Copyright (C) 2010-2015 wj32
6
- * Copyright (C) 2017-2021 dmex
6
+ * Copyright (C) 2017-2022 dmex
7
7
*
8
8
* This file is part of Process Hacker.
9
9
*
@@ -61,6 +61,20 @@ VOID PhpExecuteCallbackForAllPlugins(
61
61
PH_AVL_TREE PhPluginsByName = PH_AVL_TREE_INIT (PhpPluginsCompareFunction );
62
62
static PH_CALLBACK GeneralCallbacks [GeneralCallbackMaximum ];
63
63
static ULONG NextPluginId = IDPLUGINS + 1 ;
64
+ static PH_STRINGREF PhpDefaultPluginName [] =
65
+ {
66
+ PH_STRINGREF_INIT (L"DotNetTools.dll" ),
67
+ PH_STRINGREF_INIT (L"ExtendedNotifications.dll" ),
68
+ PH_STRINGREF_INIT (L"ExtendedServices.dll" ),
69
+ PH_STRINGREF_INIT (L"ExtendedTools.dll" ),
70
+ PH_STRINGREF_INIT (L"HardwareDevices.dll" ),
71
+ PH_STRINGREF_INIT (L"NetworkTools.dll" ),
72
+ PH_STRINGREF_INIT (L"OnlineChecks.dll" ),
73
+ PH_STRINGREF_INIT (L"ToolStatus.dll" ),
74
+ PH_STRINGREF_INIT (L"Updater.dll" ),
75
+ PH_STRINGREF_INIT (L"UserNotes.dll" ),
76
+ PH_STRINGREF_INIT (L"WindowExplorer.dll" ),
77
+ };
64
78
65
79
INT NTAPI PhpPluginsCompareFunction (
66
80
_In_ PPH_AVL_LINKS Links1 ,
@@ -322,6 +336,12 @@ static BOOLEAN EnumPluginsDirectoryCallback(
322
336
if (!PhEndsWithStringRef (& baseName , & PhpPluginExtension , FALSE))
323
337
return TRUE;
324
338
339
+ for (ULONG i = 0 ; i < RTL_NUMBER_OF (PhpDefaultPluginName ); i ++ )
340
+ {
341
+ if (PhEqualStringRef (& baseName , & PhpDefaultPluginName [i ], TRUE))
342
+ return TRUE;
343
+ }
344
+
325
345
if (!(directoryName = PhpGetPluginDirectoryPath ()))
326
346
return TRUE;
327
347
@@ -439,7 +459,8 @@ VOID PhLoadPlugins(
439
459
VOID
440
460
)
441
461
{
442
- ULONG i ;
462
+ NTSTATUS status ;
463
+ PPH_STRING fileName ;
443
464
PPH_STRING pluginsDirectory ;
444
465
PPH_LIST pluginLoadErrors ;
445
466
@@ -448,58 +469,34 @@ VOID PhLoadPlugins(
448
469
449
470
pluginLoadErrors = PhCreateList (1 );
450
471
451
- if ( PhGetIntegerSetting ( L"EnableSafeDefaultPlugins" ) )
472
+ for ( ULONG i = 0 ; i < RTL_NUMBER_OF ( PhpDefaultPluginName ); i ++ )
452
473
{
453
- static PH_STRINGREF PhpDefaultPluginName [] =
474
+ if ( fileName = PhConcatStringRef2 ( & pluginsDirectory -> sr , & PhpDefaultPluginName [i ]))
454
475
{
455
- PH_STRINGREF_INIT (L"DotNetTools.dll" ),
456
- PH_STRINGREF_INIT (L"ExtendedNotifications.dll" ),
457
- PH_STRINGREF_INIT (L"ExtendedServices.dll" ),
458
- PH_STRINGREF_INIT (L"ExtendedTools.dll" ),
459
- PH_STRINGREF_INIT (L"HardwareDevices.dll" ),
460
- PH_STRINGREF_INIT (L"NetworkTools.dll" ),
461
- PH_STRINGREF_INIT (L"OnlineChecks.dll" ),
462
- PH_STRINGREF_INIT (L"ToolStatus.dll" ),
463
- PH_STRINGREF_INIT (L"Updater.dll" ),
464
- PH_STRINGREF_INIT (L"UserNotes.dll" ),
465
- PH_STRINGREF_INIT (L"WindowExplorer.dll" ),
466
- };
467
- PPH_STRING fileName ;
468
- NTSTATUS status ;
476
+ status = PhLoadPlugin (fileName );
469
477
470
- for (i = 0 ; i < RTL_NUMBER_OF (PhpDefaultPluginName ); i ++ )
471
- {
472
- if (fileName = PhConcatStringRef2 (& pluginsDirectory -> sr , & PhpDefaultPluginName [i ]))
478
+ if (!NT_SUCCESS (status ))
473
479
{
474
- status = PhLoadPlugin (fileName );
475
-
476
- if (!NT_SUCCESS (status ))
477
- {
478
- PPHP_PLUGIN_LOAD_ERROR loadError ;
479
- PPH_STRING errorMessage ;
480
+ PPHP_PLUGIN_LOAD_ERROR loadError ;
481
+ PPH_STRING errorMessage ;
480
482
481
- loadError = PhAllocateZero (sizeof (PHP_PLUGIN_LOAD_ERROR ));
482
- PhSetReference (& loadError -> FileName , fileName );
483
+ loadError = PhAllocateZero (sizeof (PHP_PLUGIN_LOAD_ERROR ));
484
+ PhSetReference (& loadError -> FileName , fileName );
483
485
484
- if (errorMessage = PhGetNtMessage (status ))
485
- {
486
- PhSetReference (& loadError -> ErrorMessage , errorMessage );
487
- PhDereferenceObject (errorMessage );
488
- }
489
-
490
- PhAddItemList (pluginLoadErrors , loadError );
486
+ if (errorMessage = PhGetNtMessage (status ))
487
+ {
488
+ PhSetReference (& loadError -> ErrorMessage , errorMessage );
489
+ PhDereferenceObject (errorMessage );
491
490
}
492
491
493
- PhDereferenceObject ( fileName );
492
+ PhAddItemList ( pluginLoadErrors , loadError );
494
493
}
495
- }
496
494
497
- if (pluginLoadErrors -> Count != 0 && !PhStartupParameters .PhSvc )
498
- {
499
- PhpShowPluginErrorMessage (pluginLoadErrors );
495
+ PhDereferenceObject (fileName );
500
496
}
501
497
}
502
- else
498
+
499
+ if (!PhGetIntegerSetting (L"EnableSafeDefaultPlugins" ))
503
500
{
504
501
HANDLE pluginsDirectoryHandle ;
505
502
@@ -539,13 +536,13 @@ VOID PhLoadPlugins(
539
536
540
537
NtClose (pluginsDirectoryHandle );
541
538
}
539
+ }
542
540
543
- // Handle load errors.
544
- // In certain startup modes we want to ignore all plugin load errors.
545
- if (PhGetIntegerSetting (L"ShowPluginLoadErrors" ) && pluginLoadErrors -> Count != 0 && !PhStartupParameters .PhSvc )
546
- {
547
- PhpShowPluginErrorMessage (pluginLoadErrors );
548
- }
541
+ // Handle load errors.
542
+ // In certain startup modes we want to ignore all plugin load errors.
543
+ if (PhGetIntegerSetting (L"ShowPluginLoadErrors" ) && pluginLoadErrors -> Count != 0 && !PhStartupParameters .PhSvc )
544
+ {
545
+ PhpShowPluginErrorMessage (pluginLoadErrors );
549
546
}
550
547
551
548
// When we loaded settings before, we didn't know about plugin settings, so they
@@ -557,7 +554,7 @@ VOID PhLoadPlugins(
557
554
558
555
PhpExecuteCallbackForAllPlugins (PluginCallbackLoad , TRUE);
559
556
560
- for (i = 0 ; i < pluginLoadErrors -> Count ; i ++ )
557
+ for (ULONG i = 0 ; i < pluginLoadErrors -> Count ; i ++ )
561
558
{
562
559
PPHP_PLUGIN_LOAD_ERROR loadError ;
563
560
@@ -594,23 +591,6 @@ NTSTATUS PhLoadPlugin(
594
591
_In_ PPH_STRING FileName
595
592
)
596
593
{
597
- //NTSTATUS status;
598
- //PPH_STRING fileName;
599
- //
600
- //status = PhGetFullPathEx(
601
- // FileName->Buffer,
602
- // NULL,
603
- // &fileName
604
- // );
605
- //
606
- //if (NT_SUCCESS(status))
607
- //{
608
- // status = PhLoadPluginImage(fileName, NULL);
609
- //
610
- // PhDereferenceObject(fileName);
611
- //}
612
- //
613
- //return status;
614
594
return PhLoadPluginImage (FileName , NULL );
615
595
}
616
596
0 commit comments