Mercurial > mplayer.hg
comparison mpcommon.c @ 32385:8d841a288ca7
Move OS-fixup hacks in init code into a separate function.
author | reimar |
---|---|
date | Sat, 09 Oct 2010 15:14:33 +0000 |
parents | 21cd61f89753 |
children | ce1c7ac2e3d4 |
comparison
equal
deleted
inserted
replaced
32384:21cd61f89753 | 32385:8d841a288ca7 |
---|---|
364 | 364 |
365 mp_msg_init(); | 365 mp_msg_init(); |
366 } | 366 } |
367 | 367 |
368 /** | 368 /** |
369 * Code to fix any kind of insane defaults some OS might have. | |
370 * Currently mostly fixes for insecure-by-default Windows. | |
371 */ | |
372 static void sanitize_os(void) | |
373 { | |
374 #if defined(__MINGW32__) || defined(__CYGWIN__) | |
375 HMODULE kernel32 = GetModuleHandle("Kernel32.dll"); | |
376 BOOL WINAPI (*setDEP)(DWORD) = NULL; | |
377 BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL; | |
378 if (kernel32) { | |
379 setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy"); | |
380 setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA"); | |
381 } | |
382 if (setDEP) setDEP(3); | |
383 if (setDllDir) setDllDir(""); | |
384 // stop Windows from showing all kinds of annoying error dialogs | |
385 SetErrorMode(0x8003); | |
386 // request 1ms timer resolution | |
387 timeBeginPeriod(1); | |
388 #endif | |
389 } | |
390 | |
391 /** | |
369 * Initialization code to be run after command-line parsing. | 392 * Initialization code to be run after command-line parsing. |
370 */ | 393 */ |
371 int common_init(void) | 394 int common_init(void) |
372 { | 395 { |
373 #if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) | 396 #if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_WIN32DLL) |
386 csData.lpData = file; | 409 csData.lpData = file; |
387 SendMessage(runningmplayer, WM_COPYDATA, (WPARAM)runningmplayer, (LPARAM)&csData); | 410 SendMessage(runningmplayer, WM_COPYDATA, (WPARAM)runningmplayer, (LPARAM)&csData); |
388 } | 411 } |
389 } | 412 } |
390 #endif | 413 #endif |
391 | 414 #endif |
392 { | 415 sanitize_os(); |
393 HMODULE kernel32 = GetModuleHandle("Kernel32.dll"); | |
394 BOOL WINAPI (*setDEP)(DWORD) = NULL; | |
395 BOOL WINAPI (*setDllDir)(LPCTSTR) = NULL; | |
396 if (kernel32) { | |
397 setDEP = GetProcAddress(kernel32, "SetProcessDEPPolicy"); | |
398 setDllDir = GetProcAddress(kernel32, "SetDllDirectoryA"); | |
399 } | |
400 if (setDEP) setDEP(3); | |
401 if (setDllDir) setDllDir(""); | |
402 } | |
403 // stop Windows from showing all kinds of annoying error dialogs | |
404 SetErrorMode(0x8003); | |
405 // request 1ms timer resolution | |
406 timeBeginPeriod(1); | |
407 #endif | |
408 | 416 |
409 #ifdef CONFIG_PRIORITY | 417 #ifdef CONFIG_PRIORITY |
410 set_priority(); | 418 set_priority(); |
411 #endif | 419 #endif |
412 | 420 |