| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 EXCEPTION_RECORD g_surrogate_exception_record = {0}; | 97 EXCEPTION_RECORD g_surrogate_exception_record = {0}; |
| 98 CONTEXT g_surrogate_context = {0}; | 98 CONTEXT g_surrogate_context = {0}; |
| 99 | 99 |
| 100 typedef NTSTATUS (WINAPI* NtTerminateProcessPtr)(HANDLE ProcessHandle, | 100 typedef NTSTATUS (WINAPI* NtTerminateProcessPtr)(HANDLE ProcessHandle, |
| 101 NTSTATUS ExitStatus); | 101 NTSTATUS ExitStatus); |
| 102 char* g_real_terminate_process_stub = NULL; | 102 char* g_real_terminate_process_stub = NULL; |
| 103 | 103 |
| 104 static size_t g_num_of_extensions_offset = 0; | 104 static size_t g_num_of_extensions_offset = 0; |
| 105 static size_t g_extension_ids_offset = 0; | 105 static size_t g_extension_ids_offset = 0; |
| 106 static size_t g_client_id_offset = 0; | 106 static size_t g_client_id_offset = 0; |
| 107 static size_t g_gpu_info_offset = 0; | |
| 108 static size_t g_printer_info_offset = 0; | 107 static size_t g_printer_info_offset = 0; |
| 109 static size_t g_num_of_views_offset = 0; | 108 static size_t g_num_of_views_offset = 0; |
| 110 static size_t g_num_switches_offset = 0; | 109 static size_t g_num_switches_offset = 0; |
| 111 static size_t g_switches_offset = 0; | 110 static size_t g_switches_offset = 0; |
| 112 static size_t g_dynamic_keys_offset = 0; | 111 static size_t g_dynamic_keys_offset = 0; |
| 113 typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*> | 112 typedef std::map<std::wstring, google_breakpad::CustomInfoEntry*> |
| 114 DynamicEntriesMap; | 113 DynamicEntriesMap; |
| 115 DynamicEntriesMap* g_dynamic_entries = NULL; | 114 DynamicEntriesMap* g_dynamic_entries = NULL; |
| 116 // Allow for 128 entries. POSIX uses 64 entries of 256 bytes, so Windows needs | 115 // Allow for 128 entries. POSIX uses 64 entries of 256 bytes, so Windows needs |
| 117 // 256 entries of 64 bytes to match. See CustomInfoEntry::kValueMaxLength in | 116 // 256 entries of 64 bytes to match. See CustomInfoEntry::kValueMaxLength in |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 g_custom_entries->push_back( | 442 g_custom_entries->push_back( |
| 444 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); | 443 google_breakpad::CustomInfoEntry(L"num-extensions", L"N/A")); |
| 445 | 444 |
| 446 g_extension_ids_offset = g_custom_entries->size(); | 445 g_extension_ids_offset = g_custom_entries->size(); |
| 447 // one-based index for the name suffix. | 446 // one-based index for the name suffix. |
| 448 for (int i = 1; i <= kMaxReportedActiveExtensions; ++i) { | 447 for (int i = 1; i <= kMaxReportedActiveExtensions; ++i) { |
| 449 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 448 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 450 base::StringPrintf(L"extension-%i", i).c_str(), L"")); | 449 base::StringPrintf(L"extension-%i", i).c_str(), L"")); |
| 451 } | 450 } |
| 452 | 451 |
| 453 // Add empty values for the gpu_info. We'll put the actual values when we | |
| 454 // collect them at this location. | |
| 455 g_gpu_info_offset = g_custom_entries->size(); | |
| 456 static const wchar_t* const kGpuEntries[] = { | |
| 457 L"gpu-venid", | |
| 458 L"gpu-devid", | |
| 459 L"gpu-driver", | |
| 460 L"gpu-psver", | |
| 461 L"gpu-vsver", | |
| 462 }; | |
| 463 for (size_t i = 0; i < arraysize(kGpuEntries); ++i) { | |
| 464 g_custom_entries->push_back( | |
| 465 google_breakpad::CustomInfoEntry(kGpuEntries[i], L"")); | |
| 466 } | |
| 467 | |
| 468 // Add empty values for the prn_info-*. We'll put the actual values when we | 452 // Add empty values for the prn_info-*. We'll put the actual values when we |
| 469 // collect them at this location. | 453 // collect them at this location. |
| 470 g_printer_info_offset = g_custom_entries->size(); | 454 g_printer_info_offset = g_custom_entries->size(); |
| 471 // one-based index for the name suffix. | 455 // one-based index for the name suffix. |
| 472 for (size_t i = 1; i <= kMaxReportedPrinterRecords; ++i) { | 456 for (size_t i = 1; i <= kMaxReportedPrinterRecords; ++i) { |
| 473 g_custom_entries->push_back( | 457 g_custom_entries->push_back( |
| 474 google_breakpad::CustomInfoEntry( | 458 google_breakpad::CustomInfoEntry( |
| 475 base::StringPrintf(L"prn-info-%d", i).c_str(), L"")); | 459 base::StringPrintf(L"prn-info-%d", i).c_str(), L"")); |
| 476 } | 460 } |
| 477 | 461 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 DCHECK(index < kMaxReportedActiveExtensions); | 663 DCHECK(index < kMaxReportedActiveExtensions); |
| 680 | 664 |
| 681 if (!g_custom_entries) | 665 if (!g_custom_entries) |
| 682 return; | 666 return; |
| 683 | 667 |
| 684 base::wcslcpy((*g_custom_entries)[g_extension_ids_offset + index].value, | 668 base::wcslcpy((*g_custom_entries)[g_extension_ids_offset + index].value, |
| 685 id, | 669 id, |
| 686 google_breakpad::CustomInfoEntry::kValueMaxLength); | 670 google_breakpad::CustomInfoEntry::kValueMaxLength); |
| 687 } | 671 } |
| 688 | 672 |
| 689 extern "C" void __declspec(dllexport) __cdecl SetGpuInfo( | |
| 690 const wchar_t* vendor_id, const wchar_t* device_id, | |
| 691 const wchar_t* driver_version, const wchar_t* pixel_shader_version, | |
| 692 const wchar_t* vertex_shader_version) { | |
| 693 if (!g_custom_entries) | |
| 694 return; | |
| 695 | |
| 696 const wchar_t* info[] = { | |
| 697 vendor_id, | |
| 698 device_id, | |
| 699 driver_version, | |
| 700 pixel_shader_version, | |
| 701 vertex_shader_version | |
| 702 }; | |
| 703 | |
| 704 for (size_t i = 0; i < arraysize(info); ++i) { | |
| 705 base::wcslcpy((*g_custom_entries)[g_gpu_info_offset + i].value, | |
| 706 info[i], | |
| 707 google_breakpad::CustomInfoEntry::kValueMaxLength); | |
| 708 } | |
| 709 } | |
| 710 | |
| 711 extern "C" void __declspec(dllexport) __cdecl SetPrinterInfo( | 673 extern "C" void __declspec(dllexport) __cdecl SetPrinterInfo( |
| 712 const wchar_t* printer_info) { | 674 const wchar_t* printer_info) { |
| 713 if (!g_custom_entries) | 675 if (!g_custom_entries) |
| 714 return; | 676 return; |
| 715 std::vector<string16> info; | 677 std::vector<string16> info; |
| 716 base::SplitString(printer_info, L';', &info); | 678 base::SplitString(printer_info, L';', &info); |
| 717 DCHECK_LE(info.size(), kMaxReportedPrinterRecords); | 679 DCHECK_LE(info.size(), kMaxReportedPrinterRecords); |
| 718 info.resize(kMaxReportedPrinterRecords); | 680 info.resize(kMaxReportedPrinterRecords); |
| 719 for (size_t i = 0; i < info.size(); ++i) { | 681 for (size_t i = 0; i < info.size(); ++i) { |
| 720 base::wcslcpy((*g_custom_entries)[g_printer_info_offset + i].value, | 682 base::wcslcpy((*g_custom_entries)[g_printer_info_offset + i].value, |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 previous_filter = SetUnhandledExceptionFilter(filter); | 1055 previous_filter = SetUnhandledExceptionFilter(filter); |
| 1094 } | 1056 } |
| 1095 | 1057 |
| 1096 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, | 1058 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, |
| 1097 std::vector<const wchar_t*>* cstrings) { | 1059 std::vector<const wchar_t*>* cstrings) { |
| 1098 cstrings->clear(); | 1060 cstrings->clear(); |
| 1099 cstrings->reserve(wstrings.size()); | 1061 cstrings->reserve(wstrings.size()); |
| 1100 for (size_t i = 0; i < wstrings.size(); ++i) | 1062 for (size_t i = 0; i < wstrings.size(); ++i) |
| 1101 cstrings->push_back(wstrings[i].c_str()); | 1063 cstrings->push_back(wstrings[i].c_str()); |
| 1102 } | 1064 } |
| OLD | NEW |