From f5841b884107fee7b55b2cf80148391297b49dfb Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 9 Jul 2017 01:12:29 +0200 Subject: Windows: install crash handler in case of system favorites service in order to be able to clear Pre-Boot password from cache before the service is terminate if a crash happens. --- src/Mount/Mount.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 1d046249..6a7e1353 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -9133,6 +9133,21 @@ static VOID WINAPI SystemFavoritesServiceCtrlHandler (DWORD control) SystemFavoritesServiceSetStatus (SystemFavoritesServiceStatus.dwCurrentState); } +static LONG WINAPI SystemFavoritesServiceExceptionHandler (EXCEPTION_POINTERS *ep) +{ + SetUnhandledExceptionFilter (NULL); + + if (!(ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD)) + WipeCache (NULL, TRUE); + + UnhandledExceptionFilter (ep); + return EXCEPTION_EXECUTE_HANDLER; +} + +static void SystemFavoritesServiceInvalidParameterHandler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t reserved) +{ + TC_THROW_FATAL_EXCEPTION; +} static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv) { @@ -9146,6 +9161,9 @@ static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv) InitGlobalLocks (); + SetUnhandledExceptionFilter (SystemFavoritesServiceExceptionHandler); + _set_invalid_parameter_handler (SystemFavoritesServiceInvalidParameterHandler); + SystemFavoritesServiceSetStatus (SERVICE_START_PENDING, 120000); SystemFavoritesServiceLogInfo (wstring (L"Initializing list of host devices")); -- cgit v1.2.3