| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/app/breakpad_win.h" | 5 #include "chrome/app/breakpad_win.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <tchar.h> | 8 #include <tchar.h> |
| 9 #include <userenv.h> | 9 #include <userenv.h> |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 google_breakpad::ExceptionHandler* g_dumphandler_no_crash = NULL; | 95 google_breakpad::ExceptionHandler* g_dumphandler_no_crash = NULL; |
| 96 | 96 |
| 97 EXCEPTION_POINTERS g_surrogate_exception_pointers = {0}; | 97 EXCEPTION_POINTERS g_surrogate_exception_pointers = {0}; |
| 98 EXCEPTION_RECORD g_surrogate_exception_record = {0}; | 98 EXCEPTION_RECORD g_surrogate_exception_record = {0}; |
| 99 CONTEXT g_surrogate_context = {0}; | 99 CONTEXT g_surrogate_context = {0}; |
| 100 | 100 |
| 101 typedef NTSTATUS (WINAPI* NtTerminateProcessPtr)(HANDLE ProcessHandle, | 101 typedef NTSTATUS (WINAPI* NtTerminateProcessPtr)(HANDLE ProcessHandle, |
| 102 NTSTATUS ExitStatus); | 102 NTSTATUS ExitStatus); |
| 103 char* g_real_terminate_process_stub = NULL; | 103 char* g_real_terminate_process_stub = NULL; |
| 104 | 104 |
| 105 static size_t g_num_of_extensions_offset = 0; | |
| 106 static size_t g_extension_ids_offset = 0; | |
| 107 static size_t g_client_id_offset = 0; | 105 static size_t g_client_id_offset = 0; |
| 108 static size_t g_printer_info_offset = 0; | 106 static size_t g_printer_info_offset = 0; |
| 109 static size_t g_num_of_views_offset = 0; | 107 static size_t g_num_of_views_offset = 0; |
| 110 static size_t g_num_switches_offset = 0; | 108 static size_t g_num_switches_offset = 0; |
| 111 static size_t g_switches_offset = 0; | 109 static size_t g_switches_offset = 0; |
| 112 static size_t g_dynamic_keys_offset = 0; | 110 static size_t g_dynamic_keys_offset = 0; |
| 113 typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*> | 111 typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*> |
| 114 DynamicEntriesMap; | 112 DynamicEntriesMap; |
| 115 DynamicEntriesMap* g_dynamic_entries = NULL; | 113 DynamicEntriesMap* g_dynamic_entries = NULL; |
| 116 // Allow for 128 entries. POSIX uses 64 entries of 256 bytes, so Windows needs | 114 // Allow for 128 entries. POSIX uses 64 entries of 256 bytes, so Windows needs |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 L"profile-type", GetProfileType().c_str())); | 430 L"profile-type", GetProfileType().c_str())); |
| 433 | 431 |
| 434 if (g_deferred_crash_uploads) | 432 if (g_deferred_crash_uploads) |
| 435 g_custom_entries->push_back( | 433 g_custom_entries->push_back( |
| 436 google_breakpad::CustomInfoEntry(L"deferred-upload", L"true")); | 434 google_breakpad::CustomInfoEntry(L"deferred-upload", L"true")); |
| 437 | 435 |
| 438 if (!special_build.empty()) | 436 if (!special_build.empty()) |
| 439 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 437 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 440 L"special", UTF16ToWide(special_build).c_str())); | 438 L"special", UTF16ToWide(special_build).c_str())); |
| 441 | 439 |
| 442 g_num_of_extensions_offset = g_custom_entries->size(); | |
| 443 g_custom_entries->push_back( | |
| 444 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); | |
| 445 | |
| 446 g_extension_ids_offset = g_custom_entries->size(); | |
| 447 // one-based index for the name suffix. | |
| 448 for (int i = 1; i <= kMaxReportedActiveExtensions; ++i) { | |
| 449 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | |
| 450 base::StringPrintf(L"extension-%i", i).c_str(), L"")); | |
| 451 } | |
| 452 | |
| 453 // Add empty values for the prn_info-*. We'll put the actual values when we | 440 // Add empty values for the prn_info-*. We'll put the actual values when we |
| 454 // collect them at this location. | 441 // collect them at this location. |
| 455 g_printer_info_offset = g_custom_entries->size(); | 442 g_printer_info_offset = g_custom_entries->size(); |
| 456 // one-based index for the name suffix. | 443 // one-based index for the name suffix. |
| 457 for (size_t i = 1; i <= kMaxReportedPrinterRecords; ++i) { | 444 for (size_t i = 1; i <= kMaxReportedPrinterRecords; ++i) { |
| 458 g_custom_entries->push_back( | 445 g_custom_entries->push_back( |
| 459 google_breakpad::CustomInfoEntry( | 446 google_breakpad::CustomInfoEntry( |
| 460 base::StringPrintf(L"prn-info-%d", i).c_str(), L"")); | 447 base::StringPrintf(L"prn-info-%d", i).c_str(), L"")); |
| 461 } | 448 } |
| 462 | 449 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return; | 633 return; |
| 647 | 634 |
| 648 if (!g_custom_entries) | 635 if (!g_custom_entries) |
| 649 return; | 636 return; |
| 650 | 637 |
| 651 base::wcslcpy((*g_custom_entries)[g_client_id_offset].value, | 638 base::wcslcpy((*g_custom_entries)[g_client_id_offset].value, |
| 652 client_id, | 639 client_id, |
| 653 google_breakpad::CustomInfoEntry::kValueMaxLength); | 640 google_breakpad::CustomInfoEntry::kValueMaxLength); |
| 654 } | 641 } |
| 655 | 642 |
| 656 extern "C" void __declspec(dllexport) __cdecl SetNumberOfExtensions( | |
| 657 int number_of_extensions) { | |
| 658 SetIntegerValue(g_num_of_extensions_offset, number_of_extensions); | |
| 659 } | |
| 660 | |
| 661 extern "C" void __declspec(dllexport) __cdecl SetExtensionID( | |
| 662 int index, const wchar_t* id) { | |
| 663 DCHECK(id); | |
| 664 DCHECK(index < kMaxReportedActiveExtensions); | |
| 665 | |
| 666 if (!g_custom_entries) | |
| 667 return; | |
| 668 | |
| 669 base::wcslcpy((*g_custom_entries)[g_extension_ids_offset + index].value, | |
| 670 id, | |
| 671 google_breakpad::CustomInfoEntry::kValueMaxLength); | |
| 672 } | |
| 673 | |
| 674 extern "C" void __declspec(dllexport) __cdecl SetPrinterInfo( | 643 extern "C" void __declspec(dllexport) __cdecl SetPrinterInfo( |
| 675 const wchar_t* printer_info) { | 644 const wchar_t* printer_info) { |
| 676 if (!g_custom_entries) | 645 if (!g_custom_entries) |
| 677 return; | 646 return; |
| 678 std::vector<string16> info; | 647 std::vector<string16> info; |
| 679 base::SplitString(printer_info, L';', &info); | 648 base::SplitString(printer_info, L';', &info); |
| 680 DCHECK_LE(info.size(), kMaxReportedPrinterRecords); | 649 DCHECK_LE(info.size(), kMaxReportedPrinterRecords); |
| 681 info.resize(kMaxReportedPrinterRecords); | 650 info.resize(kMaxReportedPrinterRecords); |
| 682 for (size_t i = 0; i < info.size(); ++i) { | 651 for (size_t i = 0; i < info.size(); ++i) { |
| 683 base::wcslcpy((*g_custom_entries)[g_printer_info_offset + i].value, | 652 base::wcslcpy((*g_custom_entries)[g_printer_info_offset + i].value, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 previous_filter = SetUnhandledExceptionFilter(filter); | 1025 previous_filter = SetUnhandledExceptionFilter(filter); |
| 1057 } | 1026 } |
| 1058 | 1027 |
| 1059 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, | 1028 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, |
| 1060 std::vector<const wchar_t*>* cstrings) { | 1029 std::vector<const wchar_t*>* cstrings) { |
| 1061 cstrings->clear(); | 1030 cstrings->clear(); |
| 1062 cstrings->reserve(wstrings.size()); | 1031 cstrings->reserve(wstrings.size()); |
| 1063 for (size_t i = 0; i < wstrings.size(); ++i) | 1032 for (size_t i = 0; i < wstrings.size(); ++i) |
| 1064 cstrings->push_back(wstrings[i].c_str()); | 1033 cstrings->push_back(wstrings[i].c_str()); |
| 1065 } | 1034 } |
| OLD | NEW |