Fix PhSettingsInitialization error when phlib imported by tools without settings

This commit is contained in:
dmex
2022-09-06 11:48:24 +10:00
parent 9f7894ee32
commit 96514ddc1a
6 changed files with 42 additions and 34 deletions
+5 -1
View File
@@ -133,7 +133,6 @@ INT WINAPI wWinMain(
PhExitApplication(PhRunAsServiceStart(PhStartupParameters.RunAsServiceMode));
}
PhSettingsInitialization();
PhpInitializeSettings();
if (PhGetIntegerSetting(L"AllowOnlyOneInstance") &&
@@ -1476,6 +1475,10 @@ VOID PhpInitializeSettings(
{
NTSTATUS status;
PhSettingsInitialization();
PhAddDefaultSettings();
PhUpdateCachedSettings();
if (!PhStartupParameters.NoSettings)
{
static PH_STRINGREF settingsPath = PH_STRINGREF_INIT(L"%APPDATA%\\SystemInformer\\settings.xml");
@@ -1526,6 +1529,7 @@ VOID PhpInitializeSettings(
if (!PhIsNullOrEmptyString(PhSettingsFileName))
{
status = PhLoadSettings(&PhSettingsFileName->sr);
PhUpdateCachedSettings();
// If we didn't find the file, it will be created. Otherwise,
// there was probably a parsing error and we don't want to
+7 -10
View File
@@ -51,16 +51,6 @@ PhSettingsInitialization(
VOID
);
// Note: Program specific function.
VOID PhAddDefaultSettings(
VOID
);
// Note: Program specific function.
VOID PhUpdateCachedSettings(
VOID
);
// private
PPH_STRING PhSettingToString(
@@ -380,6 +370,13 @@ PhAddSettings(
_In_ ULONG NumberOfSettings
);
PHLIBAPI
PPH_SETTING
NTAPI
PhGetSetting(
_In_ PPH_STRINGREF Name
);
VOID
NTAPI
PhLoadWindowPlacementFromSetting(
+13 -14
View File
@@ -38,15 +38,6 @@ ULONG NTAPI PhpSettingsHashtableHashFunction(
_In_ PVOID Entry
);
VOID PhpFreeSettingValue(
_In_ PH_SETTING_TYPE Type,
_In_ PPH_SETTING Setting
);
PVOID PhpLookupSetting(
_In_ PPH_STRINGREF Name
);
PPH_HASHTABLE PhSettingsHashtable;
PH_QUEUED_LOCK PhSettingsLock = PH_QUEUED_LOCK_INIT;
PPH_LIST PhIgnoredSettings;
@@ -62,9 +53,6 @@ VOID PhSettingsInitialization(
512
);
PhIgnoredSettings = PhCreateList(4);
PhAddDefaultSettings();
PhUpdateCachedSettings();
}
BOOLEAN NTAPI PhpSettingsHashtableEqualFunction(
@@ -727,8 +715,6 @@ NTSTATUS PhLoadSettings(
PhFreeXmlObject(topNode);
PhUpdateCachedSettings();
return STATUS_SUCCESS;
}
@@ -893,6 +879,19 @@ VOID PhAddSettings(
PhReleaseQueuedLockExclusive(&PhSettingsLock);
}
PPH_SETTING PhGetSetting(
_In_ PPH_STRINGREF Name
)
{
PPH_SETTING setting;
PhAcquireQueuedLockShared(&PhSettingsLock);
setting = PhpLookupSetting(Name);
PhReleaseQueuedLockShared(&PhSettingsLock);
return setting;
}
VOID PhLoadWindowPlacementFromSetting(
_In_opt_ PWSTR PositionSettingName,
_In_opt_ PWSTR SizeSettingName,
+6 -2
View File
@@ -155,11 +155,15 @@ VOID PvConfigTreeBorders(
extern BOOLEAN PeEnableThemeSupport;
VOID PeInitializeSettings(
VOID PvInitializeSettings(
VOID
);
VOID PeSaveSettings(
VOID PvSaveSettings(
VOID
);
VOID PvUpdateCachedSettings(
VOID
);
+2 -2
View File
@@ -110,7 +110,7 @@ INT WINAPI wWinMain(
PhGuiSupportInitialization();
PhSettingsInitialization();
PeInitializeSettings();
PvInitializeSettings();
PvPropInitialization();
PhTreeNewInitialization();
@@ -287,7 +287,7 @@ INT WINAPI wWinMain(
}
}
PeSaveSettings();
PvSaveSettings();
return 0;
}
+9 -5
View File
@@ -11,10 +11,10 @@
#include <peview.h>
static PPH_STRING PeSettingsFileName = NULL;
static PPH_STRING PvSettingsFileName = NULL;
BOOLEAN PeEnableThemeSupport = FALSE;
VOID PhAddDefaultSettings(
VOID PvAddDefaultSettings(
VOID
)
{
@@ -87,7 +87,7 @@ VOID PhAddDefaultSettings(
PhpAddStringSetting(L"ExportsWslListViewColumns", L"");
}
VOID PhUpdateCachedSettings(
VOID PvUpdateCachedSettings(
VOID
)
{
@@ -95,7 +95,7 @@ VOID PhUpdateCachedSettings(
PeEnableThemeSupport = !!PhGetIntegerSetting(L"EnableThemeSupport");
}
VOID PeInitializeSettings(
VOID PvInitializeSettings(
VOID
)
{
@@ -105,6 +105,8 @@ VOID PeInitializeSettings(
PPH_STRING appFileName;
PPH_STRING tempFileName;
PvAddDefaultSettings();
// There are three possible locations for the settings file:
// 1. A file named peview.exe.settings.xml in the program directory. (This changes
// based on the executable file name.)
@@ -182,9 +184,11 @@ VOID PeInitializeSettings(
// Apply basic global settings.
PhMaxSizeUnit = PhGetIntegerSetting(L"MaxSizeUnit");
PvUpdateCachedSettings();
}
VOID PeSaveSettings(
VOID PvSaveSettings(
VOID
)
{