|
7 | 7 | #include <tlhelp32.h> |
8 | 8 | #include "common/IEnvironment.h" |
9 | 9 | #include "common/IRegistry.h" |
| 10 | +#include "shiconov_diag.h" |
| 11 | +#include "shellsup_diag.h" |
10 | 12 |
|
11 | 13 | // Cross-architecture register access macros for CONTEXT structure |
12 | 14 | #ifdef _WIN64 |
@@ -555,6 +557,10 @@ void CCallStack::PrintBugReport(EXCEPTION_POINTERS* Exception, DWORD ThreadID, D |
555 | 557 | static char num[50]; |
556 | 558 | static char avbuf[MAX_PATH]; |
557 | 559 | static char nameBuf[MAX_PATH]; |
| 560 | + // Scratch for the shell-integration sections. Static like the rest: this runs inside a |
| 561 | + // process that may already be crashing, so we do not want it on the stack. Sized for a |
| 562 | + // \uXXXX-escaped long path plus the surrounding fields. |
| 563 | + static char BugReportDiagBuf[4096]; |
558 | 564 |
|
559 | 565 | strcpy(buf, SALAMANDER_TEXT_VERSION); |
560 | 566 | #ifdef _DEBUG |
@@ -1478,6 +1484,77 @@ void CCallStack::PrintBugReport(EXCEPTION_POINTERS* Exception, DWORD ThreadID, D |
1478 | 1484 | PrintLine(param, "", FALSE); |
1479 | 1485 | } |
1480 | 1486 |
|
| 1487 | + // Shell integration: what actually happened to each registered icon-overlay handler, |
| 1488 | + // and to the last few context-menu interactions. These two sections exist because the |
| 1489 | + // TRACE_* calls in shiconov.cpp and shellsup.cpp are compiled out of Release, so this |
| 1490 | + // report is the only channel that reaches a reporter running a shipped build. |
| 1491 | + __try |
| 1492 | + { |
| 1493 | + PrintLine(param, "Icon Overlays:", FALSE); |
| 1494 | + |
| 1495 | + _snprintf_s(buf, _TRUNCATE, "Config root in use: %s", ShellOverlayDiag.Header.ConfigRoot); |
| 1496 | + PrintLine(param, buf, TRUE); |
| 1497 | + _snprintf_s(buf, _TRUNCATE, "ANSI code page: %u Registered: %d Loaded: %d", |
| 1498 | + ShellOverlayDiag.Header.AnsiCodePage, |
| 1499 | + ShellOverlayDiag.Header.Registered, ShellOverlayDiag.Header.Loaded); |
| 1500 | + PrintLine(param, buf, TRUE); |
| 1501 | + _snprintf_s(buf, _TRUNCATE, "System DPI: %u Required icon sizes: %d/%d/%d", |
| 1502 | + ShellOverlayDiag.Header.SystemDpi, ShellOverlayDiag.Header.IconSizes[0], |
| 1503 | + ShellOverlayDiag.Header.IconSizes[1], ShellOverlayDiag.Header.IconSizes[2]); |
| 1504 | + PrintLine(param, buf, TRUE); |
| 1505 | + |
| 1506 | + for (int i = 0; i < ShellOverlayDiag.Count(); i++) |
| 1507 | + { |
| 1508 | + const ShellOverlayDiagRecord* rec = ShellOverlayDiag.At(i); |
| 1509 | + if (rec == NULL) |
| 1510 | + continue; |
| 1511 | + BugReportDiagBuf[0] = 0; |
| 1512 | + FormatShellOverlayDiagRecord(*rec, BugReportDiagBuf, (int)sizeof(BugReportDiagBuf)); |
| 1513 | + _snprintf_s(buf, _TRUNCATE, "[%2d] %s", i, BugReportDiagBuf); |
| 1514 | + PrintLine(param, buf, TRUE); |
| 1515 | + } |
| 1516 | + PrintLine(param, "", FALSE); |
| 1517 | + } |
| 1518 | + __except (EXCEPTION_EXECUTE_HANDLER) |
| 1519 | + { |
| 1520 | + sprintf(buf, "some exception has occured..."); |
| 1521 | + PrintLine(param, buf, TRUE); |
| 1522 | + PrintLine(param, "", FALSE); |
| 1523 | + } |
| 1524 | + |
| 1525 | + __try |
| 1526 | + { |
| 1527 | + PrintLine(param, "Shell Context Menu (oldest first):", FALSE); |
| 1528 | + for (int i = 0; i < ShellMenuDiag.Count(); i++) |
| 1529 | + { |
| 1530 | + const ShellMenuDiagRecord* rec = ShellMenuDiag.At(i); |
| 1531 | + if (rec == NULL) |
| 1532 | + continue; |
| 1533 | + BugReportDiagBuf[0] = 0; |
| 1534 | + FormatShellMenuDiagRecord(*rec, BugReportDiagBuf, (int)sizeof(BugReportDiagBuf)); |
| 1535 | + |
| 1536 | + // The formatter emits several lines; PrintLine takes one at a time. |
| 1537 | + char* line = BugReportDiagBuf; |
| 1538 | + while (*line != 0) |
| 1539 | + { |
| 1540 | + char* eol = strchr(line, '\n'); |
| 1541 | + if (eol != NULL) |
| 1542 | + *eol = 0; |
| 1543 | + PrintLine(param, line, TRUE); |
| 1544 | + if (eol == NULL) |
| 1545 | + break; |
| 1546 | + line = eol + 1; |
| 1547 | + } |
| 1548 | + } |
| 1549 | + PrintLine(param, "", FALSE); |
| 1550 | + } |
| 1551 | + __except (EXCEPTION_EXECUTE_HANDLER) |
| 1552 | + { |
| 1553 | + sprintf(buf, "some exception has occured..."); |
| 1554 | + PrintLine(param, buf, TRUE); |
| 1555 | + PrintLine(param, "", FALSE); |
| 1556 | + } |
| 1557 | + |
1481 | 1558 | __try |
1482 | 1559 | { |
1483 | 1560 | PrintLine(param, "Panels:", FALSE); |
|
0 commit comments