Changeset 69872 in vbox
- Timestamp:
- Nov 29, 2017 8:09:05 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119328
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.cpp
r69500 r69872 17 17 18 18 #include "VBoxDispD3DCmn.h" 19 20 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER 21 #include <Psapi.h> 22 #endif 19 23 20 24 #include <stdio.h> … … 688 692 #ifdef VBOXWDDMDISP_DEBUG_VEHANDLER 689 693 694 typedef BOOL WINAPI FNGetModuleInformation(HANDLE hProcess, HMODULE hModule, LPMODULEINFO lpmodinfo, DWORD cb); 695 typedef FNGetModuleInformation *PFNGetModuleInformation; 696 697 static PFNGetModuleInformation g_pfnGetModuleInformation = NULL; 698 static HMODULE g_hModPsapi = NULL; 690 699 static PVOID g_VBoxWDbgVEHandler = NULL; 700 701 static bool vboxVDbgIsAddressInModule(PVOID pv, const char *pszModuleName) 702 { 703 HMODULE hMod = GetModuleHandleA(pszModuleName); 704 if (!hMod) 705 return false; 706 707 HANDLE hProcess = GetCurrentProcess(); 708 709 if (!g_pfnGetModuleInformation) 710 return false; 711 712 MODULEINFO ModuleInfo = {0}; 713 if (!g_pfnGetModuleInformation(hProcess, hMod, &ModuleInfo, sizeof(ModuleInfo))) 714 return false; 715 716 return (uintptr_t)ModuleInfo.lpBaseOfDll <= (uintptr_t)pv 717 && (uintptr_t)pv < (uintptr_t)ModuleInfo.lpBaseOfDll + ModuleInfo.SizeOfImage; 718 } 719 720 static bool vboxVDbgIsExceptionIgnored(PEXCEPTION_RECORD pExceptionRecord) 721 { 722 /* Module (dll) names for GetModuleHandle. 723 * Exceptions originated from these modules will be ignored. 724 */ 725 static const char *apszIgnoredModuleNames[] = 726 { 727 NULL 728 }; 729 730 int i = 0; 731 while (apszIgnoredModuleNames[i]) 732 { 733 if (vboxVDbgIsAddressInModule(pExceptionRecord->ExceptionAddress, apszIgnoredModuleNames[i])) 734 return true; 735 736 ++i; 737 } 738 739 return false; 740 } 741 691 742 LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo) 692 743 { 744 static volatile bool g_fAllowIgnore = true; /* Might be changed in kernel debugger. */ 745 693 746 PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord; 694 PCONTEXT pContextRecord = pExceptionInfo->ContextRecord; 747 /* PCONTEXT pContextRecord = pExceptionInfo->ContextRecord; */ 748 695 749 switch (pExceptionRecord->ExceptionCode) 696 750 { 751 default: 752 break; 697 753 case EXCEPTION_BREAKPOINT: 698 754 case EXCEPTION_ACCESS_VIOLATION: … … 703 759 case EXCEPTION_INT_DIVIDE_BY_ZERO: 704 760 case EXCEPTION_ILLEGAL_INSTRUCTION: 705 AssertRelease(0); 761 if (g_fAllowIgnore && vboxVDbgIsExceptionIgnored(pExceptionRecord)) 762 break; 763 ASMBreakpoint(); 706 764 break; 707 default: 765 case 0x40010006: /* OutputDebugStringA? */ 766 case 0x4001000a: /* OutputDebugStringW? */ 708 767 break; 709 768 } … … 716 775 g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler); 717 776 Assert(g_VBoxWDbgVEHandler); 777 778 g_hModPsapi = GetModuleHandleA("Psapi.dll"); /* Usually already loaded. */ 779 if (g_hModPsapi) 780 g_pfnGetModuleInformation = (PFNGetModuleInformation)GetProcAddress(g_hModPsapi, "GetModuleInformation"); 718 781 } 719 782 … … 722 785 Assert(g_VBoxWDbgVEHandler); 723 786 ULONG uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler); 724 Assert(uResult); 787 Assert(uResult); RT_NOREF(uResult); 725 788 g_VBoxWDbgVEHandler = NULL; 726 } 727 728 #endif 789 790 g_hModPsapi = NULL; 791 g_pfnGetModuleInformation = NULL; 792 } 793 794 #endif /* VBOXWDDMDISP_DEBUG_VEHANDLER */ 729 795 730 796 #if defined(VBOXWDDMDISP_DEBUG) || defined(LOG_TO_BACKDOOR_DRV)
Note:
See TracChangeset
for help on using the changeset viewer.