[vlc-commits] win32: use thread-safe error mode (only)
Rémi Denis-Courmont
git at videolan.org
Sun Dec 3 17:13:14 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec 3 18:06:37 2017 +0200| [4448d4d5c16c6effd11922dcf2a675bd05628ec0] | committer: Rémi Denis-Courmont
win32: use thread-safe error mode (only)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4448d4d5c16c6effd11922dcf2a675bd05628ec0
---
bin/cachegen.c | 6 ------
bin/winvlc.c | 3 ---
include/vlc/libvlc.h | 9 ++-------
src/win32/plugin.c | 39 ---------------------------------------
4 files changed, 2 insertions(+), 55 deletions(-)
diff --git a/bin/cachegen.c b/bin/cachegen.c
index 4045500507..1a5a87f95c 100644
--- a/bin/cachegen.c
+++ b/bin/cachegen.c
@@ -29,9 +29,6 @@
#ifdef HAVE_GETOPT_H
# include <getopt.h>
#endif
-#ifdef _WIN32
-# include <windows.h>
-#endif
static void version (void)
{
@@ -48,9 +45,6 @@ static void usage (const char *path)
int main (int argc, char *argv[])
{
-#if defined(_WIN32) && (_WIN32_WINNT < _WIN32_WINNT_WIN7)
- SetErrorMode(SEM_FAILCRITICALERRORS);
-#endif
#ifdef HAVE_GETOPT_H
static const struct option opts[] =
{
diff --git a/bin/winvlc.c b/bin/winvlc.c
index abef6a816d..0edadb0f88 100644
--- a/bin/winvlc.c
+++ b/bin/winvlc.c
@@ -135,9 +135,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
#endif
-#if (_WIN32_WINNT < _WIN32_WINNT_WIN7)
- SetErrorMode(SEM_FAILCRITICALERRORS);
-#endif
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
/* SetProcessDEPPolicy, SetDllDirectory, & Co. */
diff --git a/include/vlc/libvlc.h b/include/vlc/libvlc.h
index b12d900469..78afe99f16 100644
--- a/include/vlc/libvlc.h
+++ b/include/vlc/libvlc.h
@@ -152,14 +152,9 @@ LIBVLC_API const char *libvlc_printerr (const char *fmt, ...);
pthread_sigmask(SIG_BLOCK, &set, NULL);
* @endcode
*
- * On Microsoft Windows Vista/2008, the process error mode
- * SEM_FAILCRITICALERRORS flag <b>must</b> be set before using LibVLC.
- * On later versions, that is optional and unnecessary.
- * Also on Microsoft Windows (Vista and any later version), setting the default
- * DLL directories to SYSTEM32 exclusively is strongly recommended for
- * security reasons:
+ * On Microsoft Windows, setting the default DLL directories to SYSTEM32
+ * exclusively is strongly recommended for security reasons:
* @code
- SetErrorMode(SEM_FAILCRITICALERRORS);
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
* @endcode
*
diff --git a/src/win32/plugin.c b/src/win32/plugin.c
index 1a65521fca..d4ac661fec 100644
--- a/src/win32/plugin.c
+++ b/src/win32/plugin.c
@@ -35,45 +35,6 @@
extern DWORD LoadLibraryFlags;
-#if (_WIN32_WINNT < _WIN32_WINNT_WIN7)
-static BOOL WINAPI SetThreadErrorModeFallback(DWORD mode, DWORD *oldmode)
-{
- /* TODO: cache the pointer */
- HANDLE h = GetModuleHandle(_T("kernel32.dll"));
- if (unlikely(h == NULL))
- return FALSE;
-
- BOOL (WINAPI *SetThreadErrorModeReal)(DWORD, DWORD *);
-
- SetThreadErrorModeReal = GetProcAddress(h, "SetThreadErrorMode");
- if (SetThreadErrorModeReal != NULL)
- return SetThreadErrorModeReal(mode, oldmode);
-
-# if (_WIN32_WINNT < _WIN32_WINNT_VISTA)
- /* As per libvlc_new() documentation, the calling process is responsible
- * for setting a proper error mode on Windows 2008 and earlier versions.
- * This is only a sanity check. */
- UINT (WINAPI *GetErrorModeReal)(void);
- DWORD curmode = 0;
-
- GetErrorModeReal = (void *)GetProcAddress(h, "GetErrorMode");
- if (GetErrorModeReal != NULL)
- curmode = GetErrorModeReal();
- else
- curmode = SEM_FAILCRITICALERRORS;
-# else
- DWORD curmode = GetErrorMode();
-# endif
- /* Extra flags should be OK. Missing flags are NOT OK. */
- if ((mode & curmode) != mode)
- return FALSE;
- if (oldmode != NULL)
- *oldmode = curmode;
- return TRUE;
-}
-# define SetThreadErrorMode SetThreadErrorModeFallback
-#endif
-
static char *GetWindowsError( void )
{
wchar_t wmsg[256];
More information about the vlc-commits
mailing list