[MPlayer-cvslog] r32471 - trunk/mpcommon.c
reimar
subversion at mplayerhq.hu
Sat Oct 9 17:14:33 CEST 2010
Author: reimar
Date: Sat Oct 9 17:14:33 2010
New Revision: 32471
Log:
Move OS-fixup hacks in init code into a separate function.
Modified:
trunk/mpcommon.c
Modified: trunk/mpcommon.c
==============================================================================
--- trunk/mpcommon.c Sat Oct 9 17:10:08 2010 (r32470)
+++ trunk/mpcommon.c Sat Oct 9 17:14:33 2010 (r32471)
@@ -366,6 +366,29 @@ void common_preinit(void)
}
/**
+ * Code to fix any kind of insane defaults some OS might have.
+ * Currently mostly fixes for insecure-by-default Windows.
+ */
+static void sanitize_os(void)
+{
+#if defined(__MINGW32__) || defined(__CYGWIN__)
+ HMODULE kernel32 = GetModuleHandle("Kernel32.dll");
+ BOOL WINAPI (*setDEP)(DWORD) = NULL;
+ BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL;
+ if (kernel32) {
+ setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy");
+ setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA");
+ }
+ if (setDEP) setDEP(3);
+ if (setDllDir) setDllDir("");
+ // stop Windows from showing all kinds of annoying error dialogs
+ SetErrorMode(0x8003);
+ // request 1ms timer resolution
+ timeBeginPeriod(1);
+#endif
+}
+
+/**
* Initialization code to be run after command-line parsing.
*/
int common_init(void)
@@ -388,23 +411,8 @@ int common_init(void)
}
}
#endif
-
- {
- HMODULE kernel32 = GetModuleHandle("Kernel32.dll");
- BOOL WINAPI (*setDEP)(DWORD) = NULL;
- BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL;
- if (kernel32) {
- setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy");
- setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA");
- }
- if (setDEP) setDEP(3);
- if (setDllDir) setDllDir("");
- }
- // stop Windows from showing all kinds of annoying error dialogs
- SetErrorMode(0x8003);
- // request 1ms timer resolution
- timeBeginPeriod(1);
#endif
+ sanitize_os();
#ifdef CONFIG_PRIORITY
set_priority();
More information about the MPlayer-cvslog
mailing list