-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug report tool for registry (#9213)
* wip * Improved registry bug reporting * Don't use macros * Ignore spelling of NLSTEXT in macro * Various improvements * Move functions to separate files * Rename result file to registry-report-info.txt * Rename a poorly named function in ReportMonitorInfo.cpp * Restrict scope of symbols in these .cpp files Co-authored-by: Davide <davide.giacometti@outlook.it>
- Loading branch information
1 parent
b74afd3
commit 0b12798
Showing
8 changed files
with
289 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1446,6 +1446,7 @@ nielslaute | |
NIF | ||
NLD | ||
NLog | ||
NLSTEXT | ||
NMLVEMPTYMARKUP | ||
NOACTIVATE | ||
noactive | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,82 @@ | ||
#pragma once | ||
#include "ReportMonitorInfo.h" | ||
#include <Windows.h> | ||
#include <filesystem> | ||
#include "../../../src/common/utils/winapi_error.h" | ||
using namespace std; | ||
|
||
int report(std::wostream& os) | ||
namespace | ||
{ | ||
struct capture | ||
int buildMonitorInfoReport(std::wostream& os) | ||
{ | ||
std::wostream* os = nullptr; | ||
}; | ||
struct capture | ||
{ | ||
std::wostream* os = nullptr; | ||
}; | ||
|
||
auto callback = [](HMONITOR monitor, HDC, RECT*, LPARAM prm) -> BOOL { | ||
std::wostream& os = *((capture*)prm)->os; | ||
MONITORINFOEX mi; | ||
mi.cbSize = sizeof(mi); | ||
auto callback = [](HMONITOR monitor, HDC, RECT*, LPARAM prm) -> BOOL { | ||
std::wostream& os = *((capture*)prm)->os; | ||
MONITORINFOEX mi; | ||
mi.cbSize = sizeof(mi); | ||
|
||
if (GetMonitorInfoW(monitor, &mi)) | ||
{ | ||
os << "GetMonitorInfo OK\n"; | ||
DISPLAY_DEVICE displayDevice = { sizeof(displayDevice) }; | ||
if (GetMonitorInfoW(monitor, &mi)) | ||
{ | ||
os << "GetMonitorInfo OK\n"; | ||
DISPLAY_DEVICE displayDevice = { sizeof(displayDevice) }; | ||
|
||
DWORD i = 0; | ||
while (EnumDisplayDevicesW(mi.szDevice, i++, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME)) | ||
DWORD i = 0; | ||
while (EnumDisplayDevicesW(mi.szDevice, i++, &displayDevice, EDD_GET_DEVICE_INTERFACE_NAME)) | ||
{ | ||
const bool active = displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE; | ||
const bool mirroring = displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER; | ||
os << "EnumDisplayDevices OK:\n" | ||
<< "\tMirroring = " << mirroring << '\n' | ||
<< "\tActive = " << active << '\n' | ||
<< "\tDeviceID = " << displayDevice.DeviceID << '\n' | ||
<< "\tDeviceKey = " << displayDevice.DeviceKey << '\n' | ||
<< "\tDeviceName = " << displayDevice.DeviceName << '\n' | ||
<< "\tDeviceString = " << displayDevice.DeviceString << '\n'; | ||
} | ||
} | ||
else | ||
{ | ||
const bool active = displayDevice.StateFlags & DISPLAY_DEVICE_ACTIVE; | ||
const bool mirroring = displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER; | ||
os << "EnumDisplayDevices OK:\n" | ||
<< "\tMirroring = " << mirroring << '\n' | ||
<< "\tActive = " << active << '\n' | ||
<< "\tDeviceID = " << displayDevice.DeviceID << '\n' | ||
<< "\tDeviceKey = " << displayDevice.DeviceKey << '\n' | ||
<< "\tDeviceName = " << displayDevice.DeviceName << '\n' | ||
<< "\tDeviceString = " << displayDevice.DeviceString << '\n'; | ||
auto message = get_last_error_message(GetLastError()); | ||
os << "GetMonitorInfo FAILED: " << (message.has_value() ? message.value() : L"") << '\n'; | ||
} | ||
return TRUE; | ||
}; | ||
capture c; | ||
c.os = &os; | ||
if (EnumDisplayMonitors(nullptr, nullptr, callback, (LPARAM)&c)) | ||
{ | ||
os << "EnumDisplayMonitors OK\n"; | ||
} | ||
else | ||
{ | ||
auto message = get_last_error_message(GetLastError()); | ||
os << "GetMonitorInfo FAILED: " << (message.has_value() ? message.value() : L"") << '\n'; | ||
os << "EnumDisplayMonitors FAILED: " << (message.has_value() ? message.value() : L"") << '\n'; | ||
} | ||
return TRUE; | ||
}; | ||
capture c; | ||
c.os = &os; | ||
if (EnumDisplayMonitors(nullptr, nullptr, callback, (LPARAM)&c)) | ||
return 0; | ||
} | ||
} | ||
|
||
void reportMonitorInfo(const filesystem::path& tmpDir) | ||
{ | ||
auto monitorReportPath = tmpDir; | ||
monitorReportPath.append("monitor-report-info.txt"); | ||
|
||
try | ||
{ | ||
wofstream monitorReport(monitorReportPath); | ||
monitorReport << "GetSystemMetrics = " << GetSystemMetrics(SM_CMONITORS) << '\n'; | ||
buildMonitorInfoReport(monitorReport); | ||
} | ||
catch (std::exception& ex) | ||
{ | ||
os << "EnumDisplayMonitors OK\n"; | ||
printf("Failed to report monitor info. %s\n", ex.what()); | ||
} | ||
else | ||
catch (...) | ||
{ | ||
auto message = get_last_error_message(GetLastError()); | ||
os << "EnumDisplayMonitors FAILED: " << (message.has_value() ? message.value() : L"") << '\n'; | ||
printf("Failed to report monitor info\n"); | ||
} | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#pragma once | ||
#include <fstream> | ||
|
||
int report(std::wostream& os); | ||
void reportMonitorInfo(const std::filesystem::path& tmpDir); |
Oops, something went wrong.