X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bin%2Fwinvlc.c;h=a8dd08aa79be09d19dcb3933d75dd6fc26bdfe9a;hb=5c62c801edea6c4ef695668831ec4252d78166de;hp=ca6445800c07616b7e944c6dc3fabd3e5da16794;hpb=2114aaa9b0badfcbb840d4f1325e2add71e0e3aa;p=vlc diff --git a/bin/winvlc.c b/bin/winvlc.c index ca6445800c..a8dd08aa79 100644 --- a/bin/winvlc.c +++ b/bin/winvlc.c @@ -35,7 +35,7 @@ #include #include -#if !defined(UNDER_CE) && defined ( NDEBUG ) +#if !defined(UNDER_CE) # define _WIN32_IE 0x500 # include # include @@ -120,10 +120,31 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, return 1; char *argv[argc + 1]; + BOOL crash_handling = TRUE; + int j = 0; for (int i = 0; i < argc; i++) - argv[i] = FromWide (wargv[i]); + { + if(!wcscmp(wargv[i], L"--no-crashdump")) + { + crash_handling = FALSE; + } + else + { + argv[j] = FromWide (wargv[i]); + j++; + } + } + + argc = j; argv[argc] = NULL; LocalFree (wargv); + + if(crash_handling) + { + check_crashdump(); + SetUnhandledExceptionFilter(vlc_exception_filter); + } + #else char **argv, psz_cmdline[wcslen(lpCmdLine) * 4]; @@ -137,16 +158,12 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, libvlc_exception_init (&ex); libvlc_exception_init (&dummy); -#if !defined( UNDER_CE ) && defined ( NDEBUG ) - check_crashdump(); - SetUnhandledExceptionFilter(vlc_exception_filter); -#endif - /* Initialize libvlc */ libvlc_instance_t *vlc; vlc = libvlc_new (argc - 1, (const char **)argv + 1, &ex); if (vlc != NULL) { + libvlc_add_intf (vlc, "globalhotkeys,none", &ex); libvlc_add_intf (vlc, NULL, &ex); libvlc_playlist_play (vlc, -1, 0, NULL, &dummy); libvlc_wait (vlc); @@ -164,7 +181,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, return ret; } -#if !defined( UNDER_CE ) && defined ( NDEBUG ) +#if !defined( UNDER_CE ) static void get_crashdump_path(wchar_t * wdir) { @@ -223,71 +240,82 @@ static void check_crashdump() *****************************************************************************/ LONG WINAPI vlc_exception_filter(struct _EXCEPTION_POINTERS *lpExceptionInfo) { - fprintf( stderr, "unhandled vlc exception\n" ); - - wchar_t * wdir = (wchar_t *)malloc(sizeof(wchar_t)*MAX_PATH); - get_crashdump_path(wdir); - FILE * fd = _wfopen ( wdir, L"w, ccs=UTF-8" ); - free((void *)wdir); - - if( !fd ) + if(IsDebuggerPresent()) { - fprintf( stderr, "\nerror while opening file" ); - exit( 1 ); + //If a debugger is present, pass the exception to the debugger with EXCEPTION_CONTINUE_SEARCH + return EXCEPTION_CONTINUE_SEARCH; } - - OSVERSIONINFO osvi; - ZeroMemory( &osvi, sizeof(OSVERSIONINFO) ); - osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); - GetVersionEx( &osvi ); - - fwprintf( fd, L"[Version]\n0S=%d.%d.%d.%d.%s\nVLC=%s", osvi.dwMajorVersion, - osvi.dwMinorVersion, - osvi.dwBuildNumber, - osvi.dwPlatformId, - osvi.szCSDVersion, - VERSION_MESSAGE); - - const CONTEXT *const pContext = (const CONTEXT *)lpExceptionInfo->ContextRecord; - const EXCEPTION_RECORD *const pException = (const EXCEPTION_RECORD *)lpExceptionInfo->ExceptionRecord; - /*No nested exceptions for now*/ - fwprintf( fd, L"\n\n[Exceptions]\n%08x at %08x",pException->ExceptionCode, - pException->ExceptionAddress ); - if( pException->NumberParameters > 0 ) + else { - unsigned int i; - for( i = 0; i < pException->NumberParameters; i++ ) - fprintf( fd, " | %08x", pException->ExceptionInformation[i] ); - } + fprintf( stderr, "unhandled vlc exception\n" ); - fwprintf( fd, L"\n\n[CONTEXT]\nEDI:%08x\nESI:%08x\n" \ - "EBX:%08x\nEDX:%08xn\nECX:%08x\nEAX:%08x\n" \ - "EBP:%08x\nEIP:%08x\nESP:%08x\n", - pContext->Edi,pContext->Esi,pContext->Ebx, - pContext->Edx,pContext->Ecx,pContext->Eax, - pContext->Ebp,pContext->Eip,pContext->Esp ); + wchar_t * wdir = (wchar_t *)malloc(sizeof(wchar_t)*MAX_PATH); + get_crashdump_path(wdir); + FILE * fd = _wfopen ( wdir, L"w, ccs=UTF-8" ); + free((void *)wdir); - fwprintf( fd, L"\n\n[STACKTRACE]\n#EIP|base|module\n" ); + if( !fd ) + { + fprintf( stderr, "\nerror while opening file" ); + exit( 1 ); + } - DWORD pEbp = pContext->Ebp; - DWORD caller = *((DWORD*)pEbp + 1) ; + OSVERSIONINFO osvi; + ZeroMemory( &osvi, sizeof(OSVERSIONINFO) ); + osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx( &osvi ); + + fwprintf( fd, L"[version]\nOS=%d.%d.%d.%d.%s\nVLC=" VERSION_MESSAGE, osvi.dwMajorVersion, + osvi.dwMinorVersion, + osvi.dwBuildNumber, + osvi.dwPlatformId, + osvi.szCSDVersion); + + const CONTEXT *const pContext = (const CONTEXT *)lpExceptionInfo->ContextRecord; + const EXCEPTION_RECORD *const pException = (const EXCEPTION_RECORD *)lpExceptionInfo->ExceptionRecord; + /*No nested exceptions for now*/ + fwprintf( fd, L"\n\n[exceptions]\n%08x at %08x",pException->ExceptionCode, + pException->ExceptionAddress ); + if( pException->NumberParameters > 0 ) + { + unsigned int i; + for( i = 0; i < pException->NumberParameters; i++ ) + fprintf( fd, " | %08x", pException->ExceptionInformation[i] ); + } - wchar_t module[ 256 ]; + fwprintf( fd, L"\n\n[context]\nEDI:%08x\nESI:%08x\n" \ + "EBX:%08x\nEDX:%08x\nECX:%08x\nEAX:%08x\n" \ + "EBP:%08x\nEIP:%08x\nESP:%08x\n", + pContext->Edi,pContext->Esi,pContext->Ebx, + pContext->Edx,pContext->Ecx,pContext->Eax, + pContext->Ebp,pContext->Eip,pContext->Esp ); - do - { + fwprintf( fd, L"\n[stacktrace]\n#EIP|base|module\n" ); + + wchar_t module[ 256 ]; MEMORY_BASIC_INFORMATION mbi ; - VirtualQuery( (DWORD *)caller, &mbi, sizeof( mbi ) ) ; + VirtualQuery( (DWORD *)pContext->Eip, &mbi, sizeof( mbi ) ) ; HINSTANCE hInstance = mbi.AllocationBase; GetModuleFileName( hInstance, module, 256 ) ; - fwprintf( fd, L"%08x|%08x|%s\n", caller, hInstance, module ); - pEbp = *(DWORD*)pEbp ; - caller = *((DWORD*)pEbp + 1) ; - /*The last EBP points to NULL!*/ - }while(caller); - - fclose( fd ); - fflush( stderr ); - exit( 1 ); + fwprintf( fd, L"%08x|%s\n", pContext->Eip, module ); + + DWORD pEbp = pContext->Ebp; + DWORD caller = *((DWORD*)pEbp + 1); + + do + { + VirtualQuery( (DWORD *)caller, &mbi, sizeof( mbi ) ) ; + HINSTANCE hInstance = mbi.AllocationBase; + GetModuleFileName( hInstance, module, 256 ) ; + fwprintf( fd, L"%08x|%s\n", caller, module ); + pEbp = *(DWORD*)pEbp ; + caller = *((DWORD*)pEbp + 1) ; + /*The last EBP points to NULL!*/ + }while(caller); + + fclose( fd ); + fflush( stderr ); + exit( 1 ); + } } #endif