1 /*****************************************************************************
2 * breakpad.cpp: Wrapper to breakpad crash handler
3 *****************************************************************************
4 * Copyright (C) 1998-2017 VLC authors
6 * Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
28 #include "client/windows/handler/exception_handler.h"
29 #include "common/windows/http_upload.h"
34 using google_breakpad::ExceptionHandler
;
36 static bool FilterCallback(void*, EXCEPTION_POINTERS
*, MDRawAssertionInfo
*)
38 // Don't spam breakpad if we're debugging
39 return !IsDebuggerPresent();
45 void CheckCrashDump( const wchar_t* path
)
47 wchar_t pattern
[MAX_PATH
];
49 _snwprintf( pattern
, MAX_PATH
, L
"%s/*.dmp", path
);
50 HANDLE h
= FindFirstFile( pattern
, &data
);
51 if (h
== INVALID_HANDLE_VALUE
)
53 int answer
= MessageBox( NULL
, L
"Ooops: VLC media player just crashed.\n" \
54 "Would you like to send a bug report to the developers team?",
55 L
"VLC crash reporting", MB_YESNO
);
56 std::map
<std::wstring
, std::wstring
> params
;
57 params
[L
"prod"] = L
"VLC";
58 params
[L
"ver"] = TEXT(PACKAGE_VERSION
);
61 wchar_t fullPath
[MAX_PATH
];
62 _snwprintf( fullPath
, MAX_PATH
, L
"%s/%s", path
, data
.cFileName
);
65 std::map
<std::wstring
, std::wstring
> files
;
66 files
[L
"upload_file_minidump"] = fullPath
;
67 google_breakpad::HTTPUpload::SendRequest(
68 TEXT( BREAKPAD_URL
"/reports" ), params
, files
,
71 DeleteFile( fullPath
);
72 } while ( FindNextFile( h
, &data
) );
76 void* InstallCrashHandler( const wchar_t* crashdump_path
)
78 // Breakpad needs the folder to exist to generate the crashdump
79 CreateDirectory( crashdump_path
, NULL
);
80 return new(std::nothrow
) ExceptionHandler( crashdump_path
, FilterCallback
,
81 NULL
, NULL
, ExceptionHandler::HANDLER_ALL
);
84 void ReleaseCrashHandler( void* handler
)
86 ExceptionHandler
* eh
= reinterpret_cast<ExceptionHandler
*>( handler
);