X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bin%2Fwinvlc.c;h=09e739c17028f93730f02ccfdb7d24578c32901d;hb=29abf6f45dbb8352f1bff912a32889415c6eff18;hp=e752d080f21a5355d1ff8055121f138403190a13;hpb=3ace88ecf651b3549e94ff9e914c8de342f1058a;p=vlc diff --git a/bin/winvlc.c b/bin/winvlc.c index e752d080f2..09e739c170 100644 --- a/bin/winvlc.c +++ b/bin/winvlc.c @@ -36,12 +36,17 @@ #include #if !defined(UNDER_CE) -# define _WIN32_IE 0x500 +# ifndef _WIN32_IE +# define _WIN32_IE 0x501 +# endif # include # include # include -static void check_crashdump(); +# ifndef _WIN64 +static void check_crashdump(void); LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo); +# endif +#define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1 #endif #ifndef UNDER_CE @@ -113,17 +118,56 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, #endif int nCmdShow ) { - int argc, ret; + int argc; #ifndef UNDER_CE + HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0); + + HINSTANCE h_Kernel32 = LoadLibraryW(L"kernel32.dll"); + if(h_Kernel32) + { + BOOL (WINAPI * mySetProcessDEPPolicy)( DWORD dwFlags); +# define PROCESS_DEP_ENABLE 1 + + mySetProcessDEPPolicy = (BOOL WINAPI (*)(DWORD)) + GetProcAddress(h_Kernel32, "SetProcessDEPPolicy"); + if(mySetProcessDEPPolicy) + mySetProcessDEPPolicy(PROCESS_DEP_ENABLE); + FreeLibrary(h_Kernel32); + } + wchar_t **wargv = CommandLineToArgvW (GetCommandLine (), &argc); if (wargv == NULL) return 1; - char *argv[argc + 1]; - for (int i = 0; i < argc; i++) - argv[i] = FromWide (wargv[i]); + char *argv[argc + 2]; + BOOL crash_handling = TRUE; + int j = 0; + + argv[j++] = FromWide( L"--media-library" ); + argv[j++] = FromWide( L"--no-ignore-config" ); + for (int i = 1; i < argc; i++) + { + if(!wcscmp(wargv[i], L"--no-crashdump")) + { + crash_handling = FALSE; + continue; /* don't give argument to libvlc */ + } + + argv[j++] = FromWide (wargv[i]); + } + + argc = j; argv[argc] = NULL; LocalFree (wargv); + +# ifndef _WIN64 + if(crash_handling) + { + check_crashdump(); + SetUnhandledExceptionFilter(vlc_exception_filter); + } +# endif /* WIN64 */ + #else char **argv, psz_cmdline[wcslen(lpCmdLine) * 4]; @@ -133,38 +177,26 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, argc = parse_cmdline (psz_cmdline, &argv); #endif - libvlc_exception_t ex, dummy; - libvlc_exception_init (&ex); - libvlc_exception_init (&dummy); - -#if !defined( UNDER_CE ) - check_crashdump(); - SetUnhandledExceptionFilter(vlc_exception_filter); -#endif - /* Initialize libvlc */ libvlc_instance_t *vlc; - vlc = libvlc_new (argc - 1, (const char **)argv + 1, &ex); + vlc = libvlc_new (argc, (const char **)argv); if (vlc != NULL) { - libvlc_add_intf (vlc, NULL, &ex); - libvlc_playlist_play (vlc, -1, 0, NULL, &dummy); + libvlc_add_intf (vlc, "globalhotkeys,none"); + libvlc_add_intf (vlc, NULL); + libvlc_playlist_play (vlc, -1, 0, NULL); libvlc_wait (vlc); libvlc_release (vlc); } - ret = libvlc_exception_raised (&ex); - libvlc_exception_clear (&ex); - libvlc_exception_clear (&dummy); - for (int i = 0; i < argc; i++) free (argv[i]); (void)hInstance; (void)hPrevInstance; (void)lpCmdLine; (void)nCmdShow; - return ret; + return 0; } -#if !defined( UNDER_CE ) +#if !defined( UNDER_CE ) && !defined( _WIN64 ) static void get_crashdump_path(wchar_t * wdir) { @@ -285,6 +317,7 @@ LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo) DWORD pEbp = pContext->Ebp; DWORD caller = *((DWORD*)pEbp + 1); + unsigned i_line = 0; do { VirtualQuery( (DWORD *)caller, &mbi, sizeof( mbi ) ) ; @@ -293,8 +326,9 @@ LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo) fwprintf( fd, L"%08x|%s\n", caller, module ); pEbp = *(DWORD*)pEbp ; caller = *((DWORD*)pEbp + 1) ; + i_line++; /*The last EBP points to NULL!*/ - }while(caller); + }while(caller && i_line< 100); fclose( fd ); fflush( stderr );